Merge remote-tracking branch 'origin/master'

This commit is contained in:
jerger 2022-06-30 08:31:01 +02:00
commit 79806eefab
3 changed files with 27 additions and 2 deletions

View file

@ -4,6 +4,7 @@ import org.domaindrivenarchitecture.provs.framework.core.cli.createProvInstance
import org.domaindrivenarchitecture.provs.server.domain.ServerType
import org.domaindrivenarchitecture.provs.server.domain.k3s.K3sCliCommand
import org.domaindrivenarchitecture.provs.server.domain.k3s.provisionK3s
import org.domaindrivenarchitecture.provs.server.infrastructure.provisionServerCliConvenience
import kotlin.system.exitProcess

View file

@ -20,13 +20,19 @@ fun Prov.provisionK3s(cli: K3sCliCommand) = task {
provisionMeissaDesktopSubmodules(cli.submodules, grafanaConfigResolved)
}
provisionServerCliConvenience()
}
/**
* Installs a k3s server.
*/
fun Prov.provisionK3s(k3sConfig: K3sConfig, grafanaConfigResolved: GrafanaAgentConfigResolved? = null, applicationFileName: ApplicationFileName? = null) = task {
fun Prov.provisionK3s(
k3sConfig: K3sConfig,
grafanaConfigResolved: GrafanaAgentConfigResolved? = null,
applicationFileName: ApplicationFileName? = null) = task {
provisionNetwork(k3sConfig)
if (k3sConfig.reprovision && testConfigExists()) {
deprovisionK3sInfra()
}
@ -50,7 +56,10 @@ fun Prov.provisionK3s(k3sConfig: K3sConfig, grafanaConfigResolved: GrafanaAgentC
}
}
private fun Prov.provisionMeissaDesktopSubmodules(submodules: List<String>, grafanaConfigResolved: GrafanaAgentConfigResolved?) = task {
private fun Prov.provisionMeissaDesktopSubmodules(
submodules: List<String>,
grafanaConfigResolved: GrafanaAgentConfigResolved?) = task {
if (submodules.contains(ServerSubmodule.GRAFANA.name.lowercase())) {
if (grafanaConfigResolved == null) {
println("ERROR: Could not find grafana config.")

View file

@ -0,0 +1,15 @@
package org.domaindrivenarchitecture.provs.server.infrastructure
import org.domaindrivenarchitecture.provs.framework.core.Prov
import org.domaindrivenarchitecture.provs.framework.core.ProvResult
fun Prov.provisionServerCliConvenience() = task {
provisionKubectlCompletionAndAlias()
}
fun Prov.provisionKubectlCompletionAndAlias(): ProvResult = task {
cmd("kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null")
cmd("echo 'alias k=kubectl' >>~/.bashrc")
cmd("echo 'complete -o default -F __start_kubectl k' >>~/.bashrc")
}