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 region_from_zone provider function #2038

Conversation

modular-magician
Copy link
Collaborator

Implement a provider function that lets users get the region from a zone, e.g. get “us-central1” from “us-central1-a”.

We need to decide how the function responds to ‘bad' input and document this in automated tests.

Examples of bad input:

  • empty string

  • string of an inappropriate string like “foobar”

  • string of a region, when a zone is expected

Acceptance Criteria

  • Provider function is implemented
  • Unit tests cover the function’s logic
  • Appropriate levels of acceptance tests added
  • Copy for documentation created

Release Note Template for Downstream PRs (will be copied)

provider: added provider-defined function `region_from_zone` for retrieving the region from a resource's location/zone

Derived from GoogleCloudPlatform/magic-modules#10073

* add regionFromZone function logic

* add region_from_zone_test.go

* add region_from_zone_internal_test.go

* add region_from_zone.html.markdown

* get region_from_zone_test.go passing

* fix region_from_zone_internal_test.go tests

* shorten test config setup time

* have more explicit error for invalid input

* Update mmv1/third_party/terraform/functions/region_from_zone.go

Co-authored-by: Sarah French <[email protected]>

* use compute_disk for better test time

* Update mmv1/third_party/terraform/website/docs/functions/region_from_zone.html.markdown

Co-authored-by: Sarah French <[email protected]>

* Update mmv1/third_party/terraform/functions/region_from_zone_test.go

* Add `location_from_id` provider-defined function (#10061)

* Add `location_from_id` function, tests, docs

* Fix whitespace in acc test HCL config

* fix runtime error and update internal test output

* Update mmv1/third_party/terraform/functions/region_from_zone_test.go

Co-authored-by: Sarah French <[email protected]>

* update to use projectRegionRegex

* Update mmv1/third_party/terraform/functions/region_from_zone.go

---------

Co-authored-by: Sarah French <[email protected]>

[upstream:5e798accff1df8b4964e5e52ba668b5dc3ac0c4f]

Signed-off-by: Modular Magician <[email protected]>
@modular-magician modular-magician requested a review from a team as a code owner March 11, 2024 21:27
@modular-magician modular-magician requested review from shuyama1 and removed request for a team March 11, 2024 21:27
Copy link

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot
https://conventionalcommits.org/

@modular-magician modular-magician merged commit 1f16a13 into GoogleCloudPlatform:FEATURE-BRANCH-provider-functions Mar 11, 2024
5 checks passed
@modular-magician modular-magician deleted the downstream-pr-5e798accff1df8b4964e5e52ba668b5dc3ac0c4f branch November 18, 2024 05:22
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.

1 participant