[skip ci] final refactoring after pair review
This commit is contained in:
parent
acd2a9b2ee
commit
f97dd06ea8
12 changed files with 69 additions and 59 deletions
src
main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure
test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue