Skip to content

Commit 99d9388

Browse files
committed
Sort userTags in Machine and Machineset manifests
Installer inserts AWS userTags provided via install config into Machine and Machineset manifests that it generates. The userTags need to be ordered before adding to AWSMachineProviderConfig. This way when CPMS-operator compares its control plane & worker machines with the Installer generated manifests, it does not flag them as different.
1 parent 4c5fce9 commit 99d9388

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pkg/asset/machines/aws/machines.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package aws
33

44
import (
55
"fmt"
6+
"sort"
67

78
"github.com/pkg/errors"
89
corev1 "k8s.io/api/core/v1"
@@ -245,11 +246,18 @@ func tagsFromUserTags(clusterID string, usertags map[string]string) ([]machineap
245246
for idx := range tags {
246247
forbiddenTags.Insert(tags[idx].Name)
247248
}
248-
for k, v := range usertags {
249+
250+
userTagKeys := make([]string, 0, len(usertags))
251+
for key := range usertags {
252+
userTagKeys = append(userTagKeys, key)
253+
}
254+
sort.Strings(userTagKeys)
255+
256+
for _, k := range userTagKeys {
249257
if forbiddenTags.Has(k) {
250258
return nil, fmt.Errorf("user tags may not clobber %s", k)
251259
}
252-
tags = append(tags, machineapi.TagSpecification{Name: k, Value: v})
260+
tags = append(tags, machineapi.TagSpecification{Name: k, Value: usertags[k]})
253261
}
254262
return tags, nil
255263
}

0 commit comments

Comments
 (0)