diff --git a/plugins/scheduler-k3s/functions.go b/plugins/scheduler-k3s/functions.go index 2fe549f6e..76f5991d7 100644 --- a/plugins/scheduler-k3s/functions.go +++ b/plugins/scheduler-k3s/functions.go @@ -1190,6 +1190,11 @@ func getGlobalLetsencryptEmailStag() string { return common.PropertyGetDefault("scheduler-k3s", "--global", "letsencrypt-email-stag", "") } +func getKustomizeDirectory(appName string) string { + directory := filepath.Join(common.MustGetEnv("DOKKU_LIB_ROOT"), "data", "scheduler-k3s", appName) + return filepath.Join(directory, "kustomization") +} + func getKustomizeRootPath(appName string) string { return common.PropertyGetDefault("scheduler-k3s", appName, "kustomize-root-path", "") } @@ -1498,17 +1503,18 @@ func getProcessSpecificKustomizeRootPath(appName string) string { return "" } -func hasKustomizeRootPath(appName string) bool { - kustomizeRootPath := getComputedKustomizeRootPath(appName) - if common.DirectoryExists(fmt.Sprintf("%s.%s.missing", kustomizeRootPath, os.Getenv("DOKKU_PID"))) { +func hasKustomizeDirectory(appName string) bool { + directory := getKustomizeDirectory(appName) + + if common.DirectoryExists(fmt.Sprintf("%s.%s.missing", directory, os.Getenv("DOKKU_PID"))) { return false } - if common.DirectoryExists(fmt.Sprintf("%s.%s", kustomizeRootPath, os.Getenv("DOKKU_PID"))) { + if common.DirectoryExists(fmt.Sprintf("%s.%s", directory, os.Getenv("DOKKU_PID"))) { return true } - return common.DirectoryExists(kustomizeRootPath) + return common.DirectoryExists(directory) } func installHelmCharts(ctx context.Context, clientset KubernetesClient, shouldInstall func(HelmChart) bool) error { diff --git a/plugins/scheduler-k3s/triggers.go b/plugins/scheduler-k3s/triggers.go index c1b08d905..f9fcd7817 100644 --- a/plugins/scheduler-k3s/triggers.go +++ b/plugins/scheduler-k3s/triggers.go @@ -63,8 +63,7 @@ func TriggerCorePostExtract(appName string, sourceWorkDir string) error { return nil } - directory := filepath.Join(common.MustGetEnv("DOKKU_LIB_ROOT"), "data", "scheduler-k3s", appName) - existingKustomizeDirectory := filepath.Join(directory, "kustomization") + existingKustomizeDirectory := getKustomizeDirectory(appName) files, err := filepath.Glob(fmt.Sprintf("%s.*", existingKustomizeDirectory)) if err != nil { return err @@ -75,7 +74,7 @@ func TriggerCorePostExtract(appName string, sourceWorkDir string) error { } } - processSpecificKustomizeRootPath := fmt.Sprintf("%s.%s", kustomizeRootPath, os.Getenv("DOKKU_PID")) + processSpecificKustomizeRootPath := fmt.Sprintf("%s.%s", existingKustomizeDirectory, os.Getenv("DOKKU_PID")) results, _ := common.CallPlugnTrigger(common.PlugnTriggerInput{ Trigger: "git-get-property", Args: []string{appName, "source-image"}, @@ -785,7 +784,7 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e } kustomizeRootPath := "" - if hasKustomizeRootPath(appName) { + if hasKustomizeDirectory(appName) { kustomizeRootPath = getProcessSpecificKustomizeRootPath(appName) }