Skip to content

INTMDB-275: Changed the pointer in some paremeters for custom db role #596

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

Merged
merged 3 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ require (
github.com/mwielbut/pointy v1.1.0
github.com/spf13/cast v1.4.1
github.com/terraform-providers/terraform-provider-aws v1.60.1-0.20210625132053-af2d5c0ad54f
go.mongodb.org/atlas v0.13.1-0.20211103172854-77290cf48e1e
go.mongodb.org/atlas v0.13.1-0.20211104090717-43497bed4998
go.mongodb.org/realm v0.1.0
)
11 changes: 5 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1195,12 +1195,8 @@ go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQc
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
go.mongodb.org/atlas v0.12.0/go.mod h1:wVCnHcm/7/IfTjEB6K8K35PLG70yGz8BdkRwX0oK9/M=
go.mongodb.org/atlas v0.13.0 h1:JkJOWsKm9k2mcFaivaaMNDpKDsxJJj1O0eUsDtnNvuE=
go.mongodb.org/atlas v0.13.0/go.mod h1:wVCnHcm/7/IfTjEB6K8K35PLG70yGz8BdkRwX0oK9/M=
go.mongodb.org/atlas v0.13.1-0.20211015211338-c17a67cbe2bf h1:AczRmIosmEvyLpHNnvykZlUpDv90oZ0FEf1zs+CNYH0=
go.mongodb.org/atlas v0.13.1-0.20211015211338-c17a67cbe2bf/go.mod h1:wVCnHcm/7/IfTjEB6K8K35PLG70yGz8BdkRwX0oK9/M=
go.mongodb.org/atlas v0.13.1-0.20211103172854-77290cf48e1e h1:Fcx4rdJT5074x9TIENhX59vaaxgkkpMPhbJKql+FqxA=
go.mongodb.org/atlas v0.13.1-0.20211103172854-77290cf48e1e/go.mod h1:lQhRHIxc6jQHEK3/q9WLu/SdBkPj2fQYhjLGUF6Z3U8=
go.mongodb.org/atlas v0.13.1-0.20211104090717-43497bed4998 h1:FVIc+7lT1gXYoR47uBOTq7079ZEjlTTlznDAv/zUqrk=
go.mongodb.org/atlas v0.13.1-0.20211104090717-43497bed4998/go.mod h1:lQhRHIxc6jQHEK3/q9WLu/SdBkPj2fQYhjLGUF6Z3U8=
go.mongodb.org/realm v0.1.0 h1:zJiXyLaZrznQ+Pz947ziSrDKUep39DO4SfA0Fzx8M4M=
go.mongodb.org/realm v0.1.0/go.mod h1:4Vj6iy+Puo1TDERcoh4XZ+pjtwbOzPpzqy3Cwe8ZmDM=
go.mozilla.org/mozlog v0.0.0-20170222151521-4bb13139d403/go.mod h1:jHoPAGnDrCy6kaI2tAze5Prf0Nr0w/oNkROt2lw3n3o=
Expand Down Expand Up @@ -1744,6 +1740,7 @@ gopkg.in/check.v1 v1.0.0-20141024133853-64131543e789/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
Expand All @@ -1762,6 +1759,7 @@ gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76
gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down Expand Up @@ -1822,6 +1820,7 @@ mvdan.cc/gofumpt v0.1.1/go.mod h1:yXG1r1WqZVKWbVRtBWKWX9+CxGYfA51nSomhM0woR48=
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc=
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4=
mvdan.cc/unparam v0.0.0-20210104141923-aac4ce9116a7/go.mod h1:hBpJkZE8H/sb+VRFvw2+rBpHNsTBcvSpk61hr8mzXZE=
rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestAccResourceMongoDBAtlasCloudProviderSnapshot_importBasic(t *testing.T)
ImportStateIdFunc: testAccCheckMongoDBAtlasCloudProviderSnapshotImportStateIDFunc(resourceName),
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"retention_in_days"},
ImportStateVerifyIgnore: []string{"retention_in_days", "timeout"},
},
},
})
Expand Down
8 changes: 4 additions & 4 deletions mongodbatlas/resource_mongodbatlas_custom_db_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ func expandActionResources(resources *schema.Set) []matlas.Resource {
for k, v := range resources.List() {
resourceMap := v.(map[string]interface{})
actionResources[k] = matlas.Resource{
Db: resourceMap["database_name"].(string),
Collection: resourceMap["collection_name"].(string),
DB: pointy.String(resourceMap["database_name"].(string)),
Collection: pointy.String(resourceMap["collection_name"].(string)),
Cluster: pointy.Bool(cast.ToBool(resourceMap["cluster"])),
}
}
Expand Down Expand Up @@ -328,8 +328,8 @@ func flattenActionResources(resources []matlas.Resource) []map[string]interface{
})
} else {
actionResourceList = append(actionResourceList, map[string]interface{}{
"database_name": v.Db,
"collection_name": v.Collection,
"database_name": cast.ToString(v.DB),
"collection_name": cast.ToString(v.Collection),
})
}
}
Expand Down
54 changes: 27 additions & 27 deletions mongodbatlas/resource_mongodbatlas_custom_db_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_WithInheritedRoles(t *testing.T) {
Actions: []matlas.Action{{
Action: "INSERT",
Resources: []matlas.Resource{{
Db: fmt.Sprintf("b_test-acc-ddb_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("b_test-acc-ddb_name-%s", acctest.RandString(5))),
}},
}},
},
Expand All @@ -93,7 +93,7 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_WithInheritedRoles(t *testing.T) {
Actions: []matlas.Action{{
Action: "UPDATE",
Resources: []matlas.Resource{{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
}},
}},
}
Expand All @@ -104,7 +104,7 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_WithInheritedRoles(t *testing.T) {
Actions: []matlas.Action{{
Action: "FIND",
Resources: []matlas.Resource{{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
}},
}},
},
Expand All @@ -124,7 +124,7 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_WithInheritedRoles(t *testing.T) {
Actions: []matlas.Action{{
Action: "REMOVE",
Resources: []matlas.Resource{{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
}},
}},
}
Expand Down Expand Up @@ -238,18 +238,18 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_MultipleCustomRoles(t *testing.T)
Action: "REMOVE",
Resources: []matlas.Resource{
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
},
},
{
Action: "FIND",
Resources: []matlas.Resource{
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
},
},
Expand All @@ -263,18 +263,18 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_MultipleCustomRoles(t *testing.T)
Action: "UPDATE",
Resources: []matlas.Resource{
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
},
},
{
Action: "INSERT",
Resources: []matlas.Resource{
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
},
},
Expand All @@ -294,29 +294,29 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_MultipleCustomRoles(t *testing.T)
Action: "UPDATE",
Resources: []matlas.Resource{
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
},
},
{
Action: "FIND",
Resources: []matlas.Resource{
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
},
},
{
Action: "INSERT",
Resources: []matlas.Resource{
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
},
},
Expand All @@ -330,7 +330,7 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_MultipleCustomRoles(t *testing.T)
Action: "REMOVE",
Resources: []matlas.Resource{
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
},
},
Expand Down Expand Up @@ -489,18 +489,18 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_UpdatedInheritRoles(t *testing.T)
Action: "REMOVE",
Resources: []matlas.Resource{
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
},
},
{
Action: "FIND",
Resources: []matlas.Resource{
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
},
},
Expand All @@ -514,29 +514,29 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_UpdatedInheritRoles(t *testing.T)
Action: "UPDATE",
Resources: []matlas.Resource{
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
},
},
{
Action: "FIND",
Resources: []matlas.Resource{
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
},
},
{
Action: "INSERT",
Resources: []matlas.Resource{
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
{
Db: fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5)),
DB: pointy.String(fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))),
},
},
},
Expand Down Expand Up @@ -735,9 +735,9 @@ func testAccMongoDBAtlasCustomDBRolesConfigWithInheritedRoles(projectID string,
}
}
`, projectID,
inheritedRole[0].RoleName, inheritedRole[0].Actions[0].Action, inheritedRole[0].Actions[0].Resources[0].Db,
inheritedRole[0].RoleName, inheritedRole[0].Actions[0].Action, *inheritedRole[0].Actions[0].Resources[0].DB,
inheritedRole[1].RoleName, inheritedRole[1].Actions[0].Action, *inheritedRole[1].Actions[0].Resources[0].Cluster,
testRole.RoleName, testRole.Actions[0].Action, testRole.Actions[0].Resources[0].Db,
testRole.RoleName, testRole.Actions[0].Action, *testRole.Actions[0].Resources[0].DB,
)
}

Expand All @@ -758,7 +758,7 @@ func testAccMongoDBAtlasCustomDBRolesConfigMultiple(projectID string, inheritedR
collection_name = ""
database_name = "%s"
}
`, r.Db)
`, *r.DB)
}

// get the actions and set the resources
Expand Down