Skip to content

Commit

Permalink
Set EnvVars only if non-nil (#1737)
Browse files Browse the repository at this point in the history
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
ankitjain235 and mergify[bot] authored Nov 16, 2022
1 parent 53ec5b8 commit d8e475c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/kube/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ func GetPodObjectFromPodOptions(cli kubernetes.Interface, opts *PodOptions) (*v1
ImagePullPolicy: v1.PullPolicy(v1.PullIfNotPresent),
VolumeMounts: volumeMounts,
Resources: opts.Resources,
Env: opts.EnvironmentVariables,
},
},
// RestartPolicy dictates when the containers of the pod should be
Expand All @@ -122,6 +121,10 @@ func GetPodObjectFromPodOptions(cli kubernetes.Interface, opts *PodOptions) (*v1
ServiceAccountName: sa,
}

if opts.EnvironmentVariables != nil && len(opts.EnvironmentVariables) > 0 {
defaultSpecs.Containers[0].Env = opts.EnvironmentVariables
}

// Patch default Pod Specs if needed
patchedSpecs, err := patchDefaultPodSpecs(defaultSpecs, opts.PodOverride)
if err != nil {
Expand Down

0 comments on commit d8e475c

Please sign in to comment.