Refactor reprovisioning options

Moved config reprovision check to provisionK3s as it does not
influence the provisionNetwork() function.
Reprovisioning from CLI now overrides reprovisioning from config.
This commit is contained in:
erik 2022-09-06 13:16:26 +02:00
parent 411003f04a
commit 8e83cf11d0

View file

@ -11,17 +11,22 @@ fun Prov.provisionK3s(cli: K3sCliCommand) = task {
val grafanaConfigResolved: GrafanaAgentConfigResolved? = findK8sGrafanaConfig(cli.configFileName)?.resolveSecret() val grafanaConfigResolved: GrafanaAgentConfigResolved? = findK8sGrafanaConfig(cli.configFileName)?.resolveSecret()
if (cli.submodules == null && !cli.reprovision) { if (cli.submodules == null ) {
// full k3s
val k3sConfig: K3sConfig = getK3sConfig(cli.configFileName) val k3sConfig: K3sConfig = getK3sConfig(cli.configFileName)
provisionK3sWorker(k3sConfig, grafanaConfigResolved, cli.applicationFileName)
} if (!cli.reprovision && !k3sConfig.reprovision) {
else if (cli.reprovision) { // full k3s
deprovisionK3sInfra() provisionK3sWorker(k3sConfig, grafanaConfigResolved, cli.applicationFileName)
val k3sConfig: K3sConfig = getK3sConfig(cli.configFileName) }
provisionK3sWorker(k3sConfig, grafanaConfigResolved, cli.applicationFileName) if (cli.reprovision && testConfigExists()) {
} deprovisionK3sInfra()
else { provisionK3sWorker(k3sConfig, grafanaConfigResolved, cli.applicationFileName)
}
if (k3sConfig.reprovision && testConfigExists()) {
deprovisionK3sInfra()
provisionK3sWorker(k3sConfig, grafanaConfigResolved, cli.applicationFileName)
}
} else {
// submodules only // submodules only
provisionGrafanaSanitized(cli.submodules, grafanaConfigResolved) provisionGrafanaSanitized(cli.submodules, grafanaConfigResolved)
} }
@ -37,10 +42,6 @@ fun Prov.provisionK3sWorker(
provisionNetwork(k3sConfig) provisionNetwork(k3sConfig)
if (k3sConfig.reprovision && testConfigExists()) {
deprovisionK3sInfra()
}
installK3s(k3sConfig) installK3s(k3sConfig)
if (k3sConfig.certmanager != null) { if (k3sConfig.certmanager != null) {