Don't mutate original Pod's labels

because we don't want to, plus annotations may not fit in labels
because they have different character limit.

Fix for error about 63 character limit

Signed-off-by: Dimitris Karakasilis <jimmykarily@gmail.com>
This commit is contained in:
Dimitris Karakasilis
2022-12-06 12:41:42 +00:00
parent b4a78705dd
commit 2250450b88

View File

@@ -60,11 +60,16 @@ func (w *Webhook) Mutate(ctx context.Context, request admission.Request, object
pod := object.(*corev1.Pod)
// Let user use both label and annotations
info := pod.Labels
info := make(map[string]string)
// Annotations take precedence
for ann, v := range pod.Annotations {
info[ann] = v
for k, v := range pod.Labels {
info[k] = v
}
// Annotations take precedence
for k, v := range pod.Annotations {
info[k] = v
}
entanglementName, exists := info[EntanglementNameLabel]