-
Notifications
You must be signed in to change notification settings - Fork 190
feat: Adds description field to mongodbatlas_database_user
#3280
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
Conversation
APIx bot: a message has been sent to Docs Slack channel |
result.Password = dbUserModel.Password.ValueStringPointer() | ||
result.Password = plan.Password.ValueStringPointer() | ||
} | ||
if plan.Description.IsNull() && !stateDescriptionValue.Equal(plan.Description) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to confirm, what happens if we don't have this condition?
wouldn't result.Description be "" in this case because of previous: Description: plan.Description.ValueStringPointer(),
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, ValueStringPointer would be nil and therefore not dumped.
Cannot use ValueString()
since we don't want to set it to ""
when it is not defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
@@ -204,28 +208,28 @@ func (r *databaseUserRS) Schema(ctx context.Context, req resource.SchemaRequest, | |||
} | |||
|
|||
func (r *databaseUserRS) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe in a follow-up PR we want to unify RS and DS tests in the same test file and tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See PR description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
resp.Diagnostics.Append(diags...) | ||
if resp.Diagnostics.HasError() { | ||
return | ||
} | ||
|
||
dbUserReq, d := NewMongoDBDatabaseUser(ctx, types.StringNull(), databaseUserPlan) | ||
dbUserReq, d := NewMongoDBDatabaseUser(ctx, types.StringNull(), types.StringNull(), plan) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use diags or localDiags as in other places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Changed in 27168d9
|
||
// Use the ID only with the IMPORT operation | ||
if databaseUserState.ID.ValueString() != "" && (username == "" || projectID == "" || authDatabaseName == "") { | ||
projectID, username, authDatabaseName, err = SplitDatabaseUserImportID(databaseUserState.ID.ValueString()) | ||
if state.ID.ValueString() != "" && (username == "" || projectID == "" || authDatabaseName == "") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand this change is not related to this PR, but wondering why we have a different Read logic when importing, instead of Import setting the attributes we need in Read so we don't need to do a special case in Read for import
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, yeah you are right. Moved to Import function in e860fa9
@@ -65,6 +65,7 @@ var ( | |||
GroupId: projectID, | |||
DatabaseName: authDatabaseName, | |||
Username: username, | |||
Description: conversion.Pointer(""), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a var emptyDescription = ""
and then here use &emptyDescription
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, I feel this is more readable. With an intermediate var you would need to check that var. Here it is all in one line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's more readable with the var but I don't have a strong opinion
resource.TestCheckResourceAttr(resourceName, "password", "test-acc-password"), | ||
resource.TestCheckResourceAttr(resourceName, "auth_database_name", "admin"), | ||
resource.TestCheckResourceAttr(resourceName, "labels.#", "2"), | ||
), | ||
}, | ||
{ | ||
Config: acc.ConfigDatabaseUserWithLabels(projectID, username, "read", | ||
Config: acc.ConfigDatabaseUserWithLabels(projectID, username, "read", "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice test!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one doubt otherwise LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
if inModel != nil && outModel.Description.Equal(types.StringValue("")) && inModel.Description.IsNull() { | ||
// null != "" in TPF: Error: Provider produced inconsistent result after apply. .description: was null, but now cty.StringVal("") | ||
databaseUserModel.Description = model.Description | ||
outModel.Description = types.StringNull() | ||
} | ||
|
||
return databaseUserModel, nil | ||
return outModel, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice way of keeping it readable 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
Adds description field to
mongodbatlas_database_user
Link to any related issue(s): CLOUDP-288713
Considerations
optional
only attributenull
!=""
in TPF. (Similar to recent resource_policy implementation)null
in the SDK. Once it is set, it will always be""
since we cannot dumpnull
(to be discussed based on this example.)Type of change:
Required Checklist:
Further comments