@Override int getDesiredReplicas(ReplicaSet item) { return item.getSpec().getReplicas(); }
@Override protected int getReplicas(ReplicaSet obj) { return obj.getSpec().getReplicas(); }
public static boolean isReplicaSetReady(ReplicaSet r) { Utils.checkNotNull(r, "ReplicationController can't be null."); ReplicaSetSpec spec = r.getSpec(); ReplicaSetStatus status = r.getStatus(); if (status == null || status.getReadyReplicas() == null) { return false; } //Can be true in testing, so handle it to make test writing easier. if (spec == null || spec.getReplicas() == null) { return false; } return spec.getReplicas().intValue() == status.getReadyReplicas(); }
@Override public HasMetadata convert(HasMetadata item, boolean trimImageInContainerSpec, boolean enableAutomaticTrigger) { ReplicaSet resource = (ReplicaSet) item; ReplicationControllerBuilder builder = new ReplicationControllerBuilder(); builder.withMetadata(resource.getMetadata()); ReplicaSetSpec spec = resource.getSpec(); if (spec != null) { ReplicationControllerFluent.SpecNested<ReplicationControllerBuilder> specBuilder = builder.withNewSpec(); Integer replicas = spec.getReplicas(); if (replicas != null) { specBuilder.withReplicas(replicas); } LabelSelector selector = spec.getSelector(); if (selector != null) { Map<String, String> matchLabels = selector.getMatchLabels(); if (matchLabels != null && !matchLabels.isEmpty()) { specBuilder.withSelector(matchLabels); } } PodTemplateSpec template = spec.getTemplate(); if (template != null) { specBuilder.withTemplate(template); } specBuilder.endSpec(); } return builder.build(); } }