Skip to content

Commit

Permalink
to use createOrReplace
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoppii13 committed Mar 10, 2022
1 parent ada82d4 commit c758d2f
Showing 1 changed file with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit c758d2f

Please sign in to comment.