Skip to content

Commit d080f27

Browse files
committed
gce: normalize scopes in comparison
The order of scopes should not matter here, so do not force a new instance template just because the order is different.
1 parent 78d4757 commit d080f27

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

upup/pkg/fi/cloudup/gcetasks/instancetemplate.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,11 @@ func (a ByKey) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
411411
func (a ByKey) Less(i, j int) bool { return a[i].Key < a[j].Key }
412412

413413
func matches(l, r *compute.InstanceTemplate) bool {
414+
normalizeServiceAccount := func(v *compute.ServiceAccount) *compute.ServiceAccount {
415+
c := *v
416+
sort.Strings(c.Scopes)
417+
return &c
418+
}
414419
normalizeInstanceProperties := func(v *compute.InstanceProperties) *compute.InstanceProperties {
415420
c := *v
416421
if c.Metadata != nil {
@@ -419,6 +424,11 @@ func matches(l, r *compute.InstanceTemplate) bool {
419424
c.Metadata.Fingerprint = ""
420425
sort.Sort(ByKey(c.Metadata.Items))
421426
}
427+
if c.ServiceAccounts != nil {
428+
for i, serviceAccount := range c.ServiceAccounts {
429+
c.ServiceAccounts[i] = normalizeServiceAccount(serviceAccount)
430+
}
431+
}
422432
// Ignore output fields
423433
for _, ni := range c.NetworkInterfaces {
424434
ni.Name = ""

0 commit comments

Comments
 (0)