[skip ci] refactoring method names and reprovision logic

This commit is contained in:
az 2022-09-09 13:32:17 +02:00
parent 70b5dda4a7
commit db84284f8c
3 changed files with 13 additions and 19 deletions

View file

@ -77,6 +77,8 @@ fun Prov.provisionIdeDesktop(submodules: List<String>?) {
installIntelliJ()
} else if (submodules.contains(DesktopSubmodule.VERIFY.name.lowercase())) {
verifyIdeSetup()
} else if (submodules.contains(DesktopSubmodule.FIREFOX.name.lowercase())) {
installFirefox()
}
}
@ -106,6 +108,8 @@ fun Prov.provisionOfficeDesktop(submodules: List<String>?) {
aptInstall(SPELLCHECKING_DE)
} else if (submodules.contains(DesktopSubmodule.VERIFY.name.lowercase())) {
verifyOfficeSetup()
} else if (submodules.contains(DesktopSubmodule.FIREFOX.name.lowercase())) {
installFirefox()
}
}

View file

@ -3,7 +3,7 @@ package org.domaindrivenarchitecture.provs.server.application
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.domain.k3s.provisionK3sCommand
import kotlin.system.exitProcess
@ -33,6 +33,6 @@ fun main(args: Array<String>) {
}
val prov = createProvInstance(cmd.target)
prov.provisionK3s(cmd as K3sCliCommand)
prov.provisionK3sCommand(cmd as K3sCliCommand)
}

View file

@ -7,37 +7,27 @@ import org.domaindrivenarchitecture.provs.server.infrastructure.*
import kotlin.system.exitProcess
fun Prov.provisionK3s(cli: K3sCliCommand) = task {
fun Prov.provisionK3sCommand(cli: K3sCliCommand) = task {
val grafanaConfigResolved: GrafanaAgentConfigResolved? = findK8sGrafanaConfig(cli.configFileName)?.resolveSecret()
if (cli.submodules == null ) {
val k3sConfig: K3sConfig = getK3sConfig(cli.configFileName)
val repo: ApplicationFileRepository = DefaultApplicationFileRepository()
repo.assertExists(cli.applicationFileName)
DefaultApplicationFileRepository().assertExists(cli.applicationFileName)
if (!cli.reprovision && !k3sConfig.reprovision) {
// full k3s
provisionK3sWorker(k3sConfig, grafanaConfigResolved, cli.applicationFileName)
}
if (cli.reprovision && testConfigExists()) {
if (cli.reprovision || k3sConfig.reprovision) {
deprovisionK3sInfra()
provisionK3sWorker(k3sConfig, grafanaConfigResolved, cli.applicationFileName)
}
if (k3sConfig.reprovision && testConfigExists()) {
deprovisionK3sInfra()
provisionK3sWorker(k3sConfig, grafanaConfigResolved, cli.applicationFileName)
}
provisionK3s(k3sConfig, grafanaConfigResolved, cli.applicationFileName)
} else {
// submodules only
provisionGrafanaSanitized(cli.submodules, grafanaConfigResolved)
provisionGrafana(cli.submodules, grafanaConfigResolved)
}
}
/**
* Installs a k3s server.
*/
fun Prov.provisionK3sWorker(
fun Prov.provisionK3s(
k3sConfig: K3sConfig,
grafanaConfigResolved: GrafanaAgentConfigResolved? = null,
applicationFileName: ApplicationFileName? = null) = task {
@ -65,7 +55,7 @@ fun Prov.provisionK3sWorker(
provisionServerCliConvenience()
}
private fun Prov.provisionGrafanaSanitized(
private fun Prov.provisionGrafana(
submodules: List<String>?,
grafanaConfigResolved: GrafanaAgentConfigResolved?) = task {