public static Map<String, String> getOrCreateAnnotations(HasMetadata entity) { ObjectMeta metadata = getOrCreateMetadata(entity); Map<String, String> answer = metadata.getAnnotations(); if (answer == null) { // use linked so the annotations can be in the FIFO order answer = new LinkedHashMap<>(); metadata.setAnnotations(answer); } return answer; }
/** * Null safe get for fetching annotations from MetaData of Kubernetes Resource * * @param entity Kubernetes resource * @return */ public static Map<String, String> getOrCreateAnnotations(HasMetadata entity) { ObjectMeta metadata = getOrCreateMetadata(entity); Map<String, String> answer = metadata.getAnnotations(); if (answer == null) { // use linked so the annotations can be in the FIFO order answer = new LinkedHashMap<>(); metadata.setAnnotations(answer); } return answer; }
private static Map<String, String> annotations(ObjectMeta metadata) { Map<String, String> annotations = metadata.getAnnotations(); if (annotations == null) { annotations = new HashMap<>(3); metadata.setAnnotations(annotations); } return annotations; }
public static void setSourceUrlAnnotationIfNotSet(HasMetadata item, String sourceUrl) { Map<String, String> annotations = KubernetesHelper.getOrCreateAnnotations(item); if (!annotations.containsKey(RESOURCE_SOURCE_URL_ANNOTATION)) { annotations.put(RESOURCE_SOURCE_URL_ANNOTATION, sourceUrl); item.getMetadata().setAnnotations(annotations); } }
private void setGuvnorAlaGenerated(HasMetadata item) { if (item != null) { ObjectMeta metadata = item.getMetadata(); Map<String, String> annotations = metadata.getAnnotations(); if (annotations == null) { annotations = new HashMap<String, String>(); metadata.setAnnotations(annotations); } annotations.put(GUVNOR_ALA_GENERATED, Boolean.TRUE.toString()); } }
public static Map<String, String> getOrCreateAnnotations(HasMetadata entity) { ObjectMeta metadata = getOrCreateMetadata(entity); Map<String, String> answer = metadata.getAnnotations(); if (answer == null) { // use linked so the annotations can be in the FIFO order answer = new LinkedHashMap<>(); metadata.setAnnotations(answer); } return answer; }
public Address() { super(KIND, CoreCrd.API_VERSION); this.getMetadata().setAnnotations(new HashMap<>()); this.getMetadata().setLabels(new HashMap<>()); }
static void addObjectAnnotation(HasMetadata item, String annotationKey, String annotationValue) { Map<String, String> annotations = item.getMetadata().getAnnotations(); if (annotations == null) { annotations = new LinkedHashMap<>(); } annotations.put(annotationKey, annotationValue); item.getMetadata().setAnnotations(annotations); } }
static void addObjectAnnotation(HasMetadata item, String annotationKey, String annotationValue) { Map<String, String> annotations = item.getMetadata().getAnnotations(); if (annotations == null) { annotations = new LinkedHashMap<>(); } annotations.put(annotationKey, annotationValue); item.getMetadata().setAnnotations(annotations); }
static void overrideAnnotation(Address existing, Address address, String annotationKey) { if ( address.getMetadata().getAnnotations() == null ) { address.getMetadata().setAnnotations(new HashMap<>()); } override(existing.getMetadata().getAnnotations(), address.getMetadata().getAnnotations(), annotationKey); }
private static void mergeMetadata(PodTemplateSpec item1, PodTemplateSpec item2) { if (item1 != null && item2 != null) { ObjectMeta metadata1 = item1.getMetadata(); ObjectMeta metadata2 = item2.getMetadata(); if (metadata1 == null) { item1.setMetadata(metadata2); } else if (metadata2 != null) { metadata1.setAnnotations(mergeMapsAndRemoveEmptyStrings(metadata2.getAnnotations(), metadata1.getAnnotations())); metadata1.setLabels(mergeMapsAndRemoveEmptyStrings(metadata2.getLabels(), metadata1.getLabels())); } } }
protected static void mergeMetadata(HasMetadata item1, HasMetadata item2) { if (item1 != null && item2 != null) { ObjectMeta metadata1 = item1.getMetadata(); ObjectMeta metadata2 = item2.getMetadata(); if (metadata1 == null) { item1.setMetadata(metadata2); } else if (metadata2 != null) { metadata1.setAnnotations(mergeMapsAndRemoveEmptyStrings(metadata2.getAnnotations(), metadata1.getAnnotations())); metadata1.setLabels(mergeMapsAndRemoveEmptyStrings(metadata2.getLabels(), metadata1.getLabels())); } } }
om.setLabels(lbls); om.setOwnerReferences(topic.getMetadata().getOwnerReferences()); om.setAnnotations(topic.getMetadata().getAnnotations()); } else { om = new ObjectMetaBuilder() kt.getMetadata().setAnnotations(topic.getMetadata().getAnnotations()); return kt;
@Override public void adapt(KubernetesListBuilder builder) { super.adapt(builder); List<HasMetadata> items = builder.getItems(); for (HasMetadata item : items) { if (item instanceof Deployment) { Deployment deployment = (Deployment) item; ObjectMeta metadata = deployment.getMetadata(); DeploymentSpec spec = deployment.getSpec(); if (metadata != null && spec != null) { PodTemplateSpec template = spec.getTemplate(); if (template != null) { ObjectMeta templateMetadata = template.getMetadata(); if (templateMetadata == null) { templateMetadata = new ObjectMeta(); template.setMetadata(templateMetadata); } templateMetadata.setAnnotations(MapUtil.mergeMaps(templateMetadata.getAnnotations(), metadata.getAnnotations())); } } } } builder.withItems(items); } }
@Override public void adapt(KubernetesListBuilder builder) { super.adapt(builder); List<HasMetadata> items = builder.getItems(); for (HasMetadata item : items) { if (item instanceof Deployment) { Deployment deployment = (Deployment) item; ObjectMeta metadata = deployment.getMetadata(); DeploymentSpec spec = deployment.getSpec(); if (metadata != null && spec != null) { PodTemplateSpec template = spec.getTemplate(); if (template != null) { ObjectMeta templateMetadata = template.getMetadata(); if (templateMetadata == null) { templateMetadata = new ObjectMeta(); template.setMetadata(templateMetadata); } templateMetadata.setAnnotations(MapUtil.mergeMaps(templateMetadata.getAnnotations(), metadata.getAnnotations())); } } } } builder.withItems(items); } }