Skip to content

Commit

Permalink
fix: change k8s job container creation logic to retain existing value…
Browse files Browse the repository at this point in the history
…s from job manifest

Fixes GoogleContainerTools#9409
  • Loading branch information
cmanzi-bestow committed Sep 26, 2024
1 parent ae40f78 commit 2416b00
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion pkg/skaffold/actions/k8sjob/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,26 @@ func (t Task) getK8SEnvVars(envVars []latest.VerifyEnvVar) (k8sEnvVar []corev1.E
}

func (t *Task) setManifestValues(c corev1.Container) {
t.jobManifest.Spec.Template.Spec.Containers = []corev1.Container{c}
if len(t.jobManifest.Spec.Template.Spec.Containers) == 0 {
t.jobManifest.Spec.Template.Spec.Containers = []corev1.Container{c}
} else {
if c.Name != "" {
t.jobManifest.Spec.Template.Spec.Containers[0].Name = c.Name
}
if c.Image != "" {
t.jobManifest.Spec.Template.Spec.Containers[0].Image = c.Image
}
if len(c.Command) > 0 {
t.jobManifest.Spec.Template.Spec.Containers[0].Command = c.Command
}
if len(c.Args) > 0 {
t.jobManifest.Spec.Template.Spec.Containers[0].Args = c.Args
}
if len(c.Env) > 0 {
t.jobManifest.Spec.Template.Spec.Containers[0].Env = c.Env
}
}

t.jobManifest.ObjectMeta.Name = t.Name()
}

Expand Down

0 comments on commit 2416b00

Please sign in to comment.