Skip to content

Commit

Permalink
fix: avoiding nil pointer when empty map for labels and annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
prometherion committed Dec 26, 2022
1 parent 714f668 commit ce2cba1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/webhook/namespace/user_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ce2cba1

Please sign in to comment.