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: Updates database_user resource with new SDK #1840

Merged
merged 9 commits into from Jan 16, 2024

Conversation

lantoli
Copy link
Member

@lantoli lantoli commented Jan 16, 2024

Description

Updates database_user resource with new SDK.

  • Resource is not deleted and created when Scopes change, update is done in place.
  • Labels can be updated to no labels.
  • Testing improved, and clusters are not created in tests now as they're not needed.
  • Checked read-only fields: Links (not used)
  • Checked write-only fields: GroupID, Password (deprecated in data sources)

Link to any related issue(s): https://jira.mongodb.org/browse/CLOUDP-222697

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.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contribution guidelines
  • 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 defined an isolated PR with a relevant title as it will be used in the auto-generated changelog.

Further comments

@@ -189,9 +188,6 @@ func (r *databaseUserRS) Schema(ctx context.Context, req resource.SchemaRequest,
},
},
"scopes": schema.SetNestedBlock{
PlanModifiers: []planmodifier.Set{
setplanmodifier.RequiresReplace(),
},
Copy link
Member Author

Choose a reason for hiding this comment

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

no need to replace any more as we can send empty scopes if needed

Roles: conversion.NonEmptyToPtr(NewMongoDBAtlasRoles(rolesModel)),
Labels: conversion.NonEmptyToPtr(NewMongoDBAtlasLabels(labelsModel)),
Scopes: conversion.NonEmptyToPtr(NewMongoDBAtlasScopes(scopesModel)),
Roles: NewMongoDBAtlasRoles(rolesModel),
Copy link
Member Author

Choose a reason for hiding this comment

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

all NonEmptyToPtr calls in this resource can be removed, and probably this will happen in all resources

orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
clusterInfo = acc.GetClusterInfo(orgID)
Copy link
Member Author

Choose a reason for hiding this comment

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

we don't really need a real cluster to create a database_user

@lantoli lantoli marked this pull request as ready for review January 16, 2024 13:26
@lantoli lantoli requested a review from a team as a code owner January 16, 2024 13:26
Copy link
Collaborator

@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

@@ -452,6 +468,55 @@ func TestAccConfigRSDatabaseUser_withScopesAndEmpty(t *testing.T) {
})
}

func TestAccConfigRSDatabaseUser_withLabelsAndEmpty(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func TestAccConfigRSDatabaseUser_withLabelsAndEmpty(t *testing.T) {
func TestAccConfigRSDatabaseUser_updateToEmptyLabels(t *testing.T) {

Copy link
Member Author

Choose a reason for hiding this comment

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

done, and also for the scopes one

Sensitive: true,
Computed: true,
Sensitive: true,
DeprecationMessage: fmt.Sprintf(constant.DeprecationParamByVersion, "1.16.0"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you create a Jira issue already targeting 1.16.0 to remind us we have to remove it?

Copy link
Member Author

@lantoli lantoli Jan 16, 2024

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for creating it, would it be possible to add some more description? At minimum:

  • the reference of this PR,
  • the fields to remove

otherwise if we do this in say two months we won't remember exactly what to do

@lantoli lantoli merged commit fbda4ba into master Jan 16, 2024
47 checks passed
@lantoli lantoli deleted the CLOUDP-222697_database_user branch January 16, 2024 14:32
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.

None yet

3 participants