From d187a8423ce187a29d35751c16024dda1401185c Mon Sep 17 00:00:00 2001 From: ansgarz Date: Tue, 5 Mar 2024 23:33:54 +0100 Subject: [PATCH] add kubeconform --- .../provs/desktop/domain/DesktopService.kt | 2 ++ .../desktop/infrastructure/Kubeconform.kt | 26 +++++++++++++++++++ .../infrastructure/KubeconformKtTest.kt | 23 ++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Kubeconform.kt create mode 100644 src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/KubeconformKtTest.kt diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopService.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopService.kt index 26bd3c8..3435b08 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopService.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopService.kt @@ -160,4 +160,6 @@ fun Prov.provisionIdeDesktop() { // IDEs installVSC("python", "clojure") installIntelliJ() + + installKubeconform() } diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Kubeconform.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Kubeconform.kt new file mode 100644 index 0000000..1810e3a --- /dev/null +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Kubeconform.kt @@ -0,0 +1,26 @@ +package org.domaindrivenarchitecture.provs.desktop.infrastructure + +import org.domaindrivenarchitecture.provs.framework.core.Prov +import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.createDirs +import org.domaindrivenarchitecture.provs.framework.ubuntu.web.base.downloadFromURL + + +fun Prov.installKubeconform() = task { + // check for latest stable release on: https://github.com/yannh/kubeconform/releases + val version = "0.6.4" + val installationPath = "~/bin/" + val filename = "kubeconform-linux-amd64" + val packedFilename = "$filename.tar.gz" + + createDirs(installationPath) + + downloadFromURL( + "https://github.com/yannh/kubeconform/releases/download/v$version/$packedFilename", + path = installationPath, + sha256sum = "2b4ebeaa4d5ac4843cf8f7b7e66a8874252b6b71bc7cbfc4ef1cbf85acec7c07" + ) + cmd("tar -xvf $packedFilename", installationPath) + cmd("chmod +x kubeconform", installationPath) +} + + diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/KubeconformKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/KubeconformKtTest.kt new file mode 100644 index 0000000..9366457 --- /dev/null +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/KubeconformKtTest.kt @@ -0,0 +1,23 @@ +package org.domaindrivenarchitecture.provs.desktop.infrastructure + +import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.checkFile +import org.domaindrivenarchitecture.provs.test.defaultTestContainer +import org.domaindrivenarchitecture.provs.test.tags.ContainerTest + +import org.junit.jupiter.api.Assertions.* + +class KubeconformKtTest { + + @ContainerTest + fun installKubeconform() { + // given + val prov = defaultTestContainer() + + // when + val res = prov.installKubeconform() + + // then + assertTrue(res.success) + assertTrue(prov.checkFile("bin/kubeconform")) + } +} \ No newline at end of file