@Override public int compare(Build b1, Build b2) { return Long.compare( parseTimestamp(b1.getMetadata().getCreationTimestamp()), parseTimestamp(b2.getMetadata().getCreationTimestamp()) ); } });
public static Date getCreationTimestamp(HasMetadata hasMetadata) { ObjectMeta metadata = hasMetadata.getMetadata(); if (metadata != null) { return parseTimestamp(metadata.getCreationTimestamp()); } return null; }
public void scanNode(Node node) { ObjectNode n = mapper.createObjectNode(); ObjectMeta meta = node.getMetadata(); n.put("nodeUid", meta.getUid()); n.put("resourceVersion", meta.getResourceVersion()); n.put("name", meta.getName()); n.put("namespace", meta.getNamespace()); n.put("clusterName", meta.getClusterName()); n.put("generateName", meta.getGenerateName()); n.put("creationTimestamp", meta.getCreationTimestamp()); n.put("deletionTimestamp", meta.getDeletionTimestamp()); n.put("deletionGracePeriod", meta.getDeletionGracePeriodSeconds()); n.put("selfLink", meta.getSelfLink()); NodeStatus ns = node.getStatus(); NodeSpec nodeSpec = node.getSpec(); n.put("externalId", nodeSpec.getExternalID()); n.put("unschedulable", nodeSpec.getUnschedulable()); n.put("podCIDR", nodeSpec.getPodCIDR()); n.put("providerId", nodeSpec.getProviderID()); n.put("clusterId", clusterId); getNeoRxClient().execCypher("merge (n:KubeNode {nodeUid:{nodeUid}}) set n.clusterId={clusterId}, n+={props}", "nodeUid", meta.getUid(), "props", n, "clusterId", clusterId); }
.equals(secretEpoch(secret))) .filter(secret -> Instant.parse(secret.getMetadata().getCreationTimestamp()).isBefore(creationDeadline))
private OpenShiftRuntimeState getRuntimeState(OpenShiftRuntimeId runtimeId) { String prjName = runtimeId.project(); String svcName = runtimeId.service(); String state; String startedAt; Service service = delegate.services().inNamespace(prjName).withName(svcName).get(); if (service != null) { Integer replicas = getReplicas(service); if (replicas != null && replicas.intValue() > 0) { state = OpenShiftRuntimeState.RUNNING; } else { state = OpenShiftRuntimeState.READY; } startedAt = service.getMetadata().getCreationTimestamp(); } else { state = OpenShiftRuntimeState.UNKNOWN; startedAt = new Date().toString(); } return new OpenShiftRuntimeState(state, startedAt); }
static List<TableRow> createRows(UserList userList, Instant now) { return userList.getItems().stream() .map(user -> new TableRow( Arrays.asList( user.getMetadata().getName(), user.getSpec().getUsername(), user.getSpec().getAuthentication().getType().name(), Optional.ofNullable(user.getMetadata().getCreationTimestamp()) .map(s -> TimeUtil.formatHumanReadable(Duration.between(TimeUtil.parseRfc3339(s), now))) .orElse("")), new PartialObjectMetadata(new ObjectMetaBuilder() .withNamespace(user.getMetadata().getNamespace()) .withName(user.getMetadata().getName()) .withCreationTimestamp(user.getMetadata().getCreationTimestamp()) .withSelfLink(user.getMetadata().getSelfLink()) .withResourceVersion(user.getMetadata().getResourceVersion()) .build()))) .collect(Collectors.toList()); } }
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); } }
n.put("creationTimestamp", meta.getCreationTimestamp()); n.put("deletionTimestamp", meta.getDeletionTimestamp()); n.put("deletionGracePeriod", meta.getDeletionGracePeriodSeconds());
private static List<TableRow> createRows(Instant now, List<AddressSpace> addressSpaceList) { return addressSpaceList.stream() .map(addressSpace -> new TableRow( Arrays.asList( addressSpace.getMetadata().getName(), addressSpace.getSpec().getType(), addressSpace.getSpec().getPlan(), addressSpace.getStatus().isReady(), Optional.ofNullable(addressSpace.getMetadata().getCreationTimestamp()) .map(s -> TimeUtil.formatHumanReadable(Duration.between(TimeUtil.parseRfc3339(s), now))) .orElse(""), String.join(". ", addressSpace.getStatus().getMessages())), new PartialObjectMetadata(new ObjectMetaBuilder() .withNamespace(addressSpace.getMetadata().getNamespace()) .withName(addressSpace.getMetadata().getName()) .withLabels(addressSpace.getMetadata().getLabels()) .withAnnotations(addressSpace.getMetadata().getAnnotations()) .withCreationTimestamp(addressSpace.getMetadata().getCreationTimestamp()) .withSelfLink(addressSpace.getMetadata().getSelfLink()) .withUid(addressSpace.getMetadata().getUid()) .withResourceVersion(addressSpace.getMetadata().getResourceVersion()) .build()))) .collect(Collectors.toList()); } }
private List<TableRow> createRows(List<Address> addressList) { Instant now = clock.instant(); return addressList.stream() .map(address -> new TableRow( Arrays.asList( address.getMetadata().getName(), address.getSpec().getAddress(), Address.extractAddressSpace(address), address.getSpec().getType(), address.getSpec().getPlan(), address.getStatus().isReady(), address.getStatus().getPhase(), Optional.ofNullable(address.getMetadata().getCreationTimestamp()) .map(s -> TimeUtil.formatHumanReadable(Duration.between(TimeUtil.parseRfc3339(s), now))) .orElse(""), String.join(". ", address.getStatus().getMessages())), new PartialObjectMetadata(new ObjectMetaBuilder() .withNamespace(address.getMetadata().getNamespace()) .withName(address.getMetadata().getName()) .withLabels(address.getMetadata().getLabels()) .withAnnotations(address.getMetadata().getAnnotations()) .withCreationTimestamp(address.getMetadata().getCreationTimestamp()) .withSelfLink(address.getMetadata().getSelfLink()) .withUid(address.getMetadata().getUid()) .withResourceVersion(address.getMetadata().getResourceVersion()) .build()))) .collect(Collectors.toList()); } }
public ObjectMetaBuilder( ObjectMetaFluent<?> fluent , ObjectMeta instance ){ this.fluent = fluent; fluent.withAnnotations(instance.getAnnotations()); fluent.withCreationTimestamp(instance.getCreationTimestamp()); fluent.withDeletionTimestamp(instance.getDeletionTimestamp()); fluent.withGenerateName(instance.getGenerateName()); fluent.withLabels(instance.getLabels()); fluent.withName(instance.getName()); fluent.withNamespace(instance.getNamespace()); fluent.withResourceVersion(instance.getResourceVersion()); fluent.withSelfLink(instance.getSelfLink()); fluent.withUid(instance.getUid()); } public ObjectMetaBuilder( ObjectMeta instance ){
public ObjectMetaBuilder( ObjectMetaFluent<?> fluent , ObjectMeta instance ){ this.fluent = fluent; fluent.withAnnotations(instance.getAnnotations()); fluent.withCreationTimestamp(instance.getCreationTimestamp()); fluent.withDeletionTimestamp(instance.getDeletionTimestamp()); fluent.withGenerateName(instance.getGenerateName()); fluent.withLabels(instance.getLabels()); fluent.withName(instance.getName()); fluent.withNamespace(instance.getNamespace()); fluent.withResourceVersion(instance.getResourceVersion()); fluent.withSelfLink(instance.getSelfLink()); fluent.withUid(instance.getUid()); } public ObjectMetaBuilder( ObjectMeta instance ){
public ObjectMetaBuilder( ObjectMeta instance ){ this.fluent = this; this.withAnnotations(instance.getAnnotations()); this.withCreationTimestamp(instance.getCreationTimestamp()); this.withDeletionTimestamp(instance.getDeletionTimestamp()); this.withGenerateName(instance.getGenerateName()); this.withLabels(instance.getLabels()); this.withName(instance.getName()); this.withNamespace(instance.getNamespace()); this.withResourceVersion(instance.getResourceVersion()); this.withSelfLink(instance.getSelfLink()); this.withUid(instance.getUid()); }
public ObjectMetaBuilder( ObjectMeta instance ){ this.fluent = this; this.withAnnotations(instance.getAnnotations()); this.withCreationTimestamp(instance.getCreationTimestamp()); this.withDeletionTimestamp(instance.getDeletionTimestamp()); this.withGenerateName(instance.getGenerateName()); this.withLabels(instance.getLabels()); this.withName(instance.getName()); this.withNamespace(instance.getNamespace()); this.withResourceVersion(instance.getResourceVersion()); this.withSelfLink(instance.getSelfLink()); this.withUid(instance.getUid()); }
public ObjectMetaFluentImpl(ObjectMeta instance){ this.withAnnotations(instance.getAnnotations()); this.withCreationTimestamp(instance.getCreationTimestamp()); this.withDeletionGracePeriodSeconds(instance.getDeletionGracePeriodSeconds()); this.withDeletionTimestamp(instance.getDeletionTimestamp()); this.withFinalizers(instance.getFinalizers()); this.withGenerateName(instance.getGenerateName()); this.withGeneration(instance.getGeneration()); this.withLabels(instance.getLabels()); this.withName(instance.getName()); this.withNamespace(instance.getNamespace()); this.withOwnerReferences(instance.getOwnerReferences()); this.withResourceVersion(instance.getResourceVersion()); this.withSelfLink(instance.getSelfLink()); this.withUid(instance.getUid()); }
public ObjectMetaBuilder(ObjectMeta instance,Boolean validationEnabled){ this.fluent = this; this.withAnnotations(instance.getAnnotations()); this.withCreationTimestamp(instance.getCreationTimestamp()); this.withDeletionGracePeriodSeconds(instance.getDeletionGracePeriodSeconds()); this.withDeletionTimestamp(instance.getDeletionTimestamp()); this.withFinalizers(instance.getFinalizers()); this.withGenerateName(instance.getGenerateName()); this.withGeneration(instance.getGeneration()); this.withLabels(instance.getLabels()); this.withName(instance.getName()); this.withNamespace(instance.getNamespace()); this.withOwnerReferences(instance.getOwnerReferences()); this.withResourceVersion(instance.getResourceVersion()); this.withSelfLink(instance.getSelfLink()); this.withUid(instance.getUid()); this.validationEnabled = validationEnabled; }
public ObjectMetaBuilder(ObjectMetaFluent<?> fluent,ObjectMeta instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withAnnotations(instance.getAnnotations()); fluent.withCreationTimestamp(instance.getCreationTimestamp()); fluent.withDeletionGracePeriodSeconds(instance.getDeletionGracePeriodSeconds()); fluent.withDeletionTimestamp(instance.getDeletionTimestamp()); fluent.withFinalizers(instance.getFinalizers()); fluent.withGenerateName(instance.getGenerateName()); fluent.withGeneration(instance.getGeneration()); fluent.withLabels(instance.getLabels()); fluent.withName(instance.getName()); fluent.withNamespace(instance.getNamespace()); fluent.withOwnerReferences(instance.getOwnerReferences()); fluent.withResourceVersion(instance.getResourceVersion()); fluent.withSelfLink(instance.getSelfLink()); fluent.withUid(instance.getUid()); this.validationEnabled = validationEnabled; } public ObjectMetaBuilder(ObjectMeta instance){