Skip to content

Commit 856491c

Browse files
authored
fix(Annotations): Panic when applying annotations and map is nil (#2278)
* fix(Annotations): Panic when annotations is nil * chore: Refactor instantiation above key check
1 parent 91b8da1 commit 856491c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

controllers/controller_shared.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,10 @@ func patchFinalizers(ctx context.Context, cl client.Client, cr client.Object) er
479479
func addAnnotation(ctx context.Context, cl client.Client, cr client.Object, key string, value string) error {
480480
crAnnotations := cr.GetAnnotations()
481481

482+
if crAnnotations == nil {
483+
crAnnotations = make(map[string]string, 0)
484+
}
485+
482486
if crAnnotations[key] == value {
483487
return nil
484488
}

0 commit comments

Comments
 (0)