Search in sources :

Example 11 with MixedOperation

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);
}
Also used : ExtensionsAPIGroupDSL(io.fabric8.kubernetes.client.dsl.ExtensionsAPIGroupDSL)

Example 12 with MixedOperation

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());
}
Also used : DoneableService(io.fabric8.kubernetes.api.model.DoneableService) ServiceList(io.fabric8.kubernetes.api.model.ServiceList) Resource(io.fabric8.kubernetes.client.dsl.Resource) DoneableService(io.fabric8.kubernetes.api.model.DoneableService) Service(io.fabric8.kubernetes.api.model.Service) Map(java.util.Map)

Example 13 with MixedOperation

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());
}
Also used : OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) DoneableBuildConfig(io.fabric8.openshift.api.model.DoneableBuildConfig) BuildConfig(io.fabric8.openshift.api.model.BuildConfig) DoneableBuildConfig(io.fabric8.openshift.api.model.DoneableBuildConfig) BuildConfigResource(io.fabric8.openshift.client.dsl.BuildConfigResource) Map(java.util.Map) BuildConfigList(io.fabric8.openshift.api.model.BuildConfigList)

Example 14 with MixedOperation

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());
}
Also used : BuildList(io.fabric8.openshift.api.model.BuildList) DoneableBuild(io.fabric8.openshift.api.model.DoneableBuild) DoneableBuild(io.fabric8.openshift.api.model.DoneableBuild) Build(io.fabric8.openshift.api.model.Build) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) Map(java.util.Map) BuildResource(io.fabric8.openshift.client.dsl.BuildResource)

Example 15 with MixedOperation

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());
}
Also used : DoneableReplicationController(io.fabric8.kubernetes.api.model.DoneableReplicationController) ReplicationController(io.fabric8.kubernetes.api.model.ReplicationController) RollableScallableResource(io.fabric8.kubernetes.client.dsl.RollableScallableResource) Map(java.util.Map) ReplicationControllerList(io.fabric8.kubernetes.api.model.ReplicationControllerList) DoneableReplicationController(io.fabric8.kubernetes.api.model.DoneableReplicationController)

Aggregations

Resource (io.fabric8.kubernetes.client.dsl.Resource)21 MixedOperation (io.fabric8.kubernetes.client.dsl.MixedOperation)15 Async (io.vertx.ext.unit.Async)15 NonNamespaceOperation (io.fabric8.kubernetes.client.dsl.NonNamespaceOperation)13 Test (org.junit.Test)12 Map (java.util.Map)10 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)4 DeploymentList (io.fabric8.kubernetes.api.model.extensions.DeploymentList)4 DoneableDeployment (io.fabric8.kubernetes.api.model.extensions.DoneableDeployment)4 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)4 ScalableResource (io.fabric8.kubernetes.client.dsl.ScalableResource)4 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)3 ConfigMapList (io.fabric8.kubernetes.api.model.ConfigMapList)3 DoneableConfigMap (io.fabric8.kubernetes.api.model.DoneableConfigMap)3 DoneablePersistentVolumeClaim (io.fabric8.kubernetes.api.model.DoneablePersistentVolumeClaim)3 DoneablePod (io.fabric8.kubernetes.api.model.DoneablePod)3 DoneableService (io.fabric8.kubernetes.api.model.DoneableService)3 PersistentVolumeClaim (io.fabric8.kubernetes.api.model.PersistentVolumeClaim)3 PersistentVolumeClaimList (io.fabric8.kubernetes.api.model.PersistentVolumeClaimList)3 Pod (io.fabric8.kubernetes.api.model.Pod)3