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

Added new Apigee resource /v1/organizations/<apigee_org>/environments/<apigee_env>/addonsConfig #12616

Merged
merged 13 commits into from
Jan 8, 2025

Conversation

sharmajai09
Copy link
Contributor

@sharmajai09 sharmajai09 commented Dec 19, 2024

`google_apigee_environment_addons_config`

@sharmajai09 sharmajai09 changed the title Updated Added new resource Dec 19, 2024
@github-actions github-actions bot requested a review from BBBmau December 19, 2024 17:28
Copy link

github-actions bot commented Dec 19, 2024

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

@melinath, 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 Dec 19, 2024
@sharmajai09 sharmajai09 changed the title Added new resource Added new Apigee resource /v1/organizations/<apigee_org>/environments/<apigee_env>/addonsConfig Dec 19, 2024
@melinath melinath requested review from melinath and removed request for BBBmau December 19, 2024 17:37
@melinath
Copy link
Member

Taking this over as the original reviewer of #12417

@modular-magician modular-magician removed the awaiting-approval Pull requests that need reviewer's approval to run presubmit tests label Dec 19, 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, 539 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 5 files changed, 539 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 79 insertions(+))

Missing test report

Your PR includes resource fields which are not covered by any test.

Resource: google_apigee_environment_addons_config (1 total tests)
Please add an acceptance test which includes these fields. The test should include the following:

resource "google_apigee_environment_addons_config" "primary" {
  api_security_enabled = # value needed
}

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 52
Passed tests: 17
Skipped tests: 35
Affected tests: 0

Click here to see the affected service packages
  • apigee
#### Non-exercised tests

🔴 Tests were added that are skipped in VCR:

  • TestAccApigeeEnvironmentAddonsConfig_apigeeEnvAddonsAnalyticsTestExample
    🟢 All tests passed!

View the build log

org_id: 'ORG_ID'
billing_account: 'BILLING_ACCT'
exclude_docs: true
skip_vcr: true
Copy link
Member

Choose a reason for hiding this comment

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

Just want to double-check that this needs to skip VCR tests? More information on the reasons for doing this (or not): https://googlecloudplatform.github.io/magic-modules/test/test/#skip-tests-in-vcr-replaying-mode

AddonsConfig tests don't seem to need this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i had to add skip_vcr check back due to previously known error

Error waiting for Deleting Organization: error while retrieving operation: googleapi: Error 403: Permission 'apigee.operations.get' denied on resource 'organizations/tf-test-bawr39q93i/operations/55f073f3-0694-4c76-a387-a39b74c30e49' (or it may not exist)

Copy link
Member

Choose a reason for hiding this comment

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

I'd be inclined to remove this for now, since that error doesn't seem like it's inherently a VCR-blocking issue, and it should get resolved at the same time as hashicorp/terraform-provider-google#20668 (hopefully soon!), and I don't want us to forget to remove it later. I'm happy to approve with the failing test in this case since it should be possible to verify it's a problem with the Organization resource, not this one.

'Enable ApiSecurity Add-On': 'https://cloud.google.com/apigee/docs/api-platform/reference/manage-security-add-on'
api: 'https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.environments.addonsConfig/setAddonEnablement'
docs:
base_url: '{{env_id}}/addonsConfig'
Copy link
Member

Choose a reason for hiding this comment

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

The addonsConfig part doesn't need to be in the base_url, since this isn't a "real" resource. Technically the base_url should probably be organizations/{{org_id}}/environments but I think given the overrides in place this might actually not get used at all.

Suggested change
base_url: '{{env_id}}/addonsConfig'
base_url: '{{env_id}}'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines 8 to 12
nameParts := strings.Split(d.Get("env_id").(string), "/")
if len(nameParts) == 5 {
id := fmt.Sprintf("organizations/%s/environments/%s", nameParts[1], nameParts[3])
d.SetId(id)
}
Copy link
Member

Choose a reason for hiding this comment

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

Should be something like this:

Suggested change
nameParts := strings.Split(d.Get("env_id").(string), "/")
if len(nameParts) == 5 {
id := fmt.Sprintf("organizations/%s/environments/%s", nameParts[1], nameParts[3])
d.SetId(id)
}
id := d.Get("env_id").(string)
nameParts := strings.Split(id, "/")
if len(nameParts) != 4 { // you could be stricter about this check if you want.
return nil, fmt.Errorf("env is expected to have shape organizations/{{"{{"}}org_id{{"}}"}}/environments/{{"{{"}}env{{"}}"}}, got %s instead", id)
}
d.SetId(id)

Any errors parsing the import id need to be returned - otherwise you might end up with an import that looks like it succeeds but fails to actually set an id (which means the resource won't actually be imported).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@github-actions github-actions bot requested a review from melinath December 20, 2024 09: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.

google provider: Diff ( 5 files changed, 582 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 5 files changed, 582 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 69 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 52
Passed tests: 17
Skipped tests: 34
Affected tests: 1

Click here to see the affected service packages
  • apigee

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
  • TestAccApigeeEnvironmentAddonsConfig_apigeeEnvAddonsAnalyticsTestExample

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccApigeeEnvironmentAddonsConfig_apigeeEnvAddonsAnalyticsTestExample [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

@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, 582 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 5 files changed, 582 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 69 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 52
Passed tests: 17
Skipped tests: 35
Affected tests: 0

Click here to see the affected service packages
  • apigee
#### Non-exercised tests

🔴 Tests were added that are skipped in VCR:

  • TestAccApigeeEnvironmentAddonsConfig_apigeeEnvAddonsAnalyticsTestExample
    🟢 All tests passed!

View the build log

org_id: 'ORG_ID'
billing_account: 'BILLING_ACCT'
exclude_docs: true
skip_vcr: true
Copy link
Member

Choose a reason for hiding this comment

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

I'd be inclined to remove this for now, since that error doesn't seem like it's inherently a VCR-blocking issue, and it should get resolved at the same time as hashicorp/terraform-provider-google#20668 (hopefully soon!), and I don't want us to forget to remove it later. I'm happy to approve with the failing test in this case since it should be possible to verify it's a problem with the Organization resource, not this one.

@@ -0,0 +1,70 @@
resource "google_project" "project" {
Copy link
Member

Choose a reason for hiding this comment

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

Usually the purpose of having a docs-only example is to remove extra configuration the users don't necessarily need to know about; for example, apigee_addons_basic only has the google_apigee_addons_config resource.

If the extra information here is useful for users, you could create docs based on the other example instead of having a second one just for docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done I have kept Org and environment creation steps as this resource is available only when Org is PAYG and environment is COMPREHENSIVE.

mmv1/products/apigee/EnvironmentAddonsConfig.yaml Outdated Show resolved Hide resolved
@melinath
Copy link
Member

@modular-magician reassign-reviewer

@melinath
Copy link
Member

reassigning since I'll be OOO next week.

@github-actions github-actions bot requested a review from SirGitsalot December 20, 2024 23:41
@github-actions github-actions bot requested a review from melinath December 23, 2024 18:00
Copy link

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

Copy link

@GoogleCloudPlatform/terraform-team @SirGitsalot This PR has been waiting for review for 1 week. Please take a look! Use the label disable-review-reminders to disable these notifications.

Copy link

github-actions bot commented Jan 6, 2025

@GoogleCloudPlatform/terraform-team @SirGitsalot This PR has been waiting for review for 2 weeks. Please take a look! Use the label disable-review-reminders to disable these notifications.

@melinath
Copy link
Member

melinath commented Jan 6, 2025

Sorry for the delay on this one; we had a miscommunication regarding the vacation plans! I can take it back over now that I'm back.

@melinath melinath removed the request for review from SirGitsalot January 6, 2025 23:35
Copy link
Member

@melinath melinath left a comment

Choose a reason for hiding this comment

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

a couple small changes

config := meta.(*transport_tpg.Config)

// current import_formats cannot import fields with forward slashes in their value
if err := tpgresource.ParseImportId([]string{"(?P<env_id>.+)/addonsConfig"}, d, config); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

The regex here matches what users pass in when using terraform import & definitely shouldn't contain addonsConfig

Suggested change
if err := tpgresource.ParseImportId([]string{"(?P<env_id>.+)/addonsConfig"}, d, config); err != nil {
if err := tpgresource.ParseImportId([]string{"(?P<env_id>.+)"}, d, config); err != nil {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done
somehow when I was running tests locally import worked only when I added /addonsConfig

Copy link
Member

Choose a reason for hiding this comment

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

I had you make some other changes (like adding the id_format) so that removing this here would work. I think your local testing may have been before those changes?

Comment on lines 39 to 40
id_format:
- '{{env_id}}'
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I think I had suggested formatting this as a list but it should actually be just a string. This is causing the yaml parsing error.

Suggested change
id_format:
- '{{env_id}}'
id_format: '{{env_id}}'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@github-actions github-actions bot requested a review from melinath January 8, 2025 05:50
@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, 530 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 5 files changed, 530 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 69 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 52
Passed tests: 17
Skipped tests: 34
Affected tests: 1

Click here to see the affected service packages
  • apigee

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
  • TestAccApigeeEnvironmentAddonsConfig_apigeeEnvAddonsAnalyticsTestExample

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccApigeeEnvironmentAddonsConfig_apigeeEnvAddonsAnalyticsTestExample [Error message] [Debug log]

🔴 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

@melinath melinath left a comment

Choose a reason for hiding this comment

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

one small change but otherwise LGTM. the test failure is expected and is not due to a problem with this resource AFAICT. The update logic is similar enough to the create logic (even using the same API method) that I feel comfortable with not having an update test.

mmv1/products/apigee/EnvironmentAddonsConfig.yaml Outdated Show resolved Hide resolved
@github-actions github-actions bot requested a review from melinath January 8, 2025 17:07
@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, 528 insertions(+), 2 deletions(-))
google-beta provider: Diff ( 5 files changed, 528 insertions(+), 2 deletions(-))
terraform-google-conversion: Diff ( 1 file changed, 69 insertions(+))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 52
Passed tests: 17
Skipped tests: 34
Affected tests: 1

Click here to see the affected service packages
  • apigee

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
  • TestAccApigeeEnvironmentAddonsConfig_apigeeEnvAddonsAnalyticsTestExample

Get to know how VCR tests work

@modular-magician
Copy link
Collaborator

🔴 Tests failed during RECORDING mode:
TestAccApigeeEnvironmentAddonsConfig_apigeeEnvAddonsAnalyticsTestExample [Error message] [Debug log]

🔴 Errors occurred during RECORDING mode. Please fix them to complete your PR.

View the build log or the debug log for each test

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.

3 participants