-
Notifications
You must be signed in to change notification settings - Fork 190
INTMDB-290: Added advanced configuration for datasource/resource of advanced cluster #658
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
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
advancedConfReq := expandProcessArgs(d, aclist[0].(map[string]interface{})) | ||
|
||
if ok { | ||
_, _, err := conn.Clusters.UpdateProcessArgs(ctx, projectID, cluster.Name, advancedConfReq) |
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.
Remove this NL
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 questions about tests coverage difference between cluster and advanced cluster but that's it. Thank you!
@@ -247,6 +248,70 @@ func TestAccResourceMongoDBAtlasAdvancedCluster_Paused(t *testing.T) { | |||
}) | |||
} | |||
|
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.
When we added the new read/write concern options to advanced configuration we added another test:
https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/mongodbatlas/resource_mongodbatlas_cluster_test.go#L160
Should we add that here? Or at least add the additional parameters to these tests? DefaultReadConcern
& DefaultWriteConcern ?
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.
Good point, will add those parameters in the same test and see whether it passes or not
@@ -24,6 +25,7 @@ func dataSourceMongoDBAtlasAdvancedClusters() *schema.Resource { | |||
Computed: true, | |||
Elem: &schema.Resource{ | |||
Schema: map[string]*schema.Schema{ | |||
"advanced_configuration": clusterAdvancedConfigurationSchemaComputed(), | |||
"backup_enabled": { |
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.
This is not related to this change but I see that this schema has
"name": {
Type: schema.TypeString,
Computed: true,
},
where we are using Required: true
for the name
in data_source_mongodbatlas_advanced_cluster.go.
Is this correct or both should be Computed: true
?
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.
In the singular datasource is required to get a specific advanced cluster along the project ID, in the plural datasource, it will get all the advanced clusters from the project ID provided and then list it with all computed parameters. Also, you cannot use Computed if you are using Required at the same time.
log.Printf("[WARN] Error setting `advanced_configuration` for the cluster(%s): %s", clusters[i].ID, err) | ||
|
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.
[q] Shouldn’t we check that err != nil
before printing the log message?
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.
You're right, will add the validation, thank you
@@ -221,7 +223,11 @@ func flattenAdvancedClusters(ctx context.Context, d *schema.ResourceData, conn * | |||
results := make([]map[string]interface{}, 0) | |||
|
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.
[q] why d *schema.ResourceData
is an argument of this function if it is not used?
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.
Good eye, will remove the argument since is not necessary this time
*/ | ||
if d.HasChange("advanced_configuration") { | ||
ac := d.Get("advanced_configuration") | ||
if aclist, ok1 := ac.([]interface{}); ok1 && len(aclist) > 0 { |
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.
[q] any reason why you are defining ok1
instead ok
?
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 reason at all and good eye, will update the naming, thank you.
@@ -540,6 +579,22 @@ func resourceMongoDBAtlasAdvancedClusterUpdate(ctx context.Context, d *schema.Re | |||
} | |||
} | |||
|
|||
/* | |||
Check if advanced configuration option has a changes to update it |
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 think this comment is not clear. Maybe something like "update advanced configuration options if needed" would be better
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.
Understood, will update the comment, thank you
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. Thanks for all the changes
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! Thank you!
Description
advanced_configuration
for resource and datasource ofadvanced_cluster
Results of tests
Resource
Advanced cluster
Datasource
Advanced cluster
Advanced clusters
Link to any related issue(s):
Type of change:
Required Checklist:
Further comments