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.configFileName,
|
||||||
module.applicationFileName,
|
module.applicationFileName,
|
||||||
module.submodules
|
module.submodules,
|
||||||
|
module.reprovision,
|
||||||
)
|
)
|
||||||
else -> return ServerCliCommand(
|
else -> return ServerCliCommand(
|
||||||
ServerType.valueOf(module.name.uppercase()),
|
ServerType.valueOf(module.name.uppercase()),
|
||||||
|
@ -52,6 +53,7 @@ class CliArgumentsParser(name: String) : CliTargetParser(name) {
|
||||||
var configFileName: ConfigFileName? = null
|
var configFileName: ConfigFileName? = null
|
||||||
var applicationFileName: ApplicationFileName? = null
|
var applicationFileName: ApplicationFileName? = null
|
||||||
var submodules: List<String>? = 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") {
|
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",
|
"o",
|
||||||
"provisions only parts ",
|
"provisions only parts ",
|
||||||
)
|
)
|
||||||
|
val cliReprovision by option(
|
||||||
|
ArgType.Boolean,
|
||||||
|
"reprovision",
|
||||||
|
"r",
|
||||||
|
"redo provisioning, deletes old config first",
|
||||||
|
)
|
||||||
override fun execute() {
|
override fun execute() {
|
||||||
super.configFileName = cliConfigFileName?.let { ConfigFileName(it) }
|
super.configFileName = cliConfigFileName?.let { ConfigFileName(it) }
|
||||||
super.applicationFileName = cliApplicationFileName?.let { ApplicationFileName(it) }
|
super.applicationFileName = cliApplicationFileName?.let { ApplicationFileName(it) }
|
||||||
super.submodules = if (only != null) listOf(only!!.name.lowercase()) else null
|
super.submodules = if (only != null) listOf(only!!.name.lowercase()) else null
|
||||||
|
super.reprovision = cliReprovision == true
|
||||||
super.parsed = true
|
super.parsed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,9 @@ class K3sCliCommand(
|
||||||
target: TargetCliCommand,
|
target: TargetCliCommand,
|
||||||
configFileName: ConfigFileName?,
|
configFileName: ConfigFileName?,
|
||||||
val applicationFileName: ApplicationFileName?,
|
val applicationFileName: ApplicationFileName?,
|
||||||
val submodules: List<String>? = null
|
val submodules: List<String>? = null,
|
||||||
) : ServerCliCommand(
|
val reprovision: Reprovision = false,
|
||||||
serverType,
|
) :
|
||||||
target,
|
ServerCliCommand(
|
||||||
configFileName
|
serverType, target, configFileName
|
||||||
)
|
)
|
|
@ -11,14 +11,24 @@ fun Prov.provisionK3s(cli: K3sCliCommand) = task {
|
||||||
|
|
||||||
val grafanaConfigResolved: GrafanaAgentConfigResolved? = findK8sGrafanaConfig(cli.configFileName)?.resolveSecret()
|
val grafanaConfigResolved: GrafanaAgentConfigResolved? = findK8sGrafanaConfig(cli.configFileName)?.resolveSecret()
|
||||||
|
|
||||||
if (cli.submodules == null) {
|
if (cli.submodules == null ) {
|
||||||
// full k3s
|
|
||||||
val k3sConfig: K3sConfig = getK3sConfig(cli.configFileName)
|
val k3sConfig: K3sConfig = getK3sConfig(cli.configFileName)
|
||||||
val repo: ApplicationFileRepository = DefaultApplicationFileRepository()
|
val repo: ApplicationFileRepository = DefaultApplicationFileRepository()
|
||||||
repo.assertExists(cli.applicationFileName)
|
repo.assertExists(cli.applicationFileName)
|
||||||
provisionK3sWorker(k3sConfig, grafanaConfigResolved, cli.applicationFileName)
|
|
||||||
}
|
if (!cli.reprovision && !k3sConfig.reprovision) {
|
||||||
else {
|
// 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
|
// submodules only
|
||||||
provisionGrafanaSanitized(cli.submodules, grafanaConfigResolved)
|
provisionGrafanaSanitized(cli.submodules, grafanaConfigResolved)
|
||||||
}
|
}
|
||||||
|
@ -34,10 +44,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) {
|
||||||
|
|
Loading…
Reference in a new issue