File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package controllers
1818
1919import (
2020 "encoding/json"
21+ "maps"
2122
2223 infrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
2324)
@@ -40,13 +41,14 @@ func (r *AWSMachineReconciler) updateMachineAnnotationJSON(machine *infrav1.AWSM
4041// `content`.
4142func (r * AWSMachineReconciler ) updateMachineAnnotation (machine * infrav1.AWSMachine , annotation , content string ) {
4243 // Get the annotations
43- annotations := machine .GetAnnotations ()
44+ annotations := maps . Clone ( machine .GetAnnotations () )
4445
45- // Set our annotation to the given content.
46- if annotations != nil {
47- annotations [annotation ] = content
46+ if annotations == nil {
47+ annotations = map [string ]string {}
4848 }
4949
50+ annotations [annotation ] = content
51+
5052 // Update the machine object with these annotations
5153 machine .SetAnnotations (annotations )
5254}
You can’t perform that action at this time.
0 commit comments