use of io.fabric8.kubernetes.client.dsl.MixedOperation in project strimzi by strimzi.
the class DeploymentOperatorTest method mocker.
@Override
protected void mocker(KubernetesClient mockClient, MixedOperation op) {
ExtensionsAPIGroupDSL mockExt = mock(ExtensionsAPIGroupDSL.class);
when(mockExt.deployments()).thenReturn(op);
when(mockClient.extensions()).thenReturn(mockExt);
}
use of io.fabric8.kubernetes.client.dsl.MixedOperation in project camel by apache.
the class KubernetesServicesProducer method doListServiceByLabels.
protected void doListServiceByLabels(Exchange exchange, String operation) throws Exception {
ServiceList servicesList = null;
Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_SERVICE_LABELS, Map.class);
String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
if (!ObjectHelper.isEmpty(namespaceName)) {
NonNamespaceOperation<Service, ServiceList, DoneableService, Resource<Service, DoneableService>> services;
services = getEndpoint().getKubernetesClient().services().inNamespace(namespaceName);
for (Map.Entry<String, String> entry : labels.entrySet()) {
services.withLabel(entry.getKey(), entry.getValue());
}
servicesList = services.list();
} else {
MixedOperation<Service, ServiceList, DoneableService, Resource<Service, DoneableService>> services;
services = getEndpoint().getKubernetesClient().services();
for (Map.Entry<String, String> entry : labels.entrySet()) {
services.withLabel(entry.getKey(), entry.getValue());
}
servicesList = services.list();
}
exchange.getOut().setBody(servicesList.getItems());
}
use of io.fabric8.kubernetes.client.dsl.MixedOperation in project camel by apache.
the class KubernetesBuildConfigsProducer method doListBuildConfigsByLabels.
protected void doListBuildConfigsByLabels(Exchange exchange, String operation) throws Exception {
BuildConfigList buildConfigsList = null;
Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_BUILD_CONFIGS_LABELS, Map.class);
String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
if (!ObjectHelper.isEmpty(namespaceName)) {
NonNamespaceOperation<BuildConfig, BuildConfigList, DoneableBuildConfig, BuildConfigResource<BuildConfig, DoneableBuildConfig, Void, Build>> buildConfigs;
buildConfigs = getEndpoint().getKubernetesClient().adapt(OpenShiftClient.class).buildConfigs().inNamespace(namespaceName);
for (Map.Entry<String, String> entry : labels.entrySet()) {
buildConfigs.withLabel(entry.getKey(), entry.getValue());
}
buildConfigsList = buildConfigs.list();
} else {
MixedOperation<BuildConfig, BuildConfigList, DoneableBuildConfig, BuildConfigResource<BuildConfig, DoneableBuildConfig, Void, Build>> buildConfigs;
buildConfigs = getEndpoint().getKubernetesClient().adapt(OpenShiftClient.class).buildConfigs();
for (Map.Entry<String, String> entry : labels.entrySet()) {
buildConfigs.withLabel(entry.getKey(), entry.getValue());
}
buildConfigsList = buildConfigs.list();
}
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(buildConfigsList.getItems());
}
use of io.fabric8.kubernetes.client.dsl.MixedOperation in project camel by apache.
the class KubernetesBuildsProducer method doListBuildByLabels.
protected void doListBuildByLabels(Exchange exchange, String operation) throws Exception {
BuildList buildList = null;
Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_BUILDS_LABELS, Map.class);
String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
if (!ObjectHelper.isEmpty(namespaceName)) {
NonNamespaceOperation<Build, BuildList, DoneableBuild, BuildResource<Build, DoneableBuild, String, LogWatch>> builds = getEndpoint().getKubernetesClient().adapt(OpenShiftClient.class).builds().inNamespace(namespaceName);
for (Map.Entry<String, String> entry : labels.entrySet()) {
builds.withLabel(entry.getKey(), entry.getValue());
}
buildList = builds.list();
} else {
MixedOperation<Build, BuildList, DoneableBuild, BuildResource<Build, DoneableBuild, String, LogWatch>> builds = getEndpoint().getKubernetesClient().adapt(OpenShiftClient.class).builds();
for (Map.Entry<String, String> entry : labels.entrySet()) {
builds.withLabel(entry.getKey(), entry.getValue());
}
buildList = builds.list();
}
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(buildList.getItems());
}
use of io.fabric8.kubernetes.client.dsl.MixedOperation in project camel by apache.
the class KubernetesReplicationControllersProducer method doListReplicationControllersByLabels.
protected void doListReplicationControllersByLabels(Exchange exchange, String operation) throws Exception {
ReplicationControllerList rcList = null;
Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_REPLICATION_CONTROLLERS_LABELS, Map.class);
String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
if (!ObjectHelper.isEmpty(namespaceName)) {
NonNamespaceOperation<ReplicationController, ReplicationControllerList, DoneableReplicationController, RollableScallableResource<ReplicationController, DoneableReplicationController>> replicationControllers;
replicationControllers = getEndpoint().getKubernetesClient().replicationControllers().inNamespace(namespaceName);
for (Map.Entry<String, String> entry : labels.entrySet()) {
replicationControllers.withLabel(entry.getKey(), entry.getValue());
}
rcList = replicationControllers.list();
} else {
MixedOperation<ReplicationController, ReplicationControllerList, DoneableReplicationController, RollableScallableResource<ReplicationController, DoneableReplicationController>> replicationControllers;
replicationControllers = getEndpoint().getKubernetesClient().replicationControllers();
for (Map.Entry<String, String> entry : labels.entrySet()) {
replicationControllers.withLabel(entry.getKey(), entry.getValue());
}
rcList = replicationControllers.list();
}
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(rcList.getItems());
}
Aggregations