diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/ApplicationFileRepository.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/ApplicationFileRepository.kt new file mode 100644 index 0000000..c5d39d9 --- /dev/null +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/ApplicationFileRepository.kt @@ -0,0 +1,5 @@ +package org.domaindrivenarchitecture.provs.server.domain.k3s + +interface ApplicationFileRepository { + fun exists(applicationFileName: ApplicationFileName?): Boolean +} \ No newline at end of file diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sCliCommand.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sCliCommand.kt index d4526b9..740bb3f 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sCliCommand.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sCliCommand.kt @@ -18,10 +18,5 @@ class K3sCliCommand( target, configFileName ) { - fun isValidApplicationFileName(): Boolean { - if (applicationFileName == null) { - return true - } - return genericFileExistenceCheck(applicationFileName.fileName) - } + } \ No newline at end of file diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sService.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sService.kt index 662ce7a..212fd99 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sService.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sService.kt @@ -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() diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/DefaultApplicationFileRepository.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/DefaultApplicationFileRepository.kt new file mode 100644 index 0000000..89a67b0 --- /dev/null +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/DefaultApplicationFileRepository.kt @@ -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) + } + +}