From 2bb986f80ffa465166ec252cb4338664eb15b906 Mon Sep 17 00:00:00 2001 From: ansgarz Date: Sat, 24 Feb 2024 18:31:07 +0100 Subject: [PATCH] make deprovisionK3sInfra idempotent --- .../provs/server/infrastructure/K3s.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3s.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3s.kt index 615df3a..4ac8d13 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3s.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3s.kt @@ -52,7 +52,11 @@ fun Prov.deprovisionK3sInfra() = task { deleteFile(certManagerDeployment.path, sudo = true) deleteFile(certManagerIssuer.path, sudo = true) deleteFile(k3sKubeConfig.path, sudo = true) - cmd("k3s-uninstall.sh") + + val k3sUninstallScript = "k3s-uninstall.sh" + if (chk("which $k3sUninstallScript")) { + cmd(k3sUninstallScript) + } }