Skip to content

Commit

Permalink
fix: hooks for setup and migration command
Browse files Browse the repository at this point in the history
  • Loading branch information
TrayserCassa committed Oct 11, 2024
1 parent 31e8361 commit 904e2e1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions internal/job/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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(),
})

Expand Down
12 changes: 6 additions & 6 deletions internal/job/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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,
})

Expand Down

0 comments on commit 904e2e1

Please sign in to comment.