From 904e2e1e13ad97d803118871558393fc93bbfb43 Mon Sep 17 00:00:00 2001 From: Patrick Derks Date: Fri, 11 Oct 2024 14:15:08 +0200 Subject: [PATCH] fix: hooks for setup and migration command --- internal/job/migration.go | 14 +++++++------- internal/job/setup.go | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/internal/job/migration.go b/internal/job/migration.go index f9b9b79..6c9a9bd 100644 --- a/internal/job/migration.go +++ b/internal/job/migration.go @@ -55,13 +55,13 @@ func MigrationJob(store *v1.Store) *batchv1.Job { } maps.Copy(annotations, store.Spec.Container.Annotations) - var stringCommand string - if store.Spec.MigrationHook.Before != "" { - stringCommand = fmt.Sprintf("%s %s", stringCommand, store.Spec.MigrationHook.Before) + var commandString string + if store.Spec.SetupHook.Before != "" { + commandString = store.Spec.SetupHook.Before } - stringCommand = fmt.Sprintf("%s /setup", stringCommand) - if store.Spec.MigrationHook.After != "" { - stringCommand = fmt.Sprintf("%s %s", stringCommand, store.Spec.MigrationHook.After) + commandString = fmt.Sprintf("%s %s", commandString, "/setup;") + if store.Spec.SetupHook.After != "" { + commandString = fmt.Sprintf("%s %s", commandString, store.Spec.SetupHook.After) } containers := append(store.Spec.Container.ExtraContainers, corev1.Container{ @@ -70,7 +70,7 @@ func MigrationJob(store *v1.Store) *batchv1.Job { ImagePullPolicy: store.Spec.Container.ImagePullPolicy, Image: store.Spec.Container.Image, Command: []string{"sh"}, - Args: []string{"-c", stringCommand}, + Args: []string{"-c", commandString}, Env: store.GetEnv(), }) diff --git a/internal/job/setup.go b/internal/job/setup.go index 4adbf91..b70393a 100644 --- a/internal/job/setup.go +++ b/internal/job/setup.go @@ -39,13 +39,13 @@ func SetupJob(store *v1.Store) *batchv1.Job { } maps.Copy(labels, util.GetDefaultLabels(store)) - var command []string + var commandString string if store.Spec.SetupHook.Before != "" { - command = append(command, store.Spec.SetupHook.Before) + commandString = store.Spec.SetupHook.Before } - command = append(command, "/setup") + commandString = fmt.Sprintf("%s %s", commandString, "/setup;") if store.Spec.SetupHook.After != "" { - command = append(command, store.Spec.SetupHook.After) + commandString = fmt.Sprintf("%s %s", commandString, store.Spec.SetupHook.After) } envs := append(store.GetEnv(), @@ -71,8 +71,8 @@ func SetupJob(store *v1.Store) *batchv1.Job { VolumeMounts: store.Spec.Container.VolumeMounts, ImagePullPolicy: store.Spec.Container.ImagePullPolicy, Image: store.Spec.Container.Image, - Command: []string{"sh", "-c"}, - Args: command, + Command: []string{"sh"}, + Args: []string{"-c", commandString}, Env: envs, })