private Address getAddressFromConfig(ConfigMap map) { Map<String, String> data = map.getData(); try { Address address = mapper.readValue(data.get("config.json"), Address.class); AddressBuilder builder = new AddressBuilder(address); MetadataNested<AddressBuilder> metadataBuilder = builder.editOrNewMetadata(); if (address.getMetadata().getUid() == null) { metadataBuilder.withUid(map.getMetadata().getUid()); } metadataBuilder.withResourceVersion(map.getMetadata().getResourceVersion()); if (address.getMetadata().getCreationTimestamp() == null) { metadataBuilder.withCreationTimestamp(map.getMetadata().getCreationTimestamp()); } if (address.getMetadata().getSelfLink() == null) { metadataBuilder.withSelfLink("/apis/enmasse.io/v1beta1/namespaces/" + address.getMetadata().getNamespace() + "/addressspaces/" + Address.extractAddressSpace(address)); } // commit changes to metadata metadataBuilder.endMetadata(); return builder.build(); } catch (IOException e) { log.error("Error decoding address from configmap : {}", map, e); throw new UncheckedIOException(e); } }
private AddressSpace getAddressSpaceFromConfig(ConfigMap map) { try { AddressSpace addressSpace = mapper.readValue(map.getData().get("config.json"), AddressSpace.class); AddressSpaceBuilder builder = new AddressSpaceBuilder(addressSpace); MetadataNested<AddressSpaceBuilder> metadataBuilder = builder.editOrNewMetadata(); if (addressSpace.getMetadata().getUid() == null) { metadataBuilder.withUid(map.getMetadata().getUid()); } metadataBuilder.withResourceVersion(map.getMetadata().getResourceVersion()); if (addressSpace.getMetadata().getCreationTimestamp() == null) { metadataBuilder.withCreationTimestamp(map.getMetadata().getCreationTimestamp()); } if (addressSpace.getMetadata().getSelfLink() == null) { metadataBuilder.withSelfLink("/apis/enmasse.io/v1beta1/namespaces/" + addressSpace.getMetadata().getNamespace() + "/addressspaces/" + addressSpace.getMetadata().getName()); } // commit changes metadataBuilder.endMetadata(); return builder.build(); } catch (IOException e) { log.error("Error decoding address space from configmap : {}", map, e); throw new UncheckedIOException(e); } }