Java Code Examples for io.fabric8.kubernetes.api.model.ObjectMeta#getAnnotations()
The following examples show how to use
io.fabric8.kubernetes.api.model.ObjectMeta#getAnnotations() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KubernetesService.java From vault-crd with Apache License 2.0 | 6 votes |
private ObjectMeta metaData(ObjectMeta resource, String compare) { ObjectMeta meta = new ObjectMeta(); meta.setNamespace(resource.getNamespace()); meta.setName(resource.getName()); if (resource.getLabels() != null) { meta.setLabels(resource.getLabels()); } HashMap<String, String> annotations = new HashMap<>(); if (resource.getAnnotations() != null) { annotations.putAll(resource.getAnnotations()); } annotations.put(crdName + LAST_UPDATE_ANNOTATION, LocalDateTime.now().toString()); annotations.put(crdName + COMPARE_ANNOTATION, compare); meta.setAnnotations(annotations); return meta; }
Example 2
Source File: OpenShiftProjectFactory.java From che with Eclipse Public License 2.0 | 6 votes |
private KubernetesNamespaceMeta asNamespaceMeta(io.fabric8.openshift.api.model.Project project) { Map<String, String> attributes = new HashMap<>(4); ObjectMeta metadata = project.getMetadata(); Map<String, String> annotations = metadata.getAnnotations(); String displayName = annotations.get(Constants.PROJECT_DISPLAY_NAME_ANNOTATION); if (displayName != null) { attributes.put(Constants.PROJECT_DISPLAY_NAME_ATTRIBUTE, displayName); } String description = annotations.get(Constants.PROJECT_DESCRIPTION_ANNOTATION); if (description != null) { attributes.put(Constants.PROJECT_DESCRIPTION_ATTRIBUTE, description); } if (project.getStatus() != null && project.getStatus().getPhase() != null) { attributes.put(PHASE_ATTRIBUTE, project.getStatus().getPhase()); } return new KubernetesNamespaceMetaImpl(metadata.getName(), attributes); }
Example 3
Source File: RemoveBuildAnnotationsEnricher.java From jkube with Eclipse Public License 2.0 | 5 votes |
private void removeBuildAnnotations(HasMetadata item) { if (item != null) { ObjectMeta metadata = item.getMetadata(); if (metadata != null) { Map<String, String> annotations = metadata.getAnnotations(); if (annotations != null) { annotations.remove(RESOURCE_SOURCE_URL_ANNOTATION); } } } }
Example 4
Source File: KubernetesHelper.java From jkube with Eclipse Public License 2.0 | 5 votes |
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; }
Example 5
Source File: Names.java From che with Eclipse Public License 2.0 | 5 votes |
/** * Records the machine name used for given container in the annotations of the object metadata. * * @param objectMeta the object metadata * @param containerName the name of the container * @param machineName the name of the machine of the container */ public static void putMachineName( ObjectMeta objectMeta, String containerName, String machineName) { Map<String, String> annotations = objectMeta.getAnnotations(); if (annotations == null) { objectMeta.setAnnotations(annotations = new HashMap<>()); } putMachineName(annotations, containerName, machineName); }
Example 6
Source File: KubernetesObjectUtil.java From che with Eclipse Public License 2.0 | 5 votes |
/** Adds annotation to target ObjectMeta object. */ public static void putAnnotation(ObjectMeta metadata, String key, String value) { Map<String, String> annotations = metadata.getAnnotations(); if (annotations == null) { metadata.setAnnotations(annotations = new HashMap<>()); } annotations.put(key, value); }
Example 7
Source File: KubernetesObjectUtil.java From che with Eclipse Public License 2.0 | 5 votes |
/** Adds annotations to target ObjectMeta object. */ public static void putAnnotations(ObjectMeta metadata, Map<String, String> annotations) { if (annotations == null || annotations.isEmpty()) { return; } Map<String, String> metaAnnotations = metadata.getAnnotations(); if (metaAnnotations == null) { metadata.setAnnotations(new HashMap<>(annotations)); } else { metaAnnotations.putAll(annotations); } }
Example 8
Source File: KubernetesResourceUtil.java From kubernetes-client with Apache License 2.0 | 5 votes |
/** * Null safe get for fetching annotations from MetaData of Kubernetes Resource * * @param entity Kubernetes resource * @return returns a hashmap containing annotations */ 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; }