Merge branch 'reprovision-cli-option'
# Conflicts: # src/main/kotlin/org/domaindrivenarchitecture/provs/server/application/CliArgumentsParser.kt # src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sCliCommand.kt # src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sService.kt
This commit is contained in:
commit
503ca3dee4
3 changed files with 31 additions and 17 deletions
|
@ -34,7 +34,8 @@ class CliArgumentsParser(name: String) : CliTargetParser(name) {
|
|||
),
|
||||
module.configFileName,
|
||||
module.applicationFileName,
|
||||
module.submodules
|
||||
module.submodules,
|
||||
module.reprovision,
|
||||
)
|
||||
else -> return ServerCliCommand(
|
||||
ServerType.valueOf(module.name.uppercase()),
|
||||
|
@ -52,6 +53,7 @@ class CliArgumentsParser(name: String) : CliTargetParser(name) {
|
|||
var configFileName: ConfigFileName? = null
|
||||
var applicationFileName: ApplicationFileName? = null
|
||||
var submodules: List<String>? = null
|
||||
var reprovision: Boolean = false
|
||||
}
|
||||
|
||||
class K3s : ServerSubcommand("k3s", "the k3s module, 'provs-server.jar k3s --help' for more info") {
|
||||
|
@ -73,11 +75,17 @@ class CliArgumentsParser(name: String) : CliTargetParser(name) {
|
|||
"o",
|
||||
"provisions only parts ",
|
||||
)
|
||||
|
||||
val cliReprovision by option(
|
||||
ArgType.Boolean,
|
||||
"reprovision",
|
||||
"r",
|
||||
"redo provisioning, deletes old config first",
|
||||
)
|
||||
override fun execute() {
|
||||
super.configFileName = cliConfigFileName?.let { ConfigFileName(it) }
|
||||
super.applicationFileName = cliApplicationFileName?.let { ApplicationFileName(it) }
|
||||
super.submodules = if (only != null) listOf(only!!.name.lowercase()) else null
|
||||
super.reprovision = cliReprovision == true
|
||||
super.parsed = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ class K3sCliCommand(
|
|||
target: TargetCliCommand,
|
||||
configFileName: ConfigFileName?,
|
||||
val applicationFileName: ApplicationFileName?,
|
||||
val submodules: List<String>? = null
|
||||
) : ServerCliCommand(
|
||||
serverType,
|
||||
target,
|
||||
configFileName
|
||||
)
|
||||
val submodules: List<String>? = null,
|
||||
val reprovision: Reprovision = false,
|
||||
) :
|
||||
ServerCliCommand(
|
||||
serverType, target, configFileName
|
||||
)
|
|
@ -11,14 +11,24 @@ fun Prov.provisionK3s(cli: K3sCliCommand) = task {
|
|||
|
||||
val grafanaConfigResolved: GrafanaAgentConfigResolved? = findK8sGrafanaConfig(cli.configFileName)?.resolveSecret()
|
||||
|
||||
if (cli.submodules == null) {
|
||||
// full k3s
|
||||
if (cli.submodules == null ) {
|
||||
val k3sConfig: K3sConfig = getK3sConfig(cli.configFileName)
|
||||
val repo: ApplicationFileRepository = DefaultApplicationFileRepository()
|
||||
repo.assertExists(cli.applicationFileName)
|
||||
provisionK3sWorker(k3sConfig, grafanaConfigResolved, cli.applicationFileName)
|
||||
}
|
||||
else {
|
||||
|
||||
if (!cli.reprovision && !k3sConfig.reprovision) {
|
||||
// full k3s
|
||||
provisionK3sWorker(k3sConfig, grafanaConfigResolved, cli.applicationFileName)
|
||||
}
|
||||
if (cli.reprovision && testConfigExists()) {
|
||||
deprovisionK3sInfra()
|
||||
provisionK3sWorker(k3sConfig, grafanaConfigResolved, cli.applicationFileName)
|
||||
}
|
||||
if (k3sConfig.reprovision && testConfigExists()) {
|
||||
deprovisionK3sInfra()
|
||||
provisionK3sWorker(k3sConfig, grafanaConfigResolved, cli.applicationFileName)
|
||||
}
|
||||
} else {
|
||||
// submodules only
|
||||
provisionGrafanaSanitized(cli.submodules, grafanaConfigResolved)
|
||||
}
|
||||
|
@ -34,10 +44,6 @@ fun Prov.provisionK3sWorker(
|
|||
|
||||
provisionNetwork(k3sConfig)
|
||||
|
||||
if (k3sConfig.reprovision && testConfigExists()) {
|
||||
deprovisionK3sInfra()
|
||||
}
|
||||
|
||||
installK3s(k3sConfig)
|
||||
|
||||
if (k3sConfig.certmanager != null) {
|
||||
|
|
Loading…
Reference in a new issue