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());
}
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;
}
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();
}
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();
});
}
Aggregations