remove unsafe-operator and nullable parameter
This commit is contained in:
parent
05e648abe6
commit
eb04e84007
2 changed files with 14 additions and 11 deletions
|
@ -12,12 +12,12 @@ fun Prov.provisionK3sCommand(cli: K3sCliCommand) = task {
|
|||
|
||||
val grafanaConfigResolved: GrafanaAgentConfigResolved? = findK8sGrafanaConfig(cli.configFileName)?.resolveSecret()
|
||||
|
||||
if (cli.onlyModules == null ) {
|
||||
if (cli.onlyModules == null) {
|
||||
val k3sConfig: K3sConfig = getK3sConfig(cli.configFileName)
|
||||
DefaultConfigFileRepository().assertExists(cli.configFileName)
|
||||
val k3sConfigReprovision = k3sConfig.copy(reprovision = cli.reprovision || k3sConfig.reprovision)
|
||||
|
||||
val applicationFile = DefaultApplicationFileRepository(cli.applicationFileName).getFile()
|
||||
val applicationFile = cli.applicationFileName?.let { DefaultApplicationFileRepository(cli.applicationFileName).getFile() }
|
||||
provisionK3s(k3sConfigReprovision, grafanaConfigResolved, applicationFile)
|
||||
} else {
|
||||
provisionGrafana(cli.onlyModules, grafanaConfigResolved)
|
||||
|
@ -30,7 +30,8 @@ fun Prov.provisionK3sCommand(cli: K3sCliCommand) = task {
|
|||
fun Prov.provisionK3s(
|
||||
k3sConfig: K3sConfig,
|
||||
grafanaConfigResolved: GrafanaAgentConfigResolved? = null,
|
||||
applicationFile: ApplicationFile? = null) = task {
|
||||
applicationFile: ApplicationFile? = null
|
||||
) = task {
|
||||
|
||||
if (k3sConfig.reprovision) {
|
||||
deprovisionK3sInfra()
|
||||
|
@ -64,7 +65,8 @@ fun Prov.provisionK3s(
|
|||
|
||||
private fun Prov.provisionGrafana(
|
||||
onlyModules: List<String>?,
|
||||
grafanaConfigResolved: GrafanaAgentConfigResolved?) = task {
|
||||
grafanaConfigResolved: GrafanaAgentConfigResolved?
|
||||
) = task {
|
||||
|
||||
if (onlyModules != null && onlyModules.contains(ServerOnlyModule.GRAFANA.name.lowercase())) {
|
||||
if (grafanaConfigResolved == null) {
|
||||
|
|
|
@ -5,19 +5,20 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.check
|
|||
import org.domaindrivenarchitecture.provs.server.domain.k3s.ApplicationFile
|
||||
import org.domaindrivenarchitecture.provs.server.domain.k3s.ApplicationFileName
|
||||
import org.domaindrivenarchitecture.provs.server.domain.k3s.ApplicationFileRepository
|
||||
import java.io.File
|
||||
|
||||
class DefaultApplicationFileRepository(val applicationFileName: ApplicationFileName?) : ApplicationFileRepository {
|
||||
|
||||
private fun assertExists(applicationFileName: String?) {
|
||||
if (applicationFileName != null && !checkLocalFile(applicationFileName)) {
|
||||
class DefaultApplicationFileRepository(val applicationFileName: ApplicationFileName) : ApplicationFileRepository {
|
||||
|
||||
private fun assertExists(applicationFileName: String) {
|
||||
if (!checkLocalFile(applicationFileName)) {
|
||||
throw RuntimeException("Application file not found. Please check if path is correct.")
|
||||
}
|
||||
}
|
||||
override fun getFile() : ApplicationFile {
|
||||
assertExists(applicationFileName!!.fullyQualifiedName())
|
||||
|
||||
val applicationFileContents = getLocalFileContent(applicationFileName.fullyQualifiedName())
|
||||
override fun getFile(): ApplicationFile {
|
||||
assertExists(applicationFileName.fullyQualifiedName())
|
||||
|
||||
val applicationFileContents = getLocalFileContent(applicationFileName.fullyQualifiedName())
|
||||
val applicationFile = ApplicationFile(applicationFileName, applicationFileContents)
|
||||
|
||||
return if (applicationFile.isValid()) { applicationFile }
|
||||
|
|
Loading…
Reference in a new issue