Skip to content

Commit

Permalink
Merge pull request #12 from iwilltry42/fix/add-to-initContainers
Browse files Browse the repository at this point in the history
Fix: Merge env and volumeMounts with initContainers
  • Loading branch information
byxorna authored Apr 17, 2019
2 parents bf30c3b + 01e8065 commit ab798d5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/server/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,11 @@ func createPatch(pod *corev1.Pod, inj *config.InjectionConfig, annotations map[s
mutatedInjectedContainers := mergeEnvVars(inj.Environment, inj.Containers)
mutatedInjectedContainers = mergeVolumeMounts(inj.VolumeMounts, mutatedInjectedContainers)

// next, make sure any injected init containers in our config get the EnvVars and VolumeMounts injected
// this mutates inj.InitContainers with our environment vars
mutatedInjectedInitContainers := mergeEnvVars(inj.Environment, inj.InitContainers)
mutatedInjectedInitContainers = mergeVolumeMounts(inj.VolumeMounts, mutatedInjectedInitContainers)

// next, patch containers with our injected containers
patch = append(patch, addContainers(pod.Spec.Containers, mutatedInjectedContainers, "/spec/containers")...)

Expand All @@ -404,7 +409,7 @@ func createPatch(pod *corev1.Pod, inj *config.InjectionConfig, annotations map[s
patch = append(patch, addVolumeMounts(pod.Spec.Containers, inj.VolumeMounts)...)

// now, add initContainers, hostAliases and volumes
patch = append(patch, addContainers(pod.Spec.InitContainers, inj.InitContainers, "/spec/initContainers")...)
patch = append(patch, addContainers(pod.Spec.InitContainers, mutatedInjectedInitContainers, "/spec/initContainers")...)
patch = append(patch, addHostAliases(pod.Spec.HostAliases, inj.HostAliases, "/spec/hostAliases")...)
patch = append(patch, addVolumes(pod.Spec.Volumes, inj.Volumes, "/spec/volumes")...)

Expand Down

0 comments on commit ab798d5

Please sign in to comment.