Skip to content

Commit

Permalink
INTMDB-328: Update resource & data source to address change in go SDK…
Browse files Browse the repository at this point in the history
… that impacts resource_mongodbatlas_x509_authentication_database_user (#738)

* Chore(deps): Bump actions/setup-go from 2 to 3 (#710)

Bumps [actions/setup-go](https://github.com/actions/setup-go) from 2 to 3.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](actions/setup-go@v2...v3)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Chore(deps): Bump github.com/gruntwork-io/terratest (#711)

Bumps [github.com/gruntwork-io/terratest](https://github.com/gruntwork-io/terratest) from 0.40.6 to 0.40.7.
- [Release notes](https://github.com/gruntwork-io/terratest/releases)
- [Commits](gruntwork-io/terratest@v0.40.6...v0.40.7)

---
updated-dependencies:
- dependency-name: github.com/gruntwork-io/terratest
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Chore(deps): Bump hashicorp/setup-terraform from 1 to 2 (#719)

Bumps [hashicorp/setup-terraform](https://github.com/hashicorp/setup-terraform) from 1 to 2.
- [Release notes](https://github.com/hashicorp/setup-terraform/releases)
- [Changelog](https://github.com/hashicorp/setup-terraform/blob/main/CHANGELOG.md)
- [Commits](hashicorp/setup-terraform@v1...v2)

---
updated-dependencies:
- dependency-name: hashicorp/setup-terraform
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Chore(deps): Bump github.com/hashicorp/terraform-plugin-sdk/v2 (#720)

Bumps [github.com/hashicorp/terraform-plugin-sdk/v2](https://github.com/hashicorp/terraform-plugin-sdk) from 2.12.0 to 2.14.0.
- [Release notes](https://github.com/hashicorp/terraform-plugin-sdk/releases)
- [Changelog](https://github.com/hashicorp/terraform-plugin-sdk/blob/main/CHANGELOG.md)
- [Commits](hashicorp/terraform-plugin-sdk@v2.12.0...v2.14.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/terraform-plugin-sdk/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Chore(deps): Bump github.com/hashicorp/terraform-plugin-sdk/v2 (#727)

Bumps [github.com/hashicorp/terraform-plugin-sdk/v2](https://github.com/hashicorp/terraform-plugin-sdk) from 2.14.0 to 2.16.0.
- [Release notes](https://github.com/hashicorp/terraform-plugin-sdk/releases)
- [Changelog](https://github.com/hashicorp/terraform-plugin-sdk/blob/main/CHANGELOG.md)
- [Commits](hashicorp/terraform-plugin-sdk@v2.14.0...v2.16.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/terraform-plugin-sdk/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Chore(deps): Bump github.com/gruntwork-io/terratest (#726)

Bumps [github.com/gruntwork-io/terratest](https://github.com/gruntwork-io/terratest) from 0.40.7 to 0.40.8.
- [Release notes](https://github.com/gruntwork-io/terratest/releases)
- [Commits](gruntwork-io/terratest@v0.40.7...v0.40.8)

---
updated-dependencies:
- dependency-name: github.com/gruntwork-io/terratest
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Chore(deps): Bump github.com/spf13/cast from 1.4.1 to 1.5.0 (#730)

Bumps [github.com/spf13/cast](https://github.com/spf13/cast) from 1.4.1 to 1.5.0.
- [Release notes](https://github.com/spf13/cast/releases)
- [Commits](spf13/cast@v1.4.1...v1.5.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/cast
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Add default empty option list to fix breaking change for X509 certificates library function

* Remove empty options := matlas.ListOptions

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
martinstibbe and dependabot[bot] authored May 27, 2022
1 parent 5d6b7cb commit 6bc4c37
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/automated-test-acceptances.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.16
- name: Acceptance Tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/automated-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.16
- name: Website
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fetch-depth: 0
# See also: https://github.com/actions/setup-go/pull/62
- run: echo "GO_VERSION=$(cat .go-version)" >> $GITHUB_ENV
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: 1.16
- name: go build
Expand All @@ -36,7 +36,7 @@ jobs:
cp terraform-plugin-dir/terraform-provider-mongodbatlas-dev_v99.99.99_x5 ~/.terraform.d/plugins/registry.terraform.io/hashicorp/mongodbatlas-dev/99.99.99/$(go env GOOS)_$(go env GOARCH)/
- name: replace names of provider for local development
run: grep --include=\*.tf -rnl './examples' -e 'source = "mongodb/mongodbatlas"' | xargs sed -i s@mongodb/mongodbatlas@hashicorp/mongodbatlas-dev@g
- uses: hashicorp/setup-terraform@v1
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ matrix.terraform_version }}
# Needed to use the output of `terraform validate -json`
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.17
- name: golangci-lint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
run: git fetch --prune --unshallow
-
name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.16
-
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ go 1.16

require (
github.com/go-test/deep v1.0.8
github.com/gruntwork-io/terratest v0.40.6
github.com/hashicorp/terraform-plugin-sdk/v2 v2.12.0
github.com/gruntwork-io/terratest v0.40.8
github.com/hashicorp/terraform-plugin-sdk/v2 v2.16.0
github.com/hashicorp/terraform-provider-google v1.20.1-0.20210625223728-379bcb41c06b
github.com/mongodb-forks/digest v1.0.3
github.com/mwielbut/pointy v1.1.0
github.com/spf13/cast v1.4.1
github.com/spf13/cast v1.5.0
github.com/terraform-providers/terraform-provider-aws v1.60.1-0.20210625132053-af2d5c0ad54f
go.mongodb.org/atlas v0.15.1-0.20220403193624-86b34ba344cd
go.mongodb.org/atlas v0.16.1-0.20220518082525-1080bb496bd4
go.mongodb.org/realm v0.1.0
)
60 changes: 35 additions & 25 deletions go.sum

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func dataSourceMongoDBAtlasX509AuthDBUserRead(ctx context.Context, d *schema.Res
username := d.Get("username").(string)

if username != "" {
certificates, _, err := conn.X509AuthDBUsers.GetUserCertificates(ctx, projectID, username)
certificates, _, err := conn.X509AuthDBUsers.GetUserCertificates(ctx, projectID, username, nil)
if err != nil {
return diag.FromErr(fmt.Errorf(errorX509AuthDBUsersRead, username, projectID, err))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func resourceMongoDBAtlasX509AuthDBUserRead(ctx context.Context, d *schema.Resou
)

if username != "" {
certificates, _, err = conn.X509AuthDBUsers.GetUserCertificates(ctx, projectID, username)
certificates, _, err = conn.X509AuthDBUsers.GetUserCertificates(ctx, projectID, username, nil)
if err != nil {
// new resource missing
reset := strings.Contains(err.Error(), "404") && !d.IsNewResource()
Expand Down Expand Up @@ -200,7 +200,7 @@ func resourceMongoDBAtlasX509AuthDBUserImportState(ctx context.Context, d *schem
projectID := parts[0]

if username != "" {
_, _, err := conn.X509AuthDBUsers.GetUserCertificates(ctx, projectID, username)
_, _, err := conn.X509AuthDBUsers.GetUserCertificates(ctx, projectID, username, nil)
if err != nil {
return nil, fmt.Errorf(errorX509AuthDBUsersRead, username, projectID, err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func testAccCheckMongoDBAtlasX509AuthDBUserExists(resourceName string) resource.

ids := decodeStateID(rs.Primary.ID)
if ids["current_certificate"] != "" {
if _, _, err := conn.X509AuthDBUsers.GetUserCertificates(context.Background(), ids["project_id"], ids["username"]); err == nil {
if _, _, err := conn.X509AuthDBUsers.GetUserCertificates(context.Background(), ids["project_id"], ids["username"], nil); err == nil {
return nil
}

Expand All @@ -210,7 +210,7 @@ func testAccCheckMongoDBAtlasX509AuthDBUserDestroy(s *terraform.State) error {
ids := decodeStateID(rs.Primary.ID)

if ids["current_certificate"] != "" {
_, _, err := conn.X509AuthDBUsers.GetUserCertificates(context.Background(), ids["project_id"], ids["username"])
_, _, err := conn.X509AuthDBUsers.GetUserCertificates(context.Background(), ids["project_id"], ids["username"], nil)
if err == nil {
/*
There is no way to remove one user certificate so until this comes it will keep in this way
Expand Down

0 comments on commit 6bc4c37

Please sign in to comment.