Added covenience functions
There is now an alias "k" for kubectl. Autocomplete works now for kubectl.
This commit is contained in:
parent
148a0821c1
commit
515197ac27
3 changed files with 27 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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.")
|
||||
|
|
|
@ -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")
|
||||
}
|
Loading…
Reference in a new issue