diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Babashka.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Babashka.kt index 0cee166..9acdf93 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Babashka.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Babashka.kt @@ -8,10 +8,10 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.web.base.downloadFrom fun Prov.installBabashka( version: String = "1.12.196", - reInstall: Boolean = false, + enforceUpgrade: Boolean = false, sha256sum: String = "18dbf47c79cc136fe9903642a7b0c9ab75f52282984197855b489b80469b8d8f" ) = taskWithResult { - if (checkCommand("bb") && !reInstall) { + if (checkCommand("bb") && !enforceUpgrade) { return@taskWithResult ProvResult(true) } diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Citrix.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Citrix.kt index aac09fc..33ce712 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Citrix.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Citrix.kt @@ -8,9 +8,15 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.web.base.downloadFrom * ATTENTION: Download URL might be only valid for a limited time and thus might not be working. * Download from: https://www.citrix.com/downloads/workspace-app/linux/workspace-app-for-linux-latest.html */ +@Suppress("unused") fun Prov.installCitrixWorkspaceApp() = task { - downloadFromURL("https://downloads.citrix.com/20976/linuxx64-22.5.0.16.tar.gz?__gda__=exp=1654847726~acl=/*~hmac=be248338ecd7c7de50950ff7825fc0a80577fef7d3610988c64391cff8eaca16", "citrix.tar.gz", "/tmp") + downloadFromURL( + "https://downloads.citrix.com/20976/linuxx64-22.5.0.16.tar.gz?__gda__=exp=1654847726~acl=/*~hmac=be248338ecd7c7de50950ff7825fc0a80577fef7d3610988c64391cff8eaca16", + "citrix.tar.gz", + "/tmp" + ) createDir("citrix", "/tmp") + cmd("tar -xf citrix.tar.gz -C /tmp/citrix") // Run /tmp/citrix/setupwfc } diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/DevOps.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/DevOps.kt index 2e80b32..45a9d21 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/DevOps.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/DevOps.kt @@ -166,8 +166,7 @@ fun Prov.installDirenv() = taskWithResult { val bashConfigFile = "~/.bashrc.d/direnv.sh" if (!checkFile(bashConfigFile) && !checkPackage("direnv")) { aptInstall("direnv") - val content = """eval "$(direnv hook bash)" -""" + "\n".trimIndent() + val content = """eval "$(direnv hook bash)" """.trim() + "\n" createFile(bashConfigFile, content) addResult(checkPackage("direnv"), info = "direnv has been installed.") } else { diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Go.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Go.kt index 3ecfe50..0217f6a 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Go.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Go.kt @@ -9,10 +9,10 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.web.base.downloadFrom //from https://go.dev/dl/ fun Prov.installGo( version: String = "1.23.5", - reInstall: Boolean = false, + enforceUpgrade: Boolean = false, sha256sum: String = "cbcad4a6482107c7c7926df1608106c189417163428200ce357695cc7e01d091" ) = taskWithResult { - if (checkCommand("go") && !reInstall) { + if (checkCommand("go") && !enforceUpgrade) { return@taskWithResult ProvResult(true) } diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Gopass.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Gopass.kt index e719ecc..2564fd9 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Gopass.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Gopass.kt @@ -12,12 +12,12 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.web.base.downloadFrom fun Prov.installGopass( version: String = "1.15.13", // NOTE: when adjusting, pls also adjust checksum below and version of gopass bridge json api - reInstall: Boolean = false, + enforceUpgrade: Boolean = false, // from https://github.com/gopasspw/gopass/releases/tag/v1.15.13 sha256sum: String = "409ed5617e64fa2c781d5e2807ba7fcd65bc383a4e110f410f90b590e51aec55" ) = taskWithResult { - if (checkPackage("gopass") && !reInstall) { + if (checkPackage("gopass") && !enforceUpgrade) { return@taskWithResult ProvResult(true) } if (checkGopassVersion(version)) { diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/NpmByNvm.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/NpmByNvm.kt index 2e09a4a..a4a80de 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/NpmByNvm.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/NpmByNvm.kt @@ -23,9 +23,10 @@ fun Prov.installNpmByNvm(version: String = "0.40.1"): ProvResult = task { // configure bash - create file ".bashrc.d/npmbynvm.sh" with settings configureBashForUser() - val content = """export NVM_DIR="${userHome()}.nvm" -[ -s "${"\$NVM_DIR/nvm.sh"}" ] && \. "${"\$NVM_DIR/nvm.sh"}" -""" + "\n".trimIndent() + val content = """ + export NVM_DIR="${userHome()}.nvm" + [ -s "${"\$NVM_DIR/nvm.sh"}" ] && \. "${"\$NVM_DIR/nvm.sh"}" + """.trimIndent() + "\n" createFile(bashConfigFile, content) // install Node.js and NPM diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Opentofu.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Opentofu.kt index 7c5083d..2e2c055 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Opentofu.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Opentofu.kt @@ -23,16 +23,20 @@ fun Prov.installOpentofu( cmd("chmod a+r /etc/apt/keyrings/opentofu.gpg /etc/apt/keyrings/opentofu-repo.gpg", sudo = true) val tofuListFile = "/etc/apt/sources.list.d/opentofu.list" - val content = - """deb [signed-by=/etc/apt/keyrings/opentofu.gpg,/etc/apt/keyrings/opentofu-repo.gpg] https://packages.opentofu.org/opentofu/tofu/any/ any main""" + "\n" + - """deb-src [signed-by=/etc/apt/keyrings/opentofu.gpg,/etc/apt/keyrings/opentofu-repo.gpg] https://packages.opentofu.org/opentofu/tofu/any/ any main""" + "\n" + - "".trimIndent() + val content = """ + deb [signed-by=/etc/apt/keyrings/opentofu.gpg,/etc/apt/keyrings/opentofu-repo.gpg] https://packages.opentofu.org/opentofu/tofu/any/ any main + deb-src [signed-by=/etc/apt/keyrings/opentofu.gpg,/etc/apt/keyrings/opentofu-repo.gpg] https://packages.opentofu.org/opentofu/tofu/any/ any main + """.trimIndent() + "\n" createFile(tofuListFile, content, sudo = true) cmd("sudo apt-get update -q=2") aptInstall("tofu") - addResult(checkPackage("tofu"), info = "Opentofu has been installed.") + if (!checkPackage("tofu")) { + ProvResult(false, err = "tofu not successfully installed") + } else { + ProvResult(false, info = "Opentofu is installed.") + } } else { - return@taskWithResult ProvResult(false, err = "Opentofu could not be downloaded and installed. ") + ProvResult(false, err = "Opentofu could not be downloaded and installed.") } } diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Terragrunt.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Terragrunt.kt index 3ccb65b..0757fca 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Terragrunt.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Terragrunt.kt @@ -8,10 +8,10 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.web.base.downloadFrom fun Prov.installTerragrunt( version: String = "0.72.6", - reInstall: Boolean = false, + enforceUpgrade: Boolean = false, sha256sum: String = "df63a41576b8b4129b498da5b698b5792a5a228ea5012bbecdcbe49d4d662be3" ) = taskWithResult { - if (checkCommand("terragrunt") && !reInstall) { + if (checkCommand("terragrunt") && !enforceUpgrade) { return@taskWithResult ProvResult(true) } diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/BabashkaKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/BabashkaKtTest.kt index 9244ec8..1241189 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/BabashkaKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/BabashkaKtTest.kt @@ -6,19 +6,19 @@ import org.junit.jupiter.api.Assertions.assertTrue class BabashkaKtTest { - @ExtensiveContainerTest - fun installBabashka() { - // given - val prov = defaultTestContainer() + @ExtensiveContainerTest + fun installBabashka() { + // given + val prov = defaultTestContainer() - // when - val res = prov.task { - installBabashka() - installBabashka() // check repeatability - } + // when + val res = prov.task { + installBabashka() + installBabashka() // check repeatability + } - // then - assertTrue(res.success) - } + // then + assertTrue(res.success) + } } diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/GopassBridgeKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/GopassBridgeKtTest.kt index 91a40b8..b730e7c 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/GopassBridgeKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/GopassBridgeKtTest.kt @@ -72,7 +72,7 @@ internal class GopassBridgeKtTest { trust = true, skipIfExistin = false ) - installGopass("1.11.0", reInstall = true, "1ec9e0dfcfd9bcc241943e1a7d92f31bf3e66bb16f61ae5d079981325c31baa6") + installGopass("1.11.0", enforceUpgrade = true, "1ec9e0dfcfd9bcc241943e1a7d92f31bf3e66bb16f61ae5d079981325c31baa6") configureGopass(publicGpgKey = Secret(publicGPGSnakeoilKey())) } assertTrue(preparationResult.success) @@ -100,7 +100,7 @@ internal class GopassBridgeKtTest { trust = true, skipIfExistin = false ) - installGopass("1.9.0", reInstall = true, "fe13ef810d7fe200495107161e99eac081368aa0ce5e53971b1bd47a64eba4db") + installGopass("1.9.0", enforceUpgrade = true, "fe13ef810d7fe200495107161e99eac081368aa0ce5e53971b1bd47a64eba4db") configureGopass(publicGpgKey = Secret(publicGPGSnakeoilKey())) } assertTrue(preparationResult.success) diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/OpentofuKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/OpentofuKtTest.kt index 640cf80..a2279d1 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/OpentofuKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/OpentofuKtTest.kt @@ -7,20 +7,20 @@ import org.junit.jupiter.api.Assertions.assertTrue class OpentofuKtTest { - @ExtensiveContainerTest - fun installOpentofu() { - // given - val prov = defaultTestContainer() + @ExtensiveContainerTest + fun installOpentofu() { + // given + val prov = defaultTestContainer() - // when - val res = prov.task { + // when + val res = prov.task { - aptInstall("gnupg curl") - installOpentofu() - installOpentofu() // check repeatability - } + aptInstall("gnupg curl") + installOpentofu() + installOpentofu() // check repeatability + } - // then - assertTrue(res.success) - } + // then + assertTrue(res.success) + } } \ No newline at end of file diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/TerragruntKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/TerragruntKtTest.kt index 00339aa..6fc766b 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/TerragruntKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/TerragruntKtTest.kt @@ -6,18 +6,18 @@ import org.junit.jupiter.api.Assertions.assertTrue class TerragruntKtTest { - @ExtensiveContainerTest - fun installTerragrunt() { - // given - val prov = defaultTestContainer() + @ExtensiveContainerTest + fun installTerragrunt() { + // given + val prov = defaultTestContainer() - // when - val res = prov.task { - installTerragrunt() - installTerragrunt() // check repeatability - } + // when + val res = prov.task { + installTerragrunt() + installTerragrunt() // check repeatability + } - // then - assertTrue(res.success) - } + // then + assertTrue(res.success) + } }