public PodSpecBuilder( PodSpecFluent<?> fluent ){ this(fluent, new PodSpec()); } public PodSpecBuilder( PodSpecFluent<?> fluent , PodSpec instance ){
public PodSpecBuilder(PodSpecFluent<?> fluent,Boolean validationEnabled){ this(fluent, new PodSpec(), validationEnabled); } public PodSpecBuilder(PodSpecFluent<?> fluent,PodSpec instance){
public PodSpecBuilder(){ this(new PodSpec()); } public PodSpecBuilder( PodSpecFluent<?> fluent ){
public PodSpecBuilder(Boolean validationEnabled){ this(new PodSpec(), validationEnabled); } public PodSpecBuilder(PodSpecFluent<?> fluent){
public PodSpecBuilder(){ this(new PodSpec()); } public PodSpecBuilder( PodSpecFluent<?> fluent ){
public PodSpecBuilder( PodSpecFluent<?> fluent ){ this(fluent, new PodSpec()); } public PodSpecBuilder( PodSpecFluent<?> fluent , PodSpec instance ){
/** * Returns the desired state; lazily creating one if required */ public static PodSpec getOrCreatePodSpec(Pod pod) { Objects.notNull(pod, "pod"); PodSpec desiredState = pod.getSpec(); if (desiredState == null) { desiredState = new PodSpec(); pod.setSpec(desiredState); } return desiredState; }
public static Pod parseFromYaml(String yaml) { try (KubernetesClient client = new DefaultKubernetesClient()) { Pod podFromYaml = client.pods().load(new ByteArrayInputStream((yaml == null ? "" : yaml).getBytes(UTF_8))) .get(); LOGGER.log(Level.FINEST, "Parsed pod template from yaml: {0}", podFromYaml); // yaml can be just a fragment, avoid NPEs if (podFromYaml.getMetadata() == null) { podFromYaml.setMetadata(new ObjectMeta()); } if (podFromYaml.getSpec() == null) { podFromYaml.setSpec(new PodSpec()); } return podFromYaml; } }
@Test public void shouldCombineAllTolerations() { PodSpec podSpec1 = new PodSpec(); Pod pod1 = new Pod(); Toleration toleration1 = new Toleration("effect1", "key1", "oper1", Long.parseLong("1"), "val1"); Toleration toleration2 = new Toleration("effect2", "key2", "oper2", Long.parseLong("2"), "val2"); podSpec1.setTolerations(asList(toleration1, toleration2)); pod1.setSpec(podSpec1); pod1.setMetadata(new ObjectMeta()); PodSpec podSpec2 = new PodSpec(); Pod pod2 = new Pod(); Toleration toleration3 = new Toleration("effect3", "key3", "oper3", Long.parseLong("3"), "val3"); Toleration toleration4 = new Toleration("effect4", "key4", "oper4", Long.parseLong("4"), "val4"); podSpec2.setTolerations(asList(toleration3, toleration4)); pod2.setSpec(podSpec2); pod2.setMetadata(new ObjectMeta()); Pod result = combine(pod1, pod2); assertThat(result.getSpec().getTolerations(), containsInAnyOrder(toleration1, toleration2, toleration3, toleration4)); }
public PodSpec build(){ PodSpec buildable = new PodSpec(fluent.getActiveDeadlineSeconds(),fluent.getContainers(),fluent.getDnsPolicy(),fluent.getHost(),fluent.isHostNetwork(),fluent.getImagePullSecrets(),fluent.getNodeSelector(),fluent.getRestartPolicy(),fluent.getServiceAccount(),fluent.getTerminationGracePeriodSeconds(),fluent.getVolumes()); validate(buildable); return buildable; }
public PodSpec build(){ PodSpec buildable = new PodSpec(fluent.getActiveDeadlineSeconds(),fluent.getContainers(),fluent.getDnsPolicy(),fluent.getHost(),fluent.isHostIPC(),fluent.isHostNetwork(),fluent.isHostPID(),fluent.getHostname(),fluent.getImagePullSecrets(),fluent.getNodeName(),fluent.getNodeSelector(),fluent.getRestartPolicy(),fluent.getSecurityContext(),fluent.getServiceAccount(),fluent.getServiceAccountName(),fluent.getSubdomain(),fluent.getTerminationGracePeriodSeconds(),fluent.getVolumes()); validate(buildable); return buildable; }
metadata.setLabels(normalizeLabels(labels)); podTemplateSpec.setMetadata(metadata); final PodSpec podSpec = new PodSpec(); podSpec.setServiceAccountName(normalizeServiceAccountName(serviceAccountName)); podSpec.setContainers(Arrays.asList(this.createContainer(imageName, imagePullPolicy, maxHistory, namespace, tls, verifyTls)));
metadata.setLabels(normalizeLabels(labels)); podTemplateSpec.setMetadata(metadata); final PodSpec podSpec = new PodSpec(); podSpec.setServiceAccountName(normalizeServiceAccountName(serviceAccountName)); podSpec.setContainers(Arrays.asList(this.createContainer(imageName, imagePullPolicy, maxHistory, namespace, tls, verifyTls)));