This commit is contained in:
jerger 2022-08-26 09:30:27 +02:00
parent d9d8678b82
commit 1ad357ba44
4 changed files with 25 additions and 7 deletions

View file

@ -0,0 +1,5 @@
package org.domaindrivenarchitecture.provs.server.domain.k3s
interface ApplicationFileRepository {
fun exists(applicationFileName: ApplicationFileName?): Boolean
}

View file

@ -18,10 +18,5 @@ class K3sCliCommand(
target,
configFileName
) {
fun isValidApplicationFileName(): Boolean {
if (applicationFileName == null) {
return true
}
return genericFileExistenceCheck(applicationFileName.fileName)
}
}

View file

@ -14,7 +14,10 @@ fun Prov.provisionK3s(cli: K3sCliCommand) = task {
if (cli.submodules == null && !cli.reprovision) {
// full k3s
val k3sConfig: K3sConfig = getK3sConfig(cli.configFileName)
provisionK3sWorker(k3sConfig, grafanaConfigResolved, cli.applicationFileName)
val repo: ApplicationFileRepository = DefaultApplicationFileRepository()
if(repo.exists(cli.applicationFileName)) {
provisionK3sWorker(k3sConfig, grafanaConfigResolved, cli.applicationFileName)
}
}
else if (cli.reprovision) { // TODO: Add logic that overrides config, when cmd option is set
deprovisionK3sInfra()

View file

@ -0,0 +1,15 @@
package org.domaindrivenarchitecture.provs.server.infrastructure
import org.domaindrivenarchitecture.provs.server.domain.k3s.ApplicationFileName
import org.domaindrivenarchitecture.provs.server.domain.k3s.ApplicationFileRepository
class DefaultApplicationFileRepository : ApplicationFileRepository {
override fun exists(applicationFileName: ApplicationFileName?): Boolean {
if (applicationFileName == null) {
return true
}
return genericFileExistenceCheck(applicationFileName.fileName)
}
}