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

Support location in google_cloudbuild_trigger. #6440

Merged
merged 3 commits into from
Sep 1, 2022
Merged

Support location in google_cloudbuild_trigger. #6440

merged 3 commits into from
Sep 1, 2022

Conversation

vicpadilla
Copy link
Member

Summary of changes:

  • Add a url-only location parameter that defaults to "global"
  • The base paths have been updated to include locations/{{location}}/.
  • A schema migration inserts location="global" for already existing resources. https://www.terraform.io/plugin/sdkv2/resources/state-migration
  • To keep backwards compatibility in resource id, the post_create and post_import overrides change the resource id to projects/x/triggers/y instead of projects/x/locations/global/triggers/y for global triggers.
  • A pre_read override is necessary to continue supporting projects/x/triggers/y as import formats.
  • The schemaVersion field has been moved from resource_definition override to terraform.yaml. It has been increased to 2 to force migration for existing resources.
  • The migration from V0 to V1 is noop. Migration from V1 to V2 adds location="global".
  • Small fix to resource.erb template to properly handle generation of resources with more than 2 versions.
  • A handwritten test verifies that a resource can be created with an old version and then updated with the current version of the provider.

Fixes hashicorp/terraform-provider-google#11624

If this PR is for Terraform, I acknowledge that I have:

  • Searched through the issue tracker for an open issue that this either resolves or contributes to, commented on it to claim it, and written "fixes {url}" or "part of {url}" in this PR description. If there were no relevant open issues, I opened one and commented that I would like to work on it (not necessary for very small changes).
  • Generated Terraform, and ran make test and make lint to ensure it passes unit and linter tests.
  • Ensured that all new fields I added that can be set by a user appear in at least one example (for generated resources) or third_party test (for handwritten resources or update tests).
  • Ran relevant acceptance tests (If the acceptance tests do not yet pass or you are unable to run them, please let your reviewer know).
  • Read the Release Notes Guide before writing my release note below.

Release Note Template for Downstream PRs (will be copied)

cloudbuild: added `location` field to `google_cloudbuild_trigger` resource

Using schema upgrades for backwards compatibility.
@modular-magician
Copy link
Collaborator

Hello! I am a robot who works on Magic Modules PRs.

I've detected that you're a community contributor. @shuyama1, a repository maintainer, has been assigned to assist you and help review your changes.

❓ First time contributing? Click here for more details

Your assigned reviewer will help review your code by:

  • Ensuring it's backwards compatible, covers common error cases, etc.
  • Summarizing the change into a user-facing changelog note.
  • Passes tests, either our "VCR" suite, a set of presubmit tests, or with manual test runs.

You can help make sure that review is quick by running local tests and ensuring they're passing in between each push you make to your PR's branch. Also, try to leave a comment with each push you make, as pushes generally don't generate emails.

If your reviewer doesn't get back to you within a week after your most recent change, please feel free to leave a comment on the issue asking them to take a look! In the absence of a dedicated review dashboard most maintainers manage their pending reviews through email, and those will sometimes get lost in their inbox.


@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 1162 insertions(+), 30 deletions(-))
Terraform Beta: Diff ( 5 files changed, 1162 insertions(+), 30 deletions(-))
TF Validator: Diff ( 3 files changed, 4 insertions(+), 4 deletions(-))
TF OiCS: Diff ( 3 files changed, 5 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2140
Passed tests 1886
Skipped tests: 228
Failed tests: 26

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange|TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthoritySubordinateExample|TestAccFirebaserulesRelease_BasicRelease|TestAccComputeInstance_networkPerformanceConfig|TestAccComputeInstance_soleTenantNodeAffinities|TestAccComputeGlobalForwardingRule_internalLoadBalancing|TestAccCloudBuildTrigger_migration|TestAccCloudBuildTrigger_cloudbuildTriggerManualExample|TestAccCloudBuildTrigger_cloudbuildTriggerWebhookConfigExample|TestAccCloudBuildTrigger_fullStep|TestAccCloudBuildTrigger_disable|TestAccCloudfunctions2function_cloudfunctions2BasicAuditlogsExample|TestAccCloudBuildTrigger_cloudbuildTriggerPubsubConfigExample|TestAccCloudBuildTrigger_webhook_config|TestAccCloudBuildTrigger_pubsub_config|TestAccCloudBuildTrigger_cloudbuildTriggerBuildExample|TestAccCloudfunctions2function_cloudfunctions2BasicGcsExample|TestAccCloudBuildTrigger_cloudbuildTriggerFilenameExample|TestAccCloudBuildTrigger_cloudbuildTriggerServiceAccountExample|TestAccCloudBuildTrigger_available_secrets_config|TestAccCloudFunctions2Function_fullUpdate|TestAccCGCSnippet_eventarcWorkflowsExample|TestAccCloudBuildTrigger_basic|TestAccCloudRunService_cloudRunServiceStaticOutboundExample|TestAccSqlUser_mysqlDisabled|TestAccSqlDatabaseInstance_SqlServerAuditConfig

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRangeClone[view]
TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthoritySubordinateExample[view]
TestAccFirebaserulesRelease_BasicRelease[view]
TestAccCloudBuildTrigger_cloudbuildTriggerManualExample[view]
TestAccCloudBuildTrigger_cloudbuildTriggerWebhookConfigExample[view]
TestAccCloudBuildTrigger_fullStep[view]
TestAccCloudBuildTrigger_disable[view]
TestAccCloudfunctions2function_cloudfunctions2BasicAuditlogsExample[view]
TestAccCloudBuildTrigger_cloudbuildTriggerPubsubConfigExample[view]
TestAccCloudBuildTrigger_webhook_config[view]
TestAccCloudBuildTrigger_pubsub_config[view]
TestAccCloudBuildTrigger_cloudbuildTriggerBuildExample[view]
TestAccCloudBuildTrigger_cloudbuildTriggerFilenameExample[view]
TestAccCloudBuildTrigger_available_secrets_config[view]
TestAccCloudFunctions2Function_fullUpdate[view]
TestAccCGCSnippet_eventarcWorkflowsExample[view]
TestAccCloudBuildTrigger_basic[view]
TestAccSqlUser_mysqlDisabled[view]

Tests failed during RECORDING mode:
TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange[view]
TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRangeReplica[view]
TestAccComputeInstance_networkPerformanceConfig[view]
TestAccComputeGlobalForwardingRule_internalLoadBalancing[view]
TestAccCloudBuildTrigger_migration[view]
TestAccCloudBuildTrigger_cloudbuildTriggerServiceAccountExample[view]
TestAccCloudRunService_cloudRunServiceStaticOutboundExample[view]
TestAccSqlDatabaseInstance_SqlServerAuditConfig[view]

Please fix these to complete your PR
View the build log or the debug log for each test

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 1163 insertions(+), 30 deletions(-))
Terraform Beta: Diff ( 5 files changed, 1163 insertions(+), 30 deletions(-))
TF Validator: Diff ( 3 files changed, 4 insertions(+), 4 deletions(-))
TF OiCS: Diff ( 3 files changed, 5 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2141
Passed tests 1899
Skipped tests: 229
Failed tests: 13

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccComputeInstance_networkPerformanceConfig|TestAccComputeInstance_soleTenantNodeAffinities|TestAccComputeGlobalForwardingRule_internalLoadBalancing|TestAccCloudBuildTrigger_cloudbuildTriggerServiceAccountExample|TestAccCloudfunctions2function_cloudfunctions2BasicAuditlogsExample|TestAccCloudfunctions2function_cloudfunctions2BasicGcsExample|TestAccCloudFunctions2Function_fullUpdate|TestAccCloudRunService_cloudRunServiceStaticOutboundExample|TestAccBigQueryDataTable_bigtable|TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthoritySubordinateExample|TestAccSqlUser_mysqlDisabled|TestAccSqlDatabaseInstance_SqlServerAuditConfig|TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccCloudfunctions2function_cloudfunctions2BasicAuditlogsExample[view]
TestAccCloudfunctions2function_cloudfunctions2BasicGcsExample[view]
TestAccCloudFunctions2Function_fullUpdate[view]
TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthoritySubordinateExample[view]
TestAccSqlUser_mysqlDisabled[view]

Tests failed during RECORDING mode:
TestAccComputeInstance_networkPerformanceConfig[view]
TestAccComputeInstance_soleTenantNodeAffinities[view]
TestAccComputeGlobalForwardingRule_internalLoadBalancing[view]
TestAccCloudBuildTrigger_cloudbuildTriggerServiceAccountExample[view]
TestAccCloudRunService_cloudRunServiceStaticOutboundExample[view]
TestAccBigQueryDataTable_bigtable[view]
TestAccSqlDatabaseInstance_SqlServerAuditConfig[view]
TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange[view]
TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRangeClone[view]
TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRangeReplica[view]

Please fix these to complete your PR
View the build log or the debug log for each test

@shuyama1
Copy link
Member

/gcbrun

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 1163 insertions(+), 30 deletions(-))
Terraform Beta: Diff ( 5 files changed, 1163 insertions(+), 30 deletions(-))
TF Validator: Diff ( 3 files changed, 4 insertions(+), 4 deletions(-))
TF OiCS: Diff ( 3 files changed, 5 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2145
Passed tests 1900
Skipped tests: 229
Failed tests: 16

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccFirebaserulesRelease_BasicRelease|TestAccComputeInstance_networkPerformanceConfig|TestAccComputeInstance_soleTenantNodeAffinities|TestAccComputeGlobalForwardingRule_internalLoadBalancing|TestAccCloudRunService_cloudRunServiceScheduledExample|TestAccCGCSnippet_storageObjectLifecycleSettingExample|TestAccCloudRunService_cloudRunServiceStaticOutboundExample|TestAccCGCSnippet_eventarcWorkflowsExample|TestAccCloudFunctions2Function_fullUpdate|TestAccCloudfunctions2function_cloudfunctions2BasicAuditlogsExample|TestAccCloudBuildTrigger_cloudbuildTriggerServiceAccountExample|TestAccCloudfunctions2function_cloudfunctions2BasicGcsExample|TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthoritySubordinateExample|TestAccSqlUser_mysqlDisabled|TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange|TestAccSqlDatabaseInstance_SqlServerAuditConfig

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccFirebaserulesRelease_BasicRelease[view]
TestAccCGCSnippet_eventarcWorkflowsExample[view]
TestAccCloudfunctions2function_cloudfunctions2BasicAuditlogsExample[view]
TestAccCloudfunctions2function_cloudfunctions2BasicGcsExample[view]
TestAccSqlUser_mysqlDisabled[view]

Tests failed during RECORDING mode:
TestAccComputeInstance_networkPerformanceConfig[view]
TestAccComputeInstance_soleTenantNodeAffinities[view]
TestAccComputeGlobalForwardingRule_internalLoadBalancing[view]
TestAccCloudRunService_cloudRunServiceScheduledExample[view]
TestAccCGCSnippet_storageObjectLifecycleSettingExample[view]
TestAccCloudRunService_cloudRunServiceStaticOutboundExample[view]
TestAccCloudFunctions2Function_fullUpdate[view]
TestAccCloudBuildTrigger_cloudbuildTriggerServiceAccountExample[view]
TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthoritySubordinateExample[view]
TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange[view]
TestAccSqlDatabaseInstance_SqlServerAuditConfig[view]

Please fix these to complete your PR
View the build log or the debug log for each test

@shuyama1
Copy link
Member

/gcbrun

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 1163 insertions(+), 30 deletions(-))
Terraform Beta: Diff ( 5 files changed, 1163 insertions(+), 30 deletions(-))
TF Validator: Diff ( 3 files changed, 4 insertions(+), 4 deletions(-))
TF OiCS: Diff ( 3 files changed, 5 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2145
Passed tests 1900
Skipped tests: 231
Failed tests: 14

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthoritySubordinateExample|TestAccFirebaserulesRelease_BasicRelease|TestAccComputeGlobalForwardingRule_internalLoadBalancing|TestAccComputeInstance_soleTenantNodeAffinities|TestAccCloudFunctions2Function_fullUpdate|TestAccCGCSnippet_storageObjectLifecycleSettingExample|TestAccCloudBuildTrigger_cloudbuildTriggerServiceAccountExample|TestAccCloudRunService_cloudRunServiceScheduledExample|TestAccCloudRunService_cloudRunServiceStaticOutboundExample|TestAccCloudfunctions2function_cloudfunctions2BasicAuditlogsExample|TestAccCloudfunctions2function_cloudfunctions2BasicGcsExample|TestAccSqlUser_mysqlDisabled|TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange|TestAccSqlDatabaseInstance_SqlServerAuditConfig

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccFirebaserulesRelease_BasicRelease[view]
TestAccCloudBuildTrigger_cloudbuildTriggerServiceAccountExample[view]
TestAccCloudfunctions2function_cloudfunctions2BasicAuditlogsExample[view]
TestAccCloudfunctions2function_cloudfunctions2BasicGcsExample[view]
TestAccSqlUser_mysqlDisabled[view]

Tests failed during RECORDING mode:
TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthoritySubordinateExample[view]
TestAccComputeGlobalForwardingRule_internalLoadBalancing[view]
TestAccComputeInstance_soleTenantNodeAffinities[view]
TestAccCloudFunctions2Function_fullUpdate[view]
TestAccCGCSnippet_storageObjectLifecycleSettingExample[view]
TestAccCloudRunService_cloudRunServiceScheduledExample[view]
TestAccCloudRunService_cloudRunServiceStaticOutboundExample[view]
TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange[view]
TestAccSqlDatabaseInstance_SqlServerAuditConfig[view]

Please fix these to complete your PR
View the build log or the debug log for each test

Copy link
Member

@shuyama1 shuyama1 left a comment

Choose a reason for hiding this comment

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

Sorry for the delay on this!
Question: Did you have a chance to run TestAccCloudBuildTrigger_migration locally and was the test passed?

mmv1/products/cloudbuild/api.yaml Outdated Show resolved Hide resolved
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 5 files changed, 1163 insertions(+), 30 deletions(-))
Terraform Beta: Diff ( 5 files changed, 1163 insertions(+), 30 deletions(-))
TF Validator: Diff ( 3 files changed, 4 insertions(+), 4 deletions(-))
TF OiCS: Diff ( 3 files changed, 5 insertions(+))

@vicpadilla
Copy link
Member Author

Did you have a chance to run TestAccCloudBuildTrigger_migration locally and was the test passed?

Yes, the test passes locally:

export GOOGLE_PROJECT=...
export GOOGLE_USE_DEFAULT_CREDENTIALS=true
export GOOGLE_REGION=us-west1
export GOOGLE_ZONE=us-west1-c
$ make testacc TEST=./google TESTARGS='-run=TestAccCloudBuildTrigger_migration'
go generate  ./...
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google -v -run=TestAccCloudBuildTrigger_migration -timeout 240m -ldflags="-X=github.com/hashicorp/terraform-provider-google/version.ProviderVersion=acc"
=== RUN   TestAccCloudBuildTrigger_migration
=== PAUSE TestAccCloudBuildTrigger_migration
=== CONT  TestAccCloudBuildTrigger_migration
--- PASS: TestAccCloudBuildTrigger_migration (24.78s)
PASS
ok  	github.com/hashicorp/terraform-provider-google/google	24.979s

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2148
Passed tests 1906
Skipped tests: 234
Failed tests: 8

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccSqlDatabaseInstance_SqlServerAuditConfig|TestAccFirebaserulesRelease_BasicRelease|TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange|TestAccComputeInstance_soleTenantNodeAffinities|TestAccComputeGlobalForwardingRule_internalLoadBalancing|TestAccCloudFunctions2Function_fullUpdate|TestAccCloudRunService_cloudRunServiceStaticOutboundExample|TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthoritySubordinateExample

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccFirebaserulesRelease_BasicRelease[view]
TestAccCloudFunctions2Function_fullUpdate[view]
TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthoritySubordinateExample[view]

Tests failed during RECORDING mode:
TestAccSqlDatabaseInstance_SqlServerAuditConfig[view]
TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange[view]
TestAccComputeInstance_soleTenantNodeAffinities[view]
TestAccComputeGlobalForwardingRule_internalLoadBalancing[view]
TestAccCloudRunService_cloudRunServiceStaticOutboundExample[view]

Please fix these to complete your PR
View the build log or the debug log for each test

Copy link
Contributor

@slevenick slevenick left a comment

Choose a reason for hiding this comment

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

This seems good to me. I haven't tried manually upgrading between state versions for a global trigger, but assuming that works I think this should be fine.

The ID substitution is strange, but seems like what we need to do to handle backwards compatibility for existing triggers

@shuyama1
Copy link
Member

shuyama1 commented Sep 1, 2022

@slevenick Thanks for taking a look!

Copy link
Member

@shuyama1 shuyama1 left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

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.

Support location parameter in google_cloudbuild_trigger
4 participants