Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions controllers/awsmachine_annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllers

import (
"encoding/json"
"maps"

infrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
)
Expand All @@ -40,13 +41,14 @@ func (r *AWSMachineReconciler) updateMachineAnnotationJSON(machine *infrav1.AWSM
// `content`.
func (r *AWSMachineReconciler) updateMachineAnnotation(machine *infrav1.AWSMachine, annotation, content string) {
// Get the annotations
annotations := machine.GetAnnotations()
annotations := maps.Clone(machine.GetAnnotations())

// Set our annotation to the given content.
if annotations != nil {
annotations[annotation] = content
if annotations == nil {
annotations = map[string]string{}
}

annotations[annotation] = content

// Update the machine object with these annotations
machine.SetAnnotations(annotations)
}
Expand Down