Skip to content

fix: Fixes JSON comparison in audit_filter field in mongodbatlas_auditing #3302

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

Merged
merged 5 commits into from
Apr 25, 2025

Conversation

oarbusi
Copy link
Collaborator

@oarbusi oarbusi commented Apr 25, 2025

Description

Fixes JSON comparison in audit_filter field in mongodbatlas_auditing

Link to any related issue(s): CLOUDP-315476 & HELP-74398

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

@oarbusi oarbusi marked this pull request as ready for review April 25, 2025 09:05
@oarbusi oarbusi requested review from a team as code owners April 25, 2025 09:05
@github-actions github-actions bot added the bug label Apr 25, 2025
Copy link
Contributor

APIx bot: a message has been sent to Docs Slack channel

@@ -150,3 +152,7 @@ func resourceDelete(ctx context.Context, d *schema.ResourceData, meta any) diag.
d.SetId("")
return nil
}

func diffSuppressJSON(k, old, newStr string, d *schema.ResourceData) bool {
Copy link
Member

@lantoli lantoli Apr 25, 2025

Choose a reason for hiding this comment

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

can we update/add an acc test that would fail before this 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.

done in 1d4e78a
Also, you can see failing tests if there is no DiffSuppressFunc: diffSuppressJSON,
Screenshot 2025-04-25 at 12 01 16

Copy link
Member

Choose a reason for hiding this comment

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

thanks!

@@ -31,10 +40,15 @@ func TestAccGenericAuditing_basic(t *testing.T) {
{
Config: configBasic(projectID, auditFilter, true, true),
Check: resource.ComposeAggregateTestCheckFunc(checks(auditFilter, true, true)...),
ConfigPlanChecks: resource.ConfigPlanChecks{
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] I guess this explicit check is necessary because it is a SDKv2 resource? Maybe add a comment why

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not really necessary now that I think about it. Removed in 76582ca

@@ -89,18 +103,23 @@ func importStateIDFunc(resourceName string) resource.ImportStateIdFunc {
}

func configBasic(projectID, auditFilter string, auditAuth, enabled bool) string {
filterValue := fmt.Sprintf("%q", auditFilter)
if auditFilter != "{}" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] use previous var? emptyAuditFilter?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks, done in 40750dc

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

@oarbusi oarbusi merged commit a05d50a into master Apr 25, 2025
40 checks passed
@oarbusi oarbusi deleted the CLOUDP-315476 branch April 25, 2025 14:11
svc-apix-Bot added a commit that referenced this pull request Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants