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();
});
}
use of io.fabric8.kubernetes.api.model.ConfigMapList in project fabric8 by fabric8io.
the class KubernetesConfigAdminBridge method activate.
// ***********************
// Lifecycle
// ***********************
@Activate
void activate() {
enabled = getSystemPropertyOrEnvVar(FABRIC8_CM_BRIDGE_ENABLED, enabled);
pidLabel = getSystemPropertyOrEnvVar(FABRIC8_PID_LABEL, pidLabel);
configMerge = getSystemPropertyOrEnvVar(FABRIC8_CONFIG_MERGE, configMerge);
configMeta = getSystemPropertyOrEnvVar(FABRIC8_CONFIG_META, configMeta);
configWatch = getSystemPropertyOrEnvVar(FABRIC8_CONFIG_WATCH, configWatch);
filters = new HashMap<>();
String filterList = getSystemPropertyOrEnvVar(FABRIC8_PID_FILTERS);
if (!Utils.isNullOrEmpty(filterList)) {
for (String filter : filterList.split(",")) {
String[] kv = filter.split("=");
if (kv.length == 2) {
Set<String> orConditions = new HashSet<>();
for (String orCondition : kv[1].split(";")) {
orConditions.add(orCondition.trim());
}
filters.put(kv[0].trim(), orConditions);
}
}
}
if (enabled) {
synchronized (lock) {
watchConfigMapList();
ConfigMapList list = getConfigMapList();
if (list != null) {
for (ConfigMap map : list.getItems()) {
updateConfig(map);
}
}
}
}
}
use of io.fabric8.kubernetes.api.model.ConfigMapList in project fabric8 by jboss-fuse.
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");
}
}
}
Aggregations