Skip to content

Commit

Permalink
mutate: add patch to add labels
Browse files Browse the repository at this point in the history
To know which containers have been patched, labels
are added to the patched pods.
  • Loading branch information
j4m3s-s committed Aug 4, 2021
1 parent b913de1 commit bb4671f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mutate/mutate.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@ func Mutate(body []byte, verbose bool, registry string) ([]byte, error) {

patchList := getPatchFromContainerList(pod.Spec.Containers, registry, "containers")
patchList = append(patchList, getPatchFromContainerList(pod.Spec.InitContainers, registry, "initContainers")...)
annotationsPatch := map[string]string{
"op": "add",
"path": "/metadata/labels/k8s-proxy-image-swapper",
"value": "patched-image",
}
if len(patchList) != 0 {
patchList = append(patchList, annotationsPatch)
}

resp.Patch, err = json.Marshal(patchList)

// We cannot fail
Expand Down

0 comments on commit bb4671f

Please sign in to comment.