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 certificate manager certificates datasource #11543

Conversation

DanielRieske
Copy link
Contributor

@DanielRieske DanielRieske commented Aug 25, 2024

This PR adds the Certificate Manager certificates data source.

Tests:

% make testacc TEST=./google/services/certificatemanager TESTARGS='-run=TestAccDataSourceGoogleCertificateManagerCertificates_'           
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google/services/certificatemanager -v -run=TestAccDataSourceGoogleCertificateManagerCertificates_ -timeout 240m -ldflags="-X=github.com/hashicorp/terraform-provider-google/version.ProviderVersion=acc"
=== RUN   TestAccDataSourceGoogleCertificateManagerCertificates_basic
=== PAUSE TestAccDataSourceGoogleCertificateManagerCertificates_basic
=== RUN   TestAccDataSourceGoogleCertificateManagerCertificates_regionBasic
=== PAUSE TestAccDataSourceGoogleCertificateManagerCertificates_regionBasic
=== RUN   TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificate
=== PAUSE TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificate
=== RUN   TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateDNSAuthorization
=== PAUSE TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateDNSAuthorization
=== RUN   TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateIssuerConfig
=== PAUSE TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateIssuerConfig
=== CONT  TestAccDataSourceGoogleCertificateManagerCertificates_basic
=== CONT  TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateDNSAuthorization
=== CONT  TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateIssuerConfig
=== CONT  TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificate
=== CONT  TestAccDataSourceGoogleCertificateManagerCertificates_regionBasic
--- PASS: TestAccDataSourceGoogleCertificateManagerCertificates_regionBasic (12.54s)
--- PASS: TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificate (33.43s)
--- PASS: TestAccDataSourceGoogleCertificateManagerCertificates_basic (33.59s)
--- PASS: TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateDNSAuthorization (59.44s)
--- PASS: TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateIssuerConfig (93.04s)
PASS
ok      github.com/hashicorp/terraform-provider-google/google/services/certificatemanager       94.189s

Release Note Template for Downstream PRs (will be copied)

`google_certificate_manager_certificates`

@github-actions github-actions bot requested a review from shuyama1 August 25, 2024 12:14
Copy link

Hello! I am a robot. Tests will require approval from a repository maintainer to run.

@shuyama1, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look.

You can help make sure that review is quick by doing a self-review and by running impacted tests locally.

@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Aug 25, 2024
@modular-magician modular-magician added service/certificatemanager and removed awaiting-approval Pull requests that need reviewer's approval to run presubmit tests labels Aug 26, 2024
@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.

google provider: Diff ( 5 files changed, 682 insertions(+))
google-beta provider: Diff ( 5 files changed, 682 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3911
Passed tests: 3495
Skipped tests: 411
Affected tests: 5

Click here to see the affected service packages

All service packages are affected

Action taken

Found 5 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccDataSourceGoogleCertificateManagerCertificates_basic
  • TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificate
  • TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateDNSAuthorization
  • TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateIssuerConfig
  • TestAccDataSourceGoogleCertificateManagerCertificates_regionBasic

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccDataSourceGoogleCertificateManagerCertificates_basic[Debug log]
TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificate[Debug log]
TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateDNSAuthorization[Debug log]
TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateIssuerConfig[Debug log]
TestAccDataSourceGoogleCertificateManagerCertificates_regionBasic[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

Copy link

@shuyama1 This PR has been waiting for review for 3 weekdays. Please take a look! Use the label disable-review-reminders to disable these notifications.

@DanielRieske
Copy link
Contributor Author

Hi @shuyama1 👋 , anything I can do to help get this merged? Would love to use this next release!

@shuyama1
Copy link
Member

shuyama1 commented Sep 2, 2024

Hi @shuyama1 👋 , anything I can do to help get this merged? Would love to use this next release!

Thanks for the ping. Taking a look now. Sorry for the delay on review.

@shuyama1
Copy link
Member

shuyama1 commented Sep 2, 2024

/gcbrun

@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Sep 2, 2024
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we can use Schema: datasourceSchemaFromResourceSchema(ResourceCertificateManagerCertificate().Schema), to mirror the fields in the google_certificate_manager_certificate resource, avoiding the need to manually add new ones.

Copy link
Contributor Author

@DanielRieske DanielRieske Sep 2, 2024

Choose a reason for hiding this comment

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

Good suggestion, I was hesitant to do this at first because there are fields that aren't relevant.
I changed it and deleted the irrelevant fields for the data source.

While I know it's not necessary, I added a remove helper for fields that aren't relevant for the data source.
I prefer having it explicit on fields that can't be part of the data-source instead of having floating fields that exist in the schema but will never be used.

@modular-magician modular-magician removed the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Sep 2, 2024
@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.

google provider: Diff ( 5 files changed, 682 insertions(+))
google-beta provider: Diff ( 5 files changed, 682 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3255
Passed tests: 2857
Skipped tests: 397
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
  • TestAccBackupDRBackupVault_fullUpdate

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccBackupDRBackupVault_fullUpdate[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

@github-actions github-actions bot requested a review from shuyama1 September 2, 2024 08:11
@modular-magician modular-magician added the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Sep 2, 2024
@DanielRieske
Copy link
Contributor Author

DanielRieske commented Sep 2, 2024

@shuyama1 I processed your suggestions and ran the acceptance tests, ran them for resource as well as I added an additional output field to be in-line with the data source.

% make testacc TEST=./google/services/certificatemanager TESTARGS='-run=TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificate'            
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google/services/certificatemanager -v -run=TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificate -timeout 240m -ldflags="-X=github.com/hashicorp/terraform-provider-google/version.ProviderVersion=acc"
=== RUN   TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificateDnsExample
=== PAUSE TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificateDnsExample
=== RUN   TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificateIssuanceConfigExample
=== PAUSE TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificateIssuanceConfigExample
=== RUN   TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificateIssuanceConfigAllRegionsExample
=== PAUSE TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificateIssuanceConfigAllRegionsExample
=== RUN   TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificateDnsAllRegionsExample
=== PAUSE TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificateDnsAllRegionsExample
=== CONT  TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificateDnsExample
=== CONT  TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificateIssuanceConfigAllRegionsExample
=== CONT  TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificateIssuanceConfigExample
=== CONT  TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificateDnsAllRegionsExample
--- PASS: TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificateDnsAllRegionsExample (57.98s)
--- PASS: TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificateDnsExample (58.47s)
--- PASS: TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificateIssuanceConfigAllRegionsExample (90.61s)
--- PASS: TestAccCertificateManagerCertificate_certificateManagerGoogleManagedCertificateIssuanceConfigExample (90.61s)
PASS
ok      github.com/hashicorp/terraform-provider-google/google/services/certificatemanager       91.735s
% make testacc TEST=./google/services/certificatemanager TESTARGS='-run=TestAccDataSourceGoogleCertificateManagerCertificates_'     
TF_ACC=1 TF_SCHEMA_PANIC_ON_ERROR=1 go test ./google/services/certificatemanager -v -run=TestAccDataSourceGoogleCertificateManagerCertificates_ -timeout 240m -ldflags="-X=github.com/hashicorp/terraform-provider-google/version.ProviderVersion=acc"
=== RUN   TestAccDataSourceGoogleCertificateManagerCertificates_basic
=== PAUSE TestAccDataSourceGoogleCertificateManagerCertificates_basic
=== RUN   TestAccDataSourceGoogleCertificateManagerCertificates_full
=== PAUSE TestAccDataSourceGoogleCertificateManagerCertificates_full
=== RUN   TestAccDataSourceGoogleCertificateManagerCertificates_regionBasic
=== PAUSE TestAccDataSourceGoogleCertificateManagerCertificates_regionBasic
=== RUN   TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificate
=== PAUSE TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificate
=== RUN   TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateDNSAuthorization
=== PAUSE TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateDNSAuthorization
=== RUN   TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateIssuerConfig
=== PAUSE TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateIssuerConfig
=== CONT  TestAccDataSourceGoogleCertificateManagerCertificates_basic
=== CONT  TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificate
=== CONT  TestAccDataSourceGoogleCertificateManagerCertificates_regionBasic
=== CONT  TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateIssuerConfig
=== CONT  TestAccDataSourceGoogleCertificateManagerCertificates_full
=== CONT  TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateDNSAuthorization
--- PASS: TestAccDataSourceGoogleCertificateManagerCertificates_regionBasic (25.29s)
--- PASS: TestAccDataSourceGoogleCertificateManagerCertificates_basic (33.56s)
--- PASS: TestAccDataSourceGoogleCertificateManagerCertificates_full (33.60s)
--- PASS: TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificate (34.27s)
--- PASS: TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateDNSAuthorization (58.96s)
--- PASS: TestAccDataSourceGoogleCertificateManagerCertificates_managedCertificateIssuerConfig (92.87s)
PASS
ok      github.com/hashicorp/terraform-provider-google/google/services/certificatemanager       94.017s

@modular-magician modular-magician removed the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Sep 3, 2024
@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.

google provider: Diff ( 8 files changed, 623 insertions(+))
google-beta provider: Diff ( 8 files changed, 623 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 3815
Passed tests: 3398
Skipped tests: 411
Affected tests: 6

Click here to see the affected service packages

All service packages are affected

Action taken

Found 6 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
  • TestAccBackupDRBackupVault_fullUpdate
  • TestAccComputeInstanceTemplate_withNamePrefix
  • TestAccDataSourceGoogleCertificateManagerCertificates_basic
  • TestAccDataSourceGoogleCertificateManagerCertificates_full
  • TestAccNetappActiveDirectory_activeDirectory_FullUpdate
  • TestAccNetappBackup_NetappBackupFull_update

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

$\textcolor{green}{\textsf{Tests passed during RECORDING mode:}}$
TestAccBackupDRBackupVault_fullUpdate[Debug log]
TestAccDataSourceGoogleCertificateManagerCertificates_basic[Debug log]
TestAccDataSourceGoogleCertificateManagerCertificates_full[Debug log]
TestAccNetappActiveDirectory_activeDirectory_FullUpdate[Debug log]
TestAccNetappBackup_NetappBackupFull_update[Debug log]

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


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

$\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

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.

The failing test is not related to the change in this PR.

@shuyama1 shuyama1 merged commit 1ed2087 into GoogleCloudPlatform:main Sep 3, 2024
12 of 13 checks passed
iyabchen pushed a commit to iyabchen/magic-modules that referenced this pull request Sep 14, 2024
@mXtone
Copy link

mXtone commented Sep 24, 2024

Hello, I have a problem with this datasource. I'm trying to use:

data "google_certificate_manager_certificates" "cert" {
  project = var.project-id
  filter = "name:projects/${var.project-id}/locations/GLOBAL/certificates/cert"
}

but this error occured on terraform validate:

Error: Unsupported argument
│ 
│   on xxx.tf line xxx, in data "google_certificate_manager_certificates" "cert":
│  xxx:   project = var.project-id
│ 
│ An argument named "project" is not expected here.

When I removed project field:

data "google_certificate_manager_certificates" "cert" {
  filter = "name:projects/${var.project-id}/locations/GLOBAL/certificates/cert"
}

I got this error on terraform plan:

 Error: error fetching project for certificate: project: required field is not set
│ 
│   with data.google_certificate_manager_certificates.certificate_calend_cloud,
│   on xxx.tf line xxx, in data "google_certificate_manager_certificates" "cert":
│  xxx: data "google_certificate_manager_certificates" "cert" {
│ 

I don't know if I'm doing something wrong or there's a bug in implementation.

$ terraform --version
Terraform v1.9.5
on linux_amd64
+ provider registry.terraform.io/hashicorp/google v6.4.0
+ provider registry.terraform.io/hashicorp/google-beta v6.4.0
+ provider registry.terraform.io/hashicorp/random v3.6.3

niharika-98 pushed a commit to niharika-98/magic-modules that referenced this pull request Oct 7, 2024
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.

4 participants