protected Map<String, String> getLabelsWithName(String name) { return labels.withName(name).toMap(); }
public Labels withUserLabels(Map<String, String> userLabels) { Map<String, String> newLabels = new HashMap<>(labels.size()); newLabels.putAll(labels); newLabels.putAll(Labels.userLabels(userLabels).toMap()); return new Labels(newLabels); }
protected Map<String, String> getSelectorLabels() { return labels.withName(name).strimziLabels().toMap(); }
protected Map<String, String> getLabelsWithName(String name, Map<String, String> userLabels) { return labels.withName(name).withUserLabels(userLabels).toMap(); }
@Test public void testWithUserLabels() { Labels start = Labels.forCluster("my-cluster"); // null user labels Labels nullLabels = start.withUserLabels(null); assertEquals(start.toMap(), nullLabels.toMap()); // Non-null values Map userLabels = new HashMap<String, String>(2); userLabels.put("key1", "value1"); userLabels.put("key2", "value2"); Map<String, String> expected = new HashMap<String, String>(); expected.putAll(start.toMap()); expected.putAll(userLabels); Labels nonNullLabels = start.withUserLabels(userLabels); assertEquals(expected, nonNullLabels.toMap()); }
protected Watch watchInAnyNamespace(Labels selector, Watcher<T> watcher) { return operation().inAnyNamespace().withLabels(selector.toMap()).watch(watcher); }
protected Watch watchInNamespace(String namespace, Labels selector, Watcher<T> watcher) { return operation().inNamespace(namespace).withLabels(selector.toMap()).watch(watcher); }
@Test public void testStrimziLabels() { Map sourceMap = new HashMap<String, String>(5); sourceMap.put(Labels.STRIMZI_CLUSTER_LABEL, "my-cluster"); sourceMap.put("key1", "value1"); sourceMap.put(Labels.STRIMZI_KIND_LABEL, "Kafka"); sourceMap.put("key2", "value2"); sourceMap.put(Labels.STRIMZI_NAME_LABEL, "my-cluster-kafka"); Labels labels = Labels.fromMap(sourceMap); Map expected = new HashMap<String, String>(2); expected.put(Labels.STRIMZI_CLUSTER_LABEL, "my-cluster"); expected.put(Labels.STRIMZI_KIND_LABEL, "Kafka"); expected.put(Labels.STRIMZI_NAME_LABEL, "my-cluster-kafka"); assertEquals(expected, labels.strimziLabels().toMap()); }
protected List<T> listInAnyNamespace(Labels selector) { FilterWatchListMultiDeletable<T, L, Boolean, Watch, Watcher<T>> operation = operation().inAnyNamespace(); if (selector != null) { Map<String, String> labels = selector.toMap(); return operation.withLabels(labels) .list() .getItems(); } else { return operation .list() .getItems(); } }
/** * Generates service for pod. This service is used for exposing it externally. * * @param pod Number of the pod for which this service should be generated * @return The generated Service */ public Service generateExternalService(int pod) { if (isExposed()) { String perPodServiceName = externalServiceName(cluster, pod); List<ServicePort> ports = new ArrayList<>(1); ports.add(createServicePort(EXTERNAL_PORT_NAME, EXTERNAL_PORT, EXTERNAL_PORT, "TCP")); Labels selector = Labels.fromMap(getSelectorLabels()).withStatefulSetPod(kafkaPodName(cluster, pod)); return createService(perPodServiceName, getExternalServiceType(), ports, getLabelsWithName(perPodServiceName, templatePerPodServiceLabels), selector.toMap(), mergeAnnotations(Collections.EMPTY_MAP, templatePerPodServiceAnnotations)); } return null; }
protected List<T> listInNamespace(String namespace, Labels selector) { NonNamespaceOperation<T, L, D, R> tldrNonNamespaceOperation = operation().inNamespace(namespace); if (selector != null) { Map<String, String> labels = selector.toMap(); return tldrNonNamespaceOperation.withLabels(labels) .list() .getItems(); } else { return tldrNonNamespaceOperation .list() .getItems(); } }
protected ConfigMap createConfigMap(String name, Map<String, String> data) { return new ConfigMapBuilder() .withNewMetadata() .withName(name) .withNamespace(namespace) .withLabels(labels.toMap()) .withOwnerReferences(createOwnerReference()) .endMetadata() .withData(data) .build(); }
/** * Creates secret with the data * @param data Map with the Secret content * @return */ protected Secret createSecret(Map<String, String> data) { Secret s = new SecretBuilder() .withNewMetadata() .withName(getSecretName()) .withNamespace(namespace) .withLabels(labels.toMap()) .endMetadata() .withData(data) .build(); return s; }
public static Secret createSecret(String name, String namespace, Labels labels, OwnerReference ownerReference, Map<String, String> data) { if (ownerReference == null) { return new SecretBuilder() .withNewMetadata() .withName(name) .withNamespace(namespace) .withLabels(labels.toMap()) .endMetadata() .withData(data).build(); } else { return new SecretBuilder() .withNewMetadata() .withName(name) .withOwnerReferences(ownerReference) .withNamespace(namespace) .withLabels(labels.toMap()) .endMetadata() .withData(data).build(); } }
.withName(policyName(cluster)) .withNamespace(namespace) .withLabels(labels.toMap()) .withOwnerReferences(createOwnerReference()) .endMetadata()
.withName(policyName(cluster)) .withNamespace(namespace) .withLabels(labels.toMap()) .withOwnerReferences(createOwnerReference()) .endMetadata()
clusterCaConfig != null ? clusterCaConfig.getCertificateExpirationPolicy() : null); clusterCa.createRenewOrReplace( reconciliation.namespace(), reconciliation.name(), caLabels.toMap(), ownerRef); clientsCaConfig != null ? clientsCaConfig.getCertificateExpirationPolicy() : null); clientsCa.createRenewOrReplace(reconciliation.namespace(), reconciliation.name(), caLabels.toMap(), ownerRef);