private ConfigMap create(AddressSpace addressSpace) { Map<String, String> labels = addressSpace.getMetadata().getLabels(); if ( labels == null ) { labels = new HashMap<>(); addressSpace.getMetadata().setLabels(labels); } String name = getConfigMapName(addressSpace.getMetadata().getNamespace(), addressSpace.getMetadata().getName()); labels.put(LabelKeys.TYPE, "address-space"); labels.put(LabelKeys.NAMESPACE, addressSpace.getMetadata().getNamespace()); ConfigMapBuilder builder = new ConfigMapBuilder() .editOrNewMetadata() .withName(name) .addToLabels(labels) .addToAnnotations(addressSpace.getMetadata().getAnnotations()) .endMetadata(); if (addressSpace.getMetadata().getResourceVersion() != null) { builder.editOrNewMetadata() .withResourceVersion(addressSpace.getMetadata().getResourceVersion()) .endMetadata(); } try { // Reset resource version to avoid unneeded extra writes AddressSpace newAddressSpace = new AddressSpaceBuilder(addressSpace).editOrNewMetadata().withResourceVersion(null).endMetadata().build(); builder.addToData("config.json", mapper.writeValueAsString(newAddressSpace)); return builder.build(); } catch (IOException e) { log.info("Error serializing addressspace for {}", addressSpace, e); throw new UncheckedIOException(e); } }
public static synchronized ConfigMap updateConfigMapStatus(KubernetesClient client, final Session session, final String status) { try { ConfigMap configMap = new ConfigMapBuilder(). withNewMetadata().withName(FABRIC8_ARQUILLIAN).addToAnnotations(createConfigMapAnnotations(session, status)).endMetadata(). build(); return client.configMaps().inNamespace(session.getNamespace()).withName(FABRIC8_ARQUILLIAN).createOrReplace(configMap); } catch (Exception e) { LOG.warn("failed to update ConfigMap " + FABRIC8_ARQUILLIAN + ". " + e, e); return null; } }
private ConfigMap create(Address address) { ConfigMapBuilder builder = new ConfigMapBuilder() .editOrNewMetadata() .withName(getConfigMapName(address.getMetadata().getNamespace(), address.getMetadata().getName())) .addToLabels(address.getMetadata().getLabels()) .addToLabels(LabelKeys.TYPE, "address-config") .addToLabels(LabelKeys.INFRA_UUID, infraUuid) .addToLabels(LabelKeys.INFRA_TYPE, "any") .addToAnnotations(address.getMetadata().getAnnotations()) // TODO: Support other ways of doing this .addToAnnotations(AnnotationKeys.ADDRESS_SPACE, Address.extractAddressSpace(address)) .endMetadata(); if (address.getMetadata().getResourceVersion() != null) { builder.editOrNewMetadata() .withResourceVersion(address.getMetadata().getResourceVersion()) .endMetadata(); } try { // Reset resource version to avoid unneeded extra writes final Address newAddress = new AddressBuilder(address).editOrNewMetadata().withResourceVersion(null).endMetadata().build(); builder.addToData("config.json", mapper.writeValueAsString(newAddress)); return builder.build(); } catch (IOException e) { log.info("Error serializing address for {}", address, e); throw new UncheckedIOException(e); } }