Skip to content

Commit 7d81b90

Browse files
coderGo93abner-dou
authored andcommitted
INTMDB-275: Changed the pointer in some paremeters for custom db role (#596)
* chore: updated vendor * fix: fixes the pointer error for custom roles * fixes a import failing for cloud provider snapshot
1 parent 96c6a71 commit 7d81b90

5 files changed

+38
-39
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ require (
1212
github.com/mwielbut/pointy v1.1.0
1313
github.com/spf13/cast v1.4.1
1414
github.com/terraform-providers/terraform-provider-aws v1.60.1-0.20210625132053-af2d5c0ad54f
15-
go.mongodb.org/atlas v0.13.1-0.20211103172854-77290cf48e1e
15+
go.mongodb.org/atlas v0.13.1-0.20211104090717-43497bed4998
1616
go.mongodb.org/realm v0.1.0
1717
)

go.sum

+5-6
Original file line numberDiff line numberDiff line change
@@ -1195,12 +1195,8 @@ go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQc
11951195
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
11961196
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
11971197
go.mongodb.org/atlas v0.12.0/go.mod h1:wVCnHcm/7/IfTjEB6K8K35PLG70yGz8BdkRwX0oK9/M=
1198-
go.mongodb.org/atlas v0.13.0 h1:JkJOWsKm9k2mcFaivaaMNDpKDsxJJj1O0eUsDtnNvuE=
1199-
go.mongodb.org/atlas v0.13.0/go.mod h1:wVCnHcm/7/IfTjEB6K8K35PLG70yGz8BdkRwX0oK9/M=
1200-
go.mongodb.org/atlas v0.13.1-0.20211015211338-c17a67cbe2bf h1:AczRmIosmEvyLpHNnvykZlUpDv90oZ0FEf1zs+CNYH0=
1201-
go.mongodb.org/atlas v0.13.1-0.20211015211338-c17a67cbe2bf/go.mod h1:wVCnHcm/7/IfTjEB6K8K35PLG70yGz8BdkRwX0oK9/M=
1202-
go.mongodb.org/atlas v0.13.1-0.20211103172854-77290cf48e1e h1:Fcx4rdJT5074x9TIENhX59vaaxgkkpMPhbJKql+FqxA=
1203-
go.mongodb.org/atlas v0.13.1-0.20211103172854-77290cf48e1e/go.mod h1:lQhRHIxc6jQHEK3/q9WLu/SdBkPj2fQYhjLGUF6Z3U8=
1198+
go.mongodb.org/atlas v0.13.1-0.20211104090717-43497bed4998 h1:FVIc+7lT1gXYoR47uBOTq7079ZEjlTTlznDAv/zUqrk=
1199+
go.mongodb.org/atlas v0.13.1-0.20211104090717-43497bed4998/go.mod h1:lQhRHIxc6jQHEK3/q9WLu/SdBkPj2fQYhjLGUF6Z3U8=
12041200
go.mongodb.org/realm v0.1.0 h1:zJiXyLaZrznQ+Pz947ziSrDKUep39DO4SfA0Fzx8M4M=
12051201
go.mongodb.org/realm v0.1.0/go.mod h1:4Vj6iy+Puo1TDERcoh4XZ+pjtwbOzPpzqy3Cwe8ZmDM=
12061202
go.mozilla.org/mozlog v0.0.0-20170222151521-4bb13139d403/go.mod h1:jHoPAGnDrCy6kaI2tAze5Prf0Nr0w/oNkROt2lw3n3o=
@@ -1744,6 +1740,7 @@ gopkg.in/check.v1 v1.0.0-20141024133853-64131543e789/go.mod h1:Co6ibVJAznAaIkqp8
17441740
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
17451741
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
17461742
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1743+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
17471744
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
17481745
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
17491746
gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
@@ -1762,6 +1759,7 @@ gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76
17621759
gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
17631760
gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
17641761
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
1762+
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
17651763
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
17661764
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
17671765
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
@@ -1822,6 +1820,7 @@ mvdan.cc/gofumpt v0.1.1/go.mod h1:yXG1r1WqZVKWbVRtBWKWX9+CxGYfA51nSomhM0woR48=
18221820
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
18231821
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4=
18241822
mvdan.cc/unparam v0.0.0-20210104141923-aac4ce9116a7/go.mod h1:hBpJkZE8H/sb+VRFvw2+rBpHNsTBcvSpk61hr8mzXZE=
1823+
rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=
18251824
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
18261825
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
18271826
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=

mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestAccResourceMongoDBAtlasCloudProviderSnapshot_importBasic(t *testing.T)
6666
ImportStateIdFunc: testAccCheckMongoDBAtlasCloudProviderSnapshotImportStateIDFunc(resourceName),
6767
ImportState: true,
6868
ImportStateVerify: true,
69-
ImportStateVerifyIgnore: []string{"retention_in_days"},
69+
ImportStateVerifyIgnore: []string{"retention_in_days", "timeout"},
7070
},
7171
},
7272
})

mongodbatlas/resource_mongodbatlas_custom_db_role.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ func expandActionResources(resources *schema.Set) []matlas.Resource {
297297
for k, v := range resources.List() {
298298
resourceMap := v.(map[string]interface{})
299299
actionResources[k] = matlas.Resource{
300-
Db: resourceMap["database_name"].(string),
301-
Collection: resourceMap["collection_name"].(string),
300+
DB: pointy.String(resourceMap["database_name"].(string)),
301+
Collection: pointy.String(resourceMap["collection_name"].(string)),
302302
Cluster: pointy.Bool(cast.ToBool(resourceMap["cluster"])),
303303
}
304304
}
@@ -328,8 +328,8 @@ func flattenActionResources(resources []matlas.Resource) []map[string]interface{
328328
})
329329
} else {
330330
actionResourceList = append(actionResourceList, map[string]interface{}{
331-
"database_name": v.Db,
332-
"collection_name": v.Collection,
331+
"database_name": cast.ToString(v.DB),
332+
"collection_name": cast.ToString(v.Collection),
333333
})
334334
}
335335
}

mongodbatlas/resource_mongodbatlas_custom_db_role_test.go

+27-27
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_WithInheritedRoles(t *testing.T) {
7373
Actions: []matlas.Action{{
7474
Action: "INSERT",
7575
Resources: []matlas.Resource{{
76-
Db: fmt.Sprintf("b_test-acc-ddb_name-%s", acctest.RandString(5)),
76+
DB: pointy.String(fmt.Sprintf("b_test-acc-ddb_name-%s", acctest.RandString(5))),
7777
}},
7878
}},
7979
},
@@ -93,7 +93,7 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_WithInheritedRoles(t *testing.T) {
9393
Actions: []matlas.Action{{
9494
Action: "UPDATE",
9595
Resources: []matlas.Resource{{
96-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
96+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
9797
}},
9898
}},
9999
}
@@ -104,7 +104,7 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_WithInheritedRoles(t *testing.T) {
104104
Actions: []matlas.Action{{
105105
Action: "FIND",
106106
Resources: []matlas.Resource{{
107-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
107+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
108108
}},
109109
}},
110110
},
@@ -124,7 +124,7 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_WithInheritedRoles(t *testing.T) {
124124
Actions: []matlas.Action{{
125125
Action: "REMOVE",
126126
Resources: []matlas.Resource{{
127-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
127+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
128128
}},
129129
}},
130130
}
@@ -238,18 +238,18 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_MultipleCustomRoles(t *testing.T)
238238
Action: "REMOVE",
239239
Resources: []matlas.Resource{
240240
{
241-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
241+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
242242
},
243243
{
244-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
244+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
245245
},
246246
},
247247
},
248248
{
249249
Action: "FIND",
250250
Resources: []matlas.Resource{
251251
{
252-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
252+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
253253
},
254254
},
255255
},
@@ -263,18 +263,18 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_MultipleCustomRoles(t *testing.T)
263263
Action: "UPDATE",
264264
Resources: []matlas.Resource{
265265
{
266-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
266+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
267267
},
268268
{
269-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
269+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
270270
},
271271
},
272272
},
273273
{
274274
Action: "INSERT",
275275
Resources: []matlas.Resource{
276276
{
277-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
277+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
278278
},
279279
},
280280
},
@@ -294,29 +294,29 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_MultipleCustomRoles(t *testing.T)
294294
Action: "UPDATE",
295295
Resources: []matlas.Resource{
296296
{
297-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
297+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
298298
},
299299
},
300300
},
301301
{
302302
Action: "FIND",
303303
Resources: []matlas.Resource{
304304
{
305-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
305+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
306306
},
307307
{
308-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
308+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
309309
},
310310
},
311311
},
312312
{
313313
Action: "INSERT",
314314
Resources: []matlas.Resource{
315315
{
316-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
316+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
317317
},
318318
{
319-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
319+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
320320
},
321321
},
322322
},
@@ -330,7 +330,7 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_MultipleCustomRoles(t *testing.T)
330330
Action: "REMOVE",
331331
Resources: []matlas.Resource{
332332
{
333-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
333+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
334334
},
335335
},
336336
},
@@ -489,18 +489,18 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_UpdatedInheritRoles(t *testing.T)
489489
Action: "REMOVE",
490490
Resources: []matlas.Resource{
491491
{
492-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
492+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
493493
},
494494
{
495-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
495+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
496496
},
497497
},
498498
},
499499
{
500500
Action: "FIND",
501501
Resources: []matlas.Resource{
502502
{
503-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
503+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
504504
},
505505
},
506506
},
@@ -514,29 +514,29 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_UpdatedInheritRoles(t *testing.T)
514514
Action: "UPDATE",
515515
Resources: []matlas.Resource{
516516
{
517-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
517+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
518518
},
519519
},
520520
},
521521
{
522522
Action: "FIND",
523523
Resources: []matlas.Resource{
524524
{
525-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
525+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
526526
},
527527
{
528-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
528+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
529529
},
530530
},
531531
},
532532
{
533533
Action: "INSERT",
534534
Resources: []matlas.Resource{
535535
{
536-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
536+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
537537
},
538538
{
539-
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
539+
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
540540
},
541541
},
542542
},
@@ -735,9 +735,9 @@ func testAccMongoDBAtlasCustomDBRolesConfigWithInheritedRoles(projectID string,
735735
}
736736
}
737737
`, projectID,
738-
inheritedRole[0].RoleName, inheritedRole[0].Actions[0].Action, inheritedRole[0].Actions[0].Resources[0].Db,
738+
inheritedRole[0].RoleName, inheritedRole[0].Actions[0].Action, *inheritedRole[0].Actions[0].Resources[0].DB,
739739
inheritedRole[1].RoleName, inheritedRole[1].Actions[0].Action, *inheritedRole[1].Actions[0].Resources[0].Cluster,
740-
testRole.RoleName, testRole.Actions[0].Action, testRole.Actions[0].Resources[0].Db,
740+
testRole.RoleName, testRole.Actions[0].Action, *testRole.Actions[0].Resources[0].DB,
741741
)
742742
}
743743

@@ -758,7 +758,7 @@ func testAccMongoDBAtlasCustomDBRolesConfigMultiple(projectID string, inheritedR
758758
collection_name = ""
759759
database_name = "%s"
760760
}
761-
`, r.Db)
761+
`, *r.DB)
762762
}
763763

764764
// get the actions and set the resources

0 commit comments

Comments
 (0)