use of io.fabric8.kubernetes.api.model.ConfigMapList 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.ConfigMapList in project camel by apache.
the class KubernetesConfigMapsProducer method doList.
protected void doList(Exchange exchange, String operation) throws Exception {
ConfigMapList configMapsList = getEndpoint().getKubernetesClient().configMaps().list();
exchange.getOut().setBody(configMapsList.getItems());
}
use of io.fabric8.kubernetes.api.model.ConfigMapList in project fabric8 by fabric8io.
the class KubernetesConfigAdminBridge method watchConfigMapList.
private void watchConfigMapList() {
if (configWatch) {
KubernetesClient client = kubernetesClient.get();
if (client != null) {
FilterWatchListDeletable<ConfigMap, ConfigMapList, Boolean, Watch, Watcher<ConfigMap>> configMapsSelector = client.configMaps().withLabel(pidLabel);
for (String key : filters.keySet()) {
configMapsSelector.withLabelIn(key, filters.get(key).toArray(new String[filters.get(key).size()]));
}
watch = configMapsSelector.watch(this);
} else {
throw new RuntimeException("KubernetesClient not set");
}
}
}
use of io.fabric8.kubernetes.api.model.ConfigMapList 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.ConfigMapList 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