-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support unordered lists in Terraform. #351
Changes from 1 commit
0beafb3
025460c
76056c4
617ed27
67b8bf1
06937fd
3b8431d
a85cfc0
7099834
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
CustomizeDiff: customdiff.All( | ||
customdiff.ForceNewIfChange("ip_cidr_range", isShrinkageIpCidr), | ||
resourceComputeSubnetworkCustomizeDiff, | ||
), |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
keys := diff.GetChangedKeysPrefix(<%= go_literal(Google::StringUtils.underscore(prop.name)) -%>) | ||
if len(keys) < 1 { | ||
return nil | ||
} | ||
count := diff.Get("<%= Google::StringUtils.underscore(prop.name) -%>.#").(int) | ||
if count < 1 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same as the lines immediately before it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed! |
||
return nil | ||
} | ||
old := make([]interface{}, count) | ||
new := make([]interface{}, count) | ||
for i := 0; i < count; i++ { | ||
o, n := diff.GetChange(fmt.Sprintf("<%= Google::StringUtils.underscore(prop.name) -%>.%d", i)) | ||
|
||
if o != nil { | ||
old = append(old, o) | ||
} | ||
if n != nil { | ||
new = append(new, n) | ||
} | ||
} | ||
if len(old) != len(new) { | ||
return nil | ||
} | ||
|
||
for o, _ := range old { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic seems wrong to me. First off, o and n are the array indices. Second, this looks like it'll return nil (i.e. keep doing what you're doing) as soon as any two elements aren't equal. What if instead, we loaded everything into a schema.Set and then checked equality on that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Weird that the tests passed - yikes, thanks for catching that. Loading into a schema.Set is a good plan, I'll try that. I tried with regular go sets, but of course that didn't work since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's much better, thank you. |
||
for n, _ := range new { | ||
if reflect.DeepEqual(o, n) { | ||
break | ||
} | ||
return nil | ||
} | ||
} | ||
|
||
return diff.Clear(<%= go_literal(Google::StringUtils.underscore(prop.name)) -%>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: mind making this line tabs or the previous line spaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.