Set EnvVars only if non-nil
@@ -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
@@ -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 {
