fix: avoiding nil pointer when empty map for labels and annotations

This commit is contained in:
Dario Tranchitella
2022-12-27 17:53:17 +01:00
parent 0d9054db34
commit e964f34086
+8
View File
@@ -135,6 +135,14 @@ func (r *userMetadataHandler) OnUpdate(client client.Client, decoder *admission.
labels, annotations := oldNs.GetLabels(), oldNs.GetAnnotations()
if labels == nil {
labels = make(map[string]string)
}
if annotations == nil {
annotations = make(map[string]string)
}
for key, value := range newNs.GetLabels() {
v, ok := labels[key]
if !ok {