-
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 data catalog tag #3569
add data catalog tag #3569
Conversation
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 7 files changed, 1627 insertions(+), 2 deletions(-)) |
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 7 files changed, 1630 insertions(+), 2 deletions(-)) |
name: template_displayname | ||
fields.enum_value: !ruby/object:Overrides::Terraform::PropertyOverride | ||
flatten_object: true | ||
custom_expand: templates/terraform/custom_expand/data_catalog_tag.go.erb |
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.
What happens without the expander? Does it just get the name wrong?
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.
yea, i thought this was strange too. i thought maybe the issue was that i'm renaming the nested value to enum_value
, but looking closer I wonder if it's because it's a set? and calling d.Get("enum_value")
should be expanded to d.Get("fields.xxxx.enum_value")
?
The request sends, when really displayName
has a value
"pii_type": {
"enum_value": {
"displayName": null
}
}
And appears to be in issue where v
is the correct value that we want, but the autogenerated code calls d.Get("enum_value")
which in turn is nil
transformed := make(map[string]interface{})
transformedEnumValue, err := expandNestedDataCatalogTagFieldsEnumValueEnumValue(d.Get("enum_value"), d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedEnumValue); val.IsValid() && !isEmptyValue(val) {
transformed["display_name"] = transformedEnumValue
}
return transformed, nil
I tried hard-coding it and it seemed to work, so i think this might be necessary. Unless there's a way to do it without a custom_expand?
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.
ah yeah I see where the code is doing that but I don't have an immediate solution. I'm fine with the custom expand as long as it's well-commented why it's needed.
// of the field in the tag template. Depending on that type, a different | ||
// attribute needs to be populated here, but only one of these attributes | ||
// can be sent, so if an attribute is not set, we need to delete it from | ||
// the object |
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.
I'm not able to figure out from this why we have to read the template to see which attribute to populate rather than just doing it based off of which one was set by the user. Since our expanders check for emptiness, there shouldn't be anything in the object to delete.
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.
This is the request being sent if I don't have this encoder in here:
"pii_type": {
"bool_value": false,
"display_name": "",
"double_value": 0,
"enum_value": {
"display_name": "EMAIL"
},
"order": 0,
"string_value": "",
"timestamp_value": ""
},
I'm maybe missing something somewhere else in the code where this would be circumvented, but in this case we only want enum_value.display_name
populated, we don't want to send the other values. They seem to be added in expandNestedDataCatalogTagFields
where it's not really checking if it's nil and not adding it, it's still adding it to the map, despite it being 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.
https://github.com/GoogleCloudPlatform/magic-modules/blob/master/templates/terraform/expand_property_method.erb#L76-L82 I think if that logic is duplicated up into the "generate expanders for maps" section, that would do the trick
5f11783
to
c37845c
Compare
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 9 files changed, 1689 insertions(+), 24 deletions(-)) |
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 9 files changed, 1713 insertions(+), 14 deletions(-)) |
79e2509
to
b6c84c6
Compare
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 12 files changed, 1668 insertions(+), 17 deletions(-)) |
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.
LGTM though I'm curious about the custom flattener.
Also since this affects a bunch of resources due to the expander change, can you keep an eye on those tests?
} | ||
l := v.(map[string]interface{}) | ||
transformed := make([]interface{}, 0, len(l)) | ||
for k, raw := range l { |
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.
Can you add a comment on what this is doing that the generated flattener doesn't?
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.
@danawillow - thanks for mentioning this, i looked further into it and although the documentation has the fields snake case (which i originally wrote them as), i tried them with camel case and it worked, so i switched them there. that's originally what the custom flattener was for. i repurposed it now specifically for enumValue
because without the custom flattener it returns an array of interfaces rather than the string it's expecting. hope that makes sense!
ea53b19
to
1c63154
Compare
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 12 files changed, 1695 insertions(+), 17 deletions(-)) |
I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=118748" |
Addresses hashicorp/terraform-provider-google#5892
It's very possible this doesn't require all the custom code and that I'm just missing some settings in api.yaml/terraform.yaml
Release Note Template for Downstream PRs (will be copied)