[skip ci] installDirenv added
This commit is contained in:
parent
feebd5837d
commit
13f8a70ec4
2 changed files with 31 additions and 0 deletions
src
main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure
test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure
|
@ -4,6 +4,7 @@ import org.domaindrivenarchitecture.provs.framework.core.Prov
|
|||
import org.domaindrivenarchitecture.provs.framework.core.ProvResult
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.*
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.aptInstall
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.checkPackage
|
||||
import org.domaindrivenarchitecture.provs.framework.ubuntu.web.base.downloadFromURL
|
||||
|
||||
|
||||
|
@ -160,3 +161,17 @@ fun Prov.installTerraform() = task {
|
|||
cmd("tfenv install latest:^1.4.6", sudo = true)
|
||||
cmd("tfenv use latest:^1.4.6", sudo = true)
|
||||
}
|
||||
|
||||
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()
|
||||
createFile(bashConfigFile, content)
|
||||
addResult(checkPackage("direnv"), info = "direnv has been installed.")
|
||||
} else {
|
||||
return@taskWithResult ProvResult(true, out = "direnv or ~/.bashrc.d/direnv.sh already installed")
|
||||
}
|
||||
}
|
|
@ -58,4 +58,20 @@ internal class DevOpsKtTest {
|
|||
assertTrue(res.success)
|
||||
assertTrue(prov.checkFile("/usr/local/bin/kubeconform"))
|
||||
}
|
||||
|
||||
@ExtensiveContainerTest
|
||||
fun installDirenv() {
|
||||
// given
|
||||
val prov = defaultTestContainer()
|
||||
|
||||
// when
|
||||
val res = prov.task {
|
||||
installDirenv()
|
||||
installDirenv() // check repeatability
|
||||
}
|
||||
|
||||
// then
|
||||
assertTrue(res.success)
|
||||
//assertTrue(prov.checkFile("/usr/local/bin/kubeconform"))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue