Skip to content

Commit 8aa6d8a

Browse files
authored
chore: Remove unneeded Atlas versions (#3752)
* remove Atlas version 20240805 * remove admin20240530 version from resources except cluster * NormalizeBaseURL
1 parent f67386b commit 8aa6d8a

File tree

11 files changed

+56
-531
lines changed

11 files changed

+56
-531
lines changed

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ require (
3333
github.com/zclconf/go-cty v1.17.0
3434
go.mongodb.org/atlas v0.38.0
3535
go.mongodb.org/atlas-sdk/v20240530005 v20240530005.0.0
36-
go.mongodb.org/atlas-sdk/v20240805005 v20240805005.0.1-0.20250402112219-2468c5354718 // uses api-bot-update-v20240805-backport-cluster to support AdvancedConfiguration in create/updateCluster APIs
3736
go.mongodb.org/atlas-sdk/v20241113005 v20241113005.0.0
3837
go.mongodb.org/realm v0.1.0
3938
gopkg.in/yaml.v3 v3.0.1
@@ -43,6 +42,7 @@ require (
4342
github.com/hashicorp/terraform-json v0.27.2
4443
github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0
4544
go.mongodb.org/atlas-sdk/v20250312007 v20250312007.0.0
45+
golang.org/x/oauth2 v0.31.0
4646
)
4747

4848
require (
@@ -163,7 +163,6 @@ require (
163163
golang.org/x/crypto v0.42.0 // indirect
164164
golang.org/x/mod v0.27.0 // indirect
165165
golang.org/x/net v0.43.0 // indirect
166-
golang.org/x/oauth2 v0.31.0 // indirect
167166
golang.org/x/sync v0.17.0 // indirect
168167
golang.org/x/sys v0.36.0 // indirect
169168
golang.org/x/text v0.29.0 // indirect

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,8 +1364,6 @@ go.mongodb.org/atlas v0.38.0 h1:zfwymq20GqivGwxPZfypfUDry+WwMGVui97z1d8V4bU=
13641364
go.mongodb.org/atlas v0.38.0/go.mod h1:DJYtM+vsEpPEMSkQzJnFHrT0sP7ev6cseZc/GGjJYG8=
13651365
go.mongodb.org/atlas-sdk/v20240530005 v20240530005.0.0 h1:d/gbYJ+obR0EM/3DZf7+ZMi2QWISegm3mid7Or708cc=
13661366
go.mongodb.org/atlas-sdk/v20240530005 v20240530005.0.0/go.mod h1:O47ZrMMfcWb31wznNIq2PQkkdoFoK0ea2GlmRqGJC2s=
1367-
go.mongodb.org/atlas-sdk/v20240805005 v20240805005.0.1-0.20250402112219-2468c5354718 h1:M2mNSBdTkP+paQ1qZ6FliiPdTEbDR9m9qvv4vsWoJAw=
1368-
go.mongodb.org/atlas-sdk/v20240805005 v20240805005.0.1-0.20250402112219-2468c5354718/go.mod h1:PeByRxdvzfvz7xhG5vDn60j836EoduWqTqs76okUc9c=
13691367
go.mongodb.org/atlas-sdk/v20241113005 v20241113005.0.0 h1:aaU2E4rtzYXuEDxv9MoSON2gOEAA9M2gsDf2CqjcGj8=
13701368
go.mongodb.org/atlas-sdk/v20241113005 v20241113005.0.0/go.mod h1:eV9REWR36iVMrpZUAMZ5qPbXEatoVfmzwT+Ue8yqU+U=
13711369
go.mongodb.org/atlas-sdk/v20250312007 v20250312007.0.0 h1:2k6eXWQzTpbc/maZotRIoyXq3l/pbCF1RBMt+WnuB0I=

internal/config/client.go

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"time"
1212

1313
admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin"
14-
admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin"
1514
admin20241113 "go.mongodb.org/atlas-sdk/v20241113005/admin"
1615
"go.mongodb.org/atlas-sdk/v20250312007/admin"
1716
matlasClient "go.mongodb.org/atlas/mongodbatlas"
@@ -71,17 +70,16 @@ func tfLoggingInterceptor(base http.RoundTripper) http.RoundTripper {
7170
return logging.NewTransport("Atlas", base)
7271
}
7372

74-
// MongoDBClient contains the mongodbatlas clients and configurations
73+
// MongoDBClient contains the mongodbatlas clients and configurations.
7574
type MongoDBClient struct {
7675
Atlas *matlasClient.Client
7776
AtlasV2 *admin.APIClient
7877
AtlasPreview *adminpreview.APIClient
79-
AtlasV220240805 *admin20240805.APIClient // used in advanced_cluster to avoid adopting 2024-10-23 release with ISS autoscaling
80-
AtlasV220240530 *admin20240530.APIClient // used in advanced_cluster and cloud_backup_schedule for avoiding breaking changes (supporting deprecated replication_specs.id)
81-
AtlasV220241113 *admin20241113.APIClient // used in teams and atlas_users to avoiding breaking changes
78+
AtlasV220240530 *admin20240530.APIClient // Used in cluster to support deprecated attributes default_read_concern and fail_index_key_too_long in advanced_configuration.
79+
AtlasV220241113 *admin20241113.APIClient // Used in teams and atlas_users to avoiding breaking changes.
8280
Realm *RealmClient
83-
BaseURL string // needed by organization resource
84-
TerraformVersion string // needed by organization resource
81+
BaseURL string // Needed by organization resource.
82+
TerraformVersion string // Needed by organization resource.
8583
}
8684

8785
type RealmClient struct {
@@ -121,10 +119,6 @@ func NewClient(c *Credentials, terraformVersion string) (*MongoDBClient, error)
121119
if err != nil {
122120
return nil, err
123121
}
124-
sdkV220240805Client, err := newSDKV220240805Client(client, c.BaseURL, userAgent)
125-
if err != nil {
126-
return nil, err
127-
}
128122
sdkV220241113Client, err := newSDKV220241113Client(client, c.BaseURL, userAgent)
129123
if err != nil {
130124
return nil, err
@@ -135,14 +129,13 @@ func NewClient(c *Credentials, terraformVersion string) (*MongoDBClient, error)
135129
AtlasV2: sdkV2Client,
136130
AtlasPreview: sdkPreviewClient,
137131
AtlasV220240530: sdkV220240530Client,
138-
AtlasV220240805: sdkV220240805Client,
139132
AtlasV220241113: sdkV220241113Client,
140133
BaseURL: c.BaseURL,
141134
TerraformVersion: terraformVersion,
142135
Realm: &RealmClient{
143136
publicKey: c.PublicKey,
144137
privateKey: c.PrivateKey,
145-
realmBaseURL: c.RealmBaseURL,
138+
realmBaseURL: NormalizeBaseURL(c.RealmBaseURL),
146139
terraformVersion: terraformVersion,
147140
},
148141
}
@@ -204,15 +197,6 @@ func newSDKV220240530Client(client *http.Client, baseURL, userAgent string) (*ad
204197
)
205198
}
206199

207-
func newSDKV220240805Client(client *http.Client, baseURL, userAgent string) (*admin20240805.APIClient, error) {
208-
return admin20240805.NewClient(
209-
admin20240805.UseHTTPClient(client),
210-
admin20240805.UseUserAgent(userAgent),
211-
admin20240805.UseBaseURL(baseURL),
212-
admin20240805.UseDebug(false),
213-
)
214-
}
215-
216200
func newSDKV220241113Client(client *http.Client, baseURL, userAgent string) (*admin20241113.APIClient, error) {
217201
return admin20241113.NewClient(
218202
admin20241113.UseHTTPClient(client),
@@ -234,9 +218,9 @@ func (r *RealmClient) Get(ctx context.Context) (*realm.Client, error) {
234218

235219
authConfig := realmAuth.NewConfig(nil)
236220
if r.realmBaseURL != "" {
237-
adminURL := r.realmBaseURL + "api/admin/v3.0/"
221+
adminURL := r.realmBaseURL + "/api/admin/v3.0/"
238222
optsRealm = append(optsRealm, realm.SetBaseURL(adminURL))
239-
authConfig.AuthURL, _ = url.Parse(adminURL + "auth/providers/mongodb-cloud/login")
223+
authConfig.AuthURL, _ = url.Parse(adminURL + "/auth/providers/mongodb-cloud/login")
240224
}
241225

242226
token, err := authConfig.NewTokenFromCredentials(ctx, r.publicKey, r.privateKey)

internal/config/service_account.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func getTokenSource(clientID, clientSecret, baseURL string, tokenRenewalBase htt
2828
saInfo.mu.Lock()
2929
defer saInfo.mu.Unlock()
3030

31-
baseURL = strings.TrimRight(baseURL, "/")
31+
baseURL = NormalizeBaseURL(baseURL)
3232
if saInfo.tokenSource != nil { // Token source in cache.
3333
if saInfo.clientID != clientID || saInfo.clientSecret != clientSecret || saInfo.baseURL != baseURL {
3434
return nil, fmt.Errorf("service account credentials changed")
@@ -53,3 +53,7 @@ func getTokenSource(clientID, clientSecret, baseURL string, tokenRenewalBase htt
5353
saInfo.tokenSource = tokenSource
5454
return saInfo.tokenSource, nil
5555
}
56+
57+
func NormalizeBaseURL(baseURL string) string {
58+
return strings.TrimRight(baseURL, "/")
59+
}

internal/service/advancedcluster/common.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"strings"
77
"time"
88

9-
admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin"
109
"go.mongodb.org/atlas-sdk/v20250312007/admin"
1110

1211
"github.com/hashicorp/terraform-plugin-framework/diag"
@@ -27,7 +26,6 @@ var (
2726
)
2827

2928
type ProcessArgs struct {
30-
ArgsLegacy *admin20240530.ClusterDescriptionProcessArgs
3129
ArgsDefault *admin.ClusterDescriptionProcessArgs20240805
3230
ClusterAdvancedConfig *admin.ApiAtlasClusterAdvancedConfiguration
3331
}

0 commit comments

Comments
 (0)