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 resource name_from_id provider-defined function #10106

Merged

Conversation

SarahFrench
Copy link
Contributor

@SarahFrench SarahFrench commented Mar 4, 2024

This is the final PR for adding provider defined functions that enable pulling these values out of identifiers:

  • project
  • region
  • zone
  • location
  • (short-form) name

I've taken into account feedback from other PRs for this PR, e.g. updating docs and acc test resources used.

This function is special as it pulls out the end of an input string starting at the last /. There isn't an easy consistent regex to use, versus /projects/{project}

Release Note Template for Downstream PRs (will be copied)

provider: added provider-defined function `name_from_id ` for retrieving the short-form name from a resource's self link or id

@SarahFrench SarahFrench changed the title Add resource name from id func Add resource name_from_id provider-defined function Mar 8, 2024
@SarahFrench SarahFrench marked this pull request as ready for review March 8, 2024 11:52
@SarahFrench
Copy link
Contributor Author

I can't see checks for running tests etc... /gcbrun

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@SarahFrench SarahFrench force-pushed the add-resource-name-from-id-func branch from e2ca443 to bffe4cb Compare March 8, 2024 19:01
@SarahFrench
Copy link
Contributor Author

Rebased to include the latest commits from main that were synced into the feature branch. This should address VCR failures above.

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@SarahFrench SarahFrench force-pushed the add-resource-name-from-id-func branch from bffe4cb to 3a4e3ee Compare March 11, 2024 21:47
@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 ( 5 files changed, 316 insertions(+))
Terraform Beta: Diff ( 5 files changed, 316 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3501
Passed tests: 3143
Skipped tests: 357
Affected tests: 1

Click here to see the affected service packages
all service packages are affected

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
TestAccProviderFunction_name_from_id

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{red}{\textsf{Tests failed during RECORDING mode:}}$
TestAccProviderFunction_name_from_id[Error message] [Debug log]

$\textcolor{red}{\textsf{Please fix these to complete your PR.}}$
View the build log or the debug log for each test

@SarahFrench SarahFrench force-pushed the add-resource-name-from-id-func branch from 3a4e3ee to 354e3f4 Compare March 12, 2024 10:18
@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 ( 5 files changed, 318 insertions(+))
Terraform Beta: Diff ( 5 files changed, 318 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3501
Passed tests: 3143
Skipped tests: 358
Affected tests: 0

Click here to see the affected service packages
all service packages are affected

$\textcolor{green}{\textsf{All tests passed!}}$
View the build log

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@modular-magician

This comment was marked as outdated.

@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 ( 5 files changed, 321 insertions(+))
Terraform Beta: Diff ( 5 files changed, 321 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3501
Passed tests: 3142
Skipped tests: 358
Affected tests: 1

Click here to see the affected service packages
all service packages are affected

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
TestAccKMSEkmConnection_kmsEkmConnectionBasicExample_update

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

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

$\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 requested a review from shuyama1 March 12, 2024 18:36
@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 ( 5 files changed, 323 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 5 files changed, 323 insertions(+), 2 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3503
Passed tests: 3141
Skipped tests: 360
Affected tests: 2

Click here to see the affected service packages
all service packages are affected

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
TestAccDataSourceGoogleServiceAccountIdToken_impersonation|TestAccNotebooksInstance_notebookInstanceFullExample

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

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

$\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 requested review from c2thorn and removed request for shuyama1 March 14, 2024 17:06
@SarahFrench
Copy link
Contributor Author

SarahFrench commented Mar 14, 2024

Redistributing review as I've used a lot of Shuya's time recently.

@c2thorn could you please review this PR? 🙏

It's very similar to the region/zone one you previously reviewed, but now we're pulling out the short name of a resource from the long id/URL. The regex for this is more permissive though, so there might be edge cases to test for/add extra validation for.

I've triggered tests to run for this branch at : https://hashicorp.teamcity.com/buildConfiguration/TerraformProviders_GoogleCloud_FEATUREBRANCHPROVIDERFUNCTIONS_MM_GA_GOOGLE_PACKAGE_FUNCTIONS/118301?hideTestsFromDependencies=false&hideProblemsFromDependencies=false&expandBuildChangesSection=true

Copy link
Member

@c2thorn c2thorn left a comment

Choose a reason for hiding this comment

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

Looks good overall, just some minor questions

@SarahFrench SarahFrench merged commit f6c50c4 into FEATURE-BRANCH-provider-functions Mar 15, 2024
12 checks passed
@SarahFrench SarahFrench deleted the add-resource-name-from-id-func branch March 15, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants