Search in sources :

Example 1 with DoneableConfigMap

use of io.fabric8.kubernetes.api.model.DoneableConfigMap in project camel by apache.

the class KubernetesConfigMapsProducer method doListConfigMapsByLabels.

protected void doListConfigMapsByLabels(Exchange exchange, String operation) throws Exception {
    ConfigMapList configMapsList = null;
    Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_CONFIGMAPS_LABELS, Map.class);
    NonNamespaceOperation<ConfigMap, ConfigMapList, DoneableConfigMap, Resource<ConfigMap, DoneableConfigMap>> configMaps = getEndpoint().getKubernetesClient().configMaps();
    for (Map.Entry<String, String> entry : labels.entrySet()) {
        configMaps.withLabel(entry.getKey(), entry.getValue());
    }
    configMapsList = configMaps.list();
    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
    exchange.getOut().setBody(configMapsList.getItems());
}
Also used : ConfigMapList(io.fabric8.kubernetes.api.model.ConfigMapList) DoneableConfigMap(io.fabric8.kubernetes.api.model.DoneableConfigMap) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Resource(io.fabric8.kubernetes.client.dsl.Resource) HashMap(java.util.HashMap) DoneableConfigMap(io.fabric8.kubernetes.api.model.DoneableConfigMap) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Map(java.util.Map) DoneableConfigMap(io.fabric8.kubernetes.api.model.DoneableConfigMap)

Example 2 with DoneableConfigMap

use of io.fabric8.kubernetes.api.model.DoneableConfigMap in project strimzi by strimzi.

the class MockKube method build.

public KubernetesClient build() {
    KubernetesClient mockClient = mock(KubernetesClient.class);
    MixedOperation<ConfigMap, ConfigMapList, DoneableConfigMap, Resource<ConfigMap, DoneableConfigMap>> mockCms = buildConfigMaps();
    MixedOperation<PersistentVolumeClaim, PersistentVolumeClaimList, DoneablePersistentVolumeClaim, Resource<PersistentVolumeClaim, DoneablePersistentVolumeClaim>> mockPvcs = buildPvcs();
    MixedOperation<Endpoints, EndpointsList, DoneableEndpoints, Resource<Endpoints, DoneableEndpoints>> mockEndpoints = buildEndpoints();
    MixedOperation<Service, ServiceList, DoneableService, Resource<Service, DoneableService>> mockSvc = buildServices();
    MixedOperation<Pod, PodList, DoneablePod, PodResource<Pod, DoneablePod>> mockPods = buildPods();
    MixedOperation<StatefulSet, StatefulSetList, DoneableStatefulSet, RollableScalableResource<StatefulSet, DoneableStatefulSet>> mockSs = buildStatefulSets(mockPods);
    MixedOperation<Deployment, DeploymentList, DoneableDeployment, ScalableResource<Deployment, DoneableDeployment>> mockDep = buildDeployments();
    when(mockClient.configMaps()).thenReturn(mockCms);
    when(mockClient.services()).thenReturn(mockSvc);
    AppsAPIGroupDSL api = mock(AppsAPIGroupDSL.class);
    when(api.statefulSets()).thenReturn(mockSs);
    when(mockClient.apps()).thenReturn(api);
    ExtensionsAPIGroupDSL ext = mock(ExtensionsAPIGroupDSL.class);
    when(mockClient.extensions()).thenReturn(ext);
    when(ext.deployments()).thenReturn(mockDep);
    when(mockClient.pods()).thenReturn(mockPods);
    when(mockClient.endpoints()).thenReturn(mockEndpoints);
    when(mockClient.persistentVolumeClaims()).thenReturn(mockPvcs);
    return mockClient;
}
Also used : ConfigMapList(io.fabric8.kubernetes.api.model.ConfigMapList) PodResource(io.fabric8.kubernetes.client.dsl.PodResource) PersistentVolumeClaimList(io.fabric8.kubernetes.api.model.PersistentVolumeClaimList) DoneableStatefulSet(io.fabric8.kubernetes.api.model.extensions.DoneableStatefulSet) DoneablePod(io.fabric8.kubernetes.api.model.DoneablePod) Deployment(io.fabric8.kubernetes.api.model.extensions.Deployment) DoneableDeployment(io.fabric8.kubernetes.api.model.extensions.DoneableDeployment) DoneableEndpoints(io.fabric8.kubernetes.api.model.DoneableEndpoints) Endpoints(io.fabric8.kubernetes.api.model.Endpoints) DoneableDeployment(io.fabric8.kubernetes.api.model.extensions.DoneableDeployment) DeploymentList(io.fabric8.kubernetes.api.model.extensions.DeploymentList) DoneableService(io.fabric8.kubernetes.api.model.DoneableService) ExtensionsAPIGroupDSL(io.fabric8.kubernetes.client.dsl.ExtensionsAPIGroupDSL) StatefulSetList(io.fabric8.kubernetes.api.model.extensions.StatefulSetList) DoneableConfigMap(io.fabric8.kubernetes.api.model.DoneableConfigMap) EndpointsList(io.fabric8.kubernetes.api.model.EndpointsList) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) PodList(io.fabric8.kubernetes.api.model.PodList) DoneableConfigMap(io.fabric8.kubernetes.api.model.DoneableConfigMap) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) DoneablePod(io.fabric8.kubernetes.api.model.DoneablePod) Pod(io.fabric8.kubernetes.api.model.Pod) ServiceList(io.fabric8.kubernetes.api.model.ServiceList) Resource(io.fabric8.kubernetes.client.dsl.Resource) ScalableResource(io.fabric8.kubernetes.client.dsl.ScalableResource) RollableScalableResource(io.fabric8.kubernetes.client.dsl.RollableScalableResource) PodResource(io.fabric8.kubernetes.client.dsl.PodResource) KubernetesResource(io.fabric8.kubernetes.api.model.KubernetesResource) DoneableService(io.fabric8.kubernetes.api.model.DoneableService) Service(io.fabric8.kubernetes.api.model.Service) AppsAPIGroupDSL(io.fabric8.kubernetes.client.dsl.AppsAPIGroupDSL) ScalableResource(io.fabric8.kubernetes.client.dsl.ScalableResource) RollableScalableResource(io.fabric8.kubernetes.client.dsl.RollableScalableResource) DoneableEndpoints(io.fabric8.kubernetes.api.model.DoneableEndpoints) RollableScalableResource(io.fabric8.kubernetes.client.dsl.RollableScalableResource) DoneablePersistentVolumeClaim(io.fabric8.kubernetes.api.model.DoneablePersistentVolumeClaim) PersistentVolumeClaim(io.fabric8.kubernetes.api.model.PersistentVolumeClaim) DoneablePersistentVolumeClaim(io.fabric8.kubernetes.api.model.DoneablePersistentVolumeClaim) DoneableStatefulSet(io.fabric8.kubernetes.api.model.extensions.DoneableStatefulSet) StatefulSet(io.fabric8.kubernetes.api.model.extensions.StatefulSet)

Example 3 with DoneableConfigMap

use of io.fabric8.kubernetes.api.model.DoneableConfigMap in project vertx-openshift-it by cescoffier.

the class ConfigurationIT method createOrEditConfigMap.

private static void createOrEditConfigMap(Map<String, String> content) {
    DoneableConfigMap cfgMap;
    if (client.configMaps().withName(CONFIG_MAP).get() != null) {
        cfgMap = client.configMaps().withName(CONFIG_MAP).edit();
    } else {
        cfgMap = client.configMaps().createNew();
    }
    cfgMap.withNewMetadata().withName(CONFIG_MAP).endMetadata().withData(content).done();
}
Also used : DoneableConfigMap(io.fabric8.kubernetes.api.model.DoneableConfigMap)

Example 4 with DoneableConfigMap

use of io.fabric8.kubernetes.api.model.DoneableConfigMap in project strimzi by strimzi.

the class K8sImplTest method testList.

@Test
public void testList(TestContext context) {
    Async async = context.async();
    KubernetesClient mockClient = mock(KubernetesClient.class);
    MixedOperation<ConfigMap, ConfigMapList, DoneableConfigMap, Resource<ConfigMap, DoneableConfigMap>> mockConfigMaps = mock(MixedOperation.class);
    when(mockClient.configMaps()).thenReturn(mockConfigMaps);
    when(mockConfigMaps.withLabels(any())).thenReturn(mockConfigMaps);
    when(mockConfigMaps.inNamespace(any())).thenReturn(mockConfigMaps);
    when(mockConfigMaps.list()).thenReturn(new ConfigMapListBuilder().addNewItem().withKind("ConfigMap").withNewMetadata().withName("unrelated").withLabels(Collections.singletonMap("foo", "bar")).endMetadata().withData(Collections.singletonMap("foo", "bar")).endItem().addNewItem().endItem().build());
    K8sImpl k8s = new K8sImpl(vertx, mockClient, new LabelPredicate("foo", "bar"), "default");
    k8s.listMaps(ar -> {
        List<ConfigMap> list = ar.result();
        context.assertFalse(list.isEmpty());
        async.complete();
    });
}
Also used : ConfigMapList(io.fabric8.kubernetes.api.model.ConfigMapList) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) DoneableConfigMap(io.fabric8.kubernetes.api.model.DoneableConfigMap) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Async(io.vertx.ext.unit.Async) Resource(io.fabric8.kubernetes.client.dsl.Resource) ConfigMapListBuilder(io.fabric8.kubernetes.api.model.ConfigMapListBuilder) DoneableConfigMap(io.fabric8.kubernetes.api.model.DoneableConfigMap) Test(org.junit.Test)

Aggregations

DoneableConfigMap (io.fabric8.kubernetes.api.model.DoneableConfigMap)4 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)3 ConfigMapList (io.fabric8.kubernetes.api.model.ConfigMapList)3 Resource (io.fabric8.kubernetes.client.dsl.Resource)3 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)2 ConfigMapListBuilder (io.fabric8.kubernetes.api.model.ConfigMapListBuilder)1 DoneableEndpoints (io.fabric8.kubernetes.api.model.DoneableEndpoints)1 DoneablePersistentVolumeClaim (io.fabric8.kubernetes.api.model.DoneablePersistentVolumeClaim)1 DoneablePod (io.fabric8.kubernetes.api.model.DoneablePod)1 DoneableService (io.fabric8.kubernetes.api.model.DoneableService)1 Endpoints (io.fabric8.kubernetes.api.model.Endpoints)1 EndpointsList (io.fabric8.kubernetes.api.model.EndpointsList)1 KubernetesResource (io.fabric8.kubernetes.api.model.KubernetesResource)1 PersistentVolumeClaim (io.fabric8.kubernetes.api.model.PersistentVolumeClaim)1 PersistentVolumeClaimList (io.fabric8.kubernetes.api.model.PersistentVolumeClaimList)1 Pod (io.fabric8.kubernetes.api.model.Pod)1 PodList (io.fabric8.kubernetes.api.model.PodList)1 Service (io.fabric8.kubernetes.api.model.Service)1 ServiceList (io.fabric8.kubernetes.api.model.ServiceList)1 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)1