service.getMetadata().getAnnotations(), metadataProps.getAnnotationsPrefix()); if (log.isDebugEnabled()) { log.debug("Adding annotation metadata: "+annotationMetadata); service.getMetadata().getName(), service.getMetadata().getLabels(), service.getMetadata().getAnnotations()
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 void deleteBuilds() { if (getName() == null) { return; } String buildConfigLabelValue = getName().substring(0, Math.min(getName().length(), 63)); BuildList matchingBuilds = new BuildOperationsImpl(client, (OpenShiftConfig) config, namespace).inNamespace(namespace).withLabel(BUILD_CONFIG_LABEL, buildConfigLabelValue).list(); if (matchingBuilds.getItems() != null) { for (Build matchingBuild : matchingBuilds.getItems()) { if (matchingBuild.getMetadata() != null && matchingBuild.getMetadata().getAnnotations() != null && getName().equals(matchingBuild.getMetadata().getAnnotations().get(BUILD_CONFIG_ANNOTATION))) { new BuildOperationsImpl(client, (OpenShiftConfig) config, namespace).inNamespace(matchingBuild.getMetadata().getNamespace()).withName(matchingBuild.getMetadata().getName()).delete(); } } } }
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; }
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); } } } } }
private boolean isGuvnorAlaGenerated(HasMetadata item) { if (item != null) { Map<String, String> annotations = item.getMetadata().getAnnotations(); if (annotations != null) { String generated = annotations.get(GUVNOR_ALA_GENERATED); return generated != null && Boolean.parseBoolean(generated); } } return false; }
private Collection<String> asList(HasMetadata deployment, String topics) { String value = deployment.getMetadata().getAnnotations().get(topics); if (value == null || value.trim().isEmpty()) { return Collections.emptySet(); } // Return non empty strings as set return Arrays.asList(value.split(",")).stream().map(String::trim).filter(String::isEmpty).collect(Collectors.toSet()); }
protected boolean canWriteTriggers(HasMetadata res) { return res.getMetadata() == null || res.getMetadata().getAnnotations() == null || !res.getMetadata().getAnnotations().containsKey(TRIGGERS_ANNOTATION); }
protected boolean canWriteTriggers(HasMetadata res) { return res.getMetadata() == null || res.getMetadata().getAnnotations() == null || !res.getMetadata().getAnnotations().containsKey(TRIGGERS_ANNOTATION); }
public List<Pod> listPods(Map<String, String> labelSelector, Map<String, String> annotationSelector) { return client.pods().withLabels(labelSelector).list().getItems().stream().filter(pod -> { for (Map.Entry<String, String> entry : annotationSelector.entrySet()) { return pod.getMetadata().getAnnotations() != null && pod.getMetadata().getAnnotations().get(entry.getKey()) != null && pod.getMetadata().getAnnotations().get(entry.getKey()).equals(entry.getValue()); } return true; }).collect(Collectors.toList()); }
public OpenShiftServerResolver(List<Service> services, List<Route> routes) { super(services, Collections.emptyList()); this.routes = ArrayListMultimap.create(); for (Route route : routes) { String machineName = Annotations.newDeserializer(route.getMetadata().getAnnotations()).machineName(); this.routes.put(machineName, route); } }
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); }
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); } }
private void logEvent(Watcher.Action action, Pod pod, String resourceVersion, boolean polled) { final String podName = pod.getMetadata().getName(); final String workflowInstance = Optional.ofNullable(pod.getMetadata().getAnnotations()) .map(annotations -> annotations.get(STYX_WORKFLOW_INSTANCE_ANNOTATION)) .orElse("N/A"); final String status = readStatus(pod); LOG.info("{}Pod event for {} ({}) at resource version {}, action: {}, workflow instance: {}, status: {}", polled ? "Polled: " : "", podName, pod.getMetadata().getUid(), resourceVersion, action, workflowInstance, status); }
public PodLogHandler(LogsController logsController, Pod pod) { this.logsController = logsController; this.podName = pod.getMetadata().getName(); Map<String, String> annotations = pod.getMetadata().getAnnotations(); this.integrationId = annotations.get(OpenShiftService.INTEGRATION_ID_LABEL); Map<String, String> labels = pod.getMetadata().getLabels(); this.deploymentId = labels.get(OpenShiftService.DEPLOYMENT_ID_LABEL); }
protected static boolean configEqualObjectMeta(ObjectMeta entity1, ObjectMeta entity2) { if (entity1 == entity2) { return true; } else if (entity1 == null || entity2 == null) { return false; } // TODO should we ignore annotations? return java.util.Objects.equals(entity1.getName(), entity2.getName()) && java.util.Objects.equals(entity1.getNamespace(), entity2.getNamespace()) && configEqualMap(entity1.getLabels(), entity2.getLabels()) && configEqualMap(entity1.getAnnotations(), entity2.getAnnotations()); }
@Override public void visit(PersistentVolumeClaimBuilder pvcBuilder) { // lets ensure we have a default storage class so that PVs will get dynamically created OOTB if (pvcBuilder.buildMetadata() == null) { pvcBuilder.withNewMetadata().endMetadata(); } String storageClass = getConfig(Config.defaultStorageClass); if (StringUtils.isNotBlank(storageClass) && !pvcBuilder.buildMetadata().getAnnotations().containsKey(VOLUME_STORAGE_CLASS_ANNOTATION)) { pvcBuilder.editMetadata().addToAnnotations(VOLUME_STORAGE_CLASS_ANNOTATION, storageClass).endMetadata(); } } });
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())); } } }
@Override public void visit(PersistentVolumeClaimBuilder pvcBuilder) { // lets ensure we have a default storage class so that PVs will get dynamically created OOTB if (pvcBuilder.buildMetadata() == null) { pvcBuilder.withNewMetadata().endMetadata(); } String storageClass = getConfig(Config.defaultStorageClass); if (Strings.isNotBlank(storageClass) && !pvcBuilder.buildMetadata().getAnnotations().containsKey(VOLUME_STORAGE_CLASS_ANNOTATION)) { pvcBuilder.editMetadata().addToAnnotations(VOLUME_STORAGE_CLASS_ANNOTATION, storageClass).endMetadata(); } } });