Skip to content

Commit

Permalink
Merge pull request #1921 from XiShanYongYe-Chang/fix-add-annotation
Browse files Browse the repository at this point in the history
fix add annotation when annotation is nil
  • Loading branch information
karmada-bot committed May 31, 2022
2 parents d7ad34a + f2e92ab commit cff11f2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/registry/search/storage/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ func addAnnotationWithClusterName(resourceObjects []runtime.Object, clusterName
resource := resourceObjects[index].(*unstructured.Unstructured)

annotations := resource.GetAnnotations()
if annotations == nil {
annotations = make(map[string]string)
}
annotations["cluster.karmada.io/name"] = clusterName

resource.SetAnnotations(annotations)
Expand Down

0 comments on commit cff11f2

Please sign in to comment.