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

chore: Implements tags and labels as MapAttribute in advanced_cluster schema v2 #2996

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

lantoli
Copy link
Member

@lantoli lantoli commented Jan 23, 2025

Description

Implements tags and labels as MapAttribute in advanced_cluster schema v2.

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

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

@@ -25,7 +25,7 @@ func ToTFMapOfSlices(ctx context.Context, values map[string][]string) (basetypes
}

func ToTFMapOfString(ctx context.Context, diags *diag.Diagnostics, values *map[string]string) basetypes.MapValue { //nolint:gocritic // easy usage from sdk fields
if values == nil {
if values == nil || len(*values) == 0 {
Copy link
Member Author

Choose a reason for hiding this comment

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

@EspenAlbert can you confirm this change is ok for container_id ?

func NewTagsObjType(ctx context.Context, input *[]admin.ResourceTag, diags *diag.Diagnostics) types.Set {
if input == nil {
// API Response not consistent, even when not set in POST/PATCH `[]` is returned instead of null
return types.SetValueMust(TagsObjType, nil)
Copy link
Member Author

@lantoli lantoli Jan 23, 2025

Choose a reason for hiding this comment

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

@EspenAlbert do we need to keep this logic to send an empty value instead of null value, or it's ok with the previous change in ToTFMapOfString to treat empty maps as null?

as in mocked tests, with this change we don't send the value to Atlas instead of [] being done now:

   - "labels": [],
          "mongoDBMajorVersion": "8.0",
        @@ -61,4 +60,3 @@
           }
        - ],
        - "tags": []
        + ]
         }

@lantoli lantoli changed the title chore: Cloudp 295198 tpf tags labels chore: Implements tags and labels as MapAttribute in advanced_cluster schema v2 Jan 23, 2025
* master:
  chore: Updates repository to use supported Terraform versions (#2997)
  chore: Updates CHANGELOG.md header for v1.26.0 release
  chore: Updates examples link in index.md for v1.26.0 release
  doc: Upgrade guide for v1.26.0 (#2992)
* master:
  chore: Extracts out SDK logic from TPF to facilitate reuse in SDKv2 for advanced_cluster (#2982)
  ci: Adds clean-atlas-org action and related tests for project cleanup (#2960)
  chore: Adds MacT documentation (#2993)
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.

1 participant