refactor kubeconform, installpath, check, test
This commit is contained in:
parent
771d7f7b89
commit
a20b1a9144
4 changed files with 38 additions and 49 deletions
|
@ -49,9 +49,33 @@ fun Prov.installKubectlAndTools(): ProvResult = task {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task("installKubeconform") {
|
||||||
|
|
||||||
|
installKubeconform()
|
||||||
|
}
|
||||||
installDevopsScripts()
|
installDevopsScripts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Prov.installKubeconform() = task {
|
||||||
|
// check for latest stable release on: https://github.com/yannh/kubeconform/releases
|
||||||
|
val version = "0.6.4"
|
||||||
|
val installationPath = "/usr/local/bin/"
|
||||||
|
val tmpDir = "~/tmp"
|
||||||
|
val filename = "kubeconform-linux-amd64"
|
||||||
|
val packedFilename = "$filename.tar.gz"
|
||||||
|
|
||||||
|
if ( !chk("kubeconform -v") || "v$version" != cmd("kubeconform -v").out?.trim() ) {
|
||||||
|
downloadFromURL(
|
||||||
|
"https://github.com/yannh/kubeconform/releases/download/v$version/$packedFilename",
|
||||||
|
path = tmpDir,
|
||||||
|
sha256sum = "2b4ebeaa4d5ac4843cf8f7b7e66a8874252b6b71bc7cbfc4ef1cbf85acec7c07"
|
||||||
|
)
|
||||||
|
cmd("sudo tar -xzf $packedFilename -C $installationPath", tmpDir)
|
||||||
|
} else {
|
||||||
|
ProvResult(true, out = "Kubeconform $version already installed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun Prov.installKubectl(): ProvResult = task {
|
fun Prov.installKubectl(): ProvResult = task {
|
||||||
|
|
||||||
// see https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
|
// see https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.creat
|
||||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.createDirs
|
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.createDirs
|
||||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.fileContainsText
|
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.fileContainsText
|
||||||
import org.domaindrivenarchitecture.provs.test.defaultTestContainer
|
import org.domaindrivenarchitecture.provs.test.defaultTestContainer
|
||||||
|
import org.domaindrivenarchitecture.provs.test.tags.ContainerTest
|
||||||
import org.domaindrivenarchitecture.provs.test.tags.ExtensiveContainerTest
|
import org.domaindrivenarchitecture.provs.test.tags.ExtensiveContainerTest
|
||||||
import org.junit.jupiter.api.Assertions.assertTrue
|
import org.junit.jupiter.api.Assertions.assertTrue
|
||||||
import org.junit.jupiter.api.Disabled
|
import org.junit.jupiter.api.Disabled
|
||||||
|
@ -48,4 +49,17 @@ internal class DevOpsKtTest {
|
||||||
// then
|
// then
|
||||||
assertTrue(res.success)
|
assertTrue(res.success)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ContainerTest
|
||||||
|
fun installKubeconform() {
|
||||||
|
// given
|
||||||
|
val prov = defaultTestContainer()
|
||||||
|
|
||||||
|
// when
|
||||||
|
val res = prov.installKubeconform()
|
||||||
|
|
||||||
|
// then
|
||||||
|
assertTrue(res.success)
|
||||||
|
assertTrue(prov.checkFile("/usr/local/bin/kubeconform"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
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"))
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue