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 a new field desired_state to manage CertificateAuthority state #5934

Merged
merged 3 commits into from
May 4, 2022

Conversation

gfxcc
Copy link
Contributor

@gfxcc gfxcc commented Apr 12, 2022

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)

privateca: add a new field `desired_state` to manage CertificateAuthority state.

@modular-magician
Copy link
Collaborator

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

I have detected that you are a community contributor, so your PR will be assigned to someone with a commit-bit on this repo for initial review.

Thanks for your contribution! A human will be with you soon.

@c2thorn, please review this PR or find an appropriate assignee.

@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 ( 3 files changed, 135 insertions(+), 4 deletions(-))
Terraform Beta: Diff ( 3 files changed, 135 insertions(+), 4 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 1983
Passed tests 1740
Skipped tests: 240
Failed tests: 3

Action taken

Triggering VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccServiceNetworkingPeeredDNSDomain_basic|TestAccDataprocCluster_withImageVersion|TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthorityIsStaged

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthorityIsStaged[view]
TestAccServiceNetworkingPeeredDNSDomain_basic[view]

Tests failed during RECORDING mode:
TestAccDataprocCluster_withImageVersion[view]

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

@gfxcc gfxcc marked this pull request as ready for review April 12, 2022 23:48
@c2thorn
Copy link
Member

c2thorn commented Apr 20, 2022

@gfxcc asking for a second opinion from the team as this is fairly unusual behavior. May not be worth addressing my previous comment until I hear back

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.

After discussion, we think that state-controlling behavior is best represented as a desired_state field.
is_staged would not be able to accommodate new states in the future, and there is precedence for this type of field in compute instance: https://github.com/hashicorp/terraform-provider-google/blob/main/google/resource_compute_instance.go#L740

The field would be an optional field that enables the CA if unset, and controls the state when explicitly set.

It would need a lot of custom code to get working:

  1. Customizediff - would error on invalid state transitions
  2. customflatten - If desired_state is set, the current state would be read. (see https://github.com/hashicorp/terraform-provider-google/blob/main/google/resource_compute_instance.go#L1361). If unset, leave unset.
  3. customexpand - should always return empty as we do not want to send the field to the API.

This field would provide a better representation of the resource, wouldn't be a breaking change (CA is still enabled if unset), but is fairly complex. @gfxcc let me know what you think.

@gfxcc
Copy link
Contributor Author

gfxcc commented Apr 21, 2022

@c2thorn That sounds a great idea. Will push a new revision later.

@gfxcc gfxcc force-pushed the create-ca-in-staging branch from 6361ecc to 97ea5d9 Compare April 21, 2022 23:00
@gfxcc gfxcc changed the title Add a new field is_staged to create a CertificateAuthority in STAGED state Add a new field desired_state to manage CertificateAuthority state Apr 21, 2022
@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 ( 13 files changed, 270 insertions(+), 4 deletions(-))
Terraform Beta: Diff ( 14 files changed, 271 insertions(+), 4 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@gfxcc gfxcc force-pushed the create-ca-in-staging branch from 97ea5d9 to 9aa697a Compare April 21, 2022 23:24
@gfxcc gfxcc force-pushed the create-ca-in-staging branch from 9aa697a to 6f2eb18 Compare April 21, 2022 23:26
@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 ( 3 files changed, 347 insertions(+), 21 deletions(-))
Terraform Beta: Diff ( 3 files changed, 347 insertions(+), 21 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@gfxcc gfxcc requested a review from c2thorn April 21, 2022 23:47
@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 1993
Passed tests 1747
Skipped tests: 240
Failed tests: 6

Action taken

Triggering VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccDatasourceGoogleServiceNetworkingPeeredDnsDomain_basic|TestAccFirebaserulesRelease_BasicRelease|TestAccPrivatecaCertificateAuthority_rootCaManageDesiredState|TestAccPrivatecaCertificateAuthority_rootCaIsEnabledByDefault|TestAccPrivatecaCertificateAuthority_rootCaCreatedInStaged|TestAccPrivatecaCertificateAuthority_subordinateCaCreatedInAwaitingUserActivation

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccDatasourceGoogleServiceNetworkingPeeredDnsDomain_basic[view]
TestAccPrivatecaCertificateAuthority_subordinateCaCreatedInAwaitingUserActivation[view]
TestAccPrivatecaCertificateAuthority_rootCaManageDesiredState[view]
TestAccPrivatecaCertificateAuthority_rootCaIsEnabledByDefault[view]
TestAccPrivatecaCertificateAuthority_rootCaCreatedInStaged[view]
TestAccFirebaserulesRelease_BasicRelease[view]

All tests passed
View the build log or the debug log for each test

…hority.go.erb

Co-authored-by: Cameron Thornton <camthornton@google.com>
@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 ( 3 files changed, 342 insertions(+), 21 deletions(-))
Terraform Beta: Diff ( 3 files changed, 342 insertions(+), 21 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 1999
Passed tests 1755
Skipped tests: 241
Failed tests: 3

Action taken

Triggering VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccServiceNetworkingPeeredDNSDomain_basic|TestAccFirebaserulesRelease_BasicRelease|TestAccDatasourceGoogleServiceNetworkingPeeredDnsDomain_basic

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccDatasourceGoogleServiceNetworkingPeeredDnsDomain_basic[view]
TestAccServiceNetworkingPeeredDNSDomain_basic[view]
TestAccFirebaserulesRelease_BasicRelease[view]

All tests passed
View the build log or the debug log for each test

@gfxcc gfxcc force-pushed the create-ca-in-staging branch from eaa948e to 5c1c218 Compare April 29, 2022 22:23
@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 ( 3 files changed, 360 insertions(+), 21 deletions(-))
Terraform Beta: Diff ( 3 files changed, 360 insertions(+), 21 deletions(-))
TF Validator: Diff ( 3 files changed, 35 insertions(+), 4 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 1999
Passed tests 1756
Skipped tests: 241
Failed tests: 2

Action taken

Triggering VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccFirebaserulesRelease_BasicRelease|TestAccBigQueryDataTable_bigtable

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccBigQueryDataTable_bigtable[view]
TestAccFirebaserulesRelease_BasicRelease[view]

All tests passed
View the build log or the debug log for each test

@gfxcc gfxcc requested a review from c2thorn April 30, 2022 00:34
@c2thorn
Copy link
Member

c2thorn commented May 4, 2022

Apologies for the delay @gfxcc, LGTM

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