-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
compute: added numeric_id
to google_compute_subnetwork
#12285
base: main
Are you sure you want to change the base?
compute: added numeric_id
to google_compute_subnetwork
#12285
Conversation
Hello! I am a robot. Tests will require approval from a repository maintainer to run. @BBBmau, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look. You can help make sure that review is quick by doing a self-review and by running impacted tests locally. |
Added `numeric_id` to `google_compute_subnetwork` resource and data source. Since Terraform uses `id` internally, follow the example of `google_compute_network`, and make `numeric_id` contain the `id` field from the API. Part of hashicorp/terraform-provider-google#20223
a5e00b1
to
3312a35
Compare
@@ -73,6 +73,9 @@ iam_policy: | |||
custom_code: | |||
extra_schema_entry: 'templates/terraform/extra_schema_entry/subnetwork.tmpl' | |||
constants: 'templates/terraform/constants/subnetwork.tmpl' | |||
decoder: 'templates/terraform/decoders/compute_subnetwork.go.tmpl' | |||
encoder: 'templates/terraform/encoders/compute_subnetwork.go.tmpl' | |||
update_encoder: 'templates/terraform/update_encoder/compute_subnetwork.go.tmpl' |
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.
these are all identical to the ones for compute_network
; I'm assuming there's still a preference to have these be copied / pasted vs. sharing a common file with a more generic name?
@@ -203,6 +206,10 @@ properties: | |||
custom_expand: 'templates/terraform/custom_expand/resourceref_with_validation.go.tmpl' | |||
resource: 'Network' | |||
imports: 'selfLink' | |||
- name: 'numericId' | |||
type: String |
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.
It's an integer in the API, but followed the example from google_compute_network
of making it a string, so I assume that's preferred?
@@ -100,6 +105,10 @@ func dataSourceGoogleComputeSubnetworkRead(d *schema.ResourceData, meta interfac | |||
return transport_tpg.HandleDataSourceNotFoundError(err, d, fmt.Sprintf("Subnetwork Not Found : %s", name), id) | |||
} | |||
|
|||
if err := d.Set("numeric_id", strconv.Itoa(int(subnetwork.Id))); err != 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.
I am assuming this is pretty reliably an int64
; not sure if this is the right place to do the conversion and / or if any more error checking is needed here, but it seems to work and tests pass.
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.
if we mark numericId as an integer we shouldn't need to do this extra conversion unless there's something that's preventing integer to be used over string
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.
See comment above; as best I could tell, other similar fields (in particular, the one in google_compute_network
that this is based on) are implemented as strings… I could make it a number in terraform if you can confirm that’s the right thing to do, but would be nice to understand why so many of them are already implemented as strings.
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.
Google project number, org ID, etc. also seems to be implemented as strings vs. int
magic-modules/mmv1/third_party/terraform/services/resourcemanager/resource_google_project.go
Line 104 in 8179902
Type: schema.TypeString, |
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 1061 Click here to see the affected service packages
Action takenFound 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
Added
numeric_id
togoogle_compute_subnetwork
resource and data source.Since Terraform uses
id
internally, follow the example ofgoogle_compute_network
, and makenumeric_id
contain theid
field from the API.As mentioned in the issue below, it would be very nice if there were a simpler way to just say "map
id
in the API tonumericId
here", but guessing that's not possible?Part of hashicorp/terraform-provider-google#20223
Release Note Template for Downstream PRs (will be copied)
See Write release notes for guidance.