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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

sharmajai09
Copy link

@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 needs 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 needs 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

create_url: '{{env_id}}/addonsConfig:setAddonEnablement'
update_url: '{{env_id}}/addonsConfig:setAddonEnablement'
update_verb: 'POST'
exclude_delete: true
Copy link
Member

Choose a reason for hiding this comment

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

What would you think about sending a POST request to unset AddonEnablement on delete? This would match the behavior of AddonsConfig.

Suggested change
exclude_delete: true
delete_url: '{{env_id}}/addonsConfig:setAddonEnablement'
delete_verb: 'POST'

Comment on lines +31 to +32
insert_minutes: 5
update_minutes: 5
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 is desired; we usually only lengthen the timeouts, not shorten them.

insert_minutes: 5
update_minutes: 5
async:
actions: ['create', 'update']
Copy link
Member

Choose a reason for hiding this comment

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

(if delete support is added)

Suggested change
actions: ['create', 'update']
actions: ['create', 'update', 'delete']

base_url: '{{op_id}}'
import_format:
- '{{env_id}}/addonsConfig'
custom_code:
Copy link
Member

Choose a reason for hiding this comment

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

(if delete support is added) you'll also need a test_check_destroy similar to AddonsConfig

test_check_destroy: 'templates/terraform/custom_check_destroy/apigee_addons_override.go.tmpl'

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

Choose a reason for hiding this comment

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

There needs to be at least one docs example; you could add a doc-only example similar to AddonsConfig:

- name: 'apigee_addons_basic'
exclude_test: true

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.

'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}}'

api: 'https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.environments.addonsConfig/setAddonEnablement'
docs:
base_url: '{{env_id}}/addonsConfig'
self_link: '{{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.

This doesn't need addonsConfig, since it's not a "real" resource - leaving it off better matches the AddonsConfig resource behavior.

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

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.

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 {

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).

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