Skip to content

Commit 9601faa

Browse files
author
Cristina Sánchez Sánchez
committed
Preview new SDK version
1 parent 7271d8a commit 9601faa

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require (
2424
github.com/huandu/xstrings v1.5.0
2525
github.com/jarcoal/httpmock v1.4.0
2626
github.com/mongodb-forks/digest v1.1.0
27-
github.com/mongodb/atlas-sdk-go v1.0.1-0.20250709084037-30b22cb7796e
27+
github.com/mongodb/atlas-sdk-go v1.0.1-0.20250806084240-f8831d13e1be
2828
github.com/pb33f/libopenapi v0.24.0
2929
github.com/sebdah/goldie/v2 v2.7.1
3030
github.com/spf13/cast v1.9.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,8 @@ github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx
659659
github.com/mmcloughlin/avo v0.5.0/go.mod h1:ChHFdoV7ql95Wi7vuq2YT1bwCJqiWdZrQ1im3VujLYM=
660660
github.com/mongodb-forks/digest v1.1.0 h1:7eUdsR1BtqLv0mdNm4OXs6ddWvR4X2/OsLwdKksrOoc=
661661
github.com/mongodb-forks/digest v1.1.0/go.mod h1:rb+EX8zotClD5Dj4NdgxnJXG9nwrlx3NWKJ8xttz1Dg=
662-
github.com/mongodb/atlas-sdk-go v1.0.1-0.20250709084037-30b22cb7796e h1:eg4qpkTaZ9AVyprG3BRndxKYZqE4mleM+Suix6wQiVw=
663-
github.com/mongodb/atlas-sdk-go v1.0.1-0.20250709084037-30b22cb7796e/go.mod h1:pz4YlR9bUwsxcJMzUor4PKD4oCswIf8Kv9DQBbVQImU=
662+
github.com/mongodb/atlas-sdk-go v1.0.1-0.20250806084240-f8831d13e1be h1:eOflLIwA+B8enYf07dgpcy8rdzV+LT+r1odjHhkdbMY=
663+
github.com/mongodb/atlas-sdk-go v1.0.1-0.20250806084240-f8831d13e1be/go.mod h1:pz4YlR9bUwsxcJMzUor4PKD4oCswIf8Kv9DQBbVQImU=
664664
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
665665
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
666666
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=

internal/service/clouduserprojectassignment/model.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import (
66
"github.com/hashicorp/terraform-plugin-framework/diag"
77
"github.com/hashicorp/terraform-plugin-framework/types"
88
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
9-
"go.mongodb.org/atlas-sdk/v20250312005/admin"
9+
10+
// "go.mongodb.org/atlas-sdk/v20250312005/admin"
11+
"github.com/mongodb/atlas-sdk-go/admin"
1012
)
1113

1214
func NewTFModel(ctx context.Context, projectID string, apiResp *admin.GroupUserResponse) (*TFModel, diag.Diagnostics) {
@@ -79,23 +81,21 @@ func NewAtlasUpdateReq(ctx context.Context, plan, state *TFModel) (addRequests,
7981

8082
func diffRoles(oldRoles, newRoles []string) (toAdd, toRemove []string) {
8183
oldRolesMap := make(map[string]bool, len(oldRoles))
82-
newRolesMap := make(map[string]bool, len(newRoles))
8384

8485
for _, role := range oldRoles {
8586
oldRolesMap[role] = true
8687
}
8788

8889
for _, role := range newRoles {
89-
newRolesMap[role] = true
90-
if !oldRolesMap[role] {
90+
if oldRolesMap[role] {
91+
delete(oldRolesMap, role)
92+
} else {
9193
toAdd = append(toAdd, role)
9294
}
9395
}
9496

95-
for _, role := range oldRoles {
96-
if !newRolesMap[role] {
97-
toRemove = append(toRemove, role)
98-
}
97+
for role := range oldRolesMap {
98+
toRemove = append(toRemove, role)
9999
}
100100

101101
return toAdd, toRemove

internal/service/clouduserprojectassignment/model_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import (
77
"github.com/hashicorp/terraform-plugin-framework/types"
88
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/clouduserprojectassignment"
99
"github.com/stretchr/testify/assert"
10-
"go.mongodb.org/atlas-sdk/v20250312005/admin"
10+
11+
// "go.mongodb.org/atlas-sdk/v20250312005/admin"
12+
"github.com/mongodb/atlas-sdk-go/admin"
1113
)
1214

1315
const (

internal/service/clouduserprojectassignment/resource.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import (
66
"net/http"
77
"regexp"
88

9-
"go.mongodb.org/atlas-sdk/v20250312005/admin"
9+
// "go.mongodb.org/atlas-sdk/v20250312005/admin"
10+
"github.com/mongodb/atlas-sdk-go/admin"
1011

1112
"github.com/hashicorp/terraform-plugin-framework/path"
1213
"github.com/hashicorp/terraform-plugin-framework/resource"
@@ -34,7 +35,6 @@ type rs struct {
3435
}
3536

3637
func (r *rs) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
37-
// TODO: Schema and model must be defined in resource_schema.go. Details on scaffolding this file found in contributing/development-best-practices.md under "Scaffolding Schema and Model Definitions"
3838
resp.Schema = resourceSchema(ctx)
3939
conversion.UpdateSchemaDescription(&resp.Schema)
4040
}
@@ -46,7 +46,7 @@ func (r *rs) Create(ctx context.Context, req resource.CreateRequest, resp *resou
4646
return
4747
}
4848

49-
connV2 := r.Client.AtlasV2
49+
connV2 := r.Client.AtlasPreview
5050
projectID := plan.ProjectId.ValueString()
5151
projectUserRequest, diags := NewProjectUserReq(ctx, &plan)
5252
if diags.HasError() {
@@ -75,7 +75,7 @@ func (r *rs) Read(ctx context.Context, req resource.ReadRequest, resp *resource.
7575
return
7676
}
7777

78-
connV2 := r.Client.AtlasV2
78+
connV2 := r.Client.AtlasPreview
7979
projectID := state.ProjectId.ValueString()
8080
var userResp *admin.GroupUserResponse
8181
var httpResp *http.Response
@@ -126,7 +126,7 @@ func (r *rs) Update(ctx context.Context, req resource.UpdateRequest, resp *resou
126126
return
127127
}
128128

129-
connV2 := r.Client.AtlasV2
129+
connV2 := r.Client.AtlasPreview
130130
projectID := plan.ProjectId.ValueString()
131131
userID := plan.UserId.ValueString()
132132
username := plan.Username.ValueString()
@@ -185,7 +185,7 @@ func (r *rs) Delete(ctx context.Context, req resource.DeleteRequest, resp *resou
185185
return
186186
}
187187

188-
connV2 := r.Client.AtlasV2
188+
connV2 := r.Client.AtlasPreview
189189
projectID := state.ProjectId.ValueString()
190190
userID := state.UserId.ValueString()
191191
username := state.Username.ValueString()

0 commit comments

Comments
 (0)