Skip to content

Conversation

@manupedrozo
Copy link
Collaborator

Description

Generate alert_configuration_api and add acc tests based on the handwritten alert_configuration.

Link to any related issue(s): CLOUDP-356406

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals I have added appropriate changelog entries.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

@manupedrozo manupedrozo force-pushed the CLOUDP-356406-autogen-alert-configuration branch from 56a1171 to 43664fd Compare November 13, 2025 09:27
@manupedrozo manupedrozo force-pushed the CLOUDP-356406-autogen-alert-configuration branch from 43664fd to 0d1c5ca Compare November 13, 2025 09:32
@manupedrozo manupedrozo marked this pull request as ready for review November 13, 2025 11:19
@manupedrozo manupedrozo requested a review from a team as a code owner November 13, 2025 11:19
ImportStateIdFunc: importStateProjectIDFunc(resourceName),
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"group_id", "updated"},
Copy link
Member

Choose a reason for hiding this comment

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

why do we need to ignore group_id? shouldn't change

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! Removing the project_id ignores from the handwritten resource tests as well. Not sure why they were added. 006b01d

Copy link
Member

@AgustinBettati AgustinBettati left a comment

Choose a reason for hiding this comment

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

LGTM

go install github.com/terraform-linters/tflint@v0.52.0
go install github.com/rhysd/actionlint/cmd/actionlint@latest
go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@v0.38.0 # Pinning version since v0.39.0 fails to fix files with large structs. See versions at https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/fieldalignment?tab=versions
Copy link
Member

Choose a reason for hiding this comment

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

don't see a concern but curious was this a bug on their latest version (0.39.0)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It only started happening today, checked versions and 0.39 was released yesterday.
Can change back to latest when fixed, haven't looked if there is an associated bug.

@@ -0,0 +1,747 @@
package alertconfigurationapi_test
Copy link
Member

Choose a reason for hiding this comment

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

nice, great to see coverage over the full API and handling redacted sensitive values in response

Comment on lines 568 to 575
notifications.delay_min:
computability:
optional: true
computed: true
notifications.interval_min:
computability:
optional: true
computed: true
Copy link
Member

Choose a reason for hiding this comment

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

so these are both getting default values returned from the API right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Followed handwritten resource where these are optional + computed.
However, as per my testing only delay_min is computed, interval_min is not, so good call out!
Removing this override in 6da4587
We should also remove the computed flag from the handwritten resource as a followup: ptr - thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

Adjusting the existing alert_configuration resource schema in this case could risk a breaking change. Optional+Computed implies users can potentially not have the attribute in the config but have a value in the state. As soon as the attribute changes from Optional+Computed to Optional this would trigger a plan change in which terraform tries to unset the attribute. We could create a ticket and flag as candidate for including in a 3.0 release.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Got it, thanks! To clarify, a user having the value in the state but not config is not expected, correct? Or is there a common flow where this may happen?

Copy link
Member

Choose a reason for hiding this comment

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

Given API behaviour should not be common scenario: Potentially a user that defined the attribute and then removes it, leaving the config with no attribute but the state will still have it present.

@manupedrozo
Copy link
Collaborator Author

manupedrozo commented Nov 13, 2025

Tests failing due to S3 issue. Unrelated to PR changes. Oncall looking into it with upstream team.

@manupedrozo manupedrozo merged commit a9ab3f1 into master Nov 14, 2025
86 of 89 checks passed
@manupedrozo manupedrozo deleted the CLOUDP-356406-autogen-alert-configuration branch November 14, 2025 10:03
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.

4 participants