Skip to content
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 numeric_id field into google_compute_network resource #9473

Merged

Conversation

BBBmau
Copy link
Collaborator

@BBBmau BBBmau commented Nov 15, 2023

This PR will fix an issue that relates to tag binding. Where it is only possible to use an id of a resource for binding rather than name. Because of the use of id within the terraform providers, numeric_id is used as a field which is the unique resource identifier for the resource.

marked as id in API documentation but will be named as numeric_id in provider

Release Note Template for Downstream PRs (will be copied)

compute: added `numeric_id` field to `google_compute_network` resource

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 2 files changed, 15 insertions(+))
Terraform Beta: Diff ( 2 files changed, 15 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3226
Passed tests 2893
Skipped tests: 329
Affected tests: 4

Action taken

Found 4 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccContainerAttachedCluster_update|TestAccContainerAttachedCluster_containerAttachedClusterFullExample|TestAccDataprocJobIamPolicy|TestAccDataprocClusterIamPolicy

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccContainerAttachedCluster_update[Debug log]
TestAccContainerAttachedCluster_containerAttachedClusterFullExample[Debug log]
TestAccDataprocJobIamPolicy[Debug log]
TestAccDataprocClusterIamPolicy[Debug log]

Rerun these tests in REPLAYING mode to catch issues

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{green}{\textsf{All tests passed!}}$
View the build log or the debug log for each test

@SarahFrench SarahFrench self-requested a review November 16, 2023 11:38
@BBBmau BBBmau changed the title add numberic_id field into google_compute_network.network resource add numeric_id field into google_compute_network.network resource Nov 17, 2023
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 2 files changed, 52 insertions(+))
Terraform Beta: Diff ( 2 files changed, 52 insertions(+))
TF Conversion: Diff ( 1 file changed, 5 insertions(+))

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 122 insertions(+))
Terraform Beta: Diff ( 3 files changed, 122 insertions(+))
TF Conversion: Diff ( 1 file changed, 5 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2385
Passed tests 2119
Skipped tests: 265
Affected tests: 1

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccDataprocClusterIamPolicy

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccDataprocClusterIamPolicy[Debug log]

Rerun these tests in REPLAYING mode to catch issues

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{red}{\textsf{Errors occurred during RECORDING mode. Please fix them to complete your PR.}}$
View the build log or the debug log for each test

@SarahFrench
Copy link
Collaborator

Checks are failing at the moment:

# github.com/hashicorp/terraform-provider-google/google/services/compute_test [github.com/hashicorp/terraform-provider-google/google/services/compute.test]
Error: google/services/compute/resource_compute_network_test.go:481:6: invalid operation: found.Id (variable of type uint64) is not an interface
Error: google/services/compute/resource_compute_network_test.go:485:6: invalid operation: found.Id (variable of type uint64) is not an interface

@BBBmau
Copy link
Collaborator Author

BBBmau commented Nov 17, 2023

Checks are failing at the moment:

# github.com/hashicorp/terraform-provider-google/google/services/compute_test [github.com/hashicorp/terraform-provider-google/google/services/compute.test]
Error: google/services/compute/resource_compute_network_test.go:481:6: invalid operation: found.Id (variable of type uint64) is not an interface
Error: google/services/compute/resource_compute_network_test.go:485:6: invalid operation: found.Id (variable of type uint64) is not an interface

In my latest commit i addressed the value checks for id and numeric_id although it does provide a check of both values im not 100% convinced that this is the best way to go about it. Would love some input on this, I was expecting there to be a value that provides the id that's in the resource path. I found that I wasn't able to access it and had to produce it myself with the use of config.Project and found.name

@BBBmau BBBmau marked this pull request as ready for review November 17, 2023 19:07
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 122 insertions(+))
Terraform Beta: Diff ( 3 files changed, 122 insertions(+))
TF Conversion: Diff ( 1 file changed, 5 insertions(+))

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 123 insertions(+))
Terraform Beta: Diff ( 3 files changed, 123 insertions(+))
TF Conversion: Diff ( 1 file changed, 5 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3236
Passed tests 2904
Skipped tests: 330
Affected tests: 2

Action taken

Found 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccComputeNetwork_numericId|TestAccDataSourceGoogleServiceAccountAccessToken_basic

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccComputeNetwork_numericId[Debug log]
TestAccDataSourceGoogleServiceAccountAccessToken_basic[Debug log]

Rerun these tests in REPLAYING mode to catch issues

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{green}{\textsf{All tests passed!}}$
View the build log or the debug log for each test

Copy link
Collaborator

@SarahFrench SarahFrench left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the current approach is the best way to address the problem, but to be fair adding fields that don't map to the API is confusing and requires a bunch of familiarity with the templating in MMv1! Gotta learn the rules to be able to break them 😉

If you'd like to pair on this issue please let me know, I'm available to help synchronously with some planning!

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 115 insertions(+))
Terraform Beta: Diff ( 3 files changed, 115 insertions(+))
TF Conversion: Diff ( 1 file changed, 5 insertions(+))

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 115 insertions(+))
Terraform Beta: Diff ( 3 files changed, 115 insertions(+))
TF Conversion: Diff ( 1 file changed, 5 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3238
Passed tests 2906
Skipped tests: 331
Affected tests: 1

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccDataSourceGoogleServiceAccountAccessToken_basic

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccDataSourceGoogleServiceAccountAccessToken_basic[Debug log]

Rerun these tests in REPLAYING mode to catch issues

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{green}{\textsf{All tests passed!}}$
View the build log or the debug log for each test

@BBBmau BBBmau changed the title add numeric_id field into google_compute_network.network resource add numeric_id field into google_compute_network resource Dec 7, 2023
@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 82 insertions(+))
Terraform Beta: Diff ( 3 files changed, 82 insertions(+))
TF Conversion: Diff ( 1 file changed, 5 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3267
Passed tests 2932
Skipped tests: 334
Affected tests: 1

Action taken

Found 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
TestAccGKEHub2Fleet_gkehubFleetBasicExample_update

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccGKEHub2Fleet_gkehubFleetBasicExample_update[Debug log]

Rerun these tests in REPLAYING mode to catch issues

$\textcolor{green}{\textsf{No issues found for passed tests after REPLAYING rerun.}}$


$\textcolor{green}{\textsf{All tests passed!}}$
View the build log or the debug log for each test

Copy link
Collaborator

@SarahFrench SarahFrench left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, and I'll leave it to you to merge! I've left a comment about the regex that you could push a commit for before merging, up to you. Thanks for taking the time to update the tests!

{
Config: testAccComputeNetwork_basic(suffixName),
Check: resource.ComposeTestCheckFunc(
resource.TestMatchResourceAttr("google_compute_network.bar", "numeric_id",regexp.MustCompile("[1-9]\\d{0,}")),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this regex could be made a bit more strict by updating it to assert that only digits are in the value: ^[1-9]\d{0,}$. Currently the regex would match foobar123, which means it could say that projects/foobar/global/networks/foobar123 is a valid numeric_id value.

It could also be simplified down to ^\d{1,}$ which means 1 or more digits, whereas the other version looks for a digit and then 0 or more digits afterwards.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My favourite website for doing quick manual tests of regexes is https://regexr.com/

Though, just to be clear, if you're testing a regex that uses ^ and $ the regex will need to match everything in the text box:

@modular-magician
Copy link
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes:

Diff report

Your PR generated some diffs in downstreams - here they are.

Terraform GA: Diff ( 3 files changed, 82 insertions(+))
Terraform Beta: Diff ( 3 files changed, 82 insertions(+))
TF Conversion: Diff ( 1 file changed, 5 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3269
Passed tests 2935
Skipped tests: 334
Affected tests: 0

$\textcolor{green}{\textsf{All tests passed in REPLAYING mode.}}$
View the build log

trodge pushed a commit to trodge/magic-modules that referenced this pull request Dec 8, 2023
…CloudPlatform#9473)

* add numberic_id field

* add flattener, encoders, and id field for numeric_id use

* WIP: add numberId test

* add value checks for id and numeric_id

* add strconv

* use decoder to store id into numericId after API request

* remove network check and add suffix variable

* add endlines

* typo

* Updated test to explicitly check numeric_id and id with ResourceAttr

* update regex to be more strict on numeric_id check
balanaguharsha pushed a commit to balanaguharsha/magic-modules that referenced this pull request May 2, 2024
…CloudPlatform#9473)

* add numberic_id field

* add flattener, encoders, and id field for numeric_id use

* WIP: add numberId test

* add value checks for id and numeric_id

* add strconv

* use decoder to store id into numericId after API request

* remove network check and add suffix variable

* add endlines

* typo

* Updated test to explicitly check numeric_id and id with ResourceAttr

* update regex to be more strict on numeric_id check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants