Merge pull request #1012 from mrlihanbo/update-annotation

support update object annotations
This commit is contained in:
karmada-bot 2021-11-23 19:39:12 +08:00 committed by GitHub
commit 3b52b0df91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -8,8 +8,11 @@ func MergeAnnotation(obj *unstructured.Unstructured, annotationKey string, annot
if objectAnnotation == nil {
objectAnnotation = make(map[string]string, 1)
}
objectAnnotation[annotationKey] = annotationValue
obj.SetAnnotations(objectAnnotation)
if _, exist := objectAnnotation[annotationKey]; !exist {
objectAnnotation[annotationKey] = annotationValue
obj.SetAnnotations(objectAnnotation)
}
}
// MergeAnnotations merges the annotations from 'src' to 'dst'.