-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add dynamicGroupMetadata in cloud_identity_group #9452
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
636683e
Add dynamicGroupMetadata in cloud_identity_group
sqin2019 e38f6ae
fix dynamic group update
sqin2019 a6fc83e
fix update
sqin2019 90ca9d4
test dynamic group create
sqin2019 ee4a677
add diff supress func
sqin2019 aa192c5
fix build failure
sqin2019 7d01137
fix supressfunc
sqin2019 40f5fec
check
sqin2019 9bacfd4
ExpectNonEmptyPlan
sqin2019 54bd362
Revert "test dynamic group create"
sqin2019 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
mmv1/templates/terraform/constants/cloud_identity_group_dynamic_label.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const dynamicLabel = "cloudidentity.googleapis.com/groups.dynamic" | ||
|
||
// we want to suppress the dynamic label diff | ||
func resourceCloudIdentityGroupDynamicLabelDiffSuppress(k, _, _ string, d *schema.ResourceData) bool { | ||
// For a map, k is path to the element, rather than the map. | ||
// E.g. "node_groups.2.ips.0" | ||
lastDotIndex := strings.LastIndex(k, ".") | ||
if lastDotIndex != -1 { | ||
k = string(k[:lastDotIndex]) | ||
} | ||
|
||
oldData, newData := d.GetChange(k) | ||
if oldData == nil || newData == nil { | ||
return false | ||
} | ||
|
||
m := make(map[string]interface{}) | ||
for key, val := range oldData.(map[string]interface{}) { | ||
if key != dynamicLabel { | ||
m[key] = val | ||
} | ||
} | ||
return reflect.DeepEqual(m, newData.(map[string]interface{})) | ||
} |
20 changes: 20 additions & 0 deletions
20
mmv1/templates/terraform/examples/cloud_identity_groups_dynamic.tf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
resource "google_cloud_identity_group" "<%= ctx[:primary_resource_id] %>" { | ||
display_name = "<%= ctx[:vars]['id_group'] %>" | ||
|
||
parent = "customers/<%= ctx[:test_env_vars]['cust_id'] %>" | ||
|
||
group_key { | ||
id = "<%= ctx[:vars]['id_group'] %>@<%= ctx[:test_env_vars]['org_domain'] %>" | ||
} | ||
|
||
labels = { | ||
"cloudidentity.googleapis.com/groups.discussion_forum" = "" | ||
} | ||
|
||
dynamic_group_metadata { | ||
queries { | ||
resource_type = "USER" | ||
query = "user.addresses.exists(ad, ad.locality=='Sunnyvale')" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Looks like the automatically added dynamic group label is causing problems here. We may need to either add a DiffSuppressFunc for that label, or add it explicitly to the tests
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.
Thanks, added it to the tests.