From c758d2fbcf8d3b50b7c026155af89fad4dc4ee48 Mon Sep 17 00:00:00 2001 From: Kyou13 Date: Thu, 10 Mar 2022 11:28:33 +0900 Subject: [PATCH] to use createOrReplace --- .../kubernetes/DefaultKubernetesClient.java | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/digdag-standards/src/main/java/io/digdag/standards/command/kubernetes/DefaultKubernetesClient.java b/digdag-standards/src/main/java/io/digdag/standards/command/kubernetes/DefaultKubernetesClient.java index c04008ffc7..e17878a278 100644 --- a/digdag-standards/src/main/java/io/digdag/standards/command/kubernetes/DefaultKubernetesClient.java +++ b/digdag-standards/src/main/java/io/digdag/standards/command/kubernetes/DefaultKubernetesClient.java @@ -10,6 +10,7 @@ import io.digdag.spi.CommandRequest; import io.digdag.spi.TaskRequest; import io.fabric8.kubernetes.api.model.Affinity; +import io.fabric8.kubernetes.api.model.ConfigMapBuilder; import io.fabric8.kubernetes.api.model.Container; import io.fabric8.kubernetes.api.model.ContainerBuilder; import io.fabric8.kubernetes.api.model.ContainerStatus; @@ -23,8 +24,10 @@ import io.fabric8.kubernetes.api.model.Volume; import io.fabric8.kubernetes.api.model.VolumeMount; import io.fabric8.kubernetes.api.model.PersistentVolume; +import io.fabric8.kubernetes.api.model.PersistentVolumeBuilder; import io.fabric8.kubernetes.api.model.PersistentVolumeSpec; import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; +import io.fabric8.kubernetes.api.model.PersistentVolumeClaimBuilder; import io.fabric8.kubernetes.api.model.PersistentVolumeClaimSpec; import io.fabric8.kubernetes.client.dsl.PodResource; import io.fabric8.kubernetes.client.utils.Serialization; @@ -182,13 +185,15 @@ protected PersistentVolume createPersistentVolume(final CommandContext context) final Config kubernetesPvConfig = extractTargetKindConfig(context, "PersistentVolume"); if (kubernetesPvConfig != null && kubernetesPvConfig.has("spec")) return client.persistentVolumes() - .createOrReplaceWithNew() - .withNewMetadata() - .withName(kubernetesPvConfig.get("name", String.class)) - .withNamespace(client.getNamespace()) - .endMetadata() - .withSpec(getPersistentVolume(kubernetesPvConfig.get("spec", Config.class))) - .done(); + .createOrReplace( + new PersistentVolumeBuilder() + .withNewMetadata() + .withName(kubernetesPvConfig.get("name", String.class)) + .withNamespace(client.getNamespace()) + .endMetadata() + .withSpec(getPersistentVolume(kubernetesPvConfig.get("spec", Config.class))) + .build() + ); else return null; } @@ -198,13 +203,16 @@ protected PersistentVolumeClaim createPersistentVolumeClaim(final CommandContext final Config kubernetesPvcConfig = extractTargetKindConfig(context, "PersistentVolumeClaim"); if (kubernetesPvcConfig != null && kubernetesPvcConfig.has("spec")) return client.persistentVolumeClaims() - .createOrReplaceWithNew() - .withNewMetadata() - .withName(kubernetesPvcConfig.get("name", String.class)) - .withNamespace(client.getNamespace()) - .endMetadata() - .withSpec(getPersistentVolumeClaim(kubernetesPvcConfig.get("spec", Config.class))) - .done(); + .createOrReplace( + new PersistentVolumeClaimBuilder() + .withNewMetadata() + .withName(kubernetesPvcConfig.get("name", String.class)) + .withNamespace(client.getNamespace()) + .endMetadata() + .withSpec(getPersistentVolumeClaim(kubernetesPvcConfig.get("spec", Config.class))) + .build() + + ); else return null; }