Skip to content

Commit

Permalink
Add handling for nil maps
Browse files Browse the repository at this point in the history
Signed-off-by: Saswata Mukherjee <[email protected]>
  • Loading branch information
saswatamcode committed Dec 11, 2024
1 parent 242cfec commit a9665f9
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -972,12 +972,17 @@ func getObservabilityAddon(c client.Client, namespace string,
Kind: "ObservabilityAddon",
},
ObjectMeta: metav1.ObjectMeta{
Name: obsAddonName,
Namespace: spokeNameSpace,
Name: obsAddonName,
Namespace: spokeNameSpace,
Annotations: make(map[string]string),
},
}

// Handle cases where the addon doesn't have the annotation
if found.Annotations == nil {
found.Annotations = make(map[string]string)
}

if _, ok := found.Annotations["observability.open-cluster-management.io/addon-source"]; !ok {
found.Annotations["observability.open-cluster-management.io/addon-source"] = "mco"
}
Expand Down

0 comments on commit a9665f9

Please sign in to comment.