-
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 5 commits
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), | ||
customdiff.ForceNewIfChange("ip_cidr_range", isShrinkageIpCidr), | ||
resourceComputeSubnetworkSecondaryIpRangeSetStyleDiff, | ||
), |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
keys := diff.GetChangedKeysPrefix(<%= go_literal(Google::StringUtils.underscore(prop.name)) -%>) | ||
if len(keys) == 0 { | ||
return nil | ||
} | ||
oldCount, newCount := diff.GetChange("<%= Google::StringUtils.underscore(prop.name) -%>.#") | ||
var count int | ||
// There could be duplicates - worth continuing even if the counts are unequal. | ||
if oldCount.(int) < newCount.(int) { | ||
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. Does it make sense to return here if the counts aren't the same? 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. Duplicates may exist. Added a comment. |
||
count = newCount.(int) | ||
} else { | ||
count = oldCount.(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) | ||
} | ||
} | ||
|
||
oldSet := schema.NewSet(schema.HashResource(resource<%= resource_name -%>().Schema[<%= go_literal(Google::StringUtils.underscore(prop.name)) -%>].Elem.(*schema.Resource)), old) | ||
newSet := schema.NewSet(schema.HashResource(resource<%= resource_name -%>().Schema[<%= go_literal(Google::StringUtils.underscore(prop.name)) -%>].Elem.(*schema.Resource)), new) | ||
|
||
if oldSet.Equal(newSet) { | ||
if err := diff.Clear(<%= go_literal(Google::StringUtils.underscore(prop.name)) -%>); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil |
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.
why this change?
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.
The problem comes from the fact that we're implicitly comparing against the returned value from the API - we wouldn't have any diff problems otherwise.