refactor: use a common implementation to move files into place in golang core-post-deploy implementations

This commit is contained in:
Jose Diaz-Gonzalez
2025-07-23 01:58:44 -04:00
parent 58c6b137b0
commit b24035c80a

View File

@@ -34,30 +34,20 @@ import (
// TriggerCorePostDeploy moves a configured kustomize root path to be in the app root dir // TriggerCorePostDeploy moves a configured kustomize root path to be in the app root dir
func TriggerCorePostDeploy(appName string) error { func TriggerCorePostDeploy(appName string) error {
existingKustomizeRootPath := getComputedKustomizeRootPath(appName) return common.CorePostDeploy(common.CorePostDeployInput{
processSpecificKustomizeRootPath := fmt.Sprintf("%s.%s", existingKustomizeRootPath, os.Getenv("DOKKU_PID")) AppName: appName,
if common.DirectoryExists(processSpecificKustomizeRootPath) { Destination: common.GetAppDataDirectory("scheduler-k3s", appName),
if err := os.Rename(processSpecificKustomizeRootPath, existingKustomizeRootPath); err != nil { ExtractedPaths: []common.CorePostDeployPath{
return err {Name: "kustomization", IsDirectory: true},
} },
} else if common.FileExists(fmt.Sprintf("%s.missing", processSpecificKustomizeRootPath)) { })
if err := os.RemoveAll(fmt.Sprintf("%s.missing", processSpecificKustomizeRootPath)); err != nil {
return err
}
if common.DirectoryExists(existingKustomizeRootPath) {
if err := os.RemoveAll(existingKustomizeRootPath); err != nil {
return err
}
}
}
return nil return nil
} }
// TriggerCorePostExtract moves a configured kustomize root path to be in the app root dir // TriggerCorePostExtract moves a configured kustomize root path to be in the app root dir
func TriggerCorePostExtract(appName string, sourceWorkDir string) error { func TriggerCorePostExtract(appName string, sourceWorkDir string) error {
destination := filepath.Join(common.MustGetEnv("DOKKU_LIB_ROOT"), "data", "scheduler-k3s", appName) destination := common.GetAppDataDirectory("scheduler-k3s", appName)
kustomizeRootPath := getComputedKustomizeRootPath(appName) kustomizeRootPath := getComputedKustomizeRootPath(appName)
return common.CorePostExtract(common.CorePostExtractInput{ return common.CorePostExtract(common.CorePostExtractInput{
AppName: appName, AppName: appName,