-
Notifications
You must be signed in to change notification settings - Fork 178
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: Uses new Atlas Go SDK version #1831
Conversation
eae0000
to
25ea035
Compare
23793e5
to
5651c2b
Compare
internal/service/alertconfiguration/data_source_alert_configuration.go
Outdated
Show resolved
Hide resolved
Roles: conversion.NonEmptySliceToSlicePtr(NewMongoDBAtlasRoles(rolesModel)), | ||
Labels: conversion.NonEmptySliceToSlicePtr(NewMongoDBAtlasLabels(labelsModel)), | ||
Scopes: conversion.NonEmptySliceToSlicePtr(NewMongoDBAtlasScopes(scopesModel)), |
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.
why not have the New..
function return the 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'm trying to minimize the changes here, then there will a PR per resource to fix the update bugs, and check the readonly / createonly attributes, and improve the clarity as in your suggestion. Those changes will be more located (per resource)
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.
as Agusting said before we'll probably get rid of all NonEmptySliceToSlicePtr in the next PRs
@@ -216,12 +216,12 @@ func schemaOnlineArchive() map[string]*schema.Schema { | |||
} | |||
|
|||
func dataSourceMongoDBAtlasOnlineArchiveRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { | |||
connV2 := meta.(*config.MongoDBClient).AtlasV2 | |||
connOldV2 := meta.(*config.MongoDBClient).OldAtlasV2 |
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.
Could we use the name v20231001002AtlasSDK
instead of OldAtlasV2
? It is not easy to understand what we consider the old atlas v2. In addition, the new name will allow us to support multiple older versions if needed
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'm following the convention @oarbusi did in his previous PR, e.g. it's being used in federated_settings_identity_provider service
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 missed that PR 😭 What is our opinion on the name used for the Atlas SDK?
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.
maybe it's not the best name but I couldn't find a better name to suggest, the idea is that it's an SDK a little older than the current one used in most places.
also the idea is that this old SDK is only used until the corresponding service team fixes their API so use of this old sdk should be short duration
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 the correct naming would include the dates to avoid confusion if more parallel sdks are mantained
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.
right now I think it's a premature optimization as we only have 2 sdks, y we intend to have the old one a short period of time. if more than 2 would be needed at some moment then I agree.
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.
at the end I've added the date to the old sdk as per your recommendation
@@ -56,3 +56,10 @@ func IsStringPresent(strPtr *string) bool { | |||
func MongoDBRegionToAWSRegion(region string) string { | |||
return strings.ReplaceAll(strings.ToLower(region), "_", "-") | |||
} | |||
|
|||
func NonEmptySliceToSlicePtr[T any](v []T) *[]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.
if slices only let's be more correct about it
func NonEmptySliceToSlicePtr[T any](v []T) *[]T { | |
func NonEmptySliceToSlicePtr[S ~[]E, E any]](v S) *S { |
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.
name changed to NonEmptyToPtr as it might called for slices or also arrays.
internal/service/alertconfiguration/data_source_alert_configuration.go
Outdated
Show resolved
Hide resolved
@@ -216,12 +216,12 @@ func schemaOnlineArchive() map[string]*schema.Schema { | |||
} | |||
|
|||
func dataSourceMongoDBAtlasOnlineArchiveRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { | |||
connV2 := meta.(*config.MongoDBClient).AtlasV2 | |||
connOldV2 := meta.(*config.MongoDBClient).OldAtlasV2 |
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 the correct naming would include the dates to avoid confusion if more parallel sdks are mantained
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 besides pending comments
@@ -56,3 +56,10 @@ func IsStringPresent(strPtr *string) bool { | |||
func MongoDBRegionToAWSRegion(region string) string { | |||
return strings.ReplaceAll(strings.ToLower(region), "_", "-") | |||
} | |||
|
|||
func NonEmptySliceToSlicePtr[T any](v []T) *[]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.
we will likely have a similar approach in CFN and CLI for this version upgrade, could be worth incorporating within SDK as a helper function and mention in upgrade guide.
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.
@gssbzn what do you think?
on the other hand I think I'll be able to delete most of the uses of this function in next PRs
internal/config/client.go
Outdated
@@ -31,7 +31,7 @@ var ( | |||
type MongoDBClient struct { | |||
Atlas *matlasClient.Client | |||
AtlasV2 *atlasSDK.APIClient | |||
OldAtlasV2 *oldAtlasSDK.APIClient // Needed to avoid sudden breaking changes in federated_settings_identity_provider resource. Will be removed in terraform-provider-1.16.0 | |||
OldAtlasV2 *oldAtlasSDK.APIClient // Needed to avoid sudden breaking changes in federated_settings_identity_provider and online_archive resources. Will be removed in terraform-provider-1.16.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.
@andreaangiolillo @AgustinBettati @gssbzn I've added online_archive to the old sdk comment. but I would prefer to keep this PR changes as small as possible, I think old sdk renaming belongs to a different PR, it would affect client file and federated files apart from online_archive.
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.
@andreaangiolillo @AgustinBettati @gssbzn hey, at the end I've added the date to old sdk in this PR in case you want to take a look. thanks
LGTM on my side, will wait once the comments are addressed. |
Description
Uses new Atlas Go SDK version.
The goal of this PR is to do as few changes as possible while keeping the same behavior as the current code.
Next PRs will improve update operation, createonly and readonly attributes of each TF resource using this SDK.
Link to any related issue(s): https://jira.mongodb.org/browse/CLOUDP-222424
Type of change:
Required Checklist:
Further comments