Added covenience functions

There is now an alias "k" for kubectl.
Autocomplete works now for kubectl.
This commit is contained in:
see 2022-06-29 15:38:28 +02:00
parent 148a0821c1
commit 515197ac27
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.ServerType
import org.domaindrivenarchitecture.provs.server.domain.k3s.K3sCliCommand import org.domaindrivenarchitecture.provs.server.domain.k3s.K3sCliCommand
import org.domaindrivenarchitecture.provs.server.domain.k3s.provisionK3s import org.domaindrivenarchitecture.provs.server.domain.k3s.provisionK3s
import org.domaindrivenarchitecture.provs.server.infrastructure.provisionServerCliConvenience
import kotlin.system.exitProcess import kotlin.system.exitProcess

View file

@ -20,13 +20,19 @@ fun Prov.provisionK3s(cli: K3sCliCommand) = task {
provisionMeissaDesktopSubmodules(cli.submodules, grafanaConfigResolved) provisionMeissaDesktopSubmodules(cli.submodules, grafanaConfigResolved)
} }
provisionServerCliConvenience()
} }
/** /**
* Installs a k3s server. * 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) provisionNetwork(k3sConfig)
if (k3sConfig.reprovision && testConfigExists()) { if (k3sConfig.reprovision && testConfigExists()) {
deprovisionK3sInfra() 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 (submodules.contains(ServerSubmodule.GRAFANA.name.lowercase())) {
if (grafanaConfigResolved == null) { if (grafanaConfigResolved == null) {
println("ERROR: Could not find grafana config.") 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")
}