From 1fcff25a7936157a70eeab4de7f18f75373c2a72 Mon Sep 17 00:00:00 2001 From: coderGo93 Date: Tue, 27 Jul 2021 15:12:33 -0600 Subject: [PATCH] INTMDB-183: Migrate to TF SDK 2 (#489) * initial migrate sdk v2 * refactor: deleted maxitems for datasource because it's bad practice for make test * refactor: changed typemap to typelist for datasource and resources because it's bad practice for make test and not supported in sdk v2 * refactor: changed Provider to ProviderFactories in tests * updated name of funcs for sdk v2 * refactor: changed Provider to ProviderFactories in tests * refactor: get the old fields of typemap because of possibly of future issues related to state * docs: updated upgrade guide for migration * fixes bug * fixes linter * fixes linter * fixes linter * fixes bug for restore job * fixes bug * refactor: changed create without timeout to normal * refactor: changed to context without timeout for cluster resource since it can take a while usually depending of the case * fix: fixes some testacc * fixes linter * docs: updated changes suggested by melissa * refactor: made changes suggested by tony * migrated event triggers * fix: random error related to client * fixes import for search Co-authored-by: Edgar Lopez --- .../workflows/automated-test-acceptances.yml | 2 +- .github/workflows/automated-test.yml | 2 +- .../aws/aws-roles.tf | 4 +- .../atlas-cloud-provider-access/aws/main.tf | 2 +- examples/atlas-dataLake-roles/aws-roles.tf | 4 +- .../atlas-dataLake-roles/import/aws-roles.tf | 4 +- examples/atlas-dataLake-roles/import/main.tf | 2 +- examples/atlas-dataLake-roles/main.tf | 2 +- .../atlas-encryption-at-rest/aws/aws-roles.tf | 4 +- examples/atlas-encryption-at-rest/aws/main.tf | 2 +- .../snapshot-restore/main.tf | 2 +- go.mod | 9 +- go.sum | 909 +++++++++++++----- .../resource_mongodbatlas_data_lake_test.go | 2 +- integration-testing/test-upgrades_test.go | 2 +- main.go | 26 +- mongodbatlas/config.go | 18 +- ...source_mongodbatlas_alert_configuration.go | 51 +- ...e_mongodbatlas_alert_configuration_test.go | 18 +- .../data_source_mongodbatlas_auditing.go | 19 +- .../data_source_mongodbatlas_auditing_test.go | 6 +- ...urce_mongodbatlas_cloud_provider_access.go | 15 +- ...ongodbatlas_cloud_provider_access_setup.go | 28 +- ...batlas_cloud_provider_access_setup_test.go | 8 +- ...mongodbatlas_cloud_provider_access_test.go | 8 +- ...ce_mongodbatlas_cloud_provider_snapshot.go | 29 +- ...s_cloud_provider_snapshot_backup_policy.go | 25 +- ...ud_provider_snapshot_backup_policy_test.go | 8 +- ...las_cloud_provider_snapshot_restore_job.go | 39 +- ...loud_provider_snapshot_restore_job_test.go | 11 +- ...as_cloud_provider_snapshot_restore_jobs.go | 17 +- ...oud_provider_snapshot_restore_jobs_test.go | 16 +- ...ngodbatlas_cloud_provider_snapshot_test.go | 8 +- ...e_mongodbatlas_cloud_provider_snapshots.go | 17 +- ...godbatlas_cloud_provider_snapshots_test.go | 12 +- .../data_source_mongodbatlas_cluster.go | 86 +- .../data_source_mongodbatlas_cluster_test.go | 10 +- .../data_source_mongodbatlas_clusters.go | 37 +- .../data_source_mongodbatlas_clusters_test.go | 10 +- ...data_source_mongodbatlas_custom_db_role.go | 17 +- ...source_mongodbatlas_custom_db_role_test.go | 10 +- ...ata_source_mongodbatlas_custom_db_roles.go | 15 +- ...ource_mongodbatlas_custom_db_roles_test.go | 10 +- ...as_custom_dns_configuration_cluster_aws.go | 13 +- ...stom_dns_configuration_cluster_aws_test.go | 6 +- .../data_source_mongodbatlas_data_lake.go | 26 +- ...data_source_mongodbatlas_data_lake_test.go | 14 +- .../data_source_mongodbatlas_data_lakes.go | 20 +- ...ata_source_mongodbatlas_data_lakes_test.go | 6 +- .../data_source_mongodbatlas_database_user.go | 31 +- ..._source_mongodbatlas_database_user_test.go | 8 +- ...data_source_mongodbatlas_database_users.go | 17 +- ...source_mongodbatlas_database_users_test.go | 8 +- .../data_source_mongodbatlas_event_trigger.go | 49 +- ..._source_mongodbatlas_event_trigger_test.go | 10 +- ...data_source_mongodbatlas_event_triggers.go | 8 +- ...source_mongodbatlas_event_triggers_test.go | 8 +- ...urce_mongodbatlas_global_cluster_config.go | 15 +- ...mongodbatlas_global_cluster_config_test.go | 10 +- ..._source_mongodbatlas_ldap_configuration.go | 29 +- ...ce_mongodbatlas_ldap_configuration_test.go | 10 +- .../data_source_mongodbatlas_ldap_verify.go | 25 +- ...ta_source_mongodbatlas_ldap_verify_test.go | 10 +- ..._source_mongodbatlas_maintenance_window.go | 19 +- ...ce_mongodbatlas_maintenance_window_test.go | 6 +- ...a_source_mongodbatlas_network_container.go | 35 +- ...rce_mongodbatlas_network_container_test.go | 16 +- ..._source_mongodbatlas_network_containers.go | 15 +- ...ce_mongodbatlas_network_containers_test.go | 16 +- ...ata_source_mongodbatlas_network_peering.go | 51 +- ...ource_mongodbatlas_network_peering_test.go | 8 +- ...ta_source_mongodbatlas_network_peerings.go | 15 +- ...urce_mongodbatlas_network_peerings_test.go | 8 +- ...data_source_mongodbatlas_online_archive.go | 32 +- ...ource_mongodbatlas_privatelink_endpoint.go | 27 +- ...ngodbatlas_privatelink_endpoint_service.go | 19 +- ...atlas_privatelink_endpoint_service_test.go | 6 +- ..._mongodbatlas_privatelink_endpoint_test.go | 6 +- .../data_source_mongodbatlas_project.go | 27 +- ...rce_mongodbatlas_project_ip_access_list.go | 25 +- ...ongodbatlas_project_ip_access_list_test.go | 16 +- .../data_source_mongodbatlas_project_test.go | 12 +- .../data_source_mongodbatlas_projects.go | 23 +- .../data_source_mongodbatlas_projects_test.go | 12 +- .../data_source_mongodbatlas_search_index.go | 2 +- ...a_source_mongodbatlas_search_index_test.go | 4 +- ...data_source_mongodbatlas_search_indexes.go | 4 +- ...source_mongodbatlas_search_indexes_test.go | 4 +- mongodbatlas/data_source_mongodbatlas_team.go | 25 +- .../data_source_mongodbatlas_team_test.go | 16 +- ...ce_mongodbatlas_third_party_integration.go | 13 +- ...ngodbatlas_third_party_integration_test.go | 8 +- ...e_mongodbatlas_third_party_integrations.go | 15 +- ...godbatlas_third_party_integrations_test.go | 6 +- ...atlas_x509_authentication_database_user.go | 19 +- ..._x509_authentication_database_user_test.go | 8 +- mongodbatlas/provider.go | 43 +- mongodbatlas/provider_test.go | 33 +- ...source_mongodbatlas_alert_configuration.go | 198 +++- ...e_mongodbatlas_alert_configuration_test.go | 68 +- .../resource_mongodbatlas_auditing.go | 41 +- .../resource_mongodbatlas_auditing_test.go | 16 +- ...urce_mongodbatlas_cloud_provider_access.go | 49 +- ...las_cloud_provider_access_authorization.go | 68 +- ...ongodbatlas_cloud_provider_access_setup.go | 59 +- ...batlas_cloud_provider_access_setup_test.go | 14 +- ...mongodbatlas_cloud_provider_access_test.go | 18 +- ...ce_mongodbatlas_cloud_provider_snapshot.go | 70 +- ...s_cloud_provider_snapshot_backup_policy.go | 63 +- ...ud_provider_snapshot_backup_policy_test.go | 24 +- ...las_cloud_provider_snapshot_restore_job.go | 293 ++++-- ...loud_provider_snapshot_restore_job_test.go | 36 +- ...ngodbatlas_cloud_provider_snapshot_test.go | 18 +- mongodbatlas/resource_mongodbatlas_cluster.go | 211 ++-- .../resource_mongodbatlas_cluster_migrate.go | 8 +- ...rce_mongodbatlas_cluster_migration_test.go | 32 +- .../resource_mongodbatlas_cluster_test.go | 138 +-- .../resource_mongodbatlas_custom_db_role.go | 63 +- ...source_mongodbatlas_custom_db_role_test.go | 42 +- ...as_custom_dns_configuration_cluster_aws.go | 44 +- ...stom_dns_configuration_cluster_aws_test.go | 16 +- .../resource_mongodbatlas_data_lake.go | 80 +- .../resource_mongodbatlas_data_lake_test.go | 26 +- .../resource_mongodbatlas_database_user.go | 70 +- ...esource_mongodbatlas_database_user_test.go | 84 +- ...esource_mongodbatlas_encryption_at_rest.go | 349 ++++++- ...ce_mongodbatlas_encryption_at_rest_test.go | 39 +- .../resource_mongodbatlas_event_trigger.go | 87 +- ...esource_mongodbatlas_event_trigger_test.go | 42 +- ...urce_mongodbatlas_global_cluster_config.go | 69 +- ...mongodbatlas_global_cluster_config_test.go | 53 +- ...esource_mongodbatlas_ldap_configuration.go | 53 +- ...ce_mongodbatlas_ldap_configuration_test.go | 24 +- .../resource_mongodbatlas_ldap_verify.go | 56 +- .../resource_mongodbatlas_ldap_verify_test.go | 24 +- ...esource_mongodbatlas_maintenance_window.go | 55 +- ...ce_mongodbatlas_maintenance_window_test.go | 16 +- ...resource_mongodbatlas_network_container.go | 84 +- ...rce_mongodbatlas_network_container_test.go | 36 +- .../resource_mongodbatlas_network_peering.go | 144 +-- ...ource_mongodbatlas_network_peering_test.go | 28 +- .../resource_mongodbatlas_online_archive.go | 62 +- ...source_mongodbatlas_online_archive_test.go | 19 +- .../resource_mongodbatlas_private_ip_mode.go | 38 +- ...ource_mongodbatlas_private_ip_mode_test.go | 10 +- ...ource_mongodbatlas_privatelink_endpoint.go | 74 +- ...ngodbatlas_privatelink_endpoint_service.go | 72 +- ...atlas_privatelink_endpoint_service_test.go | 16 +- ..._mongodbatlas_privatelink_endpoint_test.go | 28 +- mongodbatlas/resource_mongodbatlas_project.go | 65 +- ...rce_mongodbatlas_project_ip_access_list.go | 49 +- ...ongodbatlas_project_ip_access_list_test.go | 36 +- .../resource_mongodbatlas_project_test.go | 24 +- .../resource_mongodbatlas_search_index.go | 2 +- ...resource_mongodbatlas_search_index_test.go | 6 +- mongodbatlas/resource_mongodbatlas_team.go | 73 +- .../resource_mongodbatlas_team_test.go | 18 +- ...ce_mongodbatlas_third_party_integration.go | 53 +- ...ngodbatlas_third_party_integration_test.go | 22 +- ...atlas_x509_authentication_database_user.go | 46 +- ..._x509_authentication_database_user_test.go | 32 +- .../docs/d/alert_configuration.html.markdown | 8 +- ...rovider_snapshot_restore_job.html.markdown | 2 +- ...ovider_snapshot_restore_jobs.html.markdown | 2 +- website/docs/d/data_lake.html.markdown | 4 +- website/docs/d/data_lakes.html.markdown | 4 +- .../guides/1.0.0-upgrade-guide.html.markdown | 149 +++ .../docs/r/alert_configuration.html.markdown | 8 +- website/docs/r/cloud_provider_access.markdown | 2 +- .../r/cloud_provider_snapshot.html.markdown | 2 +- ...rovider_snapshot_restore_job.html.markdown | 6 +- website/docs/r/data_lake.html.markdown | 4 +- .../docs/r/encryption_at_rest.html.markdown | 12 +- 173 files changed, 3830 insertions(+), 2569 deletions(-) diff --git a/.github/workflows/automated-test-acceptances.yml b/.github/workflows/automated-test-acceptances.yml index 63ee4d09bd..66415ae949 100644 --- a/.github/workflows/automated-test-acceptances.yml +++ b/.github/workflows/automated-test-acceptances.yml @@ -34,7 +34,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.14 + go-version: 1.16 - name: Acceptance Tests env: SKIP_TEST_EXTERNAL_CREDENTIALS: ${{ secrets.SKIP_TEST_EXTERNAL_CREDENTIALS }} diff --git a/.github/workflows/automated-test.yml b/.github/workflows/automated-test.yml index 5498962d60..fde9e323f4 100644 --- a/.github/workflows/automated-test.yml +++ b/.github/workflows/automated-test.yml @@ -11,7 +11,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.14 + go-version: 1.16 - name: Code Lint run: make tools && make lint - name: Website diff --git a/examples/atlas-cloud-provider-access/aws/aws-roles.tf b/examples/atlas-cloud-provider-access/aws/aws-roles.tf index 6ed5b48b23..b3019de6c4 100644 --- a/examples/atlas-cloud-provider-access/aws/aws-roles.tf +++ b/examples/atlas-cloud-provider-access/aws/aws-roles.tf @@ -26,12 +26,12 @@ resource "aws_iam_role" "test_role" { { "Effect": "Allow", "Principal": { - "AWS": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_aws_account_arn}" + "AWS": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.0.atlas_aws_account_arn}" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { - "sts:ExternalId": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_assumed_role_external_id}" + "sts:ExternalId": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.0.atlas_assumed_role_external_id}" } } } diff --git a/examples/atlas-cloud-provider-access/aws/main.tf b/examples/atlas-cloud-provider-access/aws/main.tf index 08789b657c..ed484154fa 100644 --- a/examples/atlas-cloud-provider-access/aws/main.tf +++ b/examples/atlas-cloud-provider-access/aws/main.tf @@ -7,7 +7,7 @@ resource "mongodbatlas_cloud_provider_access_authorization" "auth_role" { project_id = var.project_id role_id = mongodbatlas_cloud_provider_access_setup.setup_only.role_id - aws = { + aws { iam_assumed_role_arn = aws_iam_role.test_role.arn } } diff --git a/examples/atlas-dataLake-roles/aws-roles.tf b/examples/atlas-dataLake-roles/aws-roles.tf index 2fb2ef005f..4bd1d18205 100644 --- a/examples/atlas-dataLake-roles/aws-roles.tf +++ b/examples/atlas-dataLake-roles/aws-roles.tf @@ -26,12 +26,12 @@ resource "aws_iam_role" "test_role" { { "Effect": "Allow", "Principal": { - "AWS": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_aws_account_arn}" + "AWS": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.0.atlas_aws_account_arn}" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { - "sts:ExternalId": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_assumed_role_external_id}" + "sts:ExternalId": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.0.atlas_assumed_role_external_id}" } } } diff --git a/examples/atlas-dataLake-roles/import/aws-roles.tf b/examples/atlas-dataLake-roles/import/aws-roles.tf index 898fabac11..09929f81ce 100644 --- a/examples/atlas-dataLake-roles/import/aws-roles.tf +++ b/examples/atlas-dataLake-roles/import/aws-roles.tf @@ -26,12 +26,12 @@ resource "aws_iam_role" "test_role" { { "Effect": "Allow", "Principal": { - "AWS": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_aws_account_arn}" + "AWS": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.0.atlas_aws_account_arn}" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { - "sts:ExternalId": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_assumed_role_external_id}" + "sts:ExternalId": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.0.atlas_assumed_role_external_id}" } } } diff --git a/examples/atlas-dataLake-roles/import/main.tf b/examples/atlas-dataLake-roles/import/main.tf index f337c7026d..9ec48c5778 100644 --- a/examples/atlas-dataLake-roles/import/main.tf +++ b/examples/atlas-dataLake-roles/import/main.tf @@ -13,7 +13,7 @@ resource "mongodbatlas_cloud_provider_access_authorization" "auth_role" { project_id = mongodbatlas_project.test.id role_id = mongodbatlas_cloud_provider_access_setup.setup_only.role_id - aws = { + aws { iam_assumed_role_arn = aws_iam_role.test_role.arn } } diff --git a/examples/atlas-dataLake-roles/main.tf b/examples/atlas-dataLake-roles/main.tf index b257264949..043d7aaccc 100644 --- a/examples/atlas-dataLake-roles/main.tf +++ b/examples/atlas-dataLake-roles/main.tf @@ -13,7 +13,7 @@ resource "mongodbatlas_cloud_provider_access_authorization" "auth_role" { project_id = mongodbatlas_project.test.id role_id = mongodbatlas_cloud_provider_access_setup.setup_only.role_id - aws = { + aws { iam_assumed_role_arn = aws_iam_role.test_role.arn } } diff --git a/examples/atlas-encryption-at-rest/aws/aws-roles.tf b/examples/atlas-encryption-at-rest/aws/aws-roles.tf index 6ed5b48b23..b3019de6c4 100644 --- a/examples/atlas-encryption-at-rest/aws/aws-roles.tf +++ b/examples/atlas-encryption-at-rest/aws/aws-roles.tf @@ -26,12 +26,12 @@ resource "aws_iam_role" "test_role" { { "Effect": "Allow", "Principal": { - "AWS": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_aws_account_arn}" + "AWS": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.0.atlas_aws_account_arn}" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { - "sts:ExternalId": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_assumed_role_external_id}" + "sts:ExternalId": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.0.atlas_assumed_role_external_id}" } } } diff --git a/examples/atlas-encryption-at-rest/aws/main.tf b/examples/atlas-encryption-at-rest/aws/main.tf index cf7f1c7138..5461bc7fa9 100644 --- a/examples/atlas-encryption-at-rest/aws/main.tf +++ b/examples/atlas-encryption-at-rest/aws/main.tf @@ -7,7 +7,7 @@ resource "mongodbatlas_cloud_provider_access_authorization" "auth_role" { project_id = var.project_id role_id = mongodbatlas_cloud_provider_access_setup.setup_only.role_id - aws = { + aws { iam_assumed_role_arn = aws_iam_role.test_role.arn } } diff --git a/examples/test-upgrade/v100/design-id-reference/snapshot-restore/main.tf b/examples/test-upgrade/v100/design-id-reference/snapshot-restore/main.tf index 326255eb3a..11ea4d1d4f 100644 --- a/examples/test-upgrade/v100/design-id-reference/snapshot-restore/main.tf +++ b/examples/test-upgrade/v100/design-id-reference/snapshot-restore/main.tf @@ -26,7 +26,7 @@ resource "mongodbatlas_cloud_provider_snapshot_restore_job" "test" { project_id = data.mongodbatlas_project.test.id cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name snapshot_id = mongodbatlas_cloud_provider_snapshot.test.id - delivery_type = { + delivery_type { download = true } } diff --git a/go.mod b/go.mod index c371115e7b..120731d418 100644 --- a/go.mod +++ b/go.mod @@ -1,17 +1,18 @@ module github.com/mongodb/terraform-provider-mongodbatlas -go 1.14 +go 1.16 require ( github.com/client9/misspell v0.3.4 github.com/go-test/deep v1.0.7 github.com/gruntwork-io/terratest v0.32.20 - github.com/hashicorp/terraform-plugin-sdk v1.14.0 + github.com/hashicorp/hcl/v2 v2.10.0 // indirect + github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.0 + github.com/hashicorp/terraform-provider-google v1.20.1-0.20210625223728-379bcb41c06b github.com/mongodb-forks/digest v1.0.1 github.com/mwielbut/pointy v1.1.0 github.com/spf13/cast v1.3.1 - github.com/terraform-providers/terraform-provider-aws v1.60.1-0.20200518153306-40099de47e37 - github.com/terraform-providers/terraform-provider-google v1.20.1-0.20200518165017-1dd21651c496 + github.com/terraform-providers/terraform-provider-aws v1.60.1-0.20210625132053-af2d5c0ad54f go.mongodb.org/atlas v0.10.0 go.mongodb.org/realm v0.0.0-20210618220639-e70c919266f2 ) diff --git a/go.sum b/go.sum index e057876828..59df4b8231 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,7 @@ +4d63.com/gochecknoglobals v0.0.0-20201008074935-acfc0b28355a/go.mod h1:wfdC5ZjKSPr7CybKEcgJhUOgeAQW1+7WcyK8OvUilfo= +bitbucket.org/creachadair/shell v0.0.6/go.mod h1:8Qqi/cYk7vPnsOePHroKXDJYmb5x7ENhtiFtfZq8K+M= +bitbucket.org/creachadair/stringset v0.0.8 h1:gQqe4vs8XWgMyijfyKE6K8o4TcyGGrRXe0JvHgx5H+M= +bitbucket.org/creachadair/stringset v0.0.8/go.mod h1:AgthVMyMxC/6FK1KBJ2ALdqkZObGN8hOetgpwXyMn34= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= @@ -9,25 +13,52 @@ cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6T cloud.google.com/go v0.51.0/go.mod h1:hWtGJ6gnXH+KgDv+V0zFGDvpi07n3z8ZNj3T1RW0Gcw= cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= cloud.google.com/go v0.56.0 h1:WRz29PgAsVEyPSDHyk+0fpEkwEFyfhHn+JbksT6gIL4= cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.60.0/go.mod h1:yw2G51M9IfRboUH61Us8GqCeF1PzPblB823Mn2q2eAU= +cloud.google.com/go v0.61.0/go.mod h1:XukKJg4Y7QsUu0Hxg3qQKUWR4VuWivmyMK2+rUyxAqw= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= +cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= +cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= +cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= +cloud.google.com/go v0.82.0/go.mod h1:vlKccHJGuFBFufnAnuB08dfEH9Y3H7dzDzRECFdC2TA= +cloud.google.com/go v0.83.0 h1:bAMqZidYkmIsUqe6PtkEPT7Q+vfizScn+jfNA6jwK9c= +cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0 h1:xE3CPsOgttP4ACBePh79zTKALtXwn/Edhcr16R5hMWU= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/bigtable v1.1.0 h1:+IakvK2mFz1FbfA9Ti0JoKRPiJkORngh9xhfMbVkJqw= cloud.google.com/go/bigtable v1.1.0/go.mod h1:B6ByKcIdYmhoyDzmOnQxyOhN6r05qnewYIxxG6L0/b4= +cloud.google.com/go/bigtable v1.10.1 h1:QKcRHeAsraxIlrdCZ3LLobXKBvITqcOEnSbHG2rzL9g= +cloud.google.com/go/bigtable v1.10.1/go.mod h1:cyHeKlx6dcZCO0oSQucYdauseD8kIENGuDOJPKMCVg8= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0 h1:/May9ojXjRkPBNVrq+oWLqmWCkr4OU5uRY29bu0mRyQ= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0 h1:Lpy6hKgdcl7a3WGSfJIFmxmcdjSpP6OmBEfcOv1Y680= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/pubsub v1.5.0/go.mod h1:ZEwJccE3z93Z2HWvstpri00jOg7oO4UZDtKhwDwqF0w= +cloud.google.com/go/spanner v1.7.0/go.mod h1:sd3K2gZ9Fd0vMPLXzeCrF6fq4i63Q7aTLW/lBIfBkIk= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0 h1:UDpwYIwla4jHGzZJaEJYx1tOejbgSoNqsAfHAUYe2r8= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0 h1:STgFzyU5/8miMl0//zKh2aQeTyeaUH3WN9bSUiJ09bA= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +contrib.go.opencensus.io/exporter/stackdriver v0.13.4/go.mod h1:aXENhDJ1Y4lIg4EUaVTwzvYETVNZk10Pu26tevFKLUc= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/Azure/azure-sdk-for-go v35.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-sdk-for-go v38.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= @@ -67,65 +98,99 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Djarvur/go-err113 v0.0.0-20200410182137-af658d038157/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= +github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= +github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210623224421-7f5af5003bbb h1:9HBI5n77Z2ReBlOFk1h2JFLpY/HobH9Xaq90E7IjCpw= +github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20210623224421-7f5af5003bbb/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU= github.com/GoogleCloudPlatform/k8s-cloud-provider v0.0.0-20190822182118-27a4ced34534/go.mod h1:iroGtC8B3tQiqtds1l+mgk/BBOrxbqjH+eUfFQYRc14= +github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg= +github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= +github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/Masterminds/sprig v2.15.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= +github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60= +github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= +github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/OpenPeeDeeP/depguard v1.0.0/go.mod h1:7/4sitnI9YlQgTLLk734QlzXT8DuHVnAyztLplQjk+o= github.com/OpenPeeDeeP/depguard v1.0.1/go.mod h1:xsIw86fROiiwelg+jB2uM9PiKihMMmUx/1V+TNhjQvM= +github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= +github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 h1:w1UutsfOrms1J05zt7ISrnJIXKzwaspym5BTKGx93EI= github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0= +github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/apparentlymart/go-cidr v1.0.1 h1:NmIwLZ/KdsjIUlhf+/Np40atNXm/+lZ5txfTJ/SpF+U= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE= +github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= +github.com/andybalholm/crlf v0.0.0-20171020200849-670099aa064f/go.mod h1:k8feO4+kXDxro6ErPXBRTJ/ro2mf0SsFG8s7doP9kJE= +github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= +github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= +github.com/aokoli/goutils v1.0.1/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g9DP+DQ= github.com/apparentlymart/go-cidr v1.0.1/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= +github.com/apparentlymart/go-cidr v1.1.0 h1:2mAhrMoF+nhXqxTzSZMUzDHkLjmIHC+Zzn4tdgBZjnU= +github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= -github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= -github.com/apparentlymart/go-textseg/v12 v12.0.0 h1:bNEQyAGak9tojivJNkoqWErVCQbjdL7GzRt3F8NvfJ0= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= +github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= +github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= +github.com/ashanbrown/forbidigo v1.1.0/go.mod h1:vVW7PEdqEFqapJe95xHkTfB1+XvZXBFg8t0sG2FIxmI= +github.com/ashanbrown/makezero v0.0.0-20210308000810-4155955488a0/go.mod h1:oG9Dnez7/ESBqc4EdrdNlryeo7d0KcW1ftXHm7nU/UU= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= github.com/aws/aws-sdk-go v1.16.26/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.19.39/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.23.20/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.25.3/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.25.37/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.27.1/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.30.28 h1:SaPM7dlmp7h3Lj1nJ4jdzOkTdom08+g20k7AU5heZYg= -github.com/aws/aws-sdk-go v1.30.28/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= +github.com/aws/aws-sdk-go v1.31.9/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= +github.com/aws/aws-sdk-go v1.36.30/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= +github.com/aws/aws-sdk-go v1.37.0/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= +github.com/aws/aws-sdk-go v1.38.67 h1:OCeXMKiiM8X7HAKPCE5yD+t+sEsRaj8EwDs2tlgvX2c= +github.com/aws/aws-sdk-go v1.38.67/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs= github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/bflad/gopaniccheck v0.1.0/go.mod h1:ZCj2vSr7EqVeDaqVsWN4n2MwdROx1YL+LFo47TSWtsA= -github.com/bflad/tfproviderdocs v0.6.0/go.mod h1:W6wVZPtBa6V5bpjaK1eJAoVCL/7B4Amfrld0dro+fHU= -github.com/bflad/tfproviderlint v0.14.0/go.mod h1:1Jtjs6DPKoyqPrbPyMiy33h0ViO2h831uzoOuikCA60= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= +github.com/bkielbasa/cyclop v1.2.0/go.mod h1:qOI0yy6A7dYC4Zgsa72Ppm9kONl0RoIlPbzot9mhmeI= github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= -github.com/bmatcuk/doublestar v1.2.1/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= -github.com/bombsimon/wsl/v3 v3.0.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc= +github.com/bombsimon/wsl/v3 v3.3.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc= github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8WK8raXaxBx6fRVTlJILwEwQGL1I/ByEI= github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= -github.com/bsm/go-vlq v0.0.0-20150828105119-ec6e8d4f5f4e/go.mod h1:N+BjUcTjSxc2mtRGSCPsat1kze3CUtvJN3/jTXlp29k= +github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= +github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/charithe/durationcheck v0.0.6/go.mod h1:SSbRIBVfMjCi/kEB6K65XEA83D6prSM8ap1UCpNKtgg= +github.com/chavacava/garif v0.0.0-20210405163807-87a70f3d418b/go.mod h1:Qjyv4H3//PWVzTeCezG2b9IRn6myJxJSr4TD/xo6ojU= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= @@ -133,16 +198,20 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/containerd/containerd v1.3.0/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190620071333-e64a0ec8b42a/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180108230652-97fdf19511ea/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= @@ -151,16 +220,19 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/creachadair/staticfile v0.1.2/go.mod h1:a3qySzCIXEprDGxk6tSxSI+dBBdLzqeBOMhZ+o2d3pM= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/daixiang0/gci v0.2.8/go.mod h1:+4dZ7TISfSmqfAGv59ePaHfNzgGtIkHAhhdKggP1JAc= github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/denis-tingajkin/go-header v0.4.2/go.mod h1:eLRHAVXzE5atsKAnNRDB90WHCFFnBUn4RN0nRcs1LJA= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= -github.com/dnaeon/go-vcr v1.0.1 h1:r8L/HqC0Hje5AXMu1ooW8oyQyOFv4GxqpL0nRP7SLLY= github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= github.com/docker/cli v0.0.0-20191017083524-a8ff7f821017/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/cli v0.0.0-20200109221225-a4f60165b7a3/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= @@ -176,51 +248,68 @@ github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c/go.mod h1:Qh8CwZ github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dustinkirkland/golang-petname v0.0.0-20170105215008-242afa0b4f8a/go.mod h1:V+Qd57rJe8gd4eiGzZyg4h54VLHmYVVw54iMnlAMrF8= -github.com/dustinkirkland/golang-petname v0.0.0-20170921220637-d3c2ba80e75e h1:bRcq7ruHMqCVB/ugLbBylx+LrccNACFDEaqAD/aZ80Q= -github.com/dustinkirkland/golang-petname v0.0.0-20170921220637-d3c2ba80e75e/go.mod h1:V+Qd57rJe8gd4eiGzZyg4h54VLHmYVVw54iMnlAMrF8= github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= -github.com/elazarl/goproxy v0.0.0-20190911111923-ecfe977594f1 h1:yY9rWGoXv1U5pl4gxqlULARMQD7x0QG85lqEXTWysik= github.com/elazarl/goproxy v0.0.0-20190911111923-ecfe977594f1/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= -github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2 h1:dWB6v3RcOy03t/bUadywsbyrQwCqZeNIEX6M1OtSZOM= github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/protoc-gen-validate v0.0.14/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/esimonov/ifshort v1.0.2/go.mod h1:yZqNJUrNn20K8Q9n2CrjTKYyVEmX209Hgu+M1LBpeZE= +github.com/ettle/strcase v0.1.1/go.mod h1:hzDLsPC7/lwKyBOywSHEP89nt2pDgdy+No1NBA9o9VY= github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/fatih/color v1.6.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= +github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg= +github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= +github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94= +github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fullstorydev/grpcurl v1.6.0/go.mod h1:ZQ+ayqbKMJNhzLmbpCiurTVlaK2M/3nqZCxaQ2Ze/sM= +github.com/fzipp/gocyclo v0.3.1/go.mod h1:DJHO6AUmbdqj2ET4Z9iArSuwWgYDRryYt2wASxc7x3E= github.com/gammazero/deque v0.0.0-20180920172122-f6adf94963e4 h1:R+19WKQClnfMXS60cP5BmMe1wjZ4u0evY2p2Ar0ZTXo= github.com/gammazero/deque v0.0.0-20180920172122-f6adf94963e4/go.mod h1:GeIq9qoE43YdGnDXURnmKTnGg15pQz4mYkXSTChbneI= github.com/gammazero/workerpool v0.0.0-20181230203049-86a96b5d5d92 h1:EipXK6U05IQ2wtuFRn4k3h0+2lXypzItoXGVyf4r9Io= github.com/gammazero/workerpool v0.0.0-20181230203049-86a96b5d5d92/go.mod h1:w9RqFVO2BM3xwWEcAB8Fwp0OviTBBEiRmSBDfbXnd3w= github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-critic/go-critic v0.3.5-0.20190526074819-1df300866540/go.mod h1:+sE8vrLDS2M0pZkBk0wy6+nLdKexVDrl/jBqQOTDThA= -github.com/go-critic/go-critic v0.4.1/go.mod h1:7/14rZGnZbY6E38VEGk2kVhoq6itzc1E68facVDK23g= +github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= +github.com/go-critic/go-critic v0.5.6/go.mod h1:cVjj0DfqewQVIlIAGexPCaGaZDAqGE29PYDDADIVNEo= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-errors/errors v1.0.2-0.20180813162953-d98b870cc4e0 h1:skJKxRtNmevLqnayafdLe2AsenqRupVmzZSqrvb5caU= github.com/go-errors/errors v1.0.2-0.20180813162953-d98b870cc4e0/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= +github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= +github.com/go-git/go-billy/v5 v5.0.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= +github.com/go-git/go-billy/v5 v5.1.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= +github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= +github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= +github.com/go-git/go-git-fixtures/v4 v4.0.1/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw= +github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw= +github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= +github.com/go-git/go-git/v5 v5.1.0/go.mod h1:ZKfuPUoY1ZqIG4QG9BDBh3G4gLM5zvPuSJAozQrZuyM= +github.com/go-git/go-git/v5 v5.3.0/go.mod h1:xdX4bWJ48aOrdhnl2XqHYstHbbp6+LFS4r4X+lNVprw= +github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-lintpack/lintpack v0.5.2/go.mod h1:NwZuYi2nUHho8XEIZ6SIxihrnPoqBTDqfpXvXAN0sXM= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-logr/logr v0.2.0 h1:QvGt2nLcHH0WK9orKa+ppBPAxREcH364nPUedEpK0TY= github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= -github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= +github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= @@ -232,6 +321,7 @@ github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8 github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-redis/redis v6.15.8+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= @@ -242,26 +332,24 @@ github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M= github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= github.com/go-toolsmith/astcast v1.0.0/go.mod h1:mt2OdQTeAQcY4DQgPSArJjHCcOwlX+Wl/kwN+LbLGQ4= github.com/go-toolsmith/astcopy v1.0.0/go.mod h1:vrgyG+5Bxrnz4MZWPF+pI4R8h3qKRjjyvV/DSez4WVQ= -github.com/go-toolsmith/astequal v0.0.0-20180903214952-dcb477bfacd6/go.mod h1:H+xSiq0+LtiDC11+h1G32h7Of5O3CYFJ99GVbS5lDKY= github.com/go-toolsmith/astequal v1.0.0/go.mod h1:H+xSiq0+LtiDC11+h1G32h7Of5O3CYFJ99GVbS5lDKY= -github.com/go-toolsmith/astfmt v0.0.0-20180903215011-8f8ee99c3086/go.mod h1:mP93XdblcopXwlyN4X4uodxXQhldPGZbcEJIimQHrkg= github.com/go-toolsmith/astfmt v1.0.0/go.mod h1:cnWmsOAuq4jJY6Ct5YWlVLmcmLMn1JUPuQIHCY7CJDw= github.com/go-toolsmith/astinfo v0.0.0-20180906194353-9809ff7efb21/go.mod h1:dDStQCHtmZpYOmjRP/8gHHnCCch3Zz3oEgCdZVdtweU= -github.com/go-toolsmith/astp v0.0.0-20180903215135-0af7e3c24f30/go.mod h1:SV2ur98SGypH1UjcPpCatrV5hPazG6+IfNHbkDXBRrk= github.com/go-toolsmith/astp v1.0.0/go.mod h1:RSyrtpVlfTFGDYRbrjyWP1pYu//tSFcvdYrA8meBmLI= -github.com/go-toolsmith/pkgload v0.0.0-20181119091011-e9e65178eee8/go.mod h1:WoMrjiy4zvdS+Bg6z9jZH82QXwkcgCBX6nOfnmdaHks= github.com/go-toolsmith/pkgload v1.0.0/go.mod h1:5eFArkbO80v7Z0kdngIxsRXRMTaX4Ilcwuh3clNrQJc= github.com/go-toolsmith/strparse v1.0.0/go.mod h1:YI2nUKP9YGZnL/L1/DLFBfixrcjslWct4wyljWhSRy8= github.com/go-toolsmith/typep v1.0.0/go.mod h1:JSQCQMUPdRlMZFswiq3TGpNp1GMktqkR2Ns5AIQkATU= +github.com/go-toolsmith/typep v1.0.2/go.mod h1:JSQCQMUPdRlMZFswiq3TGpNp1GMktqkR2Ns5AIQkATU= github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/gofrs/flock v0.0.0-20190320160742-5135e617513b/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= +github.com/gofrs/flock v0.8.0/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -269,13 +357,14 @@ github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4er github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.0.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3 h1:GV+pQPG/EUUbkh47niozDcADz6go/dUwhVzdUQHIVRw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -290,39 +379,42 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2/go.mod h1:k9Qvh+8juN+UKMCS/3jFtGICgW8O96FVaZsaxdzDkR4= github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a/go.mod h1:ryS0uhF+x9jgbj/N71xsEqODy9BN81/GonCZiOzirOk= -github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6/go.mod h1:DbHgvLiFKX1Sh2T1w8Q/h4NAI8MHIpzCdnBUDTXU3I0= github.com/golangci/go-misc v0.0.0-20180628070357-927a3d87b613/go.mod h1:SyvUF2NxV+sN8upjjeVYr5W7tyxaT1JVtvhKhOn2ii8= -github.com/golangci/go-tools v0.0.0-20190318055746-e32c54105b7c/go.mod h1:unzUULGw35sjyOYjUt0jMTXqHlZPpPc6e+xfO4cd6mM= -github.com/golangci/goconst v0.0.0-20180610141641-041c5f2b40f3/go.mod h1:JXrF4TWy4tXYn62/9x8Wm/K/dm06p8tCKwFRDPZG/1o= -github.com/golangci/gocyclo v0.0.0-20180528134321-2becd97e67ee/go.mod h1:ozx7R9SIwqmqf5pRP90DhR2Oay2UIjGuKheCBCNwAYU= -github.com/golangci/gofmt v0.0.0-20181222123516-0b8337e80d98/go.mod h1:9qCChq59u/eW8im404Q2WWTrnBUQKjpNYKMbU4M7EFU= github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a/go.mod h1:9qCChq59u/eW8im404Q2WWTrnBUQKjpNYKMbU4M7EFU= -github.com/golangci/golangci-lint v1.18.0/go.mod h1:kaqo8l0OZKYPtjNmG4z4HrWLgcYNIJ9B9q3LWri9uLg= -github.com/golangci/golangci-lint v1.26.0/go.mod h1:tefbO6RcigFzvTnDC+Y51kntVGgkuCAVsC+mnfbPruc= -github.com/golangci/gosec v0.0.0-20190211064107-66fb7fc33547/go.mod h1:0qUabqiIQgfmlAmulqxyiGkkyF6/tOGSnY2cnPVwrzU= -github.com/golangci/ineffassign v0.0.0-20190609212857-42439a7714cc/go.mod h1:e5tpTHCfVze+7EpLEozzMB3eafxo2KT5veNg1k6byQU= -github.com/golangci/lint-1 v0.0.0-20190420132249-ee948d087217/go.mod h1:66R6K6P6VWk9I95jvqGxkqJxVWGFy9XlDwLwVz1RCFg= +github.com/golangci/golangci-lint v1.40.1/go.mod h1:OyFTr1muxaWeGTcHQcL3B7C4rETnDphTKYenZDgH2/g= github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0/go.mod h1:66R6K6P6VWk9I95jvqGxkqJxVWGFy9XlDwLwVz1RCFg= github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca/go.mod h1:tvlJhZqDe4LMs4ZHD0oMUlt9G2LWuDGoisJTBzLMV9o= -github.com/golangci/misspell v0.0.0-20180809174111-950f5d19e770/go.mod h1:dEbvlSfYbMQDtrpRMQU675gSDLDNa8sCPPChZ7PhiVA= -github.com/golangci/prealloc v0.0.0-20180630174525-215b22d4de21/go.mod h1:tf5+bzsHdTM0bsB7+8mt0GUMvjCgwLpTapNZHU8AajI= -github.com/golangci/revgrep v0.0.0-20180526074752-d9c87f5ffaf0/go.mod h1:qOQCunEYvmd/TLamH+7LlVccLvUH5kZNhbCgTHoBbp4= +github.com/golangci/misspell v0.3.5/go.mod h1:dEbvlSfYbMQDtrpRMQU675gSDLDNa8sCPPChZ7PhiVA= +github.com/golangci/revgrep v0.0.0-20210208091834-cd28932614b5/go.mod h1:LK+zW4MpyytAWQRz0M4xnzEk50lSvqDQKfx304apFkY= github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4/go.mod h1:Izgrg8RkN3rCIMLGE9CyYmU9pY2Jer6DgANEnZ/L/cQ= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= +github.com/google/certificate-transparency-go v1.0.21/go.mod h1:QeJfpSbVSfYc7RgB3gJFj9cbuQMMchQxrWXz8Ruopmg= +github.com/google/certificate-transparency-go v1.1.1/go.mod h1:FDKqPvSXawb2ecErVRrD+nfy23RCzyl7eqVCEmlT1Zs= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-containerregistry v0.0.0-20200110202235-f4fb41bf00a3/go.mod h1:2wIuQute9+hhWqvL3vEI7YB0EKluF4WcPzI1eAliazk= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= @@ -330,17 +422,31 @@ github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200507031123-427632fa3b1c/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210506205249-923b5ab0fc1a/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/trillian v1.3.11/go.mod h1:0tPraVHrSDkA3BO6vKX67zgLXs6SsOAbHEivX+9mPgw= +github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= @@ -348,111 +454,174 @@ github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsC github.com/googleapis/gnostic v0.2.2/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/googleapis/gnostic v0.4.1 h1:DLJCy1n/vrD4HPjOvYcT8aYQXpPIzoRZONaYwyycI+I= github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3ir6b65WBswg= -github.com/gookit/color v1.1.7/go.mod h1:R3ogXq2B9rTbXoSHJ1HyUVAZ3poOJHpd9nQmyGZsfvQ= +github.com/gookit/color v1.3.8/go.mod h1:R3ogXq2B9rTbXoSHJ1HyUVAZ3poOJHpd9nQmyGZsfvQ= github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= +github.com/gordonklaus/ineffassign v0.0.0-20210225214923-2e10b2664254/go.mod h1:M9mZEtGIsR1oDaZagNPNG9iq9n2HrhZ17dsXk73V3Lw= +github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75/go.mod h1:g2644b03hfBX9Ov0ZBDgXXens4rxSxmqFBbhvKv2yVA= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gostaticanalysis/analysisutil v0.0.0-20190318220348-4088753ea4d3/go.mod h1:eEOZF4jCKGi+aprrirO9e7WKB3beBRtWgqGunKl6pKE= +github.com/gostaticanalysis/analysisutil v0.0.3/go.mod h1:eEOZF4jCKGi+aprrirO9e7WKB3beBRtWgqGunKl6pKE= +github.com/gostaticanalysis/analysisutil v0.1.0/go.mod h1:dMhHRU9KTiDcuLGdy87/2gTR8WruwYZrKdRq9m1O6uw= +github.com/gostaticanalysis/analysisutil v0.4.1/go.mod h1:18U/DLpRgIUd459wGxVHE0fRgmo1UgHDcbw7F5idXu0= +github.com/gostaticanalysis/comment v1.3.0/go.mod h1:xMicKDx7XRXYdVwY9f9wQpDJVnqWxw9wCauCMKp+IBI= +github.com/gostaticanalysis/comment v1.4.1/go.mod h1:ih6ZxzTHLdadaiSnF5WY3dxUoXfXAlTaRzuaNDlSado= +github.com/gostaticanalysis/forcetypeassert v0.0.0-20200621232751-01d4955beaa5/go.mod h1:qZEedyP/sY1lTGV1uJ3VhWZ2mqag3IkWsDHVbplHXak= +github.com/gostaticanalysis/nilerr v0.1.1/go.mod h1:wZYb6YI5YAxxq0i1+VJbY0s2YONW0HU0GPE3+5PWN4A= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= +github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= github.com/gruntwork-io/go-commons v0.8.0 h1:k/yypwrPqSeYHevLlEDmvmgQzcyTwrlZGRaxEM6G0ro= github.com/gruntwork-io/go-commons v0.8.0/go.mod h1:gtp0yTtIBExIZp7vyIV9I0XQkVwiQZze678hvDXof78= github.com/gruntwork-io/terratest v0.32.20 h1:NL+RzjWAyDAmd4Uync0ByJuDRck7XubPUTvBjccecc8= github.com/gruntwork-io/terratest v0.32.20/go.mod h1:IBb+b5b7p34oZLfpz/ZADyn8TSKeWSBu+vQMmNeePLE= -github.com/hashicorp/aws-sdk-go-base v0.4.0 h1:zH9hNUdsS+2G0zJaU85ul8D59BGnZBaKM+KMNPAHGwk= -github.com/hashicorp/aws-sdk-go-base v0.4.0/go.mod h1:eRhlz3c4nhqxFZJAahJEFL7gh6Jyj5rQmQc7F9eHFyQ= -github.com/hashicorp/errwrap v0.0.0-20180715044906-d6c0cd880357/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/aws-sdk-go-base v0.7.1 h1:7s/aR3hFn74tYPVihzDyZe7y/+BorN70rr9ZvpV3j3o= +github.com/hashicorp/aws-sdk-go-base v0.7.1/go.mod h1:2fRjWDv3jJBeN6mVWFHV6hFTNeFBx2gpDLQaZNxUVAY= +github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= +github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= +github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-getter v1.4.0 h1:ENHNi8494porjD0ZhIrjlAHnveSFhY7hvOJrV/fsKkw= +github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= +github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= +github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= github.com/hashicorp/go-getter v1.4.0/go.mod h1:7qxyCd8rBfcShwsvxgIguu4KbS3l8bUCwg2Umn7RjeY= +github.com/hashicorp/go-getter v1.5.0/go.mod h1:a7z7NPPfNQpJWcn4rSWFtdrSldqLdLPEF3d8nFMsSLM= +github.com/hashicorp/go-getter v1.5.3 h1:NF5+zOlQegim+w/EUhSLh6QhXHmZMEeHLQzllkQ3ROU= +github.com/hashicorp/go-getter v1.5.3/go.mod h1:BrrV/1clo8cCYu6mxvboYg+KutTiFnXjMEgDD8+i7ZI= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-hclog v0.10.0 h1:b86HUuA126IcSHyC55WjPo7KtCOVeTCKIjr+3lBhPxI= -github.com/hashicorp/go-hclog v0.10.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-multierror v0.0.0-20180717150148-3d5d8f294aa0/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I= +github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-hclog v0.15.0 h1:qMuK0wxsoW4D0ddCCYwPSTm4KQv1X1ke3WmPWZ0Mvsk= +github.com/hashicorp/go-hclog v0.15.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI= github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= -github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY= -github.com/hashicorp/go-plugin v1.2.0 h1:CUfYokW0EJNDcGecVrHZK//Cp1GFlHwoqtcUIEiU6BY= -github.com/hashicorp/go-plugin v1.2.0/go.mod h1:F9eH4LrE/ZsRdbwhfjs9k9HoDUwAHnYtXdgmf1AVNs0= +github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= +github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= +github.com/hashicorp/go-plugin v1.3.0/go.mod h1:F9eH4LrE/ZsRdbwhfjs9k9HoDUwAHnYtXdgmf1AVNs0= +github.com/hashicorp/go-plugin v1.4.0/go.mod h1:5fGEH17QVwTTcR0zV7yhDPLLmFX9YSZ38b18Udy6vYQ= +github.com/hashicorp/go-plugin v1.4.1 h1:6UltRQlLN9iZO513VveELp5xyaFxVD2+1OVylE+2E+w= +github.com/hashicorp/go-plugin v1.4.1/go.mod h1:5fGEH17QVwTTcR0zV7yhDPLLmFX9YSZ38b18Udy6vYQ= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.3.0 h1:McDWVJIU/y+u1BRV06dPaLfLCaT7fUTJLp5r04x7iNw= +github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w= -github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/hcl/v2 v2.0.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90= github.com/hashicorp/hcl/v2 v2.3.0/go.mod h1:d+FwDBbOLvpAM3Z6J7gPj/VoAGkNe/gm352ZhjJ/Zv8= -github.com/hashicorp/hcl/v2 v2.8.2 h1:wmFle3D1vu0okesm8BTLVDyJ6/OL9DCLUwn0b2OptiY= +github.com/hashicorp/hcl/v2 v2.6.0/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY= github.com/hashicorp/hcl/v2 v2.8.2/go.mod h1:bQTN5mpo+jewjJgh8jr0JUguIi7qPHUF6yIfAEN3jqY= -github.com/hashicorp/hcl2 v0.0.0-20190821123243-0c888d1241f6/go.mod h1:Cxv+IJLuBiEhQ7pBYGEuORa0nr4U994pE8mYLuFd7v0= -github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590/go.mod h1:n2TSygSNwsLJ76m8qFXTSc7beTb+auJxYdqrnoqwZWE= +github.com/hashicorp/hcl/v2 v2.10.0 h1:1S1UnuhDGlv3gRFV4+0EdwB+znNP5HmcGbIqwnSCByg= +github.com/hashicorp/hcl/v2 v2.10.0/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/terraform-config-inspect v0.0.0-20190821133035-82a99dc22ef4/go.mod h1:JDmizlhaP5P0rYTTZB0reDMefAiJyfWPEtugV4in1oI= -github.com/hashicorp/terraform-config-inspect v0.0.0-20191115094559-17f92b0546e8 h1:+RyjwU+Gnd/aTJBPZVDNm903eXVjjqhbaR4Ypx3xYyY= -github.com/hashicorp/terraform-config-inspect v0.0.0-20191115094559-17f92b0546e8/go.mod h1:p+ivJws3dpqbp1iP84+npOyAmTTOLMgCzrXd3GSdn/A= -github.com/hashicorp/terraform-json v0.4.0/go.mod h1:eAbqb4w0pSlRmdvl8fOyHAi/+8jnkVYN28gJkSJrLhU= -github.com/hashicorp/terraform-json v0.5.0/go.mod h1:eAbqb4w0pSlRmdvl8fOyHAi/+8jnkVYN28gJkSJrLhU= -github.com/hashicorp/terraform-json v0.9.0 h1:WE7+Wt93W93feOiCligElSyS0tlDzwZUtJuDGIBr8zg= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/hashicorp/terraform-config-inspect v0.0.0-20191212124732-c6ae6269b9d7 h1:Pc5TCv9mbxFN6UVX0LH6CpQrdTM5YjbVI2w15237Pjk= +github.com/hashicorp/terraform-config-inspect v0.0.0-20191212124732-c6ae6269b9d7/go.mod h1:p+ivJws3dpqbp1iP84+npOyAmTTOLMgCzrXd3GSdn/A= +github.com/hashicorp/terraform-exec v0.12.0/go.mod h1:SGhto91bVRlgXQWcJ5znSz+29UZIa8kpBbkGwQ+g9E8= +github.com/hashicorp/terraform-exec v0.13.0/go.mod h1:SGhto91bVRlgXQWcJ5znSz+29UZIa8kpBbkGwQ+g9E8= +github.com/hashicorp/terraform-exec v0.13.3/go.mod h1:SSg6lbUsVB3DmFyCPjBPklqf6EYGX0TlQ6QTxOlikDU= +github.com/hashicorp/terraform-exec v0.14.0 h1:UQoUcxKTZZXhyyK68Cwn4mApT4mnFPmEXPiqaHL9r+w= +github.com/hashicorp/terraform-exec v0.14.0/go.mod h1:qrAASDq28KZiMPDnQ02sFS9udcqEkRly002EA2izXTA= +github.com/hashicorp/terraform-json v0.8.0/go.mod h1:3defM4kkMfttwiE7VakJDwCd4R+umhSQnvJwORXbprE= github.com/hashicorp/terraform-json v0.9.0/go.mod h1:3defM4kkMfttwiE7VakJDwCd4R+umhSQnvJwORXbprE= -github.com/hashicorp/terraform-plugin-sdk v1.0.0/go.mod h1:NuwtLpEpPsFaKJPJNGtMcn9vlhe6Ofe+Y6NqXhJgV2M= -github.com/hashicorp/terraform-plugin-sdk v1.7.0/go.mod h1:OjgQmey5VxnPej/buEhe+YqKm0KNvV3QqU4hkqHqPCY= -github.com/hashicorp/terraform-plugin-sdk v1.11.0/go.mod h1:HiWIPD/T9HixIhQUwaSoDQxo4BLFdmiBi/Qz5gjB8Q0= -github.com/hashicorp/terraform-plugin-sdk v1.12.0/go.mod h1:HiWIPD/T9HixIhQUwaSoDQxo4BLFdmiBi/Qz5gjB8Q0= -github.com/hashicorp/terraform-plugin-sdk v1.14.0 h1:sUKcw7OHqDXhBarlHjv+/yMCr8eEb1lO8CGQ3pEEFiE= -github.com/hashicorp/terraform-plugin-sdk v1.14.0/go.mod h1:t62Xy+m7Zjq5tA2vrs8Wuo/TQ0sc9Mx9MjXL3+7MHBQ= -github.com/hashicorp/terraform-plugin-test v1.2.0/go.mod h1:QIJHYz8j+xJtdtLrFTlzQVC0ocr3rf/OjIpgZLK56Hs= -github.com/hashicorp/terraform-plugin-test v1.3.0 h1:hU5LoxrOn9qvOo+LTKN6mSav2J+dAMprbdxJPEQvp4U= -github.com/hashicorp/terraform-plugin-test v1.3.0/go.mod h1:QIJHYz8j+xJtdtLrFTlzQVC0ocr3rf/OjIpgZLK56Hs= -github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596 h1:hjyO2JsNZUKT1ym+FAdlBEkGPevazYsmVgIMw7dVELg= -github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= -github.com/hashicorp/vault v0.10.4 h1:4x0lHxui/ZRp/B3E0Auv1QNBJpzETqHR2kQD3mHSBJU= -github.com/hashicorp/vault v0.10.4/go.mod h1:KfSyffbKxoVyspOdlaGVjIuwLobi07qD1bAbosPMpP0= +github.com/hashicorp/terraform-json v0.10.0/go.mod h1:3defM4kkMfttwiE7VakJDwCd4R+umhSQnvJwORXbprE= +github.com/hashicorp/terraform-json v0.12.0 h1:8czPgEEWWPROStjkWPUnTQDXmpmZPlkQAwYYLETaTvw= +github.com/hashicorp/terraform-json v0.12.0/go.mod h1:pmbq9o4EuL43db5+0ogX10Yofv1nozM+wskr/bGFJpI= +github.com/hashicorp/terraform-plugin-go v0.1.0/go.mod h1:10V6F3taeDWVAoLlkmArKttR3IULlRWFAGtQIQTIDr4= +github.com/hashicorp/terraform-plugin-go v0.2.1/go.mod h1:10V6F3taeDWVAoLlkmArKttR3IULlRWFAGtQIQTIDr4= +github.com/hashicorp/terraform-plugin-go v0.3.0 h1:AJqYzP52JFYl9NABRI7smXI1pNjgR5Q/y2WyVJ/BOZA= +github.com/hashicorp/terraform-plugin-go v0.3.0/go.mod h1:dFHsQMaTLpON2gWhVWT96fvtlc/MF1vSy3OdMhWBzdM= +github.com/hashicorp/terraform-plugin-sdk v1.17.2 h1:V7DUR3yBWFrVB9z3ddpY7kiYVSsq4NYR67NiTs93NQo= +github.com/hashicorp/terraform-plugin-sdk v1.17.2/go.mod h1:wkvldbraEMkz23NxkkAsFS88A1R9eUiooiaUZyS6TLw= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.4.0/go.mod h1:JBItawj+j8Ssla5Ib6BC/W9VQkOucBfnX7VRtyx1vw8= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.5.0/go.mod h1:z+cMZ0iswzZOahBJ3XmNWgWkVnAd2bl8g+FhyyuPDH4= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.6.1/go.mod h1:72j8cKfs9IirGhPMXJJWLTvRUK4zATtrCOvs2avDlo8= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.0 h1:SuI59MqNjYDrL7EfqHX9V6P/24isgqYx/FdglwVs9bg= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.7.0/go.mod h1:grseeRo9g3yNkYW09iFlV8LG78jTa1ssBgouogQg/RU= +github.com/hashicorp/terraform-plugin-test/v2 v2.2.1 h1:d3Rzmi5bnRzcAZon91FY4TDCMUYdU8c5vpPpf2Tz+c8= +github.com/hashicorp/terraform-plugin-test/v2 v2.2.1/go.mod h1:eZ9JL3O69Cb71Skn6OhHyj17sLmHRb+H6VrDcJjKrYU= +github.com/hashicorp/terraform-provider-google v1.20.1-0.20210625223728-379bcb41c06b h1:r7lcONv0Fk/71AkXD1DL9CEkPIR2miuEytLasvTYhms= +github.com/hashicorp/terraform-provider-google v1.20.1-0.20210625223728-379bcb41c06b/go.mod h1:OhGjOHXiFi9LYqZ1ufo11myNGbENa71nkCNavijbGw4= +github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= +github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo= +github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= +github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/imdario/mergo v0.3.4/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI= github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= +github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jen20/awspolicyequivalence v1.1.0 h1:cn37D6o0lXLwqx2neCokGfaB3LLNSo5CrLMLGjY609g= github.com/jen20/awspolicyequivalence v1.1.0/go.mod h1:PV1fS2xyHhCLp83vbgSMFr2drM4GzG61wkz+k4pOG3E= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= +github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= +github.com/jgautheron/goconst v1.4.0/go.mod h1:aAosetZ5zaeC/2EfMeRswtxUFBpe2Hr7HzkgX4fanO4= github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= -github.com/jingyugao/rowserrcheck v0.0.0-20191204022205-72ab7603b68a/go.mod h1:xRskid8CManxVta/ALEhJha/pweKBaVG6fWgc0yH25s= +github.com/jhump/protoreflect v1.6.1/go.mod h1:RZQ/lnuN+zqeRVpQigTwO6o0AJUkxbnSnpuG7toUTG4= +github.com/jingyugao/rowserrcheck v0.0.0-20210315055705-d907ca737bb1/go.mod h1:TOQpc2SLx6huPfoFGK3UOnEG+u02D3C1GeosjupAKCA= github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a h1:zPPuIq2jAWWPTrGt70eK/BSch+gFAGrNzecsoENgu2o= github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a/go.mod h1:yL958EeXv8Ylng6IfnvG4oflryUi3vgA3xPs9hmII1s= -github.com/jirfag/go-printf-func-name v0.0.0-20191110105641-45db9963cdd3/go.mod h1:HEWGJkRDzjJY2sqdDwxccsGicWEf9BQOZsq2tV+xzM0= +github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af/go.mod h1:HEWGJkRDzjJY2sqdDwxccsGicWEf9BQOZsq2tV+xzM0= github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc= github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= -github.com/jmoiron/sqlx v1.2.1-0.20190826204134-d7d95172beb5/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= +github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jonboulle/clockwork v0.2.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -463,37 +632,46 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1 github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/juju/ratelimit v1.0.1/go.mod h1:qapgC/Gy+xNh9UxzV13HGGl/6UXNN+ct+vwSgWNm/qk= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/katbyte/terrafmt v0.2.1-0.20200303174203-e6a3e82cb21b/go.mod h1:WRq5tDmK04tcYbEr400zAUWtOK0jix54e8YeHP3IoQg= +github.com/julz/importas v0.0.0-20210419104244-841f0c0fe66d/go.mod h1:oSFU2R4XK/P7kNBrnL/FEQlDGN1/6WoxXEjSSXO0DV0= +github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= +github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= +github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba h1:NARVGAAgEXvoMeNPHhPFt1SBt1VMznA3Gnz9d0qj+co= github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= -github.com/kisielk/gotool v0.0.0-20161130080628-0de1eaf82fa3/go.mod h1:jxZFDH7ILpTPQTk+E2s+z4CUas9lVNjIuKR4c5/zKgM= +github.com/kisielk/errcheck v1.6.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= -github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= +github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.11.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.11.2 h1:MiK62aErc3gIiVEtyzKfeOHgW7atJb5g/KNX5m3c2nQ= +github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= -github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kulti/thelper v0.4.0/go.mod h1:vMu2Cizjy/grP+jmsvOFDx1kYP6+PD1lqg4Yu5exl2U= +github.com/kunwardeep/paralleltest v1.0.2/go.mod h1:ZPqNm1fVHPllh5LPVujzbVz1JN2GhLxSfY+oqUsvG30= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/kyoh86/exportloopref v0.1.8/go.mod h1:1tUcJeiioIs7VWe5gcOObrux3lb66+sBqGZrRkMwPgg= +github.com/ldez/gomoddirectives v0.2.1/go.mod h1:sGicqkRgBOg//JfpXwkB9Hj0X5RyJ7mlACM5B9f6Me4= +github.com/ldez/tagliatelle v0.2.0/go.mod h1:8s6WJQwEYHbKZDsp/LjArytKOG8qaMrKQQ3mFukHs88= +github.com/letsencrypt/pkcs11key/v4 v4.0.0/go.mod h1:EFUvBDay26dErnNb70Nd0/VW3tJiIbETBPTl9ATXQag= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= -github.com/magiconair/properties v1.7.6/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -501,53 +679,73 @@ github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/maratori/testpackage v1.0.1/go.mod h1:ddKdw+XG0Phzhx8BFDTKgpWP4i7MpApTE5fXSKAqwDU= -github.com/matoous/godox v0.0.0-20190911065817-5d6d842e92eb/go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s= +github.com/matoous/godox v0.0.0-20210227103229-6504466cf951/go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s= +github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= -github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= +github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM= github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-zglob v0.0.1/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo= github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo= github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/maxbrunsfeld/counterfeiter/v6 v6.2.2/go.mod h1:eD9eIE7cdwcMi9rYluz88Jz2VyhSmden33/aXg4oVIY= +github.com/mbilski/exhaustivestruct v1.2.0/go.mod h1:OeTBVxQWoEmB2J2JCHmXWPJ0aksxSUOUy+nvtVEfzXc= +github.com/mgechev/dots v0.0.0-20190921121421-c36f7dcfbb81/go.mod h1:KQ7+USdGKfpPjXk4Ga+5XxQM4Lm4e3gAogrreFAYpOg= +github.com/mgechev/revive v1.0.6/go.mod h1:Lj5gIVxjBlH8REa3icEOkdfchwYc291nShzZ4QYWyMo= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.31/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= -github.com/mitchellh/cli v1.0.0 h1:iGBIsUe3+HZ/AD/Vd7DErOt5sU9fa8Uj7A2s1aggv1Y= +github.com/miekg/dns v1.1.35/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= +github.com/miekg/pkcs11 v1.0.2/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= +github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/cli v1.1.1/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= +github.com/mitchellh/cli v1.1.2 h1:PvH+lL2B7IQ101xQL63Of8yFS2y+aDlsFcsqNc+u/Kw= +github.com/mitchellh/cli v1.1.2/go.mod h1:6iaV0fGdElS6dPBx0EApTxHrcWvmJphyh2n8YBLPPZ4= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= -github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-ps v0.0.0-20170309133038-4fdf99ab2936/go.mod h1:r1VsdOzOPt1ZSrGZWFoNhsAedKnEd6r9Np1+5blZCWk= -github.com/mitchellh/go-ps v0.0.0-20190716172923-621e5597135b/go.mod h1:r1VsdOzOPt1ZSrGZWFoNhsAedKnEd6r9Np1+5blZCWk= +github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg= github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/go-testing-interface v1.0.4/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= +github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/mitchellh/hashstructure v1.0.0 h1:ZkRJX1CyOoTkar7p/mLS5TZU4nJ1Rn/F8u9dGS02Q3Y= -github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= -github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/hashstructure v1.1.0 h1:P6P1hdjqAAknpY/M1CGipelZgp+4y9ja9kmUZPXP+H0= +github.com/mitchellh/hashstructure v1.1.0/go.mod h1:xUDAozZz0Wmdiufv0uyhnHkUTN6/6d8ulp4AwfLKrmA= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.0.0/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/mitchellh/reflectwalk v1.0.1 h1:FVzMWA5RllMAKIdUSC8mdWo3XtwoecrH79BY70sEEpE= github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -555,52 +753,63 @@ github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lN github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/mongodb-forks/digest v1.0.1 h1:+3fpRyZcC5G44YrfrhHAffSSORh3assbetlzq8lp1hU= github.com/mongodb-forks/digest v1.0.1/go.mod h1:PA4OEwIwOqB/7OJE/xyY7x2D+5ufAlNv8Cy01DNCWgg= +github.com/moricho/tparallel v0.2.1/go.mod h1:fXEIZxG2vdfl0ZF8b42f5a78EhjjD5mX8qUplsoSU4k= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= -github.com/mozilla/tls-observatory v0.0.0-20180409132520-8791a200eb40/go.mod h1:SrKMQvPiws7F7iqYp8/TX+IhxCYhzr6N/1yb8cwHsGk= -github.com/mozilla/tls-observatory v0.0.0-20200220173314-aae45faa4006/go.mod h1:SrKMQvPiws7F7iqYp8/TX+IhxCYhzr6N/1yb8cwHsGk= +github.com/mozilla/scribe v0.0.0-20180711195314-fb71baf557c1/go.mod h1:FIczTrinKo8VaLxe6PWTPEXRXDIHz2QAwiaBaP5/4a8= +github.com/mozilla/tls-observatory v0.0.0-20210209181001-cf43108d6880/go.mod h1:FUqVoUPHSEdDR0MnFM3Dh8AU0pZHLXUD127SAJGER/s= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwielbut/pointy v1.1.0 h1:U5/YEfoIkaGCHv0St3CgjduqXID4FNRoyZgLM1kY9vg= github.com/mwielbut/pointy v1.1.0/go.mod h1:MvvO+uMFj9T5DMda33HlvogsFBX7pWWKAkFIn4teYwY= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-proto-validators v0.0.0-20180403085117-0950a7990007/go.mod h1:m2XC9Qq0AlmmVksL6FktJCdTYyLk7V3fKyp0sl1yWQo= +github.com/mwitkow/go-proto-validators v0.2.0/go.mod h1:ZfA1hW+UH/2ZHOWvQ3HnQaU0DtnpXu850MZiy+YUgcc= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/nakabonne/nestif v0.3.0/go.mod h1:dI314BppzXjJ4HsCnbo7XzrJHPszZsjnk5wEBSYHI2c= -github.com/nbutton23/zxcvbn-go v0.0.0-20160627004424-a22cb81b2ecd/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU= -github.com/nbutton23/zxcvbn-go v0.0.0-20171102151520-eafdab6b0663/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU= -github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354/go.mod h1:KSVJerMDfblTH7p5MZaTt+8zaT2iEk3AkVb9PQdZuE8= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/nishanths/exhaustive v0.1.0/go.mod h1:S1j9110vxV1ECdCudXRkeMnFQ/DQk9ajLT0Uf2MYZQQ= +github.com/nishanths/predeclared v0.0.0-20190419143655-18a43bb90ffc/go.mod h1:62PewwiQTlm/7Rj+cxVYqZvDIUc+JjZq6GHAC1fsObQ= +github.com/nishanths/predeclared v0.2.1/go.mod h1:HvkGJcA3naj4lOwnFXFDkFxVtSqQMB9sbB1usJ+xjQE= +github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce/go.mod h1:uFMI8w+ref4v2r9jz+c9i1IfIttS/OkmLfrk1jne5hs= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.2/go.mod h1:rSAaSIOAGT9odnlyGlUfAJaoc5w2fSBUmeGDbRWPxyQ= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.15.0/go.mod h1:hF8qUzuuC8DJGygJH3726JnCZX4MYbRB8yFfISqnKUg= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/openlyinc/pointy v1.1.2 h1:LywVV2BWC5Sp5v7FoP4bUD+2Yn5k0VNeRbU5vq9jUMY= github.com/openlyinc/pointy v1.1.2/go.mod h1:w2Sytx+0FVuMKn37xpXIAyBNhFNBIJGR/v2m7ik1WtM= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/oracle/oci-go-sdk v7.1.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pelletier/go-toml v1.1.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d/go.mod h1:3OzsM7FXDQlpCiw2j81fOmAwQLnZnLGXVKUzeKQXIAw= -github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -608,71 +817,92 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/polyfloyd/go-errorlint v0.0.0-20210418123303-74da32850375/go.mod h1:wi9BfjxjF/bwiZ701TzmfKu6UKC357IOAtNr0Td0Lvw= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.1 h1:LrvDIY//XNo65Lq84G/akBuMGlawHvGBABv8f/ZN6DI= github.com/posener/complete v1.2.1/go.mod h1:6gapUrK/U1TAN7ciCoNRIdVC5sbdBTUh1DKN0g6uH7E= github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= -github.com/pquerna/otp v1.2.0 h1:/A3+Jn+cagqayeR3iHs/L62m5ue7710D35zl1zJ1kok= github.com/pquerna/otp v1.2.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg= +github.com/pquerna/otp v1.3.0 h1:oJV/SkzR33anKXwQU3Of42rL4wbrffP4uvUf1SvS5Xs= +github.com/pquerna/otp v1.3.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/pseudomuto/protoc-gen-doc v1.3.2/go.mod h1:y5+P6n3iGrbKG+9O04V5ld71in3v/bX88wUwgt+U8EA= +github.com/pseudomuto/protokit v0.2.0/go.mod h1:2PdH30hxVHsup8KpBTOXTBeMVhJZVio3Q8ViKSAXT0Q= github.com/quasilyte/go-consistent v0.0.0-20190521200055-c6f3937de18c/go.mod h1:5STLWrekHfjyYwxBRVRXNOSewLJ3PWfDJd1VyTS21fI= +github.com/quasilyte/go-ruleguard v0.3.1-0.20210203134552-1b5a410e1cc8/go.mod h1:KsAh3x0e7Fkpgs+Q9pNLS5XpFSvYCEVl5gP9Pp1xp30= +github.com/quasilyte/go-ruleguard v0.3.4/go.mod h1:57FZgMnoo6jqxkYKmVj5Fc8vOt0rVzoE/UNAmFFIPqA= +github.com/quasilyte/go-ruleguard/dsl v0.3.0/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= +github.com/quasilyte/go-ruleguard/dsl v0.3.2/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= +github.com/quasilyte/go-ruleguard/rules v0.0.0-20201231183845-9e62ed36efe1/go.mod h1:7JTjp89EGyU1d6XfBiXihJNG37wB2VRkd125Q1u7Plc= +github.com/quasilyte/go-ruleguard/rules v0.0.0-20210203162857-b223e0831f88/go.mod h1:4cgAphtvu7Ftv7vOT2ZOYhC6CvBxZixcasr8qIOTA50= +github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95/go.mod h1:rlzQ04UMyJXu/aOvhd8qT+hvDrFpiwqp8MRXDY9szc0= github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc= -github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.6.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rubiojr/go-vhd v0.0.0-20160810183302-0bfd3b39853c/go.mod h1:DM5xW0nvfNNm2uytzsvhI3OnX8uzaRAg8UX/CnDqbto= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ryancurrah/gomodguard v1.0.4/go.mod h1:9T/Cfuxs5StfsocWr4WzDL36HqnX0fVb9d5fSEaLhoE= -github.com/ryanuber/go-glob v0.0.0-20170128012129-256dc444b735/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= +github.com/ryancurrah/gomodguard v1.2.0/go.mod h1:rNqbC4TOIdUDcVMSIpNNAzTbzXAZa6W5lnUepvuMMgQ= +github.com/ryanrolds/sqlclosecheck v0.3.0/go.mod h1:1gREqxyTGR3lVtpngyFo3hZAgk0KCtEdgEkHwDbigdA= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sanposhiho/wastedassign v1.0.0/go.mod h1:LGpq5Hsv74QaqM47WtIsRSF/ik9kqk07kchgv66tLVE= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sclevine/spec v1.2.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24q7p+U= -github.com/securego/gosec v0.0.0-20200316084457-7da9f46445fd/go.mod h1:NurAFZsWJAEZjogSwdVPlHkOZB3DOAU7gsPP8VFZCHc= -github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= +github.com/securego/gosec/v2 v2.7.0/go.mod h1:xNbGArrGUspJLuz3LS5XCY1EBW/0vABAl/LWfSklmiM= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/shirou/gopsutil v0.0.0-20180427012116-c95755e4bcd7/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/gopsutil v0.0.0-20190901111213-e4ec7b275ada/go.mod h1:WWnYX4lzhCH5h/3YBfyVA3VbLYjlMZZAQcW9ojMexNc= -github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c/go.mod h1:/PevMnwAxekIXwN8qQyfc5gl2NlkB3CQlkizAbOkeBs= +github.com/shirou/gopsutil/v3 v3.21.4/go.mod h1:ghfMypLDrFSWN2c9cDYFLHyynQ+QUht0cv/18ZqVczw= github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ= github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.0.5/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= -github.com/sourcegraph/go-diff v0.5.1/go.mod h1:j2dHj3m8aZgQO8lMTcTnBcXkRRRqi34cd2MNlA9u1mE= +github.com/sonatard/noctx v0.0.1/go.mod h1:9D2D/EoULe8Yy2joDHJj7bv3sZoq9AaSb8B4lqBjiZI= +github.com/sourcegraph/go-diff v0.6.1/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.1.0/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/cast v1.2.0/go.mod h1:r2rcYCSwa1IExKTDiTfzaxqT2FNHs8hODu4LnUfgKEg= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.2/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/jwalterweatherman v0.0.0-20180109140146-7c0cea34c8ec/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -680,40 +910,42 @@ github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.0.2/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/spf13/viper v1.6.1/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= -github.com/stoewer/go-strcase v1.0.2 h1:l3iQ2FPu8+36ars/7syO1dQAkjwMCb1IE3J+Th0ohfE= -github.com/stoewer/go-strcase v1.0.2/go.mod h1:eLfe5bL3qbL7ep/KafHzthxejrOF5J3xmt03uL5tzek= +github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= +github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= +github.com/ssgreg/nlreturn/v2 v2.1.0/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v0.0.0-20170130113145-4d4bfba8f1d1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.1.4/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM= -github.com/terraform-providers/terraform-provider-aws v1.60.1-0.20200518153306-40099de47e37 h1:RvenJslltDKarf59F4S+hSNU9IUOG7WYPfNWZSm0ZxY= -github.com/terraform-providers/terraform-provider-aws v1.60.1-0.20200518153306-40099de47e37/go.mod h1:lout+16lD5DqaiAJ32DHvMjU1SGLqNRO3rfpMV2Tkkk= -github.com/terraform-providers/terraform-provider-google v1.20.1-0.20200518165017-1dd21651c496 h1:OgfhJnvtgbAxl5sLFI4V3ZPtdQAIt8w/sR1AJbAfooY= -github.com/terraform-providers/terraform-provider-google v1.20.1-0.20200518165017-1dd21651c496/go.mod h1:AmBslWVsITN8GxIqLgJetXfIW4CvN0OUi8TAzOYUS/w= -github.com/terraform-providers/terraform-provider-random v0.0.0-20190925200408-30dac3233094 h1:DkT2B0Zdzd/5jvP9V+CXRCf8smxqyrB3NYFstWpZkv4= -github.com/terraform-providers/terraform-provider-random v0.0.0-20190925200408-30dac3233094/go.mod h1:F4KE9YftuJyMiBth4W1kCrsyOHndtTjAmZ+ZzjqWY+4= -github.com/tetafro/godot v0.3.3/go.mod h1:pT6/T8+h6//L/LwQcFc4C0xpfy1euZwzS1sHdrFCms0= -github.com/timakin/bodyclose v0.0.0-20190721030226-87058b9bfcec/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk= -github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk= +github.com/tdakkota/asciicheck v0.0.0-20200416200610-e657995f937b/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM= +github.com/terraform-providers/terraform-provider-aws v1.60.1-0.20210625132053-af2d5c0ad54f h1:yc8QxZvmRc09wYQCx9hYHk/jXYM916IVINrMXd1Mvqc= +github.com/terraform-providers/terraform-provider-aws v1.60.1-0.20210625132053-af2d5c0ad54f/go.mod h1:5ubu6G1APl5lfG1OONYTdL6FzHve9oPIb6+w8NjQOGA= +github.com/tetafro/godot v1.4.6/go.mod h1:LR3CJpxDVGlYOWn3ZZg1PgNZdTUvzsZWu8xaEohUpn8= +github.com/timakin/bodyclose v0.0.0-20200424151742-cb6215831a94/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk= +github.com/tklauser/go-sysconf v0.3.4/go.mod h1:Cl2c8ZRWfHD5IrfHo9VN+FX9kCFjIOyVklgXycLB6ek= +github.com/tklauser/numcpus v0.2.1/go.mod h1:9aU+wOc6WjUIZEwWMP62PL/41d65P+iks1gBkr4QyP8= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/tommy-muehle/go-mnd v1.3.1-0.20200224220436-e6f9a994e8fa/go.mod h1:dSUh0FtTP8VhvkL1S+gUR1OKd9ZnSaozuI6r3m6wOig= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/tomarrell/wrapcheck/v2 v2.1.0/go.mod h1:crK5eI4RGSUrb9duDTQ5GqcukbKZvi85vX6nbhsBAeI= +github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce/go.mod h1:o8v6yHRoik09Xen7gje4m9ERNah1d1PPsVq1VEx9vE4= +github.com/tommy-muehle/go-mnd/v2 v2.3.2/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/ulikunitz/xz v0.5.5 h1:pFrO0lVpTBXLpYw+pnLj6TbvHuyjXMfjGeCwSqCVwok= github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= -github.com/ultraware/funlen v0.0.1/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA= -github.com/ultraware/funlen v0.0.2/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA= +github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ= +github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= +github.com/ultraware/funlen v0.0.3/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA= github.com/ultraware/whitespace v0.0.4/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= @@ -721,49 +953,79 @@ github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo= github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/uudashr/gocognit v1.0.1/go.mod h1:j44Ayx2KW4+oB6SWMv8KsmHzZrOInQav7D3cQMJ5JUM= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s= -github.com/valyala/quicktemplate v1.1.1/go.mod h1:EH+4AkTd43SvgIbQHYu59/cJyxDoOVRUAfrukLPuGJ4= -github.com/valyala/quicktemplate v1.2.0/go.mod h1:EH+4AkTd43SvgIbQHYu59/cJyxDoOVRUAfrukLPuGJ4= +github.com/valyala/fasthttp v1.16.0/go.mod h1:YOKImeEosDdBPnxc0gy7INqi3m1zK6A+xl6TwOBhHCA= +github.com/valyala/quicktemplate v1.6.3/go.mod h1:fwPzK2fHuYEODzJ9pkw0ipCPNHZ2tD5KW4lOuSdPKzY= github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= github.com/vdemeester/k8s-pkg-credentialprovider v0.0.0-20200107171650-7c61ffa44238/go.mod h1:JwQJCMWpUDqjZrB5jpw0f5VbN7U95zxFy1ZDpoEarGo= +github.com/viki-org/dnscache v0.0.0-20130720023526-c70c1f23c5d8/go.mod h1:dniwbG03GafCjFohMDmz6Zc6oCuiqgH6tGNyXTkHzXE= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/vmihailenco/msgpack v4.0.1+incompatible h1:RMF1enSPeKTlXrXdOcqjFUElywVZjjC6pqse21bKbEU= -github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= +github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= +github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= +github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U= +github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= +github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY= +github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/vmware/govmomi v0.20.3/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= +github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= +github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/yeya24/promlinter v0.1.0/go.mod h1:rs5vtZzeBHqqMwXqFScncpCF6u06lezhZepno9AB1Oc= +github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= +github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= +github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= -github.com/zclconf/go-cty v1.2.1 h1:vGMsygfmeCl4Xb6OA5U5XVAaQZ69FvoG7X2jUtQujb8= github.com/zclconf/go-cty v1.2.1/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= -github.com/zclconf/go-cty-yaml v1.0.1 h1:up11wlgAaDvlAGENcFDnZgkn0qUJurso7k6EpURKNF8= -github.com/zclconf/go-cty-yaml v1.0.1/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgKa8XhiVHura0= +github.com/zclconf/go-cty v1.5.1/go.mod h1:nHzOclRkoj++EU9ZjSrZvRG0BXIWt8c7loYc0qXAFGQ= +github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= +github.com/zclconf/go-cty v1.8.2/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= +github.com/zclconf/go-cty v1.8.4 h1:pwhhz5P+Fjxse7S7UriBrMu6AUJSZM5pKqGem1PjGAs= +github.com/zclconf/go-cty v1.8.4/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= +github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= +github.com/zclconf/go-cty-yaml v1.0.2 h1:dNyg4QLTrv2IfJpm7Wtxi55ed5gLGOlPrZ6kMd51hY0= +github.com/zclconf/go-cty-yaml v1.0.2/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgKa8XhiVHura0= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= +go.etcd.io/etcd v0.0.0-20200513171258-e048e166ab9c/go.mod h1:xCI7ZzBfRuGgBXyXO6yfWfDmlWd35khcWpUa4L0xI/k= go.mongodb.org/atlas v0.8.0/go.mod h1:MMWDsc2akjTDSG4tVQrxv/82p3QbBnqeELbtTl45sbg= go.mongodb.org/atlas v0.10.0 h1:kmwgoNjb2bEj4MmupkUmEx5G29BP01O59+Yd/O5Pf/k= go.mongodb.org/atlas v0.10.0/go.mod h1:MMWDsc2akjTDSG4tVQrxv/82p3QbBnqeELbtTl45sbg= go.mongodb.org/realm v0.0.0-20210618220639-e70c919266f2 h1:3ukcBKIOun3QRMZzdVRCU/7uVhjR7XQsdD/cCH5V8So= go.mongodb.org/realm v0.0.0-20210618220639-e70c919266f2/go.mod h1:Tru1+aHka6+4uXYigPKoNySbNWgtkfsanVddwmcqvOM= +go.mozilla.org/mozlog v0.0.0-20170222151521-4bb13139d403/go.mod h1:jHoPAGnDrCy6kaI2tAze5Prf0Nr0w/oNkROt2lw3n3o= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3 h1:8sGtKOrtQqkN1bp2AtX+misvLIlOmsEsNd+9NIcPEm8= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/multierr v1.4.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +golang.org/x/crypto v0.0.0-20180501155221-613d6eafa307/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -771,21 +1033,27 @@ golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= +golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190312203227-4b39c73a6495/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191029154019-8994fa331a53/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -797,8 +1065,10 @@ golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -806,26 +1076,27 @@ golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20170915142106-8351a756f30f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180911220305-26e67e76b6c3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190502183928-7f726cade0ab/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -834,6 +1105,7 @@ golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -843,36 +1115,66 @@ golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= +golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420 h1:a8jGStKg0XqKDlKqjLrXn0ioF5MH36pT7Z0BRTqLhbk= +golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210427180440-81ed05c6b58c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c h1:pkQiBZBvdos9qq4wBAHqlzuZHEXo07pqV06ef90u1WI= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20171026204733-164713f0dfce/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -885,8 +1187,9 @@ golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -896,7 +1199,9 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -904,59 +1209,94 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210228012217-479acdf4ea46/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210503080704-8803ae5d1324/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210601080250-7ecdf8ef093b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210611083646-a4fc73990273 h1:faDu4veV+8pcThn4fewv6TVlNCezafGoC1gM/mxQLbQ= +golang.org/x/sys v0.0.0-20210611083646-a4fc73990273/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.0.0-20170915090833-1cbadb444a80/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20170915040203-e531a2a1c15f/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 h1:NusfzzA6yGQ+ua51ck7E3omNUX/JuqbFSaRGqU8CcLI= +golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181117154741-2ddaf7f79a09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190110163146-51295c7ec13a/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190121143147-24cd39ecf745/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190221204921-83362c3779f5/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190307163923-6a08e3108db3/go.mod h1:25r3+/G6/xytQM8iWZKq3Hn0kr0rgFKPUNVEL/dr3z4= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190311215038-5c2858a9cfe5/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190321232350-e250d351ecad/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190322203728-c1a832b0ad89/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190521203540-521d6ed310dd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190706070813-72ffa07ba3db/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI= -golang.org/x/tools v0.0.0-20190719005602-e377ae9d6386/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190909030654-5b82db07426d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190910044552-dd2b5c81c578/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190916130336-e45ffcd953cc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191010075000-0337d82405ff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -967,21 +1307,65 @@ golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117220505-0cba7a3a9ee9/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200214201135-548b770e2dfa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200216192241-b320d3a0f5a2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200228224639-71482053b885/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200324003944-a576cf524670/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200329025819-fd4102a86c65/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200414032229-332987a829c3/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200422022333-3d57cf2e726e/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20201110201400-7099162a900a h1:5E6TPwSBG74zT8xSrVc8W59K4ch4NFobVTnh2BYzHyU= +golang.org/x/tools v0.0.0-20200426102838-f3a5411a4c3b/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200622203043-20e05c1c8ffa/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200624225443-88f3c62a19ff/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200625211823-6506e20df31f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200626171337-aa94e735be7f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200630154851-b2d8b0336632/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200706234117-b22de6825cf7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200724022722-7017fd6b1305/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200812195022-5ae4c3c160a0/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200820010801-b793a1359eac/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200831203904-5a2aa26beb65/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201001104356-43ebab892c4c/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/tools v0.0.0-20201002184944-ecd9fd270d5d/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/tools v0.0.0-20201011145850-ed2f50202694/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/tools v0.0.0-20201023174141-c8cfbd0f21e6/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201028025901-8cd080b735b3/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201028111035-eafbe7b904eb/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201110201400-7099162a900a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201114224030-61ea331ec02b/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201118003311-bd56c0adb394/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201230224404-63754364767c/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210101214203-2dba1e4ea05c/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210104081019-d8d6ddbec6ee/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.2-0.20210512205948-8287d5da45e4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.3 h1:L69ShwSZEyCsLKoAxDKeMvLDZkumEe8gXUZAjab0tX8= +golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -995,22 +1379,41 @@ google.golang.org/api v0.6.1-0.20190607001116-5213b8090861/go.mod h1:btoxGiFvQNV google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.10.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.23.0 h1:YlvGEOq2NA2my8cZ/9V8BcEO9okD48FlJcdqN0xJL3s= -google.golang.org/api v0.23.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.34.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= +google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= +google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= +google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= +google.golang.org/api v0.46.0/go.mod h1:ceL4oozhkAiTID8XMmJBsIxID/9wMXJVVFXPg4ylg3I= +google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= +google.golang.org/api v0.48.0 h1:RDAPWfNFY06dffEXfn7hZF5Fr1ZbnChzfQZAPyBd1+I= +google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM= +google.golang.org/appengine v1.6.2/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20181107211654-5fc9ac540362/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -1018,7 +1421,7 @@ google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRn google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191028173616-919d9bdd9fe6/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= @@ -1028,15 +1431,42 @@ google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvx google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200310143817-43be25429f5a/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200626011028-ee7919e894b5/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200707001353-8e8330bf89df/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200711021454-869866162049/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= +google.golang.org/genproto v0.0.0-20210429181445-86c259c2b4ab/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= +google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= +google.golang.org/genproto v0.0.0-20210517163617-5e0236093d7a/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= +google.golang.org/genproto v0.0.0-20210601144548-a796c710e9b6/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= +google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08 h1:pc16UedxnxXXtGxHCSUhafAoVHQZ0yXl8ZelMH4EETc= +google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= -google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= @@ -1045,8 +1475,23 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0 h1:bO/TA4OxCOummhSf10siHuG7vJOiwh7SpRpFZDkOgl4= google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.0/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= +google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.38.0 h1:/9BgsAsa5nWe26HqOlvlgJnqBuktYOLCgjCPqsa56W0= +google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1055,21 +1500,24 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 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 h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +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= +gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.0/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= -gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= +gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= @@ -1078,22 +1526,29 @@ gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/square/go-jose.v2 v2.2.2/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.1/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= +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= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.6/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.1.4/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= k8s.io/api v0.17.0/go.mod h1:npsyOePkeP0CPwyGfXDHxvypiYMJxBWAMpQxCaJ4ZxI= k8s.io/api v0.19.3 h1:GN6ntFnv44Vptj/b+OnMW7FmzkpDoIDLZRvKX3XH9aU= k8s.io/api v0.19.3/go.mod h1:VF+5FT1B74Pw3KxMdKyinLo+zynBaMBiAfGMuldcNDs= @@ -1129,11 +1584,10 @@ modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= modernc.org/strutil v1.0.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs= modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I= +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-20190209190245-fbb59629db34/go.mod h1:H6SUd1XjIs+qQCyskXg5OFSrilMRUkD8ePJpHKDPaeY= -mvdan.cc/unparam v0.0.0-20190720180237-d51796306d8f/go.mod h1:4G1h5nDURzA3bwVMZIVpwbkw+04kSxk3rAtzlimaUJw= -rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE= +mvdan.cc/unparam v0.0.0-20210104141923-aac4ce9116a7/go.mod h1:hBpJkZE8H/sb+VRFvw2+rBpHNsTBcvSpk61hr8mzXZE= 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= @@ -1145,4 +1599,3 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0= diff --git a/integration-testing/resource_mongodbatlas_data_lake_test.go b/integration-testing/resource_mongodbatlas_data_lake_test.go index c1d855e531..08af968451 100644 --- a/integration-testing/resource_mongodbatlas_data_lake_test.go +++ b/integration-testing/resource_mongodbatlas_data_lake_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/gruntwork-io/terratest/modules/terraform" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" ) func TestTerraformResourceMongoDBAtlasDataLake_basicAWS(t *testing.T) { diff --git a/integration-testing/test-upgrades_test.go b/integration-testing/test-upgrades_test.go index c89fd90105..24a6d86e6f 100644 --- a/integration-testing/test-upgrades_test.go +++ b/integration-testing/test-upgrades_test.go @@ -11,7 +11,7 @@ import ( "github.com/gruntwork-io/terratest/modules/terraform" test_structure "github.com/gruntwork-io/terratest/modules/test-structure" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" ) var ( diff --git a/main.go b/main.go index d9d744e8ab..b43a0aee6a 100644 --- a/main.go +++ b/main.go @@ -1,11 +1,31 @@ package main import ( - "github.com/hashicorp/terraform-plugin-sdk/plugin" + "context" + "flag" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/v2/plugin" "github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas" ) func main() { - plugin.Serve(&plugin.ServeOpts{ - ProviderFunc: mongodbatlas.Provider}) + var debugMode bool + + flag.BoolVar(&debugMode, "debug", false, "set to true to run the provider with support for debuggers like delve") + flag.Parse() + + opts := &plugin.ServeOpts{ProviderFunc: mongodbatlas.Provider} + + if debugMode { + err := plugin.Debug(context.Background(), "registry.terraform.io/mongodb/mongodbatlas", opts) + + if err != nil { + log.Fatal(err.Error()) + } + + return + } + + plugin.Serve(opts) } diff --git a/mongodbatlas/config.go b/mongodbatlas/config.go index 2eb988835f..90707e05b0 100644 --- a/mongodbatlas/config.go +++ b/mongodbatlas/config.go @@ -3,7 +3,9 @@ package mongodbatlas import ( "context" - "github.com/hashicorp/terraform-plugin-sdk/helper/logging" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging" + digest "github.com/mongodb-forks/digest" matlasClient "go.mongodb.org/atlas/mongodbatlas" realmAuth "go.mongodb.org/realm/auth" @@ -24,14 +26,14 @@ type MongoDBClient struct { } // NewClient func... -func (c *Config) NewClient() interface{} { +func (c *Config) NewClient(ctx context.Context) (interface{}, diag.Diagnostics) { // setup a transport to handle digest transport := digest.NewTransport(c.PublicKey, c.PrivateKey) // initialize the client client, err := transport.Client() if err != nil { - return err + return nil, diag.FromErr(err) } client.Transport = logging.NewTransport("MongoDB Atlas", transport) @@ -44,7 +46,7 @@ func (c *Config) NewClient() interface{} { // Initialize the MongoDB Atlas API Client. atlasClient, err := matlasClient.New(client, optsAtlas...) if err != nil { - return err + return nil, diag.FromErr(err) } // Realm @@ -53,9 +55,9 @@ func (c *Config) NewClient() interface{} { optsRealm = append(optsRealm, realm.SetBaseURL(c.BaseURL)) } authConfig := realmAuth.NewConfig(client) - token, err := authConfig.NewTokenFromCredentials(context.Background(), c.PublicKey, c.PrivateKey) + token, err := authConfig.NewTokenFromCredentials(ctx, c.PublicKey, c.PrivateKey) if err != nil { - return err + return nil, diag.FromErr(err) } clientRealm := realmAuth.NewClient(realmAuth.BasicTokenSource(token)) @@ -64,7 +66,7 @@ func (c *Config) NewClient() interface{} { // Initialize the MongoDB Realm API Client. realmClient, err := realm.New(clientRealm, optsRealm...) if err != nil { - return err + return nil, diag.FromErr(err) } clients := &MongoDBClient{ @@ -72,5 +74,5 @@ func (c *Config) NewClient() interface{} { Realm: realmClient, } - return clients + return clients, nil } diff --git a/mongodbatlas/data_source_mongodbatlas_alert_configuration.go b/mongodbatlas/data_source_mongodbatlas_alert_configuration.go index 2aa83a95fc..5f114f4ff3 100644 --- a/mongodbatlas/data_source_mongodbatlas_alert_configuration.go +++ b/mongodbatlas/data_source_mongodbatlas_alert_configuration.go @@ -4,12 +4,13 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func dataSourceMongoDBAtlasAlertConfiguration() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasAlertConfigurationRead, + ReadContext: dataSourceMongoDBAtlasAlertConfigurationRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -60,6 +61,20 @@ func dataSourceMongoDBAtlasAlertConfiguration() *schema.Resource { "metric_threshold": { Type: schema.TypeMap, Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "threshold": { + Type: schema.TypeMap, + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "metric_threshold_config": { + Type: schema.TypeList, + Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "metric_name": { @@ -85,8 +100,8 @@ func dataSourceMongoDBAtlasAlertConfiguration() *schema.Resource { }, }, }, - "threshold": { - Type: schema.TypeMap, + "threshold_config": { + Type: schema.TypeList, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -215,43 +230,51 @@ func dataSourceMongoDBAtlasAlertConfiguration() *schema.Resource { } } -func dataSourceMongoDBAtlasAlertConfigurationRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasAlertConfigurationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) alertID := getEncodedID(d.Get("alert_configuration_id").(string), "id") - alert, _, err := conn.AlertConfigurations.GetAnAlertConfig(context.Background(), projectID, alertID) + alert, _, err := conn.AlertConfigurations.GetAnAlertConfig(ctx, projectID, alertID) if err != nil { - return fmt.Errorf(errorReadAlertConf, err) + return diag.FromErr(fmt.Errorf(errorReadAlertConf, err)) } if err := d.Set("event_type", alert.EventTypeName); err != nil { - return fmt.Errorf(errorAlertConfSetting, "event_type", projectID, err) + return diag.FromErr(fmt.Errorf(errorAlertConfSetting, "event_type", projectID, err)) } if err := d.Set("created", alert.Created); err != nil { - return fmt.Errorf(errorAlertConfSetting, "created", projectID, err) + return diag.FromErr(fmt.Errorf(errorAlertConfSetting, "created", projectID, err)) } if err := d.Set("updated", alert.Updated); err != nil { - return fmt.Errorf(errorAlertConfSetting, "updated", projectID, err) + return diag.FromErr(fmt.Errorf(errorAlertConfSetting, "updated", projectID, err)) } if err := d.Set("matcher", flattenAlertConfigurationMatchers(alert.Matchers)); err != nil { - return fmt.Errorf(errorAlertConfSetting, "matcher", projectID, err) + return diag.FromErr(fmt.Errorf(errorAlertConfSetting, "matcher", projectID, err)) } if err := d.Set("metric_threshold", flattenAlertConfigurationMetricThreshold(alert.MetricThreshold)); err != nil { - return fmt.Errorf(errorAlertConfSetting, "metric_threshold", projectID, err) + return diag.FromErr(fmt.Errorf(errorAlertConfSetting, "metric_threshold", projectID, err)) } if err := d.Set("threshold", flattenAlertConfigurationThreshold(alert.Threshold)); err != nil { - return fmt.Errorf(errorAlertConfSetting, "threshold", projectID, err) + return diag.FromErr(fmt.Errorf(errorAlertConfSetting, "threshold", projectID, err)) + } + + if err := d.Set("metric_threshold_config", flattenAlertConfigurationMetricThresholdConfig(alert.MetricThreshold)); err != nil { + return diag.FromErr(fmt.Errorf(errorAlertConfSetting, "metric_threshold_config", projectID, err)) + } + + if err := d.Set("threshold_config", flattenAlertConfigurationThresholdConfig(alert.Threshold)); err != nil { + return diag.FromErr(fmt.Errorf(errorAlertConfSetting, "threshold_config", projectID, err)) } if err := d.Set("notification", flattenAlertConfigurationNotifications(alert.Notifications)); err != nil { - return fmt.Errorf(errorAlertConfSetting, "notification", projectID, err) + return diag.FromErr(fmt.Errorf(errorAlertConfSetting, "notification", projectID, err)) } d.SetId(encodeStateID(map[string]string{ diff --git a/mongodbatlas/data_source_mongodbatlas_alert_configuration_test.go b/mongodbatlas/data_source_mongodbatlas_alert_configuration_test.go index 58a53a4adb..6c2e75e816 100644 --- a/mongodbatlas/data_source_mongodbatlas_alert_configuration_test.go +++ b/mongodbatlas/data_source_mongodbatlas_alert_configuration_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -17,9 +17,9 @@ func TestAccDataSourceMongoDBAtlaAlertConfiguration_basic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccDSMongoDBAtlasAlertConfiguration(projectID), @@ -40,9 +40,9 @@ func TestAccDataSourceMongoDBAtlaAlertConfiguration_withThreshold(t *testing.T) ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccDSMongoDBAtlasAlertConfigurationConfigWithThreshold(projectID, true, 1), @@ -76,7 +76,7 @@ func testAccDSMongoDBAtlasAlertConfiguration(projectID string) string { value = "SECONDARY" } - metric_threshold = { + metric_threshold_config { metric_name = "ASSERT_REGULAR" operator = "LESS_THAN" threshold = 99.0 @@ -114,7 +114,7 @@ func testAccDSMongoDBAtlasAlertConfigurationConfigWithThreshold(projectID string value = "SECONDARY" } - threshold = { + threshold_config { operator = "LESS_THAN" units = "HOURS" threshold = %f diff --git a/mongodbatlas/data_source_mongodbatlas_auditing.go b/mongodbatlas/data_source_mongodbatlas_auditing.go index 5666753053..f9da181b9c 100644 --- a/mongodbatlas/data_source_mongodbatlas_auditing.go +++ b/mongodbatlas/data_source_mongodbatlas_auditing.go @@ -4,12 +4,13 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func dataSourceMongoDBAtlasAuditing() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasAuditingRead, + ReadContext: dataSourceMongoDBAtlasAuditingRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -35,29 +36,29 @@ func dataSourceMongoDBAtlasAuditing() *schema.Resource { } } -func dataSourceMongoDBAtlasAuditingRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasAuditingRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) - auditing, _, err := conn.Auditing.Get(context.Background(), projectID) + auditing, _, err := conn.Auditing.Get(ctx, projectID) if err != nil { - return fmt.Errorf(errorAuditingRead, projectID, err) + return diag.FromErr(fmt.Errorf(errorAuditingRead, projectID, err)) } if err := d.Set("audit_authorization_success", auditing.AuditAuthorizationSuccess); err != nil { - return fmt.Errorf(errorAuditingRead, projectID, err) + return diag.FromErr(fmt.Errorf(errorAuditingRead, projectID, err)) } if err := d.Set("audit_filter", auditing.AuditFilter); err != nil { - return fmt.Errorf(errorAuditingRead, projectID, err) + return diag.FromErr(fmt.Errorf(errorAuditingRead, projectID, err)) } if err := d.Set("enabled", auditing.Enabled); err != nil { - return fmt.Errorf(errorAuditingRead, projectID, err) + return diag.FromErr(fmt.Errorf(errorAuditingRead, projectID, err)) } if err := d.Set("configuration_type", auditing.ConfigurationType); err != nil { - return fmt.Errorf(errorAuditingRead, projectID, err) + return diag.FromErr(fmt.Errorf(errorAuditingRead, projectID, err)) } d.SetId(projectID) diff --git a/mongodbatlas/data_source_mongodbatlas_auditing_test.go b/mongodbatlas/data_source_mongodbatlas_auditing_test.go index 86b824b470..38f4293b99 100644 --- a/mongodbatlas/data_source_mongodbatlas_auditing_test.go +++ b/mongodbatlas/data_source_mongodbatlas_auditing_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -20,8 +20,8 @@ func TestAccDataSourceMongoDBAtlasAuditing_basic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDataSourceAuditingConfig(projectID, auditFilter, auditAuth, enabled), diff --git a/mongodbatlas/data_source_mongodbatlas_cloud_provider_access.go b/mongodbatlas/data_source_mongodbatlas_cloud_provider_access.go index ffd42e1bd0..2bcfd65f3b 100644 --- a/mongodbatlas/data_source_mongodbatlas_cloud_provider_access.go +++ b/mongodbatlas/data_source_mongodbatlas_cloud_provider_access.go @@ -4,8 +4,9 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -15,7 +16,7 @@ const ( func dataSourceMongoDBAtlasCloudProviderAccessList() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasCloudProviderAccessRead, + ReadContext: dataSourceMongoDBAtlasCloudProviderAccessRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -85,18 +86,18 @@ func featureUsagesSchema() *schema.Resource { } } -func dataSourceMongoDBAtlasCloudProviderAccessRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasCloudProviderAccessRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) - roles, _, err := conn.CloudProviderAccess.ListRoles(context.Background(), projectID) + roles, _, err := conn.CloudProviderAccess.ListRoles(ctx, projectID) if err != nil { - return fmt.Errorf(errorGetRead, err) + return diag.FromErr(fmt.Errorf(errorGetRead, err)) } if err = d.Set("aws_iam_roles", flatCloudProviderAccessRoles(roles)); err != nil { - return fmt.Errorf(errorGetRead, err) + return diag.FromErr(fmt.Errorf(errorGetRead, err)) } d.SetId(resource.UniqueId()) diff --git a/mongodbatlas/data_source_mongodbatlas_cloud_provider_access_setup.go b/mongodbatlas/data_source_mongodbatlas_cloud_provider_access_setup.go index ae807ade49..dcdcb570e7 100644 --- a/mongodbatlas/data_source_mongodbatlas_cloud_provider_access_setup.go +++ b/mongodbatlas/data_source_mongodbatlas_cloud_provider_access_setup.go @@ -4,15 +4,16 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" matlas "go.mongodb.org/atlas/mongodbatlas" ) func dataSourceMongoDBAtlasCloudProviderAccessSetup() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasCloudProviderAccessSetupRead, + ReadContext: dataSourceMongoDBAtlasCloudProviderAccessSetupRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -30,6 +31,13 @@ func dataSourceMongoDBAtlasCloudProviderAccessSetup() *schema.Resource { "aws": { Type: schema.TypeMap, Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "aws_config": { + Type: schema.TypeList, + Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "atlas_aws_account_arn": { @@ -51,16 +59,16 @@ func dataSourceMongoDBAtlasCloudProviderAccessSetup() *schema.Resource { } } -func dataSourceMongoDBAtlasCloudProviderAccessSetupRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasCloudProviderAccessSetupRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) providerName := d.Get("provider_name").(string) roleID := d.Get("role_id").(string) - roles, _, err := conn.CloudProviderAccess.ListRoles(context.Background(), projectID) + roles, _, err := conn.CloudProviderAccess.ListRoles(ctx, projectID) if err != nil { - return fmt.Errorf(errorGetRead, err) + return diag.FromErr(fmt.Errorf(errorGetRead, err)) } // aws specific @@ -83,13 +91,13 @@ func dataSourceMongoDBAtlasCloudProviderAccessSetupRead(d *schema.ResourceData, for key, val := range roleSchema { if err := d.Set(key, val); err != nil { - return fmt.Errorf(errorGetRead, err) + return diag.FromErr(fmt.Errorf(errorGetRead, err)) } } } else { // planning for the future multiple providers - return fmt.Errorf(errorGetRead, - fmt.Sprintf("unsupported provider type %s", providerName)) + return diag.FromErr(fmt.Errorf(errorGetRead, + fmt.Sprintf("unsupported provider type %s", providerName))) } d.SetId(resource.UniqueId()) diff --git a/mongodbatlas/data_source_mongodbatlas_cloud_provider_access_setup_test.go b/mongodbatlas/data_source_mongodbatlas_cloud_provider_access_setup_test.go index f6cb740567..1b54d95598 100644 --- a/mongodbatlas/data_source_mongodbatlas_cloud_provider_access_setup_test.go +++ b/mongodbatlas/data_source_mongodbatlas_cloud_provider_access_setup_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) // covers both resource creation and datasource creation for setup @@ -41,8 +41,8 @@ func TestAccdataSourceMongoDBAtlasCloudProviderAccessSetup_aws_basic(t *testing. config := fmt.Sprintf(dataSourceCPASProviderConfig, name, projectID, "AWS", dataSCName) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: config, diff --git a/mongodbatlas/data_source_mongodbatlas_cloud_provider_access_test.go b/mongodbatlas/data_source_mongodbatlas_cloud_provider_access_test.go index eed81638d8..5121bf1039 100644 --- a/mongodbatlas/data_source_mongodbatlas_cloud_provider_access_test.go +++ b/mongodbatlas/data_source_mongodbatlas_cloud_provider_access_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) const ( @@ -35,8 +35,8 @@ func TestAccdataSourceMongoDBAtlasCloudProviderAccess_basic(t *testing.T) { config := fmt.Sprintf(dataSourceProviderConfig, name, projectID, "AWS", dataSCName) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: config, diff --git a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot.go b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot.go index 666cf1a426..0a9d1b82bc 100644 --- a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot.go +++ b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot.go @@ -4,14 +4,15 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) func dataSourceMongoDBAtlasCloudProviderSnapshot() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasCloudProviderSnapshotRead, + ReadContext: dataSourceMongoDBAtlasCloudProviderSnapshotRead, Schema: map[string]*schema.Schema{ "snapshot_id": { Type: schema.TypeString, @@ -65,7 +66,7 @@ func dataSourceMongoDBAtlasCloudProviderSnapshot() *schema.Resource { } } -func dataSourceMongoDBAtlasCloudProviderSnapshotRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasCloudProviderSnapshotRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas requestParameters := &matlas.SnapshotReqPathParameters{ @@ -74,45 +75,45 @@ func dataSourceMongoDBAtlasCloudProviderSnapshotRead(d *schema.ResourceData, met ClusterName: d.Get("cluster_name").(string), } - snapshotRes, _, err := conn.CloudProviderSnapshots.GetOneCloudProviderSnapshot(context.Background(), requestParameters) + snapshotRes, _, err := conn.CloudProviderSnapshots.GetOneCloudProviderSnapshot(ctx, requestParameters) if err != nil { - return fmt.Errorf("error getting cloudProviderSnapshot Information: %s", err) + return diag.FromErr(fmt.Errorf("error getting cloudProviderSnapshot Information: %s", err)) } if err = d.Set("created_at", snapshotRes.CreatedAt); err != nil { - return fmt.Errorf("error setting `created_at` for cloudProviderSnapshot (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `created_at` for cloudProviderSnapshot (%s): %s", d.Id(), err)) } if err = d.Set("description", snapshotRes.Description); err != nil { - return fmt.Errorf("error setting `description` for cloudProviderSnapshot (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `description` for cloudProviderSnapshot (%s): %s", d.Id(), err)) } if err = d.Set("expires_at", snapshotRes.ExpiresAt); err != nil { - return fmt.Errorf("error setting `expires_at` for cloudProviderSnapshot (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `expires_at` for cloudProviderSnapshot (%s): %s", d.Id(), err)) } if err = d.Set("master_key_uuid", snapshotRes.MasterKeyUUID); err != nil { - return fmt.Errorf("error setting `master_key_uuid` for cloudProviderSnapshot (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `master_key_uuid` for cloudProviderSnapshot (%s): %s", d.Id(), err)) } if err = d.Set("mongod_version", snapshotRes.MongodVersion); err != nil { - return fmt.Errorf("error setting `mongod_version` for cloudProviderSnapshot (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `mongod_version` for cloudProviderSnapshot (%s): %s", d.Id(), err)) } if err = d.Set("snapshot_type", snapshotRes.SnapshotType); err != nil { - return fmt.Errorf("error setting `snapshot_type` for cloudProviderSnapshot (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `snapshot_type` for cloudProviderSnapshot (%s): %s", d.Id(), err)) } if err = d.Set("status", snapshotRes.Status); err != nil { - return fmt.Errorf("error setting `status` for cloudProviderSnapshot (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `status` for cloudProviderSnapshot (%s): %s", d.Id(), err)) } if err = d.Set("storage_size_bytes", snapshotRes.StorageSizeBytes); err != nil { - return fmt.Errorf("error setting `storage_size_bytes` for cloudProviderSnapshot (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `storage_size_bytes` for cloudProviderSnapshot (%s): %s", d.Id(), err)) } if err = d.Set("type", snapshotRes.Type); err != nil { - return fmt.Errorf("error setting `type` for cloudProviderSnapshot (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `type` for cloudProviderSnapshot (%s): %s", d.Id(), err)) } d.SetId(snapshotRes.ID) diff --git a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_backup_policy.go b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_backup_policy.go index 077b200638..aa1d051a41 100644 --- a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_backup_policy.go +++ b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_backup_policy.go @@ -4,12 +4,13 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func dataSourceMongoDBAtlasCloudProviderSnapshotBackupPolicy() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasCloudProviderSnapshotBackupPolicyRead, + ReadContext: dataSourceMongoDBAtlasCloudProviderSnapshotBackupPolicyRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -87,43 +88,43 @@ func dataSourceMongoDBAtlasCloudProviderSnapshotBackupPolicy() *schema.Resource } } -func dataSourceMongoDBAtlasCloudProviderSnapshotBackupPolicyRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasCloudProviderSnapshotBackupPolicyRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) clusterName := d.Get("cluster_name").(string) - backupPolicy, _, err := conn.CloudProviderSnapshotBackupPolicies.Get(context.Background(), projectID, clusterName) + backupPolicy, _, err := conn.CloudProviderSnapshotBackupPolicies.Get(ctx, projectID, clusterName) if err != nil { - return fmt.Errorf(errorSnapshotBackupPolicyRead, clusterName, err) + return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicyRead, clusterName, err)) } if err := d.Set("cluster_id", backupPolicy.ClusterID); err != nil { - return fmt.Errorf(errorSnapshotBackupPolicySetting, "cluster_id", clusterName, err) + return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "cluster_id", clusterName, err)) } if err := d.Set("reference_hour_of_day", backupPolicy.ReferenceHourOfDay); err != nil { - return fmt.Errorf(errorSnapshotBackupPolicySetting, "reference_hour_of_day", clusterName, err) + return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "reference_hour_of_day", clusterName, err)) } if err := d.Set("reference_minute_of_hour", backupPolicy.ReferenceMinuteOfHour); err != nil { - return fmt.Errorf(errorSnapshotBackupPolicySetting, "reference_minute_of_hour", clusterName, err) + return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "reference_minute_of_hour", clusterName, err)) } if err := d.Set("restore_window_days", backupPolicy.RestoreWindowDays); err != nil { - return fmt.Errorf(errorSnapshotBackupPolicySetting, "restore_window_days", clusterName, err) + return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "restore_window_days", clusterName, err)) } if err := d.Set("update_snapshots", backupPolicy.UpdateSnapshots); err != nil { - return fmt.Errorf(errorSnapshotBackupPolicySetting, "update_snapshots", clusterName, err) + return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "update_snapshots", clusterName, err)) } if err := d.Set("next_snapshot", backupPolicy.NextSnapshot); err != nil { - return fmt.Errorf(errorSnapshotBackupPolicySetting, "next_snapshot", clusterName, err) + return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "next_snapshot", clusterName, err)) } if err := d.Set("policies", flattenPolicies(backupPolicy.Policies)); err != nil { - return fmt.Errorf(errorSnapshotBackupPolicySetting, "policies", clusterName, err) + return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "policies", clusterName, err)) } d.SetId(encodeStateID(map[string]string{ diff --git a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_backup_policy_test.go b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_backup_policy_test.go index fdc3ce3b0f..079b7d9612 100644 --- a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_backup_policy_test.go +++ b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_backup_policy_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccDataSourceMongoDBAtlasCloudProviderSnapshotBackupPolicy_basic(t *testing.T) { @@ -14,8 +14,8 @@ func TestAccDataSourceMongoDBAtlasCloudProviderSnapshotBackupPolicy_basic(t *tes clusterName := fmt.Sprintf("test-acc-%s", acctest.RandString(10)) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDataSourceCloudProviderSnapshotBackupPolicyConfig(projectID, clusterName), diff --git a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_restore_job.go b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_restore_job.go index eef0d0dd1e..19a88bb7a1 100644 --- a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_restore_job.go +++ b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_restore_job.go @@ -4,14 +4,15 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) func dataSourceMongoDBAtlasCloudProviderSnapshotRestoreJob() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasCloudProviderSnapshotRestoreJobRead, + ReadContext: dataSourceMongoDBAtlasCloudProviderSnapshotRestoreJobRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -91,7 +92,7 @@ func dataSourceMongoDBAtlasCloudProviderSnapshotRestoreJob() *schema.Resource { } } -func dataSourceMongoDBAtlasCloudProviderSnapshotRestoreJobRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasCloudProviderSnapshotRestoreJobRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas requestParameters := &matlas.SnapshotReqPathParameters{ @@ -100,65 +101,65 @@ func dataSourceMongoDBAtlasCloudProviderSnapshotRestoreJobRead(d *schema.Resourc ClusterName: d.Get("cluster_name").(string), } - snapshotRes, _, err := conn.CloudProviderSnapshotRestoreJobs.Get(context.Background(), requestParameters) + snapshotRes, _, err := conn.CloudProviderSnapshotRestoreJobs.Get(ctx, requestParameters) if err != nil { - return fmt.Errorf("error getting cloudProviderSnapshotRestoreJob Information: %s", err) + return diag.FromErr(fmt.Errorf("error getting cloudProviderSnapshotRestoreJob Information: %s", err)) } if err = d.Set("cancelled", snapshotRes.Cancelled); err != nil { - return fmt.Errorf("error setting `cancelled` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `cancelled` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err)) } if err = d.Set("created_at", snapshotRes.CreatedAt); err != nil { - return fmt.Errorf("error setting `created_at` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `created_at` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err)) } if err = d.Set("delivery_type", snapshotRes.DeliveryType); err != nil { - return fmt.Errorf("error setting `delivery_type` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `delivery_type` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err)) } if err = d.Set("delivery_url", snapshotRes.DeliveryURL); err != nil { - return fmt.Errorf("error setting `delivery_url` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `delivery_url` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err)) } if err = d.Set("expired", snapshotRes.Expired); err != nil { - return fmt.Errorf("error setting `expired` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `expired` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err)) } if err = d.Set("expires_at", snapshotRes.ExpiresAt); err != nil { - return fmt.Errorf("error setting `expires_at` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `expires_at` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err)) } if err = d.Set("finished_at", snapshotRes.FinishedAt); err != nil { - return fmt.Errorf("error setting `finished_at` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `finished_at` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err)) } if err = d.Set("snapshot_id", snapshotRes.SnapshotID); err != nil { - return fmt.Errorf("error setting `snapshotId` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `snapshotId` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err)) } if err = d.Set("target_project_id", snapshotRes.TargetGroupID); err != nil { - return fmt.Errorf("error setting `targetGroupId` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `targetGroupId` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err)) } if err = d.Set("target_cluster_name", snapshotRes.TargetClusterName); err != nil { - return fmt.Errorf("error setting `targetClusterName` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `targetClusterName` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err)) } if err = d.Set("timestamp", snapshotRes.Timestamp); err != nil { - return fmt.Errorf("error setting `timestamp` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `timestamp` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err)) } if err = d.Set("oplog_ts", snapshotRes.OplogTs); err != nil { - return fmt.Errorf("error setting `oplog_ts` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `oplog_ts` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err)) } if err = d.Set("point_in_time_utc_seconds", snapshotRes.PointInTimeUTCSeconds); err != nil { - return fmt.Errorf("error setting `point_in_time_utc_seconds` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `point_in_time_utc_seconds` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err)) } if err = d.Set("oplog_inc", snapshotRes.OplogInc); err != nil { - return fmt.Errorf("error setting `oplog_inc` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `oplog_inc` for cloudProviderSnapshotRestoreJob (%s): %s", d.Id(), err)) } d.SetId(snapshotRes.ID) diff --git a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_restore_job_test.go b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_restore_job_test.go index 6fa974be43..28a13ebff3 100644 --- a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_restore_job_test.go +++ b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_restore_job_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -20,8 +20,8 @@ func TestAccDataSourceMongoDBAtlasCloudProviderSnapshotRestoreJob_basic(t *testi ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDataSourceCloudProviderSnapshotRestoreJobConfig(projectID, clusterName, description, retentionInDays), @@ -63,8 +63,9 @@ func testAccMongoDBAtlasDataSourceCloudProviderSnapshotRestoreJobConfig(projectI project_id = mongodbatlas_cloud_provider_snapshot.test.project_id cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name snapshot_id = mongodbatlas_cloud_provider_snapshot.test.id - delivery_type = { + delivery_type_config { download = true + automated = true } depends_on = ["mongodbatlas_cloud_provider_snapshot.test"] } diff --git a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_restore_jobs.go b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_restore_jobs.go index c5d24ed1bb..d55cf66aff 100644 --- a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_restore_jobs.go +++ b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_restore_jobs.go @@ -4,15 +4,16 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) func dataSourceMongoDBAtlasCloudProviderSnapshotRestoreJobs() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasCloudProviderSnapshotRestoreJobsRead, + ReadContext: dataSourceMongoDBAtlasCloudProviderSnapshotRestoreJobsRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -109,7 +110,7 @@ func dataSourceMongoDBAtlasCloudProviderSnapshotRestoreJobs() *schema.Resource { } } -func dataSourceMongoDBAtlasCloudProviderSnapshotRestoreJobsRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasCloudProviderSnapshotRestoreJobsRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas requestParameters := &matlas.SnapshotReqPathParameters{ @@ -121,17 +122,17 @@ func dataSourceMongoDBAtlasCloudProviderSnapshotRestoreJobsRead(d *schema.Resour ItemsPerPage: d.Get("items_per_page").(int), } - cloudProviderSnapshotRestoreJobs, _, err := conn.CloudProviderSnapshotRestoreJobs.List(context.Background(), requestParameters, options) + cloudProviderSnapshotRestoreJobs, _, err := conn.CloudProviderSnapshotRestoreJobs.List(ctx, requestParameters, options) if err != nil { - return fmt.Errorf("error getting cloudProviderSnapshotRestoreJobs information: %s", err) + return diag.FromErr(fmt.Errorf("error getting cloudProviderSnapshotRestoreJobs information: %s", err)) } if err := d.Set("results", flattenCloudProviderSnapshotRestoreJobs(cloudProviderSnapshotRestoreJobs.Results)); err != nil { - return fmt.Errorf("error setting `results`: %s", err) + return diag.FromErr(fmt.Errorf("error setting `results`: %s", err)) } if err := d.Set("total_count", cloudProviderSnapshotRestoreJobs.TotalCount); err != nil { - return fmt.Errorf("error setting `total_count`: %s", err) + return diag.FromErr(fmt.Errorf("error setting `total_count`: %s", err)) } d.SetId(resource.UniqueId()) diff --git a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_restore_jobs_test.go b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_restore_jobs_test.go index de59901d2e..d4377641fb 100644 --- a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_restore_jobs_test.go +++ b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_restore_jobs_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -20,8 +20,8 @@ func TestAccDataSourceMongoDBAtlasCloudProviderSnapshotRestoreJobs_basic(t *test ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCloudProviderSnapshotRestoreJobsConfig(projectID, clusterName, description, retentionInDays), @@ -47,8 +47,8 @@ func TestAccDataSourceMongoDBAtlasCloudProviderSnapshotRestoreJobs_withPaginatio ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCloudProviderSnapshotRestoreJobsConfigWithPagination(projectID, clusterName, description, retentionInDays, 1, 5), @@ -90,7 +90,7 @@ func testAccMongoDBAtlasCloudProviderSnapshotRestoreJobsConfig(projectID, cluste project_id = mongodbatlas_cloud_provider_snapshot.test.project_id cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name snapshot_id = mongodbatlas_cloud_provider_snapshot.test.snapshot_id - delivery_type = { + delivery_type_config { download = true } } @@ -128,7 +128,7 @@ func testAccMongoDBAtlasCloudProviderSnapshotRestoreJobsConfigWithPagination(pro project_id = mongodbatlas_cloud_provider_snapshot.test.project_id cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name snapshot_id = mongodbatlas_cloud_provider_snapshot.test.snapshot_id - delivery_type = { + delivery_type_config { download = true } } diff --git a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_test.go b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_test.go index 166dac53e7..430d1c4ba2 100644 --- a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_test.go +++ b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshot_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -20,8 +20,8 @@ func TestAccDataSourceMongoDBAtlasCloudProviderSnapshot_basic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDataSourceCloudProviderSnapshotConfig(projectID, clusterName, description, retentionInDays), diff --git a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshots.go b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshots.go index d331bda1aa..3a88485564 100644 --- a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshots.go +++ b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshots.go @@ -4,15 +4,16 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) func dataSourceMongoDBAtlasCloudProviderSnapshots() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasCloudProviderSnapshotsRead, + ReadContext: dataSourceMongoDBAtlasCloudProviderSnapshotsRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -86,7 +87,7 @@ func dataSourceMongoDBAtlasCloudProviderSnapshots() *schema.Resource { } } -func dataSourceMongoDBAtlasCloudProviderSnapshotsRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasCloudProviderSnapshotsRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas @@ -99,17 +100,17 @@ func dataSourceMongoDBAtlasCloudProviderSnapshotsRead(d *schema.ResourceData, me ItemsPerPage: d.Get("items_per_page").(int), } - cloudProviderSnapshots, _, err := conn.CloudProviderSnapshots.GetAllCloudProviderSnapshots(context.Background(), requestParameters, options) + cloudProviderSnapshots, _, err := conn.CloudProviderSnapshots.GetAllCloudProviderSnapshots(ctx, requestParameters, options) if err != nil { - return fmt.Errorf("error getting cloudProviderSnapshots information: %s", err) + return diag.FromErr(fmt.Errorf("error getting cloudProviderSnapshots information: %s", err)) } if err := d.Set("results", flattenCloudProviderSnapshots(cloudProviderSnapshots.Results)); err != nil { - return fmt.Errorf("error setting `results`: %s", err) + return diag.FromErr(fmt.Errorf("error setting `results`: %s", err)) } if err := d.Set("total_count", cloudProviderSnapshots.TotalCount); err != nil { - return fmt.Errorf("error setting `total_count`: %s", err) + return diag.FromErr(fmt.Errorf("error setting `total_count`: %s", err)) } d.SetId(resource.UniqueId()) diff --git a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshots_test.go b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshots_test.go index 7d479382a0..e1aaf9dad4 100644 --- a/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshots_test.go +++ b/mongodbatlas/data_source_mongodbatlas_cloud_provider_snapshots_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccDataSourceMongoDBAtlasCloudProviderSnapshots_basic(t *testing.T) { @@ -18,8 +18,8 @@ func TestAccDataSourceMongoDBAtlasCloudProviderSnapshots_basic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDataSourceCloudProviderSnapshotsConfig(projectID, clusterName, description, retentionInDays), @@ -43,8 +43,8 @@ func TestAccDataSourceMongoDBAtlasCloudProviderSnapshots_withPagination(t *testi ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDataSourceCloudProviderSnapshotsConfigWithPagination(projectID, clusterName, description, retentionInDays, 1, 5), diff --git a/mongodbatlas/data_source_mongodbatlas_cluster.go b/mongodbatlas/data_source_mongodbatlas_cluster.go index 28b8f75ad6..0e8797b5c6 100644 --- a/mongodbatlas/data_source_mongodbatlas_cluster.go +++ b/mongodbatlas/data_source_mongodbatlas_cluster.go @@ -7,16 +7,16 @@ import ( "net/http" "time" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/spf13/cast" - matlas "go.mongodb.org/atlas/mongodbatlas" ) func dataSourceMongoDBAtlasCluster() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasClusterRead, + ReadContext: dataSourceMongoDBAtlasClusterRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -46,23 +46,13 @@ func dataSourceMongoDBAtlasCluster() *schema.Resource { Type: schema.TypeMap, Computed: true, Deprecated: "use bi_connector_config instead", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "enabled": { - Type: schema.TypeString, // Convert to Bool - Computed: true, - }, - "read_preference": { - Type: schema.TypeString, - Computed: true, - }, - }, + Elem: &schema.Schema{ + Type: schema.TypeString, }, }, "bi_connector_config": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "enabled": { @@ -82,8 +72,6 @@ func dataSourceMongoDBAtlasCluster() *schema.Resource { }, "connection_strings": { Type: schema.TypeList, - MinItems: 1, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -202,6 +190,10 @@ func dataSourceMongoDBAtlasCluster() *schema.Resource { Type: schema.TypeBool, Computed: true, }, + "provider_encrypt_ebs_volume_flag": { + Type: schema.TypeBool, + Computed: true, + }, "provider_region_name": { Type: schema.TypeString, Computed: true, @@ -323,19 +315,19 @@ func dataSourceMongoDBAtlasCluster() *schema.Resource { } } -func dataSourceMongoDBAtlasClusterRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasClusterRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) clusterName := d.Get("name").(string) - cluster, resp, err := conn.Clusters.Get(context.Background(), projectID, clusterName) + cluster, resp, err := conn.Clusters.Get(ctx, projectID, clusterName) if err != nil { if resp != nil && resp.StatusCode == http.StatusNotFound { return nil } - return fmt.Errorf(errorClusterRead, clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterRead, clusterName, err)) } if cluster.ProviderSettings != nil && (cast.ToString(cluster.ProviderSettings.ProviderName) == "AWS" || @@ -349,7 +341,7 @@ func dataSourceMongoDBAtlasClusterRead(d *schema.ResourceData, meta interface{}) Delay: 3 * time.Minute, } - resp, err := stateConf.WaitForState() + resp, err := stateConf.WaitForStateContext(ctx) if err != nil { log.Printf("[ERROR] %v", fmt.Errorf(errorClusterRead, clusterName, err)) } else { @@ -358,82 +350,82 @@ func dataSourceMongoDBAtlasClusterRead(d *schema.ResourceData, meta interface{}) } if err := d.Set("auto_scaling_disk_gb_enabled", cluster.AutoScaling.DiskGBEnabled); err != nil { - return fmt.Errorf(errorClusterSetting, "auto_scaling_disk_gb_enabled", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "auto_scaling_disk_gb_enabled", clusterName, err)) } if err := d.Set("backup_enabled", cluster.BackupEnabled); err != nil { - return fmt.Errorf(errorClusterSetting, "backup_enabled", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "backup_enabled", clusterName, err)) } if err := d.Set("pit_enabled", cluster.PitEnabled); err != nil { - return fmt.Errorf(errorClusterSetting, "pit_enabled", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "pit_enabled", clusterName, err)) } if err := d.Set("provider_backup_enabled", cluster.ProviderBackupEnabled); err != nil { - return fmt.Errorf(errorClusterSetting, "provider_backup_enabled", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "provider_backup_enabled", clusterName, err)) } if err := d.Set("cluster_type", cluster.ClusterType); err != nil { - return fmt.Errorf(errorClusterSetting, "cluster_type", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "cluster_type", clusterName, err)) } if err := d.Set("connection_strings", flattenConnectionStrings(cluster.ConnectionStrings)); err != nil { - return fmt.Errorf(errorClusterSetting, "connection_strings", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "connection_strings", clusterName, err)) } if err := d.Set("disk_size_gb", cluster.DiskSizeGB); err != nil { - return fmt.Errorf(errorClusterSetting, "disk_size_gb", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "disk_size_gb", clusterName, err)) } if err := d.Set("encryption_at_rest_provider", cluster.EncryptionAtRestProvider); err != nil { - return fmt.Errorf(errorClusterSetting, "encryption_at_rest_provider", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "encryption_at_rest_provider", clusterName, err)) } if err := d.Set("mongo_db_major_version", cluster.MongoDBMajorVersion); err != nil { - return fmt.Errorf(errorClusterSetting, "mongo_db_major_version", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "mongo_db_major_version", clusterName, err)) } // Avoid Global Cluster issues. (NumShards is not present in Global Clusters) if cluster.NumShards != nil { if err := d.Set("num_shards", cluster.NumShards); err != nil { - return fmt.Errorf(errorClusterSetting, "num_shards", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "num_shards", clusterName, err)) } } if err := d.Set("mongo_db_version", cluster.MongoDBVersion); err != nil { - return fmt.Errorf(errorClusterSetting, "mongo_db_version", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "mongo_db_version", clusterName, err)) } if err := d.Set("mongo_uri", cluster.MongoURI); err != nil { - return fmt.Errorf(errorClusterSetting, "mongo_uri", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "mongo_uri", clusterName, err)) } if err := d.Set("mongo_uri_updated", cluster.MongoURIUpdated); err != nil { - return fmt.Errorf(errorClusterSetting, "mongo_uri_updated", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "mongo_uri_updated", clusterName, err)) } if err := d.Set("mongo_uri_with_options", cluster.MongoURIWithOptions); err != nil { - return fmt.Errorf(errorClusterSetting, "mongo_uri_with_options", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "mongo_uri_with_options", clusterName, err)) } if err := d.Set("paused", cluster.Paused); err != nil { - return fmt.Errorf(errorClusterSetting, "paused", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "paused", clusterName, err)) } if err := d.Set("srv_address", cluster.SrvAddress); err != nil { - return fmt.Errorf(errorClusterSetting, "srv_address", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "srv_address", clusterName, err)) } if err := d.Set("state_name", cluster.StateName); err != nil { - return fmt.Errorf(errorClusterSetting, "state_name", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "state_name", clusterName, err)) } if err := d.Set("bi_connector", flattenBiConnector(cluster.BiConnector)); err != nil { - return fmt.Errorf(errorClusterSetting, "bi_connector", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "bi_connector", clusterName, err)) } if err := d.Set("bi_connector_config", flattenBiConnectorConfig(cluster.BiConnector)); err != nil { - return fmt.Errorf(errorClusterSetting, "bi_connector_config", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "bi_connector_config", clusterName, err)) } if cluster.ProviderSettings != nil { @@ -441,25 +433,25 @@ func dataSourceMongoDBAtlasClusterRead(d *schema.ResourceData, meta interface{}) } if err := d.Set("replication_specs", flattenReplicationSpecs(cluster.ReplicationSpecs)); err != nil { - return fmt.Errorf(errorClusterSetting, "replication_specs", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "replication_specs", clusterName, err)) } if err := d.Set("replication_factor", cluster.ReplicationFactor); err != nil { - return fmt.Errorf(errorClusterSetting, "replication_factor", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "replication_factor", clusterName, err)) } if err := d.Set("labels", flattenLabels(cluster.Labels)); err != nil { - return fmt.Errorf(errorClusterSetting, "labels", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "labels", clusterName, err)) } // Get the snapshot policy and set the data - snapshotBackupPolicy, err := flattenCloudProviderSnapshotBackupPolicy(d, conn, projectID, clusterName) + snapshotBackupPolicy, err := flattenCloudProviderSnapshotBackupPolicy(ctx, d, conn, projectID, clusterName) if err != nil { - return err + return diag.FromErr(err) } if err := d.Set("snapshot_backup_policy", snapshotBackupPolicy); err != nil { - return err + return diag.FromErr(err) } d.SetId(cluster.ID) diff --git a/mongodbatlas/data_source_mongodbatlas_cluster_test.go b/mongodbatlas/data_source_mongodbatlas_cluster_test.go index 1888a275d8..44f72cbcb3 100644 --- a/mongodbatlas/data_source_mongodbatlas_cluster_test.go +++ b/mongodbatlas/data_source_mongodbatlas_cluster_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -20,9 +20,9 @@ func TestAccDataSourceMongoDBAtlasCluster_basic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccDataSourceMongoDBAtlasClusterConfig(projectID, name, "true"), diff --git a/mongodbatlas/data_source_mongodbatlas_clusters.go b/mongodbatlas/data_source_mongodbatlas_clusters.go index 56f4a4cf0c..a36d46a8d7 100644 --- a/mongodbatlas/data_source_mongodbatlas_clusters.go +++ b/mongodbatlas/data_source_mongodbatlas_clusters.go @@ -6,15 +6,16 @@ import ( "log" "net/http" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) func dataSourceMongoDBAtlasClusters() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasClustersRead, + ReadContext: dataSourceMongoDBAtlasClustersRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -49,23 +50,13 @@ func dataSourceMongoDBAtlasClusters() *schema.Resource { Type: schema.TypeMap, Computed: true, Deprecated: "use bi_connector_config instead", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "enabled": { - Type: schema.TypeString, // Convert to Bool - Computed: true, - }, - "read_preference": { - Type: schema.TypeString, - Computed: true, - }, - }, + Elem: &schema.Schema{ + Type: schema.TypeString, }, }, "bi_connector_config": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "enabled": { @@ -85,8 +76,6 @@ func dataSourceMongoDBAtlasClusters() *schema.Resource { }, "connection_strings": { Type: schema.TypeList, - MinItems: 1, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -329,33 +318,33 @@ func dataSourceMongoDBAtlasClusters() *schema.Resource { } } -func dataSourceMongoDBAtlasClustersRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasClustersRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) d.SetId(resource.UniqueId()) - clusters, resp, err := conn.Clusters.List(context.Background(), projectID, nil) + clusters, resp, err := conn.Clusters.List(ctx, projectID, nil) if err != nil { if resp != nil && resp.StatusCode == http.StatusNotFound { return nil } - return fmt.Errorf("error reading cluster list for project(%s): %s", projectID, err) + return diag.FromErr(fmt.Errorf("error reading cluster list for project(%s): %s", projectID, err)) } - if err := d.Set("results", flattenClusters(d, conn, clusters)); err != nil { - return fmt.Errorf(errorClusterSetting, "results", d.Id(), err) + if err := d.Set("results", flattenClusters(ctx, d, conn, clusters)); err != nil { + return diag.FromErr(fmt.Errorf(errorClusterSetting, "results", d.Id(), err)) } return nil } -func flattenClusters(d *schema.ResourceData, conn *matlas.Client, clusters []matlas.Cluster) []map[string]interface{} { +func flattenClusters(ctx context.Context, d *schema.ResourceData, conn *matlas.Client, clusters []matlas.Cluster) []map[string]interface{} { results := make([]map[string]interface{}, 0) for i := range clusters { - snapshotBackupPolicy, err := flattenCloudProviderSnapshotBackupPolicy(d, conn, clusters[i].GroupID, clusters[i].Name) + snapshotBackupPolicy, err := flattenCloudProviderSnapshotBackupPolicy(ctx, d, conn, clusters[i].GroupID, clusters[i].Name) if err != nil { log.Printf("[WARN] Error setting `snapshot_backup_policy` for the cluster(%s): %s", clusters[i].ID, err) } diff --git a/mongodbatlas/data_source_mongodbatlas_clusters_test.go b/mongodbatlas/data_source_mongodbatlas_clusters_test.go index 84554f8956..1954f46772 100644 --- a/mongodbatlas/data_source_mongodbatlas_clusters_test.go +++ b/mongodbatlas/data_source_mongodbatlas_clusters_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -20,9 +20,9 @@ func TestAccDataSourceMongoDBAtlasClusters_basic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccDataSourceMongoDBAtlasClustersConfig(projectID, name, "true"), diff --git a/mongodbatlas/data_source_mongodbatlas_custom_db_role.go b/mongodbatlas/data_source_mongodbatlas_custom_db_role.go index 4b32894d89..791f2cfbf1 100644 --- a/mongodbatlas/data_source_mongodbatlas_custom_db_role.go +++ b/mongodbatlas/data_source_mongodbatlas_custom_db_role.go @@ -4,12 +4,13 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func dataSourceMongoDBAtlasCustomDBRole() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasCustomDBRoleRead, + ReadContext: dataSourceMongoDBAtlasCustomDBRoleRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -71,26 +72,26 @@ func dataSourceMongoDBAtlasCustomDBRole() *schema.Resource { } } -func dataSourceMongoDBAtlasCustomDBRoleRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasCustomDBRoleRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) roleName := d.Get("role_name").(string) - customDBRole, _, err := conn.CustomDBRoles.Get(context.Background(), projectID, roleName) + customDBRole, _, err := conn.CustomDBRoles.Get(ctx, projectID, roleName) if err != nil { - return fmt.Errorf("error getting custom db role information: %s", err) + return diag.FromErr(fmt.Errorf("error getting custom db role information: %s", err)) } if err := d.Set("role_name", customDBRole.RoleName); err != nil { - return fmt.Errorf("error setting `role_name` for custom db role (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `role_name` for custom db role (%s): %s", d.Id(), err)) } if err := d.Set("actions", flattenActions(customDBRole.Actions)); err != nil { - return fmt.Errorf("error setting `actions` for custom db role (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `actions` for custom db role (%s): %s", d.Id(), err)) } if err := d.Set("inherited_roles", flattenInheritedRoles(customDBRole.InheritedRoles)); err != nil { - return fmt.Errorf("error setting `inherited_roles` for custom db role (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `inherited_roles` for custom db role (%s): %s", d.Id(), err)) } d.SetId(encodeStateID(map[string]string{ diff --git a/mongodbatlas/data_source_mongodbatlas_custom_db_role_test.go b/mongodbatlas/data_source_mongodbatlas_custom_db_role_test.go index 39ad3663ff..2d6e76eae0 100644 --- a/mongodbatlas/data_source_mongodbatlas_custom_db_role_test.go +++ b/mongodbatlas/data_source_mongodbatlas_custom_db_role_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccDataSourceMongoDBAtlasCustomDBRole_basic(t *testing.T) { @@ -16,9 +16,9 @@ func TestAccDataSourceMongoDBAtlasCustomDBRole_basic(t *testing.T) { roleName := fmt.Sprintf("test-acc-custom_role-%s", acctest.RandString(5)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, Steps: []resource.TestStep{ { Config: testAccDSMongoDBAtlasCustomDBRoleConfig(projectID, roleName, "INSERT", fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))), diff --git a/mongodbatlas/data_source_mongodbatlas_custom_db_roles.go b/mongodbatlas/data_source_mongodbatlas_custom_db_roles.go index 8b2b384676..94be5ca766 100644 --- a/mongodbatlas/data_source_mongodbatlas_custom_db_roles.go +++ b/mongodbatlas/data_source_mongodbatlas_custom_db_roles.go @@ -4,14 +4,15 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) func dataSourceMongoDBAtlasCustomDBRoles() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasCustomDBRolesRead, + ReadContext: dataSourceMongoDBAtlasCustomDBRolesRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -81,17 +82,17 @@ func dataSourceMongoDBAtlasCustomDBRoles() *schema.Resource { } } -func dataSourceMongoDBAtlasCustomDBRolesRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasCustomDBRolesRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) - customDBRoles, _, err := conn.CustomDBRoles.List(context.Background(), projectID, nil) + customDBRoles, _, err := conn.CustomDBRoles.List(ctx, projectID, nil) if err != nil { - return fmt.Errorf("error getting custom db roles information: %s", err) + return diag.FromErr(fmt.Errorf("error getting custom db roles information: %s", err)) } if err := d.Set("results", flattenCustomDBRoles(*customDBRoles)); err != nil { - return fmt.Errorf("error setting `results for custom db roles: %s", err) + return diag.FromErr(fmt.Errorf("error setting `results for custom db roles: %s", err)) } d.SetId(resource.UniqueId()) diff --git a/mongodbatlas/data_source_mongodbatlas_custom_db_roles_test.go b/mongodbatlas/data_source_mongodbatlas_custom_db_roles_test.go index 7124d6fc45..fcb2a8e44d 100644 --- a/mongodbatlas/data_source_mongodbatlas_custom_db_roles_test.go +++ b/mongodbatlas/data_source_mongodbatlas_custom_db_roles_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccDataSourceMongoDBAtlasCustomDBRoles_basic(t *testing.T) { @@ -16,9 +16,9 @@ func TestAccDataSourceMongoDBAtlasCustomDBRoles_basic(t *testing.T) { roleName := fmt.Sprintf("test-acc-custom_role-%s", acctest.RandString(5)) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, Steps: []resource.TestStep{ { Config: testAccDSMongoDBAtlasCustomDBRolesConfig(projectID, roleName, "INSERT", fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))), diff --git a/mongodbatlas/data_source_mongodbatlas_custom_dns_configuration_cluster_aws.go b/mongodbatlas/data_source_mongodbatlas_custom_dns_configuration_cluster_aws.go index 0e35d28f42..f7abb2b18e 100644 --- a/mongodbatlas/data_source_mongodbatlas_custom_dns_configuration_cluster_aws.go +++ b/mongodbatlas/data_source_mongodbatlas_custom_dns_configuration_cluster_aws.go @@ -4,12 +4,13 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func dataSourceMongoDBAtlasCustomDNSConfigurationAWS() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasCustomDNSConfigurationAWSRead, + ReadContext: dataSourceMongoDBAtlasCustomDNSConfigurationAWSRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -24,19 +25,19 @@ func dataSourceMongoDBAtlasCustomDNSConfigurationAWS() *schema.Resource { } } -func dataSourceMongoDBAtlasCustomDNSConfigurationAWSRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasCustomDNSConfigurationAWSRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) - customDNSSetting, _, err := conn.CustomAWSDNS.Get(context.Background(), projectID) + customDNSSetting, _, err := conn.CustomAWSDNS.Get(ctx, projectID) if err != nil { - return fmt.Errorf(errorCustomDNSConfigurationRead, err) + return diag.FromErr(fmt.Errorf(errorCustomDNSConfigurationRead, err)) } if err := d.Set("enabled", customDNSSetting.Enabled); err != nil { - return fmt.Errorf(errorCustomDNSConfigurationSetting, "enabled", projectID, err) + return diag.FromErr(fmt.Errorf(errorCustomDNSConfigurationSetting, "enabled", projectID, err)) } d.SetId(projectID) diff --git a/mongodbatlas/data_source_mongodbatlas_custom_dns_configuration_cluster_aws_test.go b/mongodbatlas/data_source_mongodbatlas_custom_dns_configuration_cluster_aws_test.go index ddf19c9822..15deb8e050 100644 --- a/mongodbatlas/data_source_mongodbatlas_custom_dns_configuration_cluster_aws_test.go +++ b/mongodbatlas/data_source_mongodbatlas_custom_dns_configuration_cluster_aws_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccDataSourceMongoDBAtlasCustomDNSConfigurationAWS_basic(t *testing.T) { @@ -13,8 +13,8 @@ func TestAccDataSourceMongoDBAtlasCustomDNSConfigurationAWS_basic(t *testing.T) projectID := os.Getenv("MONGODB_ATLAS_PROJECT_ID") resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCustomDNSConfigurationAWSDataSourceConfig(projectID, true), diff --git a/mongodbatlas/data_source_mongodbatlas_data_lake.go b/mongodbatlas/data_source_mongodbatlas_data_lake.go index fc88b25703..e049925f95 100644 --- a/mongodbatlas/data_source_mongodbatlas_data_lake.go +++ b/mongodbatlas/data_source_mongodbatlas_data_lake.go @@ -5,12 +5,13 @@ import ( "fmt" "net/http" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func dataSourceMongoDBAtlasDataLake() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasDataLakeRead, + ReadContext: dataSourceMongoDBAtlasDataLakeRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -22,7 +23,6 @@ func dataSourceMongoDBAtlasDataLake() *schema.Resource { }, "aws": { Type: schema.TypeList, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -50,7 +50,7 @@ func dataSourceMongoDBAtlasDataLake() *schema.Resource { }, }, "data_process_region": { - Type: schema.TypeMap, + Type: schema.TypeList, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -82,44 +82,44 @@ func dataSourceMongoDBAtlasDataLake() *schema.Resource { } } -func dataSourceMongoDBAtlasDataLakeRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasDataLakeRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) name := d.Get("name").(string) - dataLake, resp, err := conn.DataLakes.Get(context.Background(), projectID, name) + dataLake, resp, err := conn.DataLakes.Get(ctx, projectID, name) if err != nil { if resp != nil && resp.StatusCode == http.StatusNotFound { d.SetId("") return nil } - return fmt.Errorf(errorDataLakeRead, name, err) + return diag.FromErr(fmt.Errorf(errorDataLakeRead, name, err)) } if err := d.Set("aws", flattenAWSBlock(&dataLake.CloudProviderConfig)); err != nil { - return fmt.Errorf(errorDataLakeSetting, "aws", name, err) + return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "aws", name, err)) } if err := d.Set("data_process_region", flattenDataLakeProcessRegion(&dataLake.DataProcessRegion)); err != nil { - return fmt.Errorf(errorDataLakeSetting, "data_process_region", name, err) + return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "data_process_region", name, err)) } if err := d.Set("hostnames", dataLake.Hostnames); err != nil { - return fmt.Errorf(errorDataLakeSetting, "hostnames", name, err) + return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "hostnames", name, err)) } if err := d.Set("state", dataLake.State); err != nil { - return fmt.Errorf(errorDataLakeSetting, "state", name, err) + return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "state", name, err)) } if err := d.Set("storage_databases", flattenDataLakeStorageDatabases(dataLake.Storage.Databases)); err != nil { - return fmt.Errorf(errorDataLakeSetting, "storage_databases", name, err) + return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "storage_databases", name, err)) } if err := d.Set("storage_stores", flattenDataLakeStorageStores(dataLake.Storage.Stores)); err != nil { - return fmt.Errorf(errorDataLakeSetting, "storage_stores", name, err) + return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "storage_stores", name, err)) } d.SetId(encodeStateID(map[string]string{ diff --git a/mongodbatlas/data_source_mongodbatlas_data_lake_test.go b/mongodbatlas/data_source_mongodbatlas_data_lake_test.go index 1197bbaec4..033b9e6b59 100644 --- a/mongodbatlas/data_source_mongodbatlas_data_lake_test.go +++ b/mongodbatlas/data_source_mongodbatlas_data_lake_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -24,8 +24,8 @@ func TestAccDataSourceMongoDBAtlasDataLake_basic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDataLakeDataSourceConfig(policyName, roleName, projectName, orgID, name, testS3Bucket), @@ -70,12 +70,12 @@ resource "aws_iam_role" "test_role" { { "Effect": "Allow", "Principal": { - "AWS": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_aws_account_arn}" + "AWS": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws_config.0.atlas_aws_account_arn}" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { - "sts:ExternalId": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_assumed_role_external_id}" + "sts:ExternalId": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws_config.0.atlas_assumed_role_external_id}" } } } @@ -100,7 +100,7 @@ resource "mongodbatlas_cloud_provider_access_authorization" "auth_role" { project_id = mongodbatlas_project.test.id role_id = mongodbatlas_cloud_provider_access_setup.setup_only.role_id - aws = { + aws { iam_assumed_role_arn = aws_iam_role.test_role.arn } } diff --git a/mongodbatlas/data_source_mongodbatlas_data_lakes.go b/mongodbatlas/data_source_mongodbatlas_data_lakes.go index 1a36370a73..e0d2ffc44e 100644 --- a/mongodbatlas/data_source_mongodbatlas_data_lakes.go +++ b/mongodbatlas/data_source_mongodbatlas_data_lakes.go @@ -4,15 +4,16 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" matlas "go.mongodb.org/atlas/mongodbatlas" ) func dataSourceMongoDBAtlasDataLakes() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasDataLakesRead, + ReadContext: dataSourceMongoDBAtlasDataLakesRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -34,7 +35,6 @@ func dataSourceMongoDBAtlasDataLakes() *schema.Resource { }, "aws": { Type: schema.TypeList, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -62,7 +62,7 @@ func dataSourceMongoDBAtlasDataLakes() *schema.Resource { }, }, "data_process_region": { - Type: schema.TypeMap, + Type: schema.TypeList, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -97,19 +97,19 @@ func dataSourceMongoDBAtlasDataLakes() *schema.Resource { } } -func dataSourceMongoDBAtlasDataLakesRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasDataLakesRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) - dataLakes, _, err := conn.DataLakes.List(context.Background(), projectID) + dataLakes, _, err := conn.DataLakes.List(ctx, projectID) if err != nil { - return fmt.Errorf("error getting MongoDB Atlas Data Lakes information: %s", err) + return diag.FromErr(fmt.Errorf("error getting MongoDB Atlas Data Lakes information: %s", err)) } if err := d.Set("results", flattenDataLakes(dataLakes)); err != nil { - return fmt.Errorf(errorDataLakeSetting, "results", projectID, err) + return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "results", projectID, err)) } d.SetId(resource.UniqueId()) diff --git a/mongodbatlas/data_source_mongodbatlas_data_lakes_test.go b/mongodbatlas/data_source_mongodbatlas_data_lakes_test.go index cf4384ffa5..5c16d703b6 100644 --- a/mongodbatlas/data_source_mongodbatlas_data_lakes_test.go +++ b/mongodbatlas/data_source_mongodbatlas_data_lakes_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccDataSourceMongoDBAtlasDataLakes_basic(t *testing.T) { @@ -13,8 +13,8 @@ func TestAccDataSourceMongoDBAtlasDataLakes_basic(t *testing.T) { projectID := os.Getenv("MONGODB_ATLAS_PROJECT_ID") resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDataLakesDataSourceConfig(projectID), diff --git a/mongodbatlas/data_source_mongodbatlas_database_user.go b/mongodbatlas/data_source_mongodbatlas_database_user.go index 313ab8528b..2ec314db3d 100644 --- a/mongodbatlas/data_source_mongodbatlas_database_user.go +++ b/mongodbatlas/data_source_mongodbatlas_database_user.go @@ -5,12 +5,13 @@ import ( "errors" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func dataSourceMongoDBAtlasDatabaseUser() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasDatabaseUserRead, + ReadContext: dataSourceMongoDBAtlasDatabaseUserRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -99,7 +100,7 @@ func dataSourceMongoDBAtlasDatabaseUser() *schema.Resource { } } -func dataSourceMongoDBAtlasDatabaseUserRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasDatabaseUserRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) @@ -109,7 +110,7 @@ func dataSourceMongoDBAtlasDatabaseUserRead(d *schema.ResourceData, meta interfa authDBName, authDBNameOk := d.GetOk("auth_database_name") if !dbNameOk && !authDBNameOk { - return errors.New("one of database_name or auth_database_name must be configured") + return diag.FromErr(errors.New("one of database_name or auth_database_name must be configured")) } var authDatabaseName string @@ -119,47 +120,47 @@ func dataSourceMongoDBAtlasDatabaseUserRead(d *schema.ResourceData, meta interfa authDatabaseName = authDBName.(string) } - dbUser, _, err := conn.DatabaseUsers.Get(context.Background(), authDatabaseName, projectID, username) + dbUser, _, err := conn.DatabaseUsers.Get(ctx, authDatabaseName, projectID, username) if err != nil { - return fmt.Errorf("error getting database user information: %s", err) + return diag.FromErr(fmt.Errorf("error getting database user information: %s", err)) } if err := d.Set("username", dbUser.Username); err != nil { - return fmt.Errorf("error setting `username` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `username` for database user (%s): %s", d.Id(), err)) } if _, ok := d.GetOk("auth_database_name"); ok { if err := d.Set("auth_database_name", dbUser.DatabaseName); err != nil { - return fmt.Errorf("error setting `auth_database_name` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `auth_database_name` for database user (%s): %s", d.Id(), err)) } } else { if err := d.Set("database_name", dbUser.DatabaseName); err != nil { - return fmt.Errorf("error setting `database_name` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `database_name` for database user (%s): %s", d.Id(), err)) } } if err := d.Set("x509_type", dbUser.X509Type); err != nil { - return fmt.Errorf("error setting `x509_type` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `x509_type` for database user (%s): %s", d.Id(), err)) } if err := d.Set("aws_iam_type", dbUser.AWSIAMType); err != nil { - return fmt.Errorf("error setting `aws_iam_type` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `aws_iam_type` for database user (%s): %s", d.Id(), err)) } if err := d.Set("ldap_auth_type", dbUser.LDAPAuthType); err != nil { - return fmt.Errorf("error setting `ldap_auth_type` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `ldap_auth_type` for database user (%s): %s", d.Id(), err)) } if err := d.Set("roles", flattenRoles(dbUser.Roles)); err != nil { - return fmt.Errorf("error setting `roles` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `roles` for database user (%s): %s", d.Id(), err)) } if err := d.Set("labels", flattenLabels(dbUser.Labels)); err != nil { - return fmt.Errorf("error setting `labels` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `labels` for database user (%s): %s", d.Id(), err)) } if err := d.Set("scopes", flattenScopes(dbUser.Scopes)); err != nil { - return fmt.Errorf("error setting `scopes` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `scopes` for database user (%s): %s", d.Id(), err)) } d.SetId(encodeStateID(map[string]string{ diff --git a/mongodbatlas/data_source_mongodbatlas_database_user_test.go b/mongodbatlas/data_source_mongodbatlas_database_user_test.go index d1539e3d78..4f2318fcb7 100644 --- a/mongodbatlas/data_source_mongodbatlas_database_user_test.go +++ b/mongodbatlas/data_source_mongodbatlas_database_user_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -19,8 +19,8 @@ func TestAccDataSourceMongoDBAtlasDatabaseUser_basic(t *testing.T) { username := fmt.Sprintf("test-acc-%s", acctest.RandString(10)) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDatabaseUserDataSourceConfig(projectID, roleName, username), diff --git a/mongodbatlas/data_source_mongodbatlas_database_users.go b/mongodbatlas/data_source_mongodbatlas_database_users.go index 1a50f2c995..382b596a3f 100644 --- a/mongodbatlas/data_source_mongodbatlas_database_users.go +++ b/mongodbatlas/data_source_mongodbatlas_database_users.go @@ -4,16 +4,17 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" matlas "go.mongodb.org/atlas/mongodbatlas" ) func dataSourceMongoDBAtlasDatabaseUsers() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasDatabaseUsersRead, + ReadContext: dataSourceMongoDBAtlasDatabaseUsersRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -108,19 +109,19 @@ func dataSourceMongoDBAtlasDatabaseUsers() *schema.Resource { } } -func dataSourceMongoDBAtlasDatabaseUsersRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasDatabaseUsersRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) - dbUsers, _, err := conn.DatabaseUsers.List(context.Background(), projectID, nil) + dbUsers, _, err := conn.DatabaseUsers.List(ctx, projectID, nil) if err != nil { - return fmt.Errorf("error getting database users information: %s", err) + return diag.FromErr(fmt.Errorf("error getting database users information: %s", err)) } if err := d.Set("results", flattenDBUsers(dbUsers)); err != nil { - return fmt.Errorf("error setting `result` for database users: %s", err) + return diag.FromErr(fmt.Errorf("error setting `result` for database users: %s", err)) } d.SetId(resource.UniqueId()) diff --git a/mongodbatlas/data_source_mongodbatlas_database_users_test.go b/mongodbatlas/data_source_mongodbatlas_database_users_test.go index 9c21400f22..c8c9801286 100644 --- a/mongodbatlas/data_source_mongodbatlas_database_users_test.go +++ b/mongodbatlas/data_source_mongodbatlas_database_users_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccDataSourceMongoDBAtlasDatabaseUsers_basic(t *testing.T) { @@ -17,8 +17,8 @@ func TestAccDataSourceMongoDBAtlasDatabaseUsers_basic(t *testing.T) { roleName := "atlasAdmin" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDatabaseUsersDataSourceConfig(projectID, roleName, username), diff --git a/mongodbatlas/data_source_mongodbatlas_event_trigger.go b/mongodbatlas/data_source_mongodbatlas_event_trigger.go index 1d367f7d20..4e38348ab3 100644 --- a/mongodbatlas/data_source_mongodbatlas_event_trigger.go +++ b/mongodbatlas/data_source_mongodbatlas_event_trigger.go @@ -4,12 +4,13 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func dataSourceMongoDBAtlasEventTrigger() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasEventTriggerRead, + ReadContext: dataSourceMongoDBAtlasEventTriggerRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -95,13 +96,11 @@ func dataSourceMongoDBAtlasEventTrigger() *schema.Resource { }, "event_processors": { Type: schema.TypeList, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "aws_eventbridge": { Type: schema.TypeList, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -127,70 +126,70 @@ func dataSourceMongoDBAtlasEventTrigger() *schema.Resource { } } -func dataSourceMongoDBAtlasEventTriggerRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasEventTriggerRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Realm projectID := d.Get("project_id").(string) appID := d.Get("app_id").(string) triggerID := getEncodedID(d.Get("trigger_id").(string), "trigger_id") - eventResp, _, err := conn.EventTriggers.Get(context.Background(), projectID, appID, triggerID) + eventResp, _, err := conn.EventTriggers.Get(ctx, projectID, appID, triggerID) if err != nil { - return fmt.Errorf(errorEventTriggersRead, projectID, triggerID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersRead, projectID, triggerID, err)) } if err = d.Set("name", eventResp.Name); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "name", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "name", projectID, appID, err)) } if err = d.Set("type", eventResp.Type); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "type", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "type", projectID, appID, err)) } if err = d.Set("function_id", eventResp.FunctionID); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "function_id", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "function_id", projectID, appID, err)) } if err = d.Set("function_name", eventResp.FunctionName); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "function_name", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "function_name", projectID, appID, err)) } if err = d.Set("disabled", eventResp.Disabled); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "disabled", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "disabled", projectID, appID, err)) } if err = d.Set("config_operation_types", eventResp.Config.OperationTypes); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_operation_types", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_operation_types", projectID, appID, err)) } if err = d.Set("config_operation_type", eventResp.Config.OperationType); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_operation_type", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_operation_type", projectID, appID, err)) } if err = d.Set("config_providers", eventResp.Config.Providers); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_providers", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_providers", projectID, appID, err)) } if err = d.Set("config_database", eventResp.Config.Database); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_database", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_database", projectID, appID, err)) } if err = d.Set("config_collection", eventResp.Config.Collection); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_collection", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_collection", projectID, appID, err)) } if err = d.Set("config_service_id", eventResp.Config.ServiceID); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_service_id", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_service_id", projectID, appID, err)) } if err = d.Set("config_match", matchToString(eventResp.Config.Match)); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_match", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_match", projectID, appID, err)) } if err = d.Set("config_project", matchToString(eventResp.Config.Project)); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_project", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_project", projectID, appID, err)) } if err = d.Set("config_full_document", eventResp.Config.FullDocument); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_full_document", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_full_document", projectID, appID, err)) } if err = d.Set("config_full_document_before", eventResp.Config.FullDocumentBeforeChange); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_full_document_before", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_full_document_before", projectID, appID, err)) } if err = d.Set("config_schedule", eventResp.Config.Schedule); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_schedule", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_schedule", projectID, appID, err)) } if err = d.Set("config_schedule_type", eventResp.Config.ScheduleType); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_schedule_type", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_schedule_type", projectID, appID, err)) } if err = d.Set("event_processors", flattenTriggerEventProcessorAWSEventBridge(eventResp.EventProcessors)); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "event_processors", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "event_processors", projectID, appID, err)) } d.SetId(encodeStateID(map[string]string{ diff --git a/mongodbatlas/data_source_mongodbatlas_event_trigger_test.go b/mongodbatlas/data_source_mongodbatlas_event_trigger_test.go index 4d5a8046cc..555bb5f3af 100644 --- a/mongodbatlas/data_source_mongodbatlas_event_trigger_test.go +++ b/mongodbatlas/data_source_mongodbatlas_event_trigger_test.go @@ -5,11 +5,11 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/mwielbut/pointy" "go.mongodb.org/realm/realm" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccDataSourceMongoDBAtlasEventTrigger_basic(t *testing.T) { @@ -35,9 +35,9 @@ func TestAccDataSourceMongoDBAtlasEventTrigger_basic(t *testing.T) { } resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDataSourceEventTriggerConfig(projectID, appID, `"INSERT", "UPDATE"`, &event), diff --git a/mongodbatlas/data_source_mongodbatlas_event_triggers.go b/mongodbatlas/data_source_mongodbatlas_event_triggers.go index 4eeab79559..299e4ae3c7 100644 --- a/mongodbatlas/data_source_mongodbatlas_event_triggers.go +++ b/mongodbatlas/data_source_mongodbatlas_event_triggers.go @@ -4,9 +4,9 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "go.mongodb.org/realm/realm" ) @@ -105,13 +105,11 @@ func dataSourceMongoDBAtlasEventTriggers() *schema.Resource { }, "event_processors": { Type: schema.TypeList, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "aws_eventbridge": { Type: schema.TypeList, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/mongodbatlas/data_source_mongodbatlas_event_triggers_test.go b/mongodbatlas/data_source_mongodbatlas_event_triggers_test.go index 9fa47307f1..310378aa85 100644 --- a/mongodbatlas/data_source_mongodbatlas_event_triggers_test.go +++ b/mongodbatlas/data_source_mongodbatlas_event_triggers_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/mwielbut/pointy" "go.mongodb.org/realm/realm" ) @@ -37,8 +37,8 @@ func TestAccDataSourceMongoDBAtlasEventTriggers_basic(t *testing.T) { } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasEventTriggersDataSourceConfig(projectID, appID, `"INSERT", "UPDATE"`, &event), diff --git a/mongodbatlas/data_source_mongodbatlas_global_cluster_config.go b/mongodbatlas/data_source_mongodbatlas_global_cluster_config.go index 46fb05acf7..bd589e4f02 100644 --- a/mongodbatlas/data_source_mongodbatlas_global_cluster_config.go +++ b/mongodbatlas/data_source_mongodbatlas_global_cluster_config.go @@ -5,12 +5,13 @@ import ( "fmt" "net/http" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func dataSourceMongoDBAtlasGlobalCluster() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasGlobalClusterRead, + ReadContext: dataSourceMongoDBAtlasGlobalClusterRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -49,27 +50,27 @@ func dataSourceMongoDBAtlasGlobalCluster() *schema.Resource { } } -func dataSourceMongoDBAtlasGlobalClusterRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasGlobalClusterRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) clusterName := d.Get("cluster_name").(string) - globalCluster, resp, err := conn.GlobalClusters.Get(context.Background(), projectID, clusterName) + globalCluster, resp, err := conn.GlobalClusters.Get(ctx, projectID, clusterName) if err != nil { if resp != nil && resp.StatusCode == http.StatusNotFound { return nil } - return fmt.Errorf(errorGlobalClusterRead, clusterName, err) + return diag.FromErr(fmt.Errorf(errorGlobalClusterRead, clusterName, err)) } if err := d.Set("managed_namespaces", flattenManagedNamespaces(globalCluster.ManagedNamespaces)); err != nil { - return fmt.Errorf(errorGlobalClusterRead, clusterName, err) + return diag.FromErr(fmt.Errorf(errorGlobalClusterRead, clusterName, err)) } if err := d.Set("custom_zone_mapping", globalCluster.CustomZoneMapping); err != nil { - return fmt.Errorf(errorGlobalClusterRead, clusterName, err) + return diag.FromErr(fmt.Errorf(errorGlobalClusterRead, clusterName, err)) } d.SetId(clusterName) diff --git a/mongodbatlas/data_source_mongodbatlas_global_cluster_config_test.go b/mongodbatlas/data_source_mongodbatlas_global_cluster_config_test.go index f160793938..0f6a64e05b 100644 --- a/mongodbatlas/data_source_mongodbatlas_global_cluster_config_test.go +++ b/mongodbatlas/data_source_mongodbatlas_global_cluster_config_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccDataSourceMongoDBAtlasGlobalCluster_basic(t *testing.T) { @@ -17,9 +17,9 @@ func TestAccDataSourceMongoDBAtlasGlobalCluster_basic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasGlobalClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasGlobalClusterDestroy, Steps: []resource.TestStep{ { Config: testAccDSMongoDBAtlasGlobalClusterConfig(projectID, name), diff --git a/mongodbatlas/data_source_mongodbatlas_ldap_configuration.go b/mongodbatlas/data_source_mongodbatlas_ldap_configuration.go index e5aa84ea65..50ce3a12bc 100644 --- a/mongodbatlas/data_source_mongodbatlas_ldap_configuration.go +++ b/mongodbatlas/data_source_mongodbatlas_ldap_configuration.go @@ -4,12 +4,13 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func dataSourceMongoDBAtlasLDAPConfiguration() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasLDAPConfigurationRead, + ReadContext: dataSourceMongoDBAtlasLDAPConfigurationRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -71,41 +72,41 @@ func dataSourceMongoDBAtlasLDAPConfiguration() *schema.Resource { } } -func dataSourceMongoDBAtlasLDAPConfigurationRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasLDAPConfigurationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) - ldap, _, err := conn.LDAPConfigurations.Get(context.Background(), projectID) + ldap, _, err := conn.LDAPConfigurations.Get(ctx, projectID) if err != nil { - return fmt.Errorf(errorLDAPConfigurationRead, projectID, err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationRead, projectID, err)) } if err = d.Set("authentication_enabled", ldap.LDAP.AuthenticationEnabled); err != nil { - return fmt.Errorf(errorLDAPConfigurationSetting, "authentication_enabled", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationSetting, "authentication_enabled", d.Id(), err)) } if err = d.Set("authorization_enabled", ldap.LDAP.AuthorizationEnabled); err != nil { - return fmt.Errorf(errorLDAPConfigurationSetting, "authorization_enabled", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationSetting, "authorization_enabled", d.Id(), err)) } if err = d.Set("hostname", ldap.LDAP.Hostname); err != nil { - return fmt.Errorf(errorLDAPConfigurationSetting, "hostname", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationSetting, "hostname", d.Id(), err)) } if err = d.Set("port", ldap.LDAP.Port); err != nil { - return fmt.Errorf(errorLDAPConfigurationSetting, "port", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationSetting, "port", d.Id(), err)) } if err = d.Set("bind_username", ldap.LDAP.BindUsername); err != nil { - return fmt.Errorf(errorLDAPConfigurationSetting, "bind_username", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationSetting, "bind_username", d.Id(), err)) } if err = d.Set("bind_password", ldap.LDAP.BindPassword); err != nil { - return fmt.Errorf(errorLDAPConfigurationSetting, "bind_password", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationSetting, "bind_password", d.Id(), err)) } if err = d.Set("ca_certificate", ldap.LDAP.CaCertificate); err != nil { - return fmt.Errorf(errorLDAPConfigurationSetting, "ca_certificate", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationSetting, "ca_certificate", d.Id(), err)) } if err = d.Set("authz_query_template", ldap.LDAP.AuthzQueryTemplate); err != nil { - return fmt.Errorf(errorLDAPConfigurationSetting, "authz_query_template", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationSetting, "authz_query_template", d.Id(), err)) } if err = d.Set("user_to_dn_mapping", flattenDNMapping(ldap.LDAP.UserToDNMapping)); err != nil { - return fmt.Errorf(errorLDAPConfigurationSetting, "user_to_dn_mapping", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationSetting, "user_to_dn_mapping", d.Id(), err)) } d.SetId(projectID) diff --git a/mongodbatlas/data_source_mongodbatlas_ldap_configuration_test.go b/mongodbatlas/data_source_mongodbatlas_ldap_configuration_test.go index 31e8fd2222..13b61f1c95 100644 --- a/mongodbatlas/data_source_mongodbatlas_ldap_configuration_test.go +++ b/mongodbatlas/data_source_mongodbatlas_ldap_configuration_test.go @@ -7,9 +7,9 @@ import ( "github.com/spf13/cast" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -28,9 +28,9 @@ func TestAccDataSourceMongoDBAtlasLDAPConfiguration_basic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkLDAP(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasLDAPConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t); checkLDAP(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasLDAPConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDataSourceLDAPConfigurationConfig(projectName, orgID, hostname, username, password, authEnabled, cast.ToInt(port)), diff --git a/mongodbatlas/data_source_mongodbatlas_ldap_verify.go b/mongodbatlas/data_source_mongodbatlas_ldap_verify.go index 4976b073fa..476d46cbe0 100644 --- a/mongodbatlas/data_source_mongodbatlas_ldap_verify.go +++ b/mongodbatlas/data_source_mongodbatlas_ldap_verify.go @@ -4,12 +4,13 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func dataSourceMongoDBAtlasLDAPVerify() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasLDAPVerifyRead, + ReadContext: dataSourceMongoDBAtlasLDAPVerifyRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -71,36 +72,36 @@ func dataSourceMongoDBAtlasLDAPVerify() *schema.Resource { } } -func dataSourceMongoDBAtlasLDAPVerifyRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasLDAPVerifyRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) requestID := d.Get("request_id").(string) - ldapResp, _, err := conn.LDAPConfigurations.GetStatus(context.Background(), projectID, requestID) + ldapResp, _, err := conn.LDAPConfigurations.GetStatus(ctx, projectID, requestID) if err != nil { - return fmt.Errorf(errorLDAPVerifyRead, projectID, err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifyRead, projectID, err)) } if err := d.Set("hostname", ldapResp.Request.Hostname); err != nil { - return fmt.Errorf(errorLDAPVerifySetting, "hostname", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifySetting, "hostname", d.Id(), err)) } if err := d.Set("port", ldapResp.Request.Port); err != nil { - return fmt.Errorf(errorLDAPVerifySetting, "port", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifySetting, "port", d.Id(), err)) } if err := d.Set("bind_username", ldapResp.Request.BindUsername); err != nil { - return fmt.Errorf(errorLDAPVerifySetting, "bind_username", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifySetting, "bind_username", d.Id(), err)) } if err := d.Set("links", flattenLinks(ldapResp.Links)); err != nil { - return fmt.Errorf(errorLDAPVerifySetting, "links", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifySetting, "links", d.Id(), err)) } if err := d.Set("validations", flattenValidations(ldapResp.Validations)); err != nil { - return fmt.Errorf(errorLDAPVerifySetting, "validations", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifySetting, "validations", d.Id(), err)) } if err := d.Set("request_id", ldapResp.RequestID); err != nil { - return fmt.Errorf(errorLDAPVerifySetting, "request_id", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifySetting, "request_id", d.Id(), err)) } if err := d.Set("status", ldapResp.Status); err != nil { - return fmt.Errorf(errorLDAPVerifySetting, "status", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifySetting, "status", d.Id(), err)) } d.SetId(encodeStateID(map[string]string{ diff --git a/mongodbatlas/data_source_mongodbatlas_ldap_verify_test.go b/mongodbatlas/data_source_mongodbatlas_ldap_verify_test.go index 947cf8d2c4..be963184f4 100644 --- a/mongodbatlas/data_source_mongodbatlas_ldap_verify_test.go +++ b/mongodbatlas/data_source_mongodbatlas_ldap_verify_test.go @@ -5,10 +5,10 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/spf13/cast" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -27,9 +27,9 @@ func TestAccDataSourceMongoDBAtlasLDAPVerify_basic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkLDAP(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasLDAPConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t); checkLDAP(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasLDAPConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDataSourceLDAPVerifyConfig(projectName, orgID, clusterName, hostname, username, password, cast.ToInt(port)), diff --git a/mongodbatlas/data_source_mongodbatlas_maintenance_window.go b/mongodbatlas/data_source_mongodbatlas_maintenance_window.go index f2c53b5e80..234fbe46f1 100644 --- a/mongodbatlas/data_source_mongodbatlas_maintenance_window.go +++ b/mongodbatlas/data_source_mongodbatlas_maintenance_window.go @@ -4,13 +4,14 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/spf13/cast" ) func dataSourceMongoDBAtlasMaintenanceWindow() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasMaintenanceWindowRead, + ReadContext: dataSourceMongoDBAtlasMaintenanceWindowRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -36,30 +37,30 @@ func dataSourceMongoDBAtlasMaintenanceWindow() *schema.Resource { } } -func dataSourceMongoDBAtlasMaintenanceWindowRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasMaintenanceWindowRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) - maintenance, _, err := conn.MaintenanceWindows.Get(context.Background(), projectID) + maintenance, _, err := conn.MaintenanceWindows.Get(ctx, projectID) if err != nil { - return fmt.Errorf(errorMaintenanceRead, projectID, err) + return diag.FromErr(fmt.Errorf(errorMaintenanceRead, projectID, err)) } if err := d.Set("day_of_week", maintenance.DayOfWeek); err != nil { - return fmt.Errorf(errorMaintenanceRead, projectID, err) + return diag.FromErr(fmt.Errorf(errorMaintenanceRead, projectID, err)) } if err := d.Set("hour_of_day", maintenance.HourOfDay); err != nil { - return fmt.Errorf(errorMaintenanceRead, projectID, err) + return diag.FromErr(fmt.Errorf(errorMaintenanceRead, projectID, err)) } if err := d.Set("number_of_deferrals", maintenance.NumberOfDeferrals); err != nil { - return fmt.Errorf(errorMaintenanceRead, projectID, err) + return diag.FromErr(fmt.Errorf(errorMaintenanceRead, projectID, err)) } if err := d.Set("start_asap", cast.ToBool(maintenance.StartASAP)); err != nil { - return fmt.Errorf(errorMaintenanceRead, projectID, err) + return diag.FromErr(fmt.Errorf(errorMaintenanceRead, projectID, err)) } d.SetId(projectID) diff --git a/mongodbatlas/data_source_mongodbatlas_maintenance_window_test.go b/mongodbatlas/data_source_mongodbatlas_maintenance_window_test.go index ba7e7fa38f..57941d9625 100644 --- a/mongodbatlas/data_source_mongodbatlas_maintenance_window_test.go +++ b/mongodbatlas/data_source_mongodbatlas_maintenance_window_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -17,8 +17,8 @@ func TestAccDataSourceMongoDBAtlasMaintenanceWindow_basic(t *testing.T) { hourOfDay := 3 resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDataSourceMaintenanceWindowConfig(projectID, dayOfWeek, hourOfDay), diff --git a/mongodbatlas/data_source_mongodbatlas_network_container.go b/mongodbatlas/data_source_mongodbatlas_network_container.go index ba05c60a1c..31f76cce71 100644 --- a/mongodbatlas/data_source_mongodbatlas_network_container.go +++ b/mongodbatlas/data_source_mongodbatlas_network_container.go @@ -5,12 +5,13 @@ import ( "fmt" "net/http" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func dataSourceMongoDBAtlasNetworkContainer() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasNetworkContainerRead, + ReadContext: dataSourceMongoDBAtlasNetworkContainerRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -71,67 +72,67 @@ func dataSourceMongoDBAtlasNetworkContainer() *schema.Resource { } } -func dataSourceMongoDBAtlasNetworkContainerRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasNetworkContainerRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) containerID := getEncodedID(d.Get("container_id").(string), "container_id") - container, resp, err := conn.Containers.Get(context.Background(), projectID, containerID) + container, resp, err := conn.Containers.Get(ctx, projectID, containerID) if err != nil { if resp != nil && resp.StatusCode == http.StatusNotFound { return nil } - return fmt.Errorf(errorContainerRead, containerID, err) + return diag.FromErr(fmt.Errorf(errorContainerRead, containerID, err)) } if err := d.Set("atlas_cidr_block", container.AtlasCIDRBlock); err != nil { - return fmt.Errorf("error setting `atlas_cidr_block` for Network Container (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `atlas_cidr_block` for Network Container (%s): %s", d.Id(), err)) } if err = d.Set("provider_name", container.ProviderName); err != nil { - return fmt.Errorf("error setting `provider_name` for Network Container (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `provider_name` for Network Container (%s): %s", d.Id(), err)) } if err = d.Set("region_name", container.RegionName); err != nil { - return fmt.Errorf("error setting `region_name` for Network Container (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `region_name` for Network Container (%s): %s", d.Id(), err)) } if err = d.Set("region", container.Region); err != nil { - return fmt.Errorf("error setting `region` for Network Container (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `region` for Network Container (%s): %s", d.Id(), err)) } if err = d.Set("azure_subscription_id", container.AzureSubscriptionID); err != nil { - return fmt.Errorf("error setting `azure_subscription_id` for Network Container (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `azure_subscription_id` for Network Container (%s): %s", d.Id(), err)) } if err = d.Set("provisioned", container.Provisioned); err != nil { - return fmt.Errorf("error setting `provisioned` for Network Container (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `provisioned` for Network Container (%s): %s", d.Id(), err)) } if err = d.Set("gcp_project_id", container.GCPProjectID); err != nil { - return fmt.Errorf("error setting `gcp_project_id` for Network Container (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `gcp_project_id` for Network Container (%s): %s", d.Id(), err)) } if err = d.Set("network_name", container.NetworkName); err != nil { - return fmt.Errorf("error setting `network_name` for Network Container (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `network_name` for Network Container (%s): %s", d.Id(), err)) } if err = d.Set("gcp_project_id", container.GCPProjectID); err != nil { - return fmt.Errorf("error setting `gcp_project_id` for Network Container (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `gcp_project_id` for Network Container (%s): %s", d.Id(), err)) } if err = d.Set("vpc_id", container.VPCID); err != nil { - return fmt.Errorf("error setting `vpc_id` for Network Container (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `vpc_id` for Network Container (%s): %s", d.Id(), err)) } if err = d.Set("vnet_name", container.VNetName); err != nil { - return fmt.Errorf("error setting `vnet_name` for Network Container (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `vnet_name` for Network Container (%s): %s", d.Id(), err)) } if err = d.Set("regions", container.Regions); err != nil { - return fmt.Errorf("error setting `regions` for Network Container (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `regions` for Network Container (%s): %s", d.Id(), err)) } d.SetId(container.ID) diff --git a/mongodbatlas/data_source_mongodbatlas_network_container_test.go b/mongodbatlas/data_source_mongodbatlas_network_container_test.go index 04ddcfa7dd..8adccbc5f6 100644 --- a/mongodbatlas/data_source_mongodbatlas_network_container_test.go +++ b/mongodbatlas/data_source_mongodbatlas_network_container_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -24,9 +24,9 @@ func TestAccDataSourceMongoDBAtlasNetworkContainer_basic(t *testing.T) { providerName := "AWS" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasNetworkContainerDSConfig(projectName, orgID, cidrBlock), @@ -59,9 +59,9 @@ func TestAccDataSourceMongoDBAtlasNetworkContainer_WithGCPRegions(t *testing.T) providerName := "GCP" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasNetworkContainerDSWithGCPRegionsConfig(projectName, orgID, cidrBlock), diff --git a/mongodbatlas/data_source_mongodbatlas_network_containers.go b/mongodbatlas/data_source_mongodbatlas_network_containers.go index bc6c9d1684..19619d5974 100644 --- a/mongodbatlas/data_source_mongodbatlas_network_containers.go +++ b/mongodbatlas/data_source_mongodbatlas_network_containers.go @@ -4,14 +4,15 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) func dataSourceMongoDBAtlasNetworkContainers() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasNetworkContainersRead, + ReadContext: dataSourceMongoDBAtlasNetworkContainersRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -84,21 +85,21 @@ func dataSourceMongoDBAtlasNetworkContainers() *schema.Resource { } } -func dataSourceMongoDBAtlasNetworkContainersRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasNetworkContainersRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) - containers, _, err := conn.Containers.List(context.Background(), projectID, &matlas.ContainersListOptions{ + containers, _, err := conn.Containers.List(ctx, projectID, &matlas.ContainersListOptions{ ProviderName: d.Get("provider_name").(string), }) if err != nil { - return fmt.Errorf("error getting network peering containers information: %s", err) + return diag.FromErr(fmt.Errorf("error getting network peering containers information: %s", err)) } if err := d.Set("results", flattenNetworkContainers(containers)); err != nil { - return fmt.Errorf("error setting `result` for network containers: %s", err) + return diag.FromErr(fmt.Errorf("error setting `result` for network containers: %s", err)) } d.SetId(resource.UniqueId()) diff --git a/mongodbatlas/data_source_mongodbatlas_network_containers_test.go b/mongodbatlas/data_source_mongodbatlas_network_containers_test.go index b7ee7f86dd..8ffcbc203b 100644 --- a/mongodbatlas/data_source_mongodbatlas_network_containers_test.go +++ b/mongodbatlas/data_source_mongodbatlas_network_containers_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -24,9 +24,9 @@ func TestAccDataSourceMongoDBAtlasNetworkContainers_basic(t *testing.T) { providerName := "AWS" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasNetworkContainersDSConfig(projectName, orgID, cidrBlock), @@ -60,9 +60,9 @@ func TestAccDataSourceMongoDBAtlasNetworkContainers_WithGCPRegions(t *testing.T) providerName := "GCP" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasNetworkContainersDSWithGCPRegionsConfig(projectName, orgID, cidrBlock), diff --git a/mongodbatlas/data_source_mongodbatlas_network_peering.go b/mongodbatlas/data_source_mongodbatlas_network_peering.go index 9c54fc05a9..53aef85bf7 100644 --- a/mongodbatlas/data_source_mongodbatlas_network_peering.go +++ b/mongodbatlas/data_source_mongodbatlas_network_peering.go @@ -5,12 +5,13 @@ import ( "fmt" "net/http" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func dataSourceMongoDBAtlasNetworkPeering() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasNetworkPeeringRead, + ReadContext: dataSourceMongoDBAtlasNetworkPeeringRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -106,98 +107,98 @@ func dataSourceMongoDBAtlasNetworkPeering() *schema.Resource { } } -func dataSourceMongoDBAtlasNetworkPeeringRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasNetworkPeeringRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) peerID := getEncodedID(d.Get("peering_id").(string), "peer_id") - peer, resp, err := conn.Peers.Get(context.Background(), projectID, peerID) + peer, resp, err := conn.Peers.Get(ctx, projectID, peerID) if err != nil { if resp != nil && resp.StatusCode == http.StatusNotFound { return nil } - return fmt.Errorf(errorPeersRead, peerID, err) + return diag.FromErr(fmt.Errorf(errorPeersRead, peerID, err)) } // Workaround until fix. if peer.AccepterRegionName != "" { if err := d.Set("accepter_region_name", peer.AccepterRegionName); err != nil { - return fmt.Errorf("error setting `accepter_region_name` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `accepter_region_name` for Network Peering Connection (%s): %s", peerID, err)) } } if err := d.Set("aws_account_id", peer.AWSAccountID); err != nil { - return fmt.Errorf("error setting `aws_account_id` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `aws_account_id` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("container_id", peer.ContainerID); err != nil { - return fmt.Errorf("error setting `container_id` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `container_id` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("route_table_cidr_block", peer.RouteTableCIDRBlock); err != nil { - return fmt.Errorf("error setting `route_table_cidr_block` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `route_table_cidr_block` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("vpc_id", peer.VpcID); err != nil { - return fmt.Errorf("error setting `vpc_id` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `vpc_id` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("connection_id", peer.ConnectionID); err != nil { - return fmt.Errorf("error setting `connection_id` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `connection_id` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("error_state_name", peer.ErrorStateName); err != nil { - return fmt.Errorf("error setting `error_state_name` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `error_state_name` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("atlas_id", peer.ID); err != nil { - return fmt.Errorf("error setting `atlas_id` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `atlas_id` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("status_name", peer.StatusName); err != nil { - return fmt.Errorf("error setting `status_name` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `status_name` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("atlas_cidr_block", peer.AtlasCIDRBlock); err != nil { - return fmt.Errorf("error setting `atlas_cidr_block` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `atlas_cidr_block` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("azure_directory_id", peer.AzureDirectoryID); err != nil { - return fmt.Errorf("error setting `azure_directory_id` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `azure_directory_id` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("azure_subscription_id", peer.AzureSubscriptionID); err != nil { - return fmt.Errorf("error setting `azure_subscription_id` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `azure_subscription_id` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("resource_group_name", peer.ResourceGroupName); err != nil { - return fmt.Errorf("error setting `resource_group_name` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `resource_group_name` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("vnet_name", peer.VNetName); err != nil { - return fmt.Errorf("error setting `vnet_name` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `vnet_name` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("error_state", peer.ErrorState); err != nil { - return fmt.Errorf("error setting `error_state` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `error_state` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("status", peer.Status); err != nil { - return fmt.Errorf("error setting `status` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `status` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("gcp_project_id", peer.GCPProjectID); err != nil { - return fmt.Errorf("error setting `gcp_project_id` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `gcp_project_id` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("network_name", peer.NetworkName); err != nil { - return fmt.Errorf("error setting `network_name` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `network_name` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("error_message", peer.ErrorMessage); err != nil { - return fmt.Errorf("error setting `error_message` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `error_message` for Network Peering Connection (%s): %s", peerID, err)) } provider := "AWS" @@ -208,7 +209,7 @@ func dataSourceMongoDBAtlasNetworkPeeringRead(d *schema.ResourceData, meta inter } if err := d.Set("provider_name", provider); err != nil { - return fmt.Errorf("[WARN] Error setting provider_name for (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("[WARN] Error setting provider_name for (%s): %s", d.Id(), err)) } d.SetId(encodeStateID(map[string]string{ diff --git a/mongodbatlas/data_source_mongodbatlas_network_peering_test.go b/mongodbatlas/data_source_mongodbatlas_network_peering_test.go index d030415a74..3029cf8540 100644 --- a/mongodbatlas/data_source_mongodbatlas_network_peering_test.go +++ b/mongodbatlas/data_source_mongodbatlas_network_peering_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -22,9 +22,9 @@ func TestAccDataSourceMongoDBAtlasNetworkPeering_basic(t *testing.T) { awsRegion := os.Getenv("AWS_REGION") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkPeeringEnvAWS(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, + PreCheck: func() { testAccPreCheck(t); checkPeeringEnvAWS(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, Steps: []resource.TestStep{ { Config: testAccDSMongoDBAtlasNetworkPeeringConfig(projectID, vpcID, awsAccountID, vpcCIDRBlock, awsRegion), diff --git a/mongodbatlas/data_source_mongodbatlas_network_peerings.go b/mongodbatlas/data_source_mongodbatlas_network_peerings.go index 250e3a503a..d27e19b9c6 100644 --- a/mongodbatlas/data_source_mongodbatlas_network_peerings.go +++ b/mongodbatlas/data_source_mongodbatlas_network_peerings.go @@ -4,15 +4,16 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) func dataSourceMongoDBAtlasNetworkPeerings() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasNetworkPeeringsRead, + ReadContext: dataSourceMongoDBAtlasNetworkPeeringsRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -112,18 +113,18 @@ func dataSourceMongoDBAtlasNetworkPeerings() *schema.Resource { } } -func dataSourceMongoDBAtlasNetworkPeeringsRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasNetworkPeeringsRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) - peers, _, err := conn.Peers.List(context.Background(), projectID, nil) + peers, _, err := conn.Peers.List(ctx, projectID, nil) if err != nil { - return fmt.Errorf("error getting network peering connections information: %s", err) + return diag.FromErr(fmt.Errorf("error getting network peering connections information: %s", err)) } if err := d.Set("results", flattenNetworkPeerings(peers)); err != nil { - return fmt.Errorf("error setting `result` for network peering connections: %s", err) + return diag.FromErr(fmt.Errorf("error setting `result` for network peering connections: %s", err)) } d.SetId(resource.UniqueId()) diff --git a/mongodbatlas/data_source_mongodbatlas_network_peerings_test.go b/mongodbatlas/data_source_mongodbatlas_network_peerings_test.go index 9c83c5e85c..16e6c90125 100644 --- a/mongodbatlas/data_source_mongodbatlas_network_peerings_test.go +++ b/mongodbatlas/data_source_mongodbatlas_network_peerings_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -22,9 +22,9 @@ func TestAccDataSourceMongoDBAtlasNetworkPeerings_basic(t *testing.T) { awsRegion := os.Getenv("AWS_REGION") resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkPeeringEnvAWS(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, + PreCheck: func() { testAccPreCheck(t); checkPeeringEnvAWS(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, Steps: []resource.TestStep{ { Config: testAccDSMongoDBAtlasNetworkPeeringsConfig(projectID, vpcID, awsAccountID, vpcCIDRBlock, awsRegion), diff --git a/mongodbatlas/data_source_mongodbatlas_online_archive.go b/mongodbatlas/data_source_mongodbatlas_online_archive.go index 0fe8cb3527..42cf286e35 100644 --- a/mongodbatlas/data_source_mongodbatlas_online_archive.go +++ b/mongodbatlas/data_source_mongodbatlas_online_archive.go @@ -4,9 +4,10 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -29,7 +30,7 @@ func dataSourceMongoDBAtlasOnlineArchives() *schema.Resource { } return &schema.Resource{ - Read: dataSourceMongoDBAtlasOnlineArchivesRead, + ReadContext: dataSourceMongoDBAtlasOnlineArchivesRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -58,8 +59,8 @@ func dataSourceMongoDBAtlasOnlineArchives() *schema.Resource { func dataSourceMongoDBAtlasOnlineArchive() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasOnlineArchiveRead, - Schema: schemaOnlineArchive(), + ReadContext: dataSourceMongoDBAtlasOnlineArchiveRead, + Schema: schemaOnlineArchive(), } } @@ -88,7 +89,6 @@ func schemaOnlineArchive() map[string]*schema.Schema { }, "criteria": { Type: schema.TypeList, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -146,23 +146,23 @@ func schemaOnlineArchive() map[string]*schema.Schema { } } -func dataSourceMongoDBAtlasOnlineArchiveRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasOnlineArchiveRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) clusterName := d.Get("cluster_name").(string) atlasID := d.Get("archive_id").(string) - archive, _, err := conn.OnlineArchives.Get(context.Background(), projectID, clusterName, atlasID) + archive, _, err := conn.OnlineArchives.Get(ctx, projectID, clusterName, atlasID) if err != nil { - return fmt.Errorf("error reading Online Archive datasource with id %s: %s", atlasID, err.Error()) + return diag.FromErr(fmt.Errorf("error reading Online Archive datasource with id %s: %s", atlasID, err.Error())) } onlineArchiveMap := fromOnlineArchiveToMap(archive) for key, val := range onlineArchiveMap { if err := d.Set(key, val); err != nil { - return fmt.Errorf("error reading Online Archive datasource with id %s: %s", atlasID, err.Error()) + return diag.FromErr(fmt.Errorf("error reading Online Archive datasource with id %s: %s", atlasID, err.Error())) } } @@ -175,14 +175,14 @@ func dataSourceMongoDBAtlasOnlineArchiveRead(d *schema.ResourceData, meta interf return nil } -func dataSourceMongoDBAtlasOnlineArchivesRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasOnlineArchivesRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) clusterName := d.Get("cluster_name").(string) - archives, _, err := conn.OnlineArchives.List(context.Background(), projectID, clusterName, &matlas.ListOptions{}) + archives, _, err := conn.OnlineArchives.List(ctx, projectID, clusterName, &matlas.ListOptions{}) if err != nil { - return fmt.Errorf("error getting Online Archives list for project(%s) in cluster (%s): (%s)", projectID, clusterName, err.Error()) + return diag.FromErr(fmt.Errorf("error getting Online Archives list for project(%s) in cluster (%s): (%s)", projectID, clusterName, err.Error())) } results := make([]map[string]interface{}, 0, len(archives.Results)) @@ -194,11 +194,11 @@ func dataSourceMongoDBAtlasOnlineArchivesRead(d *schema.ResourceData, meta inter } if err = d.Set("results", results); err != nil { - return fmt.Errorf("error getting Online Archives list for project(%s) in cluster (%s): (%s)", projectID, clusterName, err.Error()) + return diag.FromErr(fmt.Errorf("error getting Online Archives list for project(%s) in cluster (%s): (%s)", projectID, clusterName, err.Error())) } if err = d.Set("total_count", archives.TotalCount); err != nil { - return fmt.Errorf("error getting Online Archives list for project(%s) in cluster (%s): (%s)", projectID, clusterName, err.Error()) + return diag.FromErr(fmt.Errorf("error getting Online Archives list for project(%s) in cluster (%s): (%s)", projectID, clusterName, err.Error())) } d.SetId(resource.UniqueId()) diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint.go index c18a46d672..d6aa446ea0 100644 --- a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint.go +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint.go @@ -4,12 +4,13 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func dataSourceMongoDBAtlasPrivateLinkEndpoint() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasPrivateLinkEndpointRead, + ReadContext: dataSourceMongoDBAtlasPrivateLinkEndpointRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -64,7 +65,7 @@ func dataSourceMongoDBAtlasPrivateLinkEndpoint() *schema.Resource { } } -func dataSourceMongoDBAtlasPrivateLinkEndpointRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasPrivateLinkEndpointRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas @@ -72,41 +73,41 @@ func dataSourceMongoDBAtlasPrivateLinkEndpointRead(d *schema.ResourceData, meta privateLinkID := getEncodedID(d.Get("private_link_id").(string), "private_link_id") providerName := d.Get("provider_name").(string) - privateEndpoint, _, err := conn.PrivateEndpoints.Get(context.Background(), projectID, providerName, privateLinkID) + privateEndpoint, _, err := conn.PrivateEndpoints.Get(ctx, projectID, providerName, privateLinkID) if err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsRead, privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsRead, privateLinkID, err)) } if err := d.Set("private_link_id", privateEndpoint.ID); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "private_link_id", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "private_link_id", privateLinkID, err)) } if err := d.Set("endpoint_service_name", privateEndpoint.EndpointServiceName); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "endpoint_service_name", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "endpoint_service_name", privateLinkID, err)) } if err := d.Set("error_message", privateEndpoint.ErrorMessage); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "error_message", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "error_message", privateLinkID, err)) } if err := d.Set("interface_endpoints", privateEndpoint.InterfaceEndpoints); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "interface_endpoints", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "interface_endpoints", privateLinkID, err)) } if err := d.Set("private_endpoints", privateEndpoint.PrivateEndpoints); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "private_endpoints", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "private_endpoints", privateLinkID, err)) } if err := d.Set("private_link_service_name", privateEndpoint.PrivateLinkServiceName); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "private_link_service_name", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "private_link_service_name", privateLinkID, err)) } if err := d.Set("private_link_service_resource_id", privateEndpoint.PrivateLinkServiceResourceID); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "private_link_service_resource_id", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "private_link_service_resource_id", privateLinkID, err)) } if err := d.Set("status", privateEndpoint.Status); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "status", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "status", privateLinkID, err)) } d.SetId(encodeStateID(map[string]string{ diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service.go index dc5a4b237e..448edd3ee6 100644 --- a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service.go +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service.go @@ -4,13 +4,14 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/spf13/cast" ) func dataSourceMongoDBAtlasPrivateEndpointServiceLink() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasPrivateEndpointServiceLinkRead, + ReadContext: dataSourceMongoDBAtlasPrivateEndpointServiceLinkRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -68,7 +69,7 @@ func dataSourceMongoDBAtlasPrivateEndpointServiceLink() *schema.Resource { } } -func dataSourceMongoDBAtlasPrivateEndpointServiceLinkRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasPrivateEndpointServiceLinkRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas @@ -77,25 +78,25 @@ func dataSourceMongoDBAtlasPrivateEndpointServiceLinkRead(d *schema.ResourceData endpointServiceID := getEncodedID(d.Get("endpoint_service_id").(string), "endpoint_service_id") providerName := d.Get("provider_name").(string) - serviceEndpoint, _, err := conn.PrivateEndpoints.GetOnePrivateEndpoint(context.Background(), projectID, providerName, privateLinkID, endpointServiceID) + serviceEndpoint, _, err := conn.PrivateEndpoints.GetOnePrivateEndpoint(ctx, projectID, providerName, privateLinkID, endpointServiceID) if err != nil { - return fmt.Errorf(errorServiceEndpointRead, endpointServiceID, err) + return diag.FromErr(fmt.Errorf(errorServiceEndpointRead, endpointServiceID, err)) } if err := d.Set("delete_requested", cast.ToBool(serviceEndpoint.DeleteRequested)); err != nil { - return fmt.Errorf(errorEndpointSetting, "delete_requested", endpointServiceID, err) + return diag.FromErr(fmt.Errorf(errorEndpointSetting, "delete_requested", endpointServiceID, err)) } if err := d.Set("error_message", serviceEndpoint.ErrorMessage); err != nil { - return fmt.Errorf(errorEndpointSetting, "error_message", endpointServiceID, err) + return diag.FromErr(fmt.Errorf(errorEndpointSetting, "error_message", endpointServiceID, err)) } if err := d.Set("aws_connection_status", serviceEndpoint.AWSConnectionStatus); err != nil { - return fmt.Errorf(errorEndpointSetting, "aws_connection_status", endpointServiceID, err) + return diag.FromErr(fmt.Errorf(errorEndpointSetting, "aws_connection_status", endpointServiceID, err)) } if err := d.Set("azure_status", serviceEndpoint.AzureStatus); err != nil { - return fmt.Errorf(errorEndpointSetting, "azure_status", endpointServiceID, err) + return diag.FromErr(fmt.Errorf(errorEndpointSetting, "azure_status", endpointServiceID, err)) } d.SetId(encodeStateID(map[string]string{ diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_test.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_test.go index f6bb10eda4..44719d0073 100644 --- a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_test.go +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccDataSourceMongoDBAtlasPrivateLinkEndpointServiceAWS_basic(t *testing.T) { @@ -24,8 +24,8 @@ func TestAccDataSourceMongoDBAtlasPrivateLinkEndpointServiceAWS_basic(t *testing securityGroupID := os.Getenv("AWS_SECURITY_GROUP_ID") resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkAwsEnv(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t); checkAwsEnv(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasPrivateLinkEndpointServiceDataSourceConfig( diff --git a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_test.go b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_test.go index 267caba69e..b53d2e3f77 100644 --- a/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_test.go +++ b/mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccDataSourceMongoDBAtlasPrivateLinkEndpoint_basic(t *testing.T) { @@ -16,8 +16,8 @@ func TestAccDataSourceMongoDBAtlasPrivateLinkEndpoint_basic(t *testing.T) { providerName := "AWS" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasPrivateLinkEndpointDataSourceConfig(projectID, providerName, region), diff --git a/mongodbatlas/data_source_mongodbatlas_project.go b/mongodbatlas/data_source_mongodbatlas_project.go index 5d06007cb9..f5bd489bfd 100644 --- a/mongodbatlas/data_source_mongodbatlas_project.go +++ b/mongodbatlas/data_source_mongodbatlas_project.go @@ -5,14 +5,15 @@ import ( "errors" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) func dataSourceMongoDBAtlasProject() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasProjectRead, + ReadContext: dataSourceMongoDBAtlasProjectRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -59,7 +60,7 @@ func dataSourceMongoDBAtlasProject() *schema.Resource { } } -func dataSourceMongoDBAtlasProjectRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasProjectRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas @@ -67,7 +68,7 @@ func dataSourceMongoDBAtlasProjectRead(d *schema.ResourceData, meta interface{}) name, nameOk := d.GetOk("name") if !projectIDOk && !nameOk { - return errors.New("either project_id or name must be configured") + return diag.FromErr(errors.New("either project_id or name must be configured")) } var ( @@ -76,34 +77,34 @@ func dataSourceMongoDBAtlasProjectRead(d *schema.ResourceData, meta interface{}) ) if projectIDOk { - project, _, err = conn.Projects.GetOneProject(context.Background(), projectID.(string)) + project, _, err = conn.Projects.GetOneProject(ctx, projectID.(string)) } else { - project, _, err = conn.Projects.GetOneProjectByName(context.Background(), name.(string)) + project, _, err = conn.Projects.GetOneProjectByName(ctx, name.(string)) } if err != nil { - return fmt.Errorf(errorProjectRead, projectID, err) + return diag.FromErr(fmt.Errorf(errorProjectRead, projectID, err)) } - teams, _, err := conn.Projects.GetProjectTeamsAssigned(context.Background(), project.ID) + teams, _, err := conn.Projects.GetProjectTeamsAssigned(ctx, project.ID) if err != nil { - return fmt.Errorf("error getting project's teams assigned (%s): %s", projectID, err) + return diag.FromErr(fmt.Errorf("error getting project's teams assigned (%s): %s", projectID, err)) } if err := d.Set("org_id", project.OrgID); err != nil { - return fmt.Errorf(errorProjectSetting, `org_id`, project.ID, err) + return diag.FromErr(fmt.Errorf(errorProjectSetting, `org_id`, project.ID, err)) } if err := d.Set("cluster_count", project.ClusterCount); err != nil { - return fmt.Errorf(errorProjectSetting, `clusterCount`, project.ID, err) + return diag.FromErr(fmt.Errorf(errorProjectSetting, `clusterCount`, project.ID, err)) } if err := d.Set("created", project.Created); err != nil { - return fmt.Errorf(errorProjectSetting, `created`, project.ID, err) + return diag.FromErr(fmt.Errorf(errorProjectSetting, `created`, project.ID, err)) } if err := d.Set("teams", flattenTeams(teams)); err != nil { - return fmt.Errorf(errorProjectSetting, `teams`, project.ID, err) + return diag.FromErr(fmt.Errorf(errorProjectSetting, `teams`, project.ID, err)) } d.SetId(project.ID) diff --git a/mongodbatlas/data_source_mongodbatlas_project_ip_access_list.go b/mongodbatlas/data_source_mongodbatlas_project_ip_access_list.go index 1f7b086925..bc1765be48 100644 --- a/mongodbatlas/data_source_mongodbatlas_project_ip_access_list.go +++ b/mongodbatlas/data_source_mongodbatlas_project_ip_access_list.go @@ -7,14 +7,15 @@ import ( "fmt" "net" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) func dataSourceMongoDBAtlasProjectIPAccessList() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasProjectIPAccessListRead, + ReadContext: dataSourceMongoDBAtlasProjectIPAccessListRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -66,7 +67,7 @@ func dataSourceMongoDBAtlasProjectIPAccessList() *schema.Resource { } } -func dataSourceMongoDBAtlasProjectIPAccessListRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasProjectIPAccessListRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) cidrBlock := d.Get("cidr_block").(string) @@ -74,7 +75,7 @@ func dataSourceMongoDBAtlasProjectIPAccessListRead(d *schema.ResourceData, meta awsSecurityGroup := d.Get("aws_security_group").(string) if cidrBlock == "" && ipAddress == "" && awsSecurityGroup == "" { - return errors.New("cidr_block, ip_address or aws_security_group needs to contain a value") + return diag.FromErr(errors.New("cidr_block, ip_address or aws_security_group needs to contain a value")) } var entry bytes.Buffer @@ -82,22 +83,22 @@ func dataSourceMongoDBAtlasProjectIPAccessListRead(d *schema.ResourceData, meta entry.WriteString(ipAddress) entry.WriteString(awsSecurityGroup) - accessList, _, err := conn.ProjectIPAccessList.Get(context.Background(), projectID, entry.String()) + accessList, _, err := conn.ProjectIPAccessList.Get(ctx, projectID, entry.String()) if err != nil { - return fmt.Errorf("error getting access list information: %s", err) + return diag.FromErr(fmt.Errorf("error getting access list information: %s", err)) } if err := d.Set("cidr_block", accessList.CIDRBlock); err != nil { - return fmt.Errorf("error setting `cidr_block` for the project access list: %s", err) + return diag.FromErr(fmt.Errorf("error setting `cidr_block` for the project access list: %s", err)) } if err := d.Set("ip_address", accessList.IPAddress); err != nil { - return fmt.Errorf("error setting `ip_address` for the project access list: %s", err) + return diag.FromErr(fmt.Errorf("error setting `ip_address` for the project access list: %s", err)) } if err := d.Set("aws_security_group", accessList.AwsSecurityGroup); err != nil { - return fmt.Errorf("error setting `aws_security_group` for the project access list: %s", err) + return diag.FromErr(fmt.Errorf("error setting `aws_security_group` for the project access list: %s", err)) } if err := d.Set("comment", accessList.Comment); err != nil { - return fmt.Errorf("error setting `comment` for the project access list: %s", err) + return diag.FromErr(fmt.Errorf("error setting `comment` for the project access list: %s", err)) } d.SetId(resource.UniqueId()) diff --git a/mongodbatlas/data_source_mongodbatlas_project_ip_access_list_test.go b/mongodbatlas/data_source_mongodbatlas_project_ip_access_list_test.go index f8f0629523..07c3386555 100644 --- a/mongodbatlas/data_source_mongodbatlas_project_ip_access_list_test.go +++ b/mongodbatlas/data_source_mongodbatlas_project_ip_access_list_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccDataMongoDBAtlasProjectIPAccessList_SettingIPAddress(t *testing.T) { @@ -16,8 +16,8 @@ func TestAccDataMongoDBAtlasProjectIPAccessList_SettingIPAddress(t *testing.T) { comment := fmt.Sprintf("TestAcc for ipAddress (%s)", ipAddress) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccDataMongoDBAtlasProjectIPAccessListConfigSettingIPAddress(projectID, ipAddress, comment), @@ -42,8 +42,8 @@ func TestAccDataMongoDBAtlasProjectIPAccessList_SettingCIDRBlock(t *testing.T) { comment := fmt.Sprintf("TestAcc for cidrBlock (%s)", cidrBlock) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccDataMongoDBAtlasProjectIPAccessListConfigSettingCIDRBlock(projectID, cidrBlock, comment), @@ -76,8 +76,8 @@ func TestAccDataMongoDBAtlasProjectIPAccessList_SettingAWSSecurityGroup(t *testi comment := fmt.Sprintf("TestAcc for awsSecurityGroup (%s)", awsSGroup) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccDataMongoDBAtlasProjectIPAccessListConfigSettingAWSSecurityGroup(projectID, providerName, vpcID, awsAccountID, vpcCIDRBlock, awsRegion, awsSGroup, comment), diff --git a/mongodbatlas/data_source_mongodbatlas_project_test.go b/mongodbatlas/data_source_mongodbatlas_project_test.go index ef5ea11b36..0482a954a3 100644 --- a/mongodbatlas/data_source_mongodbatlas_project_test.go +++ b/mongodbatlas/data_source_mongodbatlas_project_test.go @@ -6,8 +6,8 @@ import ( "strings" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -20,8 +20,8 @@ func TestAccDataSourceMongoDBAtlasProject_byID(t *testing.T) { } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkTeamsIds(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t); checkTeamsIds(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasProjectConfigWithDSByID(projectName, orgID, @@ -54,8 +54,8 @@ func TestAccDataSourceMongoDBAtlasProject_byName(t *testing.T) { } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkTeamsIds(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t); checkTeamsIds(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasProjectConfigWithDSByName(projectName, orgID, diff --git a/mongodbatlas/data_source_mongodbatlas_projects.go b/mongodbatlas/data_source_mongodbatlas_projects.go index 544d31b924..351d8fef08 100644 --- a/mongodbatlas/data_source_mongodbatlas_projects.go +++ b/mongodbatlas/data_source_mongodbatlas_projects.go @@ -4,15 +4,16 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) func dataSourceMongoDBAtlasProjects() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasProjectsRead, + ReadContext: dataSourceMongoDBAtlasProjectsRead, Schema: map[string]*schema.Schema{ "page_num": { Type: schema.TypeInt, @@ -77,7 +78,7 @@ func dataSourceMongoDBAtlasProjects() *schema.Resource { } } -func dataSourceMongoDBAtlasProjectsRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasProjectsRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas options := &matlas.ListOptions{ @@ -85,17 +86,17 @@ func dataSourceMongoDBAtlasProjectsRead(d *schema.ResourceData, meta interface{} ItemsPerPage: d.Get("items_per_page").(int), } - projects, _, err := conn.Projects.GetAllProjects(context.Background(), options) + projects, _, err := conn.Projects.GetAllProjects(ctx, options) if err != nil { - return fmt.Errorf("error getting projects information: %s", err) + return diag.FromErr(fmt.Errorf("error getting projects information: %s", err)) } - if err := d.Set("results", flattenProjects(conn, projects.Results)); err != nil { - return fmt.Errorf("error setting `results`: %s", err) + if err := d.Set("results", flattenProjects(ctx, conn, projects.Results)); err != nil { + return diag.FromErr(fmt.Errorf("error setting `results`: %s", err)) } if err := d.Set("total_count", projects.TotalCount); err != nil { - return fmt.Errorf("error setting `name`: %s", err) + return diag.FromErr(fmt.Errorf("error setting `name`: %s", err)) } d.SetId(resource.UniqueId()) @@ -103,14 +104,14 @@ func dataSourceMongoDBAtlasProjectsRead(d *schema.ResourceData, meta interface{} return nil } -func flattenProjects(conn *matlas.Client, projects []*matlas.Project) []map[string]interface{} { +func flattenProjects(ctx context.Context, conn *matlas.Client, projects []*matlas.Project) []map[string]interface{} { var results []map[string]interface{} if len(projects) > 0 { results = make([]map[string]interface{}, len(projects)) for k, project := range projects { - teams, _, err := conn.Projects.GetProjectTeamsAssigned(context.Background(), project.ID) + teams, _, err := conn.Projects.GetProjectTeamsAssigned(ctx, project.ID) if err != nil { fmt.Printf("[WARN] error getting project's teams assigned (%s): %s", project.ID, err) } diff --git a/mongodbatlas/data_source_mongodbatlas_projects_test.go b/mongodbatlas/data_source_mongodbatlas_projects_test.go index 3fbe835666..3a390481fa 100644 --- a/mongodbatlas/data_source_mongodbatlas_projects_test.go +++ b/mongodbatlas/data_source_mongodbatlas_projects_test.go @@ -7,8 +7,8 @@ import ( "strings" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -21,8 +21,8 @@ func TestAccDataSourceMongoDBAtlasProjects_basic(t *testing.T) { } resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkTeamsIds(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t); checkTeamsIds(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasProjectsConfigWithDS(projectName, orgID, @@ -55,8 +55,8 @@ func TestAccDataSourceMongoDBAtlasProjects_withPagination(t *testing.T) { } resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkTeamsIds(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t); checkTeamsIds(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasProjectsConfigWithPagination(projectName, orgID, diff --git a/mongodbatlas/data_source_mongodbatlas_search_index.go b/mongodbatlas/data_source_mongodbatlas_search_index.go index 50d1863ee6..00de8e6b1f 100644 --- a/mongodbatlas/data_source_mongodbatlas_search_index.go +++ b/mongodbatlas/data_source_mongodbatlas_search_index.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func dataSourceMongoDBAtlasSearchIndex() *schema.Resource { diff --git a/mongodbatlas/data_source_mongodbatlas_search_index_test.go b/mongodbatlas/data_source_mongodbatlas_search_index_test.go index e4b4f8682f..5a904ffa3a 100644 --- a/mongodbatlas/data_source_mongodbatlas_search_index_test.go +++ b/mongodbatlas/data_source_mongodbatlas_search_index_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccDataSourceMongoDBAtlasSearchIndexes_byID(t *testing.T) { diff --git a/mongodbatlas/data_source_mongodbatlas_search_indexes.go b/mongodbatlas/data_source_mongodbatlas_search_indexes.go index adfac8c62f..f6050dfda6 100644 --- a/mongodbatlas/data_source_mongodbatlas_search_indexes.go +++ b/mongodbatlas/data_source_mongodbatlas_search_indexes.go @@ -5,8 +5,8 @@ import ( "errors" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) diff --git a/mongodbatlas/data_source_mongodbatlas_search_indexes_test.go b/mongodbatlas/data_source_mongodbatlas_search_indexes_test.go index ed16bdc9b7..561ed52bf6 100644 --- a/mongodbatlas/data_source_mongodbatlas_search_indexes_test.go +++ b/mongodbatlas/data_source_mongodbatlas_search_indexes_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccDataSourceMongoDBAtlasSearchIndexes_basic(t *testing.T) { diff --git a/mongodbatlas/data_source_mongodbatlas_team.go b/mongodbatlas/data_source_mongodbatlas_team.go index 53e3da598c..ef26aa52fa 100644 --- a/mongodbatlas/data_source_mongodbatlas_team.go +++ b/mongodbatlas/data_source_mongodbatlas_team.go @@ -5,14 +5,15 @@ import ( "errors" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) func dataSourceMongoDBAtlasTeam() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasTeamRead, + ReadContext: dataSourceMongoDBAtlasTeamRead, Schema: map[string]*schema.Schema{ "org_id": { Type: schema.TypeString, @@ -41,7 +42,7 @@ func dataSourceMongoDBAtlasTeam() *schema.Resource { } } -func dataSourceMongoDBAtlasTeamRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasTeamRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var ( conn = meta.(*MongoDBClient).Atlas orgID = d.Get("org_id").(string) @@ -53,31 +54,31 @@ func dataSourceMongoDBAtlasTeamRead(d *schema.ResourceData, meta interface{}) er ) if !teamIDOk && !nameOk { - return errors.New("either team_id or name must be configured") + return diag.FromErr(errors.New("either team_id or name must be configured")) } if teamIDOk { - team, _, err = conn.Teams.Get(context.Background(), orgID, teamID.(string)) + team, _, err = conn.Teams.Get(ctx, orgID, teamID.(string)) } else { - team, _, err = conn.Teams.GetOneTeamByName(context.Background(), orgID, name.(string)) + team, _, err = conn.Teams.GetOneTeamByName(ctx, orgID, name.(string)) } if err != nil { - return fmt.Errorf(errorTeamRead, err) + return diag.FromErr(fmt.Errorf(errorTeamRead, err)) } if err := d.Set("team_id", team.ID); err != nil { - return fmt.Errorf(errorTeamSetting, "name", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorTeamSetting, "name", d.Id(), err)) } if err := d.Set("name", team.Name); err != nil { - return fmt.Errorf(errorTeamSetting, "name", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorTeamSetting, "name", d.Id(), err)) } // Set Usernames - users, _, err := conn.Teams.GetTeamUsersAssigned(context.Background(), orgID, team.ID) + users, _, err := conn.Teams.GetTeamUsersAssigned(ctx, orgID, team.ID) if err != nil { - return fmt.Errorf(errorTeamRead, err) + return diag.FromErr(fmt.Errorf(errorTeamRead, err)) } usernames := []string{} @@ -86,7 +87,7 @@ func dataSourceMongoDBAtlasTeamRead(d *schema.ResourceData, meta interface{}) er } if err := d.Set("usernames", usernames); err != nil { - return fmt.Errorf(errorTeamSetting, "usernames", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorTeamSetting, "usernames", d.Id(), err)) } d.SetId(encodeStateID(map[string]string{ diff --git a/mongodbatlas/data_source_mongodbatlas_team_test.go b/mongodbatlas/data_source_mongodbatlas_team_test.go index 1b73e8650b..69196602b1 100644 --- a/mongodbatlas/data_source_mongodbatlas_team_test.go +++ b/mongodbatlas/data_source_mongodbatlas_team_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccDataSourceMongoDBAtlasTeam_basic(t *testing.T) { @@ -18,9 +18,9 @@ func TestAccDataSourceMongoDBAtlasTeam_basic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasTeamDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasTeamDestroy, Steps: []resource.TestStep{ { Config: testAccDataSourceMongoDBAtlasTeamConfig(orgID, name, username), @@ -44,9 +44,9 @@ func TestAccDataSourceMongoDBAtlasTeamByName_basic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasTeamDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasTeamDestroy, Steps: []resource.TestStep{ { Config: testAccDataSourceMongoDBAtlasTeamConfigByName(orgID, name, username), diff --git a/mongodbatlas/data_source_mongodbatlas_third_party_integration.go b/mongodbatlas/data_source_mongodbatlas_third_party_integration.go index 3d8e641c21..cc73a1a0cb 100644 --- a/mongodbatlas/data_source_mongodbatlas_third_party_integration.go +++ b/mongodbatlas/data_source_mongodbatlas_third_party_integration.go @@ -4,7 +4,8 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func dataSourceMongoDBAtlasThirdPartyIntegration() *schema.Resource { @@ -20,7 +21,7 @@ func dataSourceMongoDBAtlasThirdPartyIntegration() *schema.Resource { Description: "Third-party service integration identifier", } - integration.Read = dataSourceMongoDBAtlasThirdPartyIntegrationRead + integration.ReadContext = dataSourceMongoDBAtlasThirdPartyIntegrationRead return integration } @@ -108,23 +109,23 @@ func thirdPartyIntegrationSchema() *schema.Resource { } } -func dataSourceMongoDBAtlasThirdPartyIntegrationRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasThirdPartyIntegrationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { projectID := d.Get("project_id").(string) queryType := d.Get("type").(string) conn := meta.(*MongoDBClient).Atlas - integration, _, err := conn.Integrations.Get(context.Background(), projectID, queryType) + integration, _, err := conn.Integrations.Get(ctx, projectID, queryType) if err != nil { - return fmt.Errorf("error getting third party integration for type %s %w", queryType, err) + return diag.FromErr(fmt.Errorf("error getting third party integration for type %s %w", queryType, err)) } fieldMap := integrationToSchema(integration) for property, value := range fieldMap { if err = d.Set(property, value); err != nil { - return fmt.Errorf("error setting %s for third party integration %w", property, err) + return diag.FromErr(fmt.Errorf("error setting %s for third party integration %w", property, err)) } } diff --git a/mongodbatlas/data_source_mongodbatlas_third_party_integration_test.go b/mongodbatlas/data_source_mongodbatlas_third_party_integration_test.go index 6602476a90..026d4d3f61 100644 --- a/mongodbatlas/data_source_mongodbatlas_third_party_integration_test.go +++ b/mongodbatlas/data_source_mongodbatlas_third_party_integration_test.go @@ -9,8 +9,8 @@ import ( "math/rand" "time" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -115,8 +115,8 @@ func TestAccdataSourceMongoDBAtlasThirdPartyIntegration_basic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasThirdPartyIntegrationDataSourceConfig(&seedConfig), diff --git a/mongodbatlas/data_source_mongodbatlas_third_party_integrations.go b/mongodbatlas/data_source_mongodbatlas_third_party_integrations.go index bb2ba3a15f..313a46efbd 100644 --- a/mongodbatlas/data_source_mongodbatlas_third_party_integrations.go +++ b/mongodbatlas/data_source_mongodbatlas_third_party_integrations.go @@ -4,14 +4,15 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) func dataSourceMongoDBAtlasThirdPartyIntegrations() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasThirdPartyIntegrationsRead, + ReadContext: dataSourceMongoDBAtlasThirdPartyIntegrationsRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -26,18 +27,18 @@ func dataSourceMongoDBAtlasThirdPartyIntegrations() *schema.Resource { } } -func dataSourceMongoDBAtlasThirdPartyIntegrationsRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasThirdPartyIntegrationsRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) - integrations, _, err := conn.Integrations.List(context.Background(), projectID) + integrations, _, err := conn.Integrations.List(ctx, projectID) if err != nil { - return fmt.Errorf("error getting third party integration list: %s", err) + return diag.FromErr(fmt.Errorf("error getting third party integration list: %s", err)) } if err = d.Set("results", flattenIntegrations(integrations, projectID)); err != nil { - return fmt.Errorf("error setting results for third party integrations %s", err) + return diag.FromErr(fmt.Errorf("error setting results for third party integrations %s", err)) } d.SetId(resource.UniqueId()) diff --git a/mongodbatlas/data_source_mongodbatlas_third_party_integrations_test.go b/mongodbatlas/data_source_mongodbatlas_third_party_integrations_test.go index 64247a79e4..083afc6d4f 100644 --- a/mongodbatlas/data_source_mongodbatlas_third_party_integrations_test.go +++ b/mongodbatlas/data_source_mongodbatlas_third_party_integrations_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "go.mongodb.org/atlas/mongodbatlas" ) @@ -36,8 +36,8 @@ func TestAccdataSourceMongoDBAtlasThirdPartyIntegrations_basic(t *testing.T) { intgResourcesHCL := testAccMongoDBAtlasThirdPartyIntegrationsDataSourceConfig(hclConfig, projectID) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: intgResourcesHCL, diff --git a/mongodbatlas/data_source_mongodbatlas_x509_authentication_database_user.go b/mongodbatlas/data_source_mongodbatlas_x509_authentication_database_user.go index c905adc00b..c1582e2477 100644 --- a/mongodbatlas/data_source_mongodbatlas_x509_authentication_database_user.go +++ b/mongodbatlas/data_source_mongodbatlas_x509_authentication_database_user.go @@ -4,12 +4,13 @@ import ( "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func dataSourceMongoDBAtlasX509AuthDBUser() *schema.Resource { return &schema.Resource{ - Read: dataSourceMongoDBAtlasX509AuthDBUserRead, + ReadContext: dataSourceMongoDBAtlasX509AuthDBUserRead, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -58,30 +59,30 @@ func dataSourceMongoDBAtlasX509AuthDBUser() *schema.Resource { } } -func dataSourceMongoDBAtlasX509AuthDBUserRead(d *schema.ResourceData, meta interface{}) error { +func dataSourceMongoDBAtlasX509AuthDBUserRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) username := d.Get("username").(string) if username != "" { - certificates, _, err := conn.X509AuthDBUsers.GetUserCertificates(context.Background(), projectID, username) + certificates, _, err := conn.X509AuthDBUsers.GetUserCertificates(ctx, projectID, username) if err != nil { - return fmt.Errorf(errorX509AuthDBUsersRead, username, projectID, err) + return diag.FromErr(fmt.Errorf(errorX509AuthDBUsersRead, username, projectID, err)) } if err := d.Set("certificates", flattenCertificates(certificates)); err != nil { - return fmt.Errorf(errorX509AuthDBUsersSetting, "certificates", username, err) + return diag.FromErr(fmt.Errorf(errorX509AuthDBUsersSetting, "certificates", username, err)) } } - customerX509, _, err := conn.X509AuthDBUsers.GetCurrentX509Conf(context.Background(), projectID) + customerX509, _, err := conn.X509AuthDBUsers.GetCurrentX509Conf(ctx, projectID) if err != nil { - return fmt.Errorf(errorCustomerX509AuthDBUsersRead, projectID, err) + return diag.FromErr(fmt.Errorf(errorCustomerX509AuthDBUsersRead, projectID, err)) } if err := d.Set("customer_x509_cas", customerX509.Cas); err != nil { - return fmt.Errorf(errorX509AuthDBUsersSetting, "certificates", username, err) + return diag.FromErr(fmt.Errorf(errorX509AuthDBUsersSetting, "certificates", username, err)) } d.SetId(encodeStateID(map[string]string{ diff --git a/mongodbatlas/data_source_mongodbatlas_x509_authentication_database_user_test.go b/mongodbatlas/data_source_mongodbatlas_x509_authentication_database_user_test.go index 9b4fbcb725..86244bb3f9 100644 --- a/mongodbatlas/data_source_mongodbatlas_x509_authentication_database_user_test.go +++ b/mongodbatlas/data_source_mongodbatlas_x509_authentication_database_user_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) func TestAccDataSourceMongoX509AuthDBUser_basic(t *testing.T) { @@ -22,7 +22,7 @@ func TestAccDataSourceMongoX509AuthDBUser_basic(t *testing.T) { } }() }, - Providers: testAccProviders, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoX509AuthDBUserDataSourceConfig(projectID, username), @@ -44,8 +44,8 @@ func TestAccDataSourceMongoX509AuthDBUser_WithCustomerX509(t *testing.T) { cas := os.Getenv("CA_CERT") resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, Steps: []resource.TestStep{ { Config: testAccMongoX509AuthDBUserDataSourceConfigWithCustomerX509(projectID, cas), diff --git a/mongodbatlas/provider.go b/mongodbatlas/provider.go index 677ae6389f..183b6cd567 100644 --- a/mongodbatlas/provider.go +++ b/mongodbatlas/provider.go @@ -1,21 +1,24 @@ package mongodbatlas import ( + "bytes" + "context" "encoding/base64" "fmt" + "hash/crc32" "log" "reflect" "sort" "strings" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/spf13/cast" matlas "go.mongodb.org/atlas/mongodbatlas" ) // Provider returns the provider to be use by the code. -func Provider() terraform.ResourceProvider { +func Provider() *schema.Provider { return &schema.Provider{ Schema: map[string]*schema.Schema{ "public_key": { @@ -118,11 +121,11 @@ func Provider() terraform.ResourceProvider { "mongodbatlas_event_trigger": resourceMongoDBAtlasEventTriggers(), }, - ConfigureFunc: providerConfigure, + ConfigureContextFunc: providerConfigure, } } -func providerConfigure(d *schema.ResourceData) (interface{}, error) { +func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) { config := Config{ PublicKey: d.Get("public_key").(string), PrivateKey: d.Get("private_key").(string), @@ -132,7 +135,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) { config.BaseURL = baseURL.(string) } - return config.NewClient(), nil + return config.NewClient(ctx) } func encodeStateID(values map[string]string) string { @@ -280,3 +283,31 @@ func hasMultipleValues(value string) bool { return false } + +// HashCodeString hashes a string to a unique hashcode. +// +// crc32 returns a uint32, but for our use we need +// and non negative integer. Here we cast to an integer +// and invert it if the result is negative. +func HashCodeString(s string) int { + v := int(crc32.ChecksumIEEE([]byte(s))) + if v >= 0 { + return v + } + if -v >= 0 { + return -v + } + // v == MinInt + return 0 +} + +// HashCodeStrings hashes a list of strings to a unique hashcode. +func HashCodeStrings(hashStrings []string) string { + var buf bytes.Buffer + + for _, s := range hashStrings { + buf.WriteString(fmt.Sprintf("%s-", s)) + } + + return fmt.Sprintf("%d", HashCodeString(buf.String())) +} diff --git a/mongodbatlas/provider_test.go b/mongodbatlas/provider_test.go index 77689deac2..21b54ba341 100644 --- a/mongodbatlas/provider_test.go +++ b/mongodbatlas/provider_test.go @@ -6,28 +6,41 @@ import ( "testing" "github.com/go-test/deep" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-provider-google/google" "github.com/terraform-providers/terraform-provider-aws/aws" - "github.com/terraform-providers/terraform-provider-google/google" matlas "go.mongodb.org/atlas/mongodbatlas" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) -var testAccProviders map[string]terraform.ResourceProvider +const ( + // Provider name for single configuration testing + ProviderNameMongoDBAtlas = "mongodbatlas" + ProviderNameAws = "aws" + ProviderNameGoogle = "google" +) +var testAccProviders map[string]*schema.Provider +var testAccProviderFactories map[string]func() (*schema.Provider, error) var testAccProvider *schema.Provider func init() { - testAccProvider = Provider().(*schema.Provider) - testAccProviders = map[string]terraform.ResourceProvider{ - "mongodbatlas": testAccProvider, - "aws": aws.Provider(), - "google": google.Provider(), + testAccProvider = Provider() + testAccProviders = map[string]*schema.Provider{ + ProviderNameMongoDBAtlas: testAccProvider, + ProviderNameAws: aws.Provider(), + ProviderNameGoogle: google.Provider(), + } + + testAccProviderFactories = map[string]func() (*schema.Provider, error){ + ProviderNameMongoDBAtlas: func() (*schema.Provider, error) { return testAccProvider, nil }, + ProviderNameAws: func() (*schema.Provider, error) { return aws.Provider(), nil }, + ProviderNameGoogle: func() (*schema.Provider, error) { return google.Provider(), nil }, } } func TestProvider(t *testing.T) { - if err := Provider().(*schema.Provider).InternalValidate(); err != nil { + if err := Provider().InternalValidate(); err != nil { t.Fatalf("err: %s", err) } } diff --git a/mongodbatlas/resource_mongodbatlas_alert_configuration.go b/mongodbatlas/resource_mongodbatlas_alert_configuration.go index 5cc17981be..df9a3eb7c9 100644 --- a/mongodbatlas/resource_mongodbatlas_alert_configuration.go +++ b/mongodbatlas/resource_mongodbatlas_alert_configuration.go @@ -8,10 +8,12 @@ import ( "reflect" "strings" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/mwielbut/pointy" "github.com/spf13/cast" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -25,12 +27,12 @@ const ( func resourceMongoDBAtlasAlertConfiguration() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasAlertConfigurationCreate, - Read: resourceMongoDBAtlasAlertConfigurationRead, - Update: resourceMongoDBAtlasAlertConfigurationUpdate, - Delete: resourceMongoDBAtlasAlertConfigurationDelete, + CreateContext: resourceMongoDBAtlasAlertConfigurationCreate, + ReadContext: resourceMongoDBAtlasAlertConfigurationRead, + UpdateContext: resourceMongoDBAtlasAlertConfigurationUpdate, + DeleteContext: resourceMongoDBAtlasAlertConfigurationDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasAlertConfigurationImportState, + StateContext: resourceMongoDBAtlasAlertConfigurationImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -82,6 +84,26 @@ func resourceMongoDBAtlasAlertConfiguration() *schema.Resource { "metric_threshold": { Type: schema.TypeMap, Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + ConflictsWith: []string{"metric_threshold_config"}, + Deprecated: "use metric_threshold_config instead", + }, + "threshold": { + Type: schema.TypeMap, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + ConflictsWith: []string{"threshold_config"}, + Deprecated: "use threshold_config instead", + }, + "metric_threshold_config": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + ConflictsWith: []string{"metric_threshold"}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "metric_name": { @@ -125,9 +147,11 @@ func resourceMongoDBAtlasAlertConfiguration() *schema.Resource { }, }, }, - "threshold": { - Type: schema.TypeMap, - Optional: true, + "threshold_config": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + ConflictsWith: []string{"threshold"}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "operator": { @@ -274,7 +298,7 @@ func resourceMongoDBAtlasAlertConfiguration() *schema.Resource { } } -func resourceMongoDBAtlasAlertConfigurationCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasAlertConfigurationCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) @@ -283,14 +307,14 @@ func resourceMongoDBAtlasAlertConfigurationCreate(d *schema.ResourceData, meta i EventTypeName: d.Get("event_type").(string), Enabled: pointy.Bool(d.Get("enabled").(bool)), Matchers: expandAlertConfigurationMatchers(d), - MetricThreshold: expandAlertConfigurationMetricThreshold(d), - Threshold: expandAlertConfigurationThreshold(d), + MetricThreshold: expandAlertConfigurationMetricThresholdConfig(d), + Threshold: expandAlertConfigurationThresholdConfig(d), Notifications: expandAlertConfigurationNotification(d), } - resp, _, err := conn.AlertConfigurations.Create(context.Background(), projectID, req) + resp, _, err := conn.AlertConfigurations.Create(ctx, projectID, req) if err != nil { - return fmt.Errorf(errorCreateAlertConf, err) + return diag.FromErr(fmt.Errorf(errorCreateAlertConf, err)) } d.SetId(encodeStateID(map[string]string{ @@ -298,10 +322,10 @@ func resourceMongoDBAtlasAlertConfigurationCreate(d *schema.ResourceData, meta i "project_id": projectID, })) - return resourceMongoDBAtlasAlertConfigurationRead(d, meta) + return resourceMongoDBAtlasAlertConfigurationRead(ctx, d, meta) } -func resourceMongoDBAtlasAlertConfigurationRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasAlertConfigurationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -313,33 +337,33 @@ func resourceMongoDBAtlasAlertConfigurationRead(d *schema.ResourceData, meta int return nil } - return fmt.Errorf(errorReadAlertConf, err) + return diag.FromErr(fmt.Errorf(errorReadAlertConf, err)) } if err := d.Set("alert_configuration_id", alert.ID); err != nil { - return fmt.Errorf(errorAlertConfSetting, "alert_configuration_id", ids["id"], err) + return diag.FromErr(fmt.Errorf(errorAlertConfSetting, "alert_configuration_id", ids["id"], err)) } if err := d.Set("event_type", alert.EventTypeName); err != nil { - return fmt.Errorf(errorAlertConfSetting, "event_type", ids["id"], err) + return diag.FromErr(fmt.Errorf(errorAlertConfSetting, "event_type", ids["id"], err)) } if err := d.Set("created", alert.Created); err != nil { - return fmt.Errorf(errorAlertConfSetting, "created", ids["id"], err) + return diag.FromErr(fmt.Errorf(errorAlertConfSetting, "created", ids["id"], err)) } if err := d.Set("updated", alert.Updated); err != nil { - return fmt.Errorf(errorAlertConfSetting, "updated", ids["id"], err) + return diag.FromErr(fmt.Errorf(errorAlertConfSetting, "updated", ids["id"], err)) } if err := d.Set("notification", flattenAlertConfigurationNotifications(alert.Notifications)); err != nil { - return fmt.Errorf(errorAlertConfSetting, "notification", ids["id"], err) + return diag.FromErr(fmt.Errorf(errorAlertConfSetting, "notification", ids["id"], err)) } return nil } -func resourceMongoDBAtlasAlertConfigurationUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasAlertConfigurationUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var ( conn = meta.(*MongoDBClient).Atlas ids = decodeStateID(d.Id()) @@ -348,9 +372,9 @@ func resourceMongoDBAtlasAlertConfigurationUpdate(d *schema.ResourceData, meta i // In order to update an alert config it is necessary to send the original alert configuration request again, if not the // server returns an error 500 - req, _, err := conn.AlertConfigurations.GetAnAlertConfig(context.Background(), ids["project_id"], ids["id"]) + req, _, err := conn.AlertConfigurations.GetAnAlertConfig(ctx, ids["project_id"], ids["id"]) if err != nil { - return fmt.Errorf(errorReadAlertConf, err) + return diag.FromErr(fmt.Errorf(errorReadAlertConf, err)) } // Removing the computed attributes to recreate the original request req.GroupID = "" @@ -379,6 +403,14 @@ func resourceMongoDBAtlasAlertConfigurationUpdate(d *schema.ResourceData, meta i req.Threshold = expandAlertConfigurationThreshold(d) } + if d.HasChange("metric_threshold_config") { + req.MetricThreshold = expandAlertConfigurationMetricThresholdConfig(d) + } + + if d.HasChange("threshold_config") { + req.Threshold = expandAlertConfigurationThresholdConfig(d) + } + if d.HasChange("notification") { req.Notifications = expandAlertConfigurationNotification(d) } @@ -386,31 +418,31 @@ func resourceMongoDBAtlasAlertConfigurationUpdate(d *schema.ResourceData, meta i // Cannot enable/disable ONLY via update (if only send enable as changed field server returns a 500 error) so have to use different method to change enabled. if reflect.DeepEqual(req, &matlas.AlertConfiguration{Enabled: pointy.Bool(true)}) || reflect.DeepEqual(req, &matlas.AlertConfiguration{Enabled: pointy.Bool(false)}) { - _, _, err = conn.AlertConfigurations.EnableAnAlertConfig(context.Background(), ids["project_id"], ids["id"], req.Enabled) + _, _, err = conn.AlertConfigurations.EnableAnAlertConfig(ctx, ids["project_id"], ids["id"], req.Enabled) } else { - _, _, err = conn.AlertConfigurations.Update(context.Background(), ids["project_id"], ids["id"], req) + _, _, err = conn.AlertConfigurations.Update(ctx, ids["project_id"], ids["id"], req) } if err != nil { - return fmt.Errorf(errorReadAlertConf, err) + return diag.FromErr(fmt.Errorf(errorReadAlertConf, err)) } - return resourceMongoDBAtlasAlertConfigurationRead(d, meta) + return resourceMongoDBAtlasAlertConfigurationRead(ctx, d, meta) } -func resourceMongoDBAtlasAlertConfigurationDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasAlertConfigurationDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) - _, err := conn.AlertConfigurations.Delete(context.Background(), ids["project_id"], ids["id"]) + _, err := conn.AlertConfigurations.Delete(ctx, ids["project_id"], ids["id"]) if err != nil { - return fmt.Errorf(errorDeleteAlertConf, err) + return diag.FromErr(fmt.Errorf(errorDeleteAlertConf, err)) } return nil } -func resourceMongoDBAtlasAlertConfigurationImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasAlertConfigurationImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas parts := strings.SplitN(d.Id(), "-", 2) @@ -421,7 +453,7 @@ func resourceMongoDBAtlasAlertConfigurationImportState(d *schema.ResourceData, m projectID := parts[0] id := parts[1] - alert, _, err := conn.AlertConfigurations.GetAnAlertConfig(context.Background(), projectID, id) + alert, _, err := conn.AlertConfigurations.GetAnAlertConfig(ctx, projectID, id) if err != nil { return nil, fmt.Errorf(errorImportAlertConf, id, projectID, err) } @@ -442,12 +474,12 @@ func resourceMongoDBAtlasAlertConfigurationImportState(d *schema.ResourceData, m return nil, fmt.Errorf(errorAlertConfSetting, "matcher", id, err) } - if err := d.Set("metric_threshold", flattenAlertConfigurationMetricThreshold(alert.MetricThreshold)); err != nil { - return nil, fmt.Errorf(errorAlertConfSetting, "metric_threshold", id, err) + if err := d.Set("metric_threshold_config", flattenAlertConfigurationMetricThresholdConfig(alert.MetricThreshold)); err != nil { + return nil, fmt.Errorf(errorAlertConfSetting, "metric_threshold_config", id, err) } - if err := d.Set("threshold", flattenAlertConfigurationThreshold(alert.Threshold)); err != nil { - return nil, fmt.Errorf(errorAlertConfSetting, "metric_threshold", id, err) + if err := d.Set("threshold_config", flattenAlertConfigurationThresholdConfig(alert.Threshold)); err != nil { + return nil, fmt.Errorf(errorAlertConfSetting, "threshold_config", id, err) } if err := d.Set("notification", flattenAlertConfigurationNotifications(alert.Notifications)); err != nil { @@ -524,6 +556,68 @@ func expandAlertConfigurationThreshold(d *schema.ResourceData) *matlas.Threshold return nil } +func expandAlertConfigurationMetricThresholdConfig(d *schema.ResourceData) *matlas.MetricThreshold { + if value, ok := d.GetOk("metric_threshold_config"); ok { + vL := value.([]interface{}) + + if len(vL) > 0 { + v := vL[0].(map[string]interface{}) + + return &matlas.MetricThreshold{ + MetricName: cast.ToString(v["metric_name"]), + Operator: cast.ToString(v["operator"]), + Threshold: cast.ToFloat64(v["threshold"]), + Units: cast.ToString(v["units"]), + Mode: cast.ToString(v["mode"]), + } + } + } + + // Deprecated, will be removed later + if value, ok := d.GetOk("metric_threshold"); ok { + v := value.(map[string]interface{}) + + return &matlas.MetricThreshold{ + MetricName: cast.ToString(v["metric_name"]), + Operator: cast.ToString(v["operator"]), + Threshold: cast.ToFloat64(v["threshold"]), + Units: cast.ToString(v["units"]), + Mode: cast.ToString(v["mode"]), + } + } + + return nil +} + +func expandAlertConfigurationThresholdConfig(d *schema.ResourceData) *matlas.Threshold { + if value, ok := d.GetOk("threshold_config"); ok { + vL := value.([]interface{}) + + if len(vL) > 0 { + v := vL[0].(map[string]interface{}) + + return &matlas.Threshold{ + Operator: cast.ToString(v["operator"]), + Units: cast.ToString(v["units"]), + Threshold: cast.ToFloat64(v["threshold"]), + } + } + } + + // Deprecated, will be removed later + if value, ok := d.GetOk("threshold"); ok { + v := value.(map[string]interface{}) + + return &matlas.Threshold{ + Operator: cast.ToString(v["operator"]), + Units: cast.ToString(v["units"]), + Threshold: cast.ToFloat64(v["threshold"]), + } + } + + return nil +} + func flattenAlertConfigurationMetricThreshold(m *matlas.MetricThreshold) map[string]interface{} { if m != nil { return map[string]interface{}{ @@ -550,6 +644,32 @@ func flattenAlertConfigurationThreshold(m *matlas.Threshold) map[string]interfac return map[string]interface{}{} } +func flattenAlertConfigurationMetricThresholdConfig(m *matlas.MetricThreshold) []interface{} { + if m != nil { + return []interface{}{map[string]interface{}{ + "metric_name": m.MetricName, + "operator": m.Operator, + "threshold": m.Threshold, + "units": m.Units, + "mode": m.Mode, + }} + } + + return []interface{}{} +} + +func flattenAlertConfigurationThresholdConfig(m *matlas.Threshold) []interface{} { + if m != nil { + return []interface{}{map[string]interface{}{ + "operator": m.Operator, + "units": m.Units, + "threshold": m.Threshold, + }} + } + + return []interface{}{} +} + func expandAlertConfigurationNotification(d *schema.ResourceData) []matlas.Notification { notifications := make([]matlas.Notification, len(d.Get("notification").([]interface{}))) diff --git a/mongodbatlas/resource_mongodbatlas_alert_configuration_test.go b/mongodbatlas/resource_mongodbatlas_alert_configuration_test.go index be9c2c92f9..17ede55470 100644 --- a/mongodbatlas/resource_mongodbatlas_alert_configuration_test.go +++ b/mongodbatlas/resource_mongodbatlas_alert_configuration_test.go @@ -6,8 +6,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -19,9 +19,9 @@ func TestAccResourceMongoDBAtlasAlertConfiguration_basic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasAlertConfigurationConfig(projectID, true), @@ -49,9 +49,9 @@ func TestAccResourceMongoDBAtlasAlertConfiguration_Notifications(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasAlertConfigurationConfigNotifications(projectID, true, true, false), @@ -79,9 +79,9 @@ func TestAccResourceMongoDBAtlasAlertConfiguration_WithMatchers(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasAlertConfigurationConfigWithMatchers(projectID, true, false, true, @@ -129,9 +129,9 @@ func TestAccResourceMongoDBAtlasAlertConfiguration_whitMetricUpdated(t *testing. ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasAlertConfigurationConfigWithMetrictUpdated(projectID, true, 99.0), @@ -159,9 +159,9 @@ func TestAccResourceMongoDBAtlasAlertConfiguration_whitThresholdUpdated(t *testi ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasAlertConfigurationConfigWithThresholdUpdated(projectID, true, 1), @@ -196,9 +196,9 @@ func TestAccResourceMongoDBAtlasAlertConfiguration_whitoutRoles(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasAlertConfigurationConfigWithoutRoles(projectID, true, 99.0), @@ -218,9 +218,9 @@ func TestAccResourceMongoDBAtlasAlertConfiguration_importBasic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasAlertConfigurationConfig(projectID, true), @@ -243,9 +243,9 @@ func TestAccResourceMongoDBAtlasAlertConfiguration_importConfigNotifications(t * ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasAlertConfigurationConfigNotifications(projectID, true, true, false), @@ -273,9 +273,9 @@ func TestAccResourceMongoDBAtlasAlertConfiguration_DataDog(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasAlertConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasAlertConfigurationConfigWithDataDog(projectID, ddAPIKey, ddRegion, true), @@ -366,7 +366,7 @@ func testAccMongoDBAtlasAlertConfigurationConfig(projectID string, enabled bool) value = "SECONDARY" } - metric_threshold = { + metric_threshold_config { metric_name = "ASSERT_REGULAR" operator = "LESS_THAN" threshold = 99.0 @@ -458,7 +458,7 @@ func testAccMongoDBAtlasAlertConfigurationConfigWithMetrictUpdated(projectID str value = "SECONDARY" } - metric_threshold = { + metric_threshold_config { metric_name = "ASSERT_REGULAR" operator = "LESS_THAN" threshold = %f @@ -491,7 +491,7 @@ func testAccMongoDBAtlasAlertConfigurationConfigWithoutRoles(projectID string, e value = "SECONDARY" } - metric_threshold = { + metric_threshold_config { metric_name = "ASSERT_REGULAR" operator = "LESS_THAN" threshold = %f @@ -524,7 +524,7 @@ func testAccMongoDBAtlasAlertConfigurationConfigWithThresholdUpdated(projectID s value = "SECONDARY" } - threshold = { + threshold_config { operator = "LESS_THAN" units = "HOURS" threshold = %f @@ -570,7 +570,7 @@ resource "mongodbatlas_alert_configuration" "test" { value = "SECONDARY" } - threshold = { + threshold_config { operator = "LESS_THAN" threshold = 72 units = "HOURS" diff --git a/mongodbatlas/resource_mongodbatlas_auditing.go b/mongodbatlas/resource_mongodbatlas_auditing.go index 7ff51da709..f450043a45 100644 --- a/mongodbatlas/resource_mongodbatlas_auditing.go +++ b/mongodbatlas/resource_mongodbatlas_auditing.go @@ -5,7 +5,8 @@ import ( "fmt" "net/http" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mwielbut/pointy" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -18,12 +19,12 @@ const ( func resourceMongoDBAtlasAuditing() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasAuditingCreate, - Read: resourceMongoDBAtlasAuditingRead, - Update: resourceMongoDBAtlasAuditingUpdate, - Delete: resourceMongoDBAtlasAuditingDelete, + CreateContext: resourceMongoDBAtlasAuditingCreate, + ReadContext: resourceMongoDBAtlasAuditingRead, + UpdateContext: resourceMongoDBAtlasAuditingUpdate, + DeleteContext: resourceMongoDBAtlasAuditingDelete, Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, + StateContext: schema.ImportStatePassthroughContext, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -53,7 +54,7 @@ func resourceMongoDBAtlasAuditing() *schema.Resource { } } -func resourceMongoDBAtlasAuditingCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasAuditingCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) @@ -71,17 +72,17 @@ func resourceMongoDBAtlasAuditingCreate(d *schema.ResourceData, meta interface{} auditingReq.Enabled = pointy.Bool(enabled.(bool)) } - _, _, err := conn.Auditing.Configure(context.Background(), projectID, auditingReq) + _, _, err := conn.Auditing.Configure(ctx, projectID, auditingReq) if err != nil { - return fmt.Errorf(errorAuditingCreate, projectID, err) + return diag.FromErr(fmt.Errorf(errorAuditingCreate, projectID, err)) } d.SetId(projectID) - return resourceMongoDBAtlasAuditingRead(d, meta) + return resourceMongoDBAtlasAuditingRead(ctx, d, meta) } -func resourceMongoDBAtlasAuditingRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasAuditingRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas auditing, resp, err := conn.Auditing.Get(context.Background(), d.Id()) @@ -91,29 +92,29 @@ func resourceMongoDBAtlasAuditingRead(d *schema.ResourceData, meta interface{}) return nil } - return fmt.Errorf(errorAuditingRead, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorAuditingRead, d.Id(), err)) } if err := d.Set("audit_authorization_success", auditing.AuditAuthorizationSuccess); err != nil { - return fmt.Errorf(errorAuditingRead, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorAuditingRead, d.Id(), err)) } if err := d.Set("audit_filter", auditing.AuditFilter); err != nil { - return fmt.Errorf(errorAuditingRead, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorAuditingRead, d.Id(), err)) } if err := d.Set("enabled", auditing.Enabled); err != nil { - return fmt.Errorf(errorAuditingRead, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorAuditingRead, d.Id(), err)) } if err := d.Set("configuration_type", auditing.ConfigurationType); err != nil { - return fmt.Errorf(errorAuditingRead, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorAuditingRead, d.Id(), err)) } return nil } -func resourceMongoDBAtlasAuditingUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasAuditingUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get the client connection. conn := meta.(*MongoDBClient).Atlas @@ -131,15 +132,15 @@ func resourceMongoDBAtlasAuditingUpdate(d *schema.ResourceData, meta interface{} auditingReq.Enabled = pointy.Bool(d.Get("enabled").(bool)) } - _, _, err := conn.Auditing.Configure(context.Background(), d.Id(), auditingReq) + _, _, err := conn.Auditing.Configure(ctx, d.Id(), auditingReq) if err != nil { - return fmt.Errorf(errorAuditingUpdate, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorAuditingUpdate, d.Id(), err)) } return nil } -func resourceMongoDBAtlasAuditingDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasAuditingDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { d.SetId("") return nil diff --git a/mongodbatlas/resource_mongodbatlas_auditing_test.go b/mongodbatlas/resource_mongodbatlas_auditing_test.go index f4ab1a0c5a..0741dadf27 100644 --- a/mongodbatlas/resource_mongodbatlas_auditing_test.go +++ b/mongodbatlas/resource_mongodbatlas_auditing_test.go @@ -6,8 +6,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -22,9 +22,9 @@ func TestAccResourceMongoDBAtlasAuditing_basic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasAuditingDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasAuditingDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasAuditingConfig(projectID, auditFilter, auditAuth, enabled), @@ -74,9 +74,9 @@ func TestAccResourceMongoDBAtlasAuditing_importBasic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasAuditingDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasAuditingDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasAuditingConfig(projectID, auditFilter, auditAuth, enabled), diff --git a/mongodbatlas/resource_mongodbatlas_cloud_provider_access.go b/mongodbatlas/resource_mongodbatlas_cloud_provider_access.go index e643be2d39..464304c59a 100644 --- a/mongodbatlas/resource_mongodbatlas_cloud_provider_access.go +++ b/mongodbatlas/resource_mongodbatlas_cloud_provider_access.go @@ -6,8 +6,9 @@ import ( "net/http" "regexp" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -20,12 +21,12 @@ const ( func resourceMongoDBAtlasCloudProviderAccess() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasCloudProviderAccessCreate, - Read: resourceMongoDBAtlasCloudProviderAccessRead, - Update: resourceMongoDBAtlasCloudProviderAccessUpdate, - Delete: resourceMongoDBAtlasCloudProviderAccessDelete, + CreateContext: resourceMongoDBAtlasCloudProviderAccessCreate, + ReadContext: resourceMongoDBAtlasCloudProviderAccessRead, + UpdateContext: resourceMongoDBAtlasCloudProviderAccessUpdate, + DeleteContext: resourceMongoDBAtlasCloudProviderAccessDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasCloudProviderAccessImportState, + StateContext: resourceMongoDBAtlasCloudProviderAccessImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -70,7 +71,7 @@ func resourceMongoDBAtlasCloudProviderAccess() *schema.Resource { } } -func resourceMongoDBAtlasCloudProviderAccessCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderAccessCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { projectID := d.Get("project_id").(string) conn := meta.(*MongoDBClient).Atlas @@ -79,10 +80,10 @@ func resourceMongoDBAtlasCloudProviderAccessCreate(d *schema.ResourceData, meta ProviderName: d.Get("provider_name").(string), } - role, _, err := conn.CloudProviderAccess.CreateRole(context.Background(), projectID, requestParameters) + role, _, err := conn.CloudProviderAccess.CreateRole(ctx, projectID, requestParameters) if err != nil { - return fmt.Errorf(errorCloudProviderAccessCreate, err) + return diag.FromErr(fmt.Errorf(errorCloudProviderAccessCreate, err)) } roleSchema := roleToSchema(role) @@ -95,14 +96,14 @@ func resourceMongoDBAtlasCloudProviderAccessCreate(d *schema.ResourceData, meta for key, val := range roleSchema { if err := d.Set(key, val); err != nil { - return fmt.Errorf(errorCloudProviderAccessCreate, err) + return diag.FromErr(fmt.Errorf(errorCloudProviderAccessCreate, err)) } } return nil } -func resourceMongoDBAtlasCloudProviderAccessRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderAccessRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // sadly there is no just get API conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -116,7 +117,7 @@ func resourceMongoDBAtlasCloudProviderAccessRead(d *schema.ResourceData, meta in return nil } - return fmt.Errorf(errorGetRead, err) + return diag.FromErr(fmt.Errorf(errorGetRead, err)) } var targetRole matlas.AWSIAMRole @@ -140,14 +141,14 @@ func resourceMongoDBAtlasCloudProviderAccessRead(d *schema.ResourceData, meta in for key, val := range roleSchema { if err := d.Set(key, val); err != nil { - return fmt.Errorf(errorGetRead, err) + return diag.FromErr(fmt.Errorf(errorGetRead, err)) } } return nil } -func resourceMongoDBAtlasCloudProviderAccessUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderAccessUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -160,16 +161,16 @@ func resourceMongoDBAtlasCloudProviderAccessUpdate(d *schema.ResourceData, meta IAMAssumedRoleARN: d.Get("iam_assumed_role_arn").(string), } - role, _, err := conn.CloudProviderAccess.AuthorizeRole(context.Background(), projectID, roleID, req) + role, _, err := conn.CloudProviderAccess.AuthorizeRole(ctx, projectID, roleID, req) if err != nil { - return fmt.Errorf(errorCloudProviderAccessUpdate, err) + return diag.FromErr(fmt.Errorf(errorCloudProviderAccessUpdate, err)) } roleSchema := roleToSchema(role) for key, val := range roleSchema { if err := d.Set(key, val); err != nil { - return fmt.Errorf(errorGetRead, err) + return diag.FromErr(fmt.Errorf(errorGetRead, err)) } } } @@ -177,7 +178,7 @@ func resourceMongoDBAtlasCloudProviderAccessUpdate(d *schema.ResourceData, meta return nil } -func resourceMongoDBAtlasCloudProviderAccessDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderAccessDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -191,16 +192,16 @@ func resourceMongoDBAtlasCloudProviderAccessDelete(d *schema.ResourceData, meta GroupID: projectID, } - _, err := conn.CloudProviderAccess.DeauthorizeRole(context.Background(), req) + _, err := conn.CloudProviderAccess.DeauthorizeRole(ctx, req) if err != nil { - return fmt.Errorf(errorCloudProviderAccessDelete, err) + return diag.FromErr(fmt.Errorf(errorCloudProviderAccessDelete, err)) } return nil } -func resourceMongoDBAtlasCloudProviderAccessImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasCloudProviderAccessImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { projectID, providerName, roleID, err := splitCloudProviderAccessID(d.Id()) if err != nil { @@ -214,9 +215,9 @@ func resourceMongoDBAtlasCloudProviderAccessImportState(d *schema.ResourceData, "provider_name": providerName, })) - err = resourceMongoDBAtlasCloudProviderAccessRead(d, meta) + err2 := resourceMongoDBAtlasCloudProviderAccessRead(ctx, d, meta) - if err != nil { + if err2 != nil { return nil, fmt.Errorf(errorCloudProviderAccessImporter, err) } diff --git a/mongodbatlas/resource_mongodbatlas_cloud_provider_access_authorization.go b/mongodbatlas/resource_mongodbatlas_cloud_provider_access_authorization.go index bde0c73e99..095464a397 100644 --- a/mongodbatlas/resource_mongodbatlas_cloud_provider_access_authorization.go +++ b/mongodbatlas/resource_mongodbatlas_cloud_provider_access_authorization.go @@ -8,7 +8,8 @@ import ( "strings" "time" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -18,10 +19,10 @@ import ( func resourceMongoDBAtlasCloudProviderAccessAuthorization() *schema.Resource { return &schema.Resource{ - Read: resourceMongoDBAtlasCloudProviderAccessAuthorizationRead, - Create: resourceMongoDBAtlasCloudProviderAccessAuthorizationCreate, - Update: resourceMongoDBAtlasCloudProviderAccessAuthorizationUpdate, - Delete: resourceMongoDBAtlasCloudProviderAccessAuthorizationPlaceHolder, + ReadContext: resourceMongoDBAtlasCloudProviderAccessAuthorizationRead, + CreateContext: resourceMongoDBAtlasCloudProviderAccessAuthorizationCreate, + UpdateContext: resourceMongoDBAtlasCloudProviderAccessAuthorizationUpdate, + DeleteContext: resourceMongoDBAtlasCloudProviderAccessAuthorizationPlaceHolder, Schema: map[string]*schema.Schema{ "project_id": { @@ -33,7 +34,8 @@ func resourceMongoDBAtlasCloudProviderAccessAuthorization() *schema.Resource { Required: true, }, "aws": { - Type: schema.TypeMap, + Type: schema.TypeList, + MaxItems: 1, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -57,7 +59,7 @@ func resourceMongoDBAtlasCloudProviderAccessAuthorization() *schema.Resource { } } -func resourceMongoDBAtlasCloudProviderAccessAuthorizationRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderAccessAuthorizationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // sadly there is no just get API conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -65,7 +67,7 @@ func resourceMongoDBAtlasCloudProviderAccessAuthorizationRead(d *schema.Resource roleID := ids["id"] // atlas ID projectID := ids["project_id"] - targetRole, err := FindRole(conn, projectID, roleID) + targetRole, err := FindRole(ctx, conn, projectID, roleID) if err != nil { reset := strings.Contains(err.Error(), "404") && !d.IsNewResource() if reset { @@ -73,18 +75,18 @@ func resourceMongoDBAtlasCloudProviderAccessAuthorizationRead(d *schema.Resource return nil } - return err + return diag.FromErr(err) } if targetRole == nil { - return fmt.Errorf(errorGetRead, "cloud provider access role not found in mongodbatlas, please create it first") + return diag.FromErr(fmt.Errorf(errorGetRead, "cloud provider access role not found in mongodbatlas, please create it first")) } roleSchema := roleToSchemaAuthorization(targetRole) for key, val := range roleSchema { if err := d.Set(key, val); err != nil { - return fmt.Errorf(errorGetRead, err) + return diag.FromErr(fmt.Errorf(errorGetRead, err)) } } @@ -97,31 +99,31 @@ func resourceMongoDBAtlasCloudProviderAccessAuthorizationRead(d *schema.Resource return nil } -func resourceMongoDBAtlasCloudProviderAccessAuthorizationCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderAccessAuthorizationCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) roleID := d.Get("role_id").(string) // validation - targetRole, err := FindRole(conn, projectID, roleID) + targetRole, err := FindRole(ctx, conn, projectID, roleID) if err != nil { - return err + return diag.FromErr(err) } if targetRole == nil { - return fmt.Errorf(errorGetRead, "cloud provider access role not found in mongodbatlas, please create it first") + return diag.FromErr(fmt.Errorf(errorGetRead, "cloud provider access role not found in mongodbatlas, please create it first")) } // once multiple providers added, modify this section roleAWS, ok := d.GetOk("aws") if !ok { - return fmt.Errorf("error CloudProviderAccessAuthorization missing iam_assumed_role_arn") + return diag.FromErr(fmt.Errorf("error CloudProviderAccessAuthorization missing iam_assumed_role_arn")) } - iamRole := (roleAWS.(map[string]interface{}))["iam_assumed_role_arn"] + iamRole := roleAWS.([]interface{})[0].(map[string]interface{})["iam_assumed_role_arn"] req := &matlas.CloudProviderAuthorizationRequest{ ProviderName: targetRole.ProviderName, @@ -132,7 +134,7 @@ func resourceMongoDBAtlasCloudProviderAccessAuthorizationCreate(d *schema.Resour // aws takes time to update , in case of single path for i := 0; i < 3; i++ { - role, _, err = conn.CloudProviderAccess.AuthorizeRole(context.Background(), projectID, roleID, req) + role, _, err = conn.CloudProviderAccess.AuthorizeRole(ctx, projectID, roleID, req) if err != nil && strings.Contains(err.Error(), "CANNOT_ASSUME_ROLE") { log.Printf("warning issue performing authorize: %s \n", err.Error()) log.Println("retrying ") @@ -143,7 +145,7 @@ func resourceMongoDBAtlasCloudProviderAccessAuthorizationCreate(d *schema.Resour } if err != nil { - return fmt.Errorf("error cloud provider access authorization %s", err) + return diag.FromErr(fmt.Errorf("error cloud provider access authorization %s", err)) } authSchema := roleToSchemaAuthorization(role) @@ -156,14 +158,14 @@ func resourceMongoDBAtlasCloudProviderAccessAuthorizationCreate(d *schema.Resour for key, val := range authSchema { if err := d.Set(key, val); err != nil { - return fmt.Errorf(errorCloudProviderAccessCreate, err) + return diag.FromErr(fmt.Errorf(errorCloudProviderAccessCreate, err)) } } return nil } -func resourceMongoDBAtlasCloudProviderAccessAuthorizationUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderAccessAuthorizationUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // sadly there is no just get API conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -171,21 +173,21 @@ func resourceMongoDBAtlasCloudProviderAccessAuthorizationUpdate(d *schema.Resour roleID := ids["id"] // atlas ID projectID := ids["project_id"] - targetRole, err := FindRole(conn, projectID, roleID) + targetRole, err := FindRole(ctx, conn, projectID, roleID) if err != nil { - return err + return diag.FromErr(err) } if targetRole == nil { - return fmt.Errorf(errorGetRead, "cloud provider access role not found in mongodbatlas, please create it first") + return diag.FromErr(fmt.Errorf(errorGetRead, "cloud provider access role not found in mongodbatlas, please create it first")) } if d.HasChange("aws") { roleAWS, ok := d.GetOk("aws") if !ok { - return fmt.Errorf("error CloudProviderAccessAuthorization missing iam_assumed_role_arn") + return diag.FromErr(fmt.Errorf("error CloudProviderAccessAuthorization missing iam_assumed_role_arn")) } iamRole := (roleAWS.(map[string]interface{}))["iam_assumed_role_arn"] @@ -199,7 +201,7 @@ func resourceMongoDBAtlasCloudProviderAccessAuthorizationUpdate(d *schema.Resour // aws takes time to update , in case of single path for i := 0; i < 3; i++ { - role, _, err = conn.CloudProviderAccess.AuthorizeRole(context.Background(), projectID, roleID, req) + role, _, err = conn.CloudProviderAccess.AuthorizeRole(ctx, projectID, roleID, req) if err != nil && strings.Contains(err.Error(), "CANNOT_ASSUME_ROLE") { log.Printf("warning issue performing authorize: %s \n", err.Error()) log.Println("retrying ") @@ -210,7 +212,7 @@ func resourceMongoDBAtlasCloudProviderAccessAuthorizationUpdate(d *schema.Resour } if err != nil { - return fmt.Errorf("error cloud provider access authorization update %s", err) + return diag.FromErr(fmt.Errorf("error cloud provider access authorization update %s", err)) } authSchema := roleToSchemaAuthorization(role) @@ -223,7 +225,7 @@ func resourceMongoDBAtlasCloudProviderAccessAuthorizationUpdate(d *schema.Resour for key, val := range authSchema { if err := d.Set(key, val); err != nil { - return fmt.Errorf(errorCloudProviderAccessCreate, err) + return diag.FromErr(fmt.Errorf(errorCloudProviderAccessCreate, err)) } } } @@ -231,16 +233,16 @@ func resourceMongoDBAtlasCloudProviderAccessAuthorizationUpdate(d *schema.Resour return nil } -func resourceMongoDBAtlasCloudProviderAccessAuthorizationPlaceHolder(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderAccessAuthorizationPlaceHolder(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { return nil } func roleToSchemaAuthorization(role *matlas.AWSIAMRole) map[string]interface{} { out := map[string]interface{}{ "role_id": role.RoleID, - "aws": map[string]interface{}{ + "aws": []interface{}{map[string]interface{}{ "iam_assumed_role_arn": role.IAMAssumedRoleARN, - }, + }}, "authorized_date": role.AuthorizedDate, } @@ -256,8 +258,8 @@ func roleToSchemaAuthorization(role *matlas.AWSIAMRole) map[string]interface{} { return out } -func FindRole(conn *matlas.Client, projectID, roleID string) (targetRole *matlas.AWSIAMRole, err error) { - roles, _, err := conn.CloudProviderAccess.ListRoles(context.Background(), projectID) +func FindRole(ctx context.Context, conn *matlas.Client, projectID, roleID string) (targetRole *matlas.AWSIAMRole, err error) { + roles, _, err := conn.CloudProviderAccess.ListRoles(ctx, projectID) if err != nil { return nil, fmt.Errorf(errorGetRead, err) diff --git a/mongodbatlas/resource_mongodbatlas_cloud_provider_access_setup.go b/mongodbatlas/resource_mongodbatlas_cloud_provider_access_setup.go index ef9d0b7141..4147211cb3 100644 --- a/mongodbatlas/resource_mongodbatlas_cloud_provider_access_setup.go +++ b/mongodbatlas/resource_mongodbatlas_cloud_provider_access_setup.go @@ -5,8 +5,9 @@ import ( "fmt" "net/http" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -18,12 +19,12 @@ import ( func resourceMongoDBAtlasCloudProviderAccessSetup() *schema.Resource { return &schema.Resource{ - Read: resourceMongoDBAtlasCloudProviderAccessSetupRead, - Create: resourceMongoDBAtlasCloudProviderAccessSetupCreate, - Update: resourceMongoDBAtlasCloudProviderAccessAuthorizationPlaceHolder, - Delete: resourceMongoDBAtlasCloudProviderAccessSetupDelete, + ReadContext: resourceMongoDBAtlasCloudProviderAccessSetupRead, + CreateContext: resourceMongoDBAtlasCloudProviderAccessSetupCreate, + UpdateContext: resourceMongoDBAtlasCloudProviderAccessAuthorizationPlaceHolder, + DeleteContext: resourceMongoDBAtlasCloudProviderAccessSetupDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasCloudProviderAccessSetupImportState, + StateContext: resourceMongoDBAtlasCloudProviderAccessSetupImportState, }, Schema: map[string]*schema.Schema{ @@ -40,6 +41,14 @@ func resourceMongoDBAtlasCloudProviderAccessSetup() *schema.Resource { "aws": { Type: schema.TypeMap, Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + Deprecated: "use aws_config instead", + }, + "aws_config": { + Type: schema.TypeList, + Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "atlas_aws_account_arn": { @@ -65,7 +74,7 @@ func resourceMongoDBAtlasCloudProviderAccessSetup() *schema.Resource { } } -func resourceMongoDBAtlasCloudProviderAccessSetupRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderAccessSetupRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // sadly there is no just get API conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -79,7 +88,7 @@ func resourceMongoDBAtlasCloudProviderAccessSetupRead(d *schema.ResourceData, me return nil } - return fmt.Errorf(errorGetRead, err) + return diag.FromErr(fmt.Errorf(errorGetRead, err)) } // aws specific @@ -102,19 +111,19 @@ func resourceMongoDBAtlasCloudProviderAccessSetupRead(d *schema.ResourceData, me for key, val := range roleSchema { if err := d.Set(key, val); err != nil { - return fmt.Errorf(errorGetRead, err) + return diag.FromErr(fmt.Errorf(errorGetRead, err)) } } } else { // planning for the future multiple providers - return fmt.Errorf(errorGetRead, - fmt.Sprintf("unsopported provider type %s", providerName)) + return diag.FromErr(fmt.Errorf(errorGetRead, + fmt.Sprintf("unsopported provider type %s", providerName))) } return nil } -func resourceMongoDBAtlasCloudProviderAccessSetupCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderAccessSetupCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { projectID := d.Get("project_id").(string) conn := meta.(*MongoDBClient).Atlas @@ -123,10 +132,10 @@ func resourceMongoDBAtlasCloudProviderAccessSetupCreate(d *schema.ResourceData, ProviderName: d.Get("provider_name").(string), } - role, _, err := conn.CloudProviderAccess.CreateRole(context.Background(), projectID, requestParameters) + role, _, err := conn.CloudProviderAccess.CreateRole(ctx, projectID, requestParameters) if err != nil { - return fmt.Errorf(errorCloudProviderAccessCreate, err) + return diag.FromErr(fmt.Errorf(errorCloudProviderAccessCreate, err)) } // once multiple providers enable here do a switch, select for provider type @@ -140,14 +149,14 @@ func resourceMongoDBAtlasCloudProviderAccessSetupCreate(d *schema.ResourceData, for key, val := range roleSchema { if err := d.Set(key, val); err != nil { - return fmt.Errorf(errorCloudProviderAccessCreate, err) + return diag.FromErr(fmt.Errorf(errorCloudProviderAccessCreate, err)) } } return nil } -func resourceMongoDBAtlasCloudProviderAccessSetupDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderAccessSetupDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -161,10 +170,10 @@ func resourceMongoDBAtlasCloudProviderAccessSetupDelete(d *schema.ResourceData, GroupID: projectID, } - _, err := conn.CloudProviderAccess.DeauthorizeRole(context.Background(), req) + _, err := conn.CloudProviderAccess.DeauthorizeRole(ctx, req) if err != nil { - return fmt.Errorf(errorCloudProviderAccessDelete, err) + return diag.FromErr(fmt.Errorf(errorCloudProviderAccessDelete, err)) } return nil @@ -173,10 +182,14 @@ func resourceMongoDBAtlasCloudProviderAccessSetupDelete(d *schema.ResourceData, func roleToSchemaSetup(role *matlas.AWSIAMRole) map[string]interface{} { out := map[string]interface{}{ "provider_name": role.ProviderName, - "aws": map[string]interface{}{ + "aws": map[string]interface{}{ // Deprecated, will be deleted later "atlas_aws_account_arn": role.AtlasAWSAccountARN, "atlas_assumed_role_external_id": role.AtlasAssumedRoleExternalID, }, + "aws_config": []interface{}{map[string]interface{}{ + "atlas_aws_account_arn": role.AtlasAWSAccountARN, + "atlas_assumed_role_external_id": role.AtlasAssumedRoleExternalID, + }}, "created_date": role.CreatedDate, "role_id": role.RoleID, } @@ -184,7 +197,7 @@ func roleToSchemaSetup(role *matlas.AWSIAMRole) map[string]interface{} { return out } -func resourceMongoDBAtlasCloudProviderAccessSetupImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasCloudProviderAccessSetupImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { projectID, providerName, roleID, err := splitCloudProviderAccessID(d.Id()) if err != nil { @@ -198,9 +211,9 @@ func resourceMongoDBAtlasCloudProviderAccessSetupImportState(d *schema.ResourceD "provider_name": providerName, })) - err = resourceMongoDBAtlasCloudProviderAccessSetupRead(d, meta) + err2 := resourceMongoDBAtlasCloudProviderAccessSetupRead(ctx, d, meta) - if err != nil { + if err2 != nil { return nil, fmt.Errorf(errorCloudProviderAccessImporter, err) } diff --git a/mongodbatlas/resource_mongodbatlas_cloud_provider_access_setup_test.go b/mongodbatlas/resource_mongodbatlas_cloud_provider_access_setup_test.go index 161859349b..a5a4161d79 100644 --- a/mongodbatlas/resource_mongodbatlas_cloud_provider_access_setup_test.go +++ b/mongodbatlas/resource_mongodbatlas_cloud_provider_access_setup_test.go @@ -5,8 +5,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -29,8 +29,8 @@ func TestAccResourceMongoDBAtlasCloudProviderAccessSetup_basic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, // same as regular cloud provider access resource CheckDestroy: testAccCheckMongoDBAtlasProviderAccessDestroy, Steps: []resource.TestStep{ @@ -57,9 +57,9 @@ func TestAccResourceMongoDBAtlasCloudProviderAccessSetup_importBasic(t *testing. ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasProviderAccessDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasProviderAccessDestroy, Steps: []resource.TestStep{ { Config: fmt.Sprintf(createProviderAccessSetupRole, name, projectID, "AWS"), diff --git a/mongodbatlas/resource_mongodbatlas_cloud_provider_access_test.go b/mongodbatlas/resource_mongodbatlas_cloud_provider_access_test.go index 2052f0bef4..3095fc6f6b 100644 --- a/mongodbatlas/resource_mongodbatlas_cloud_provider_access_test.go +++ b/mongodbatlas/resource_mongodbatlas_cloud_provider_access_test.go @@ -6,9 +6,9 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -31,9 +31,9 @@ func TestAccResourceMongoDBAtlasCloudProviderAccess_basic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasProviderAccessDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasProviderAccessDestroy, Steps: []resource.TestStep{ { Config: fmt.Sprintf(createProviderAccessRole, name, projectID, "AWS"), @@ -57,9 +57,9 @@ func TestAccResourceMongoDBAtlasCloudProviderAccess_importBasic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasProviderAccessDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasProviderAccessDestroy, Steps: []resource.TestStep{ { Config: fmt.Sprintf(createProviderAccessRole, name, projectID, "AWS"), diff --git a/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot.go b/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot.go index 9974bd72d5..98bacd7564 100644 --- a/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot.go +++ b/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot.go @@ -9,18 +9,20 @@ import ( "regexp" "time" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + matlas "go.mongodb.org/atlas/mongodbatlas" ) func resourceMongoDBAtlasCloudProviderSnapshot() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasCloudProviderSnapshotCreate, - Read: resourceMongoDBAtlasCloudProviderSnapshotRead, - Delete: resourceMongoDBAtlasCloudProviderSnapshotDelete, + CreateContext: resourceMongoDBAtlasCloudProviderSnapshotCreate, + ReadContext: resourceMongoDBAtlasCloudProviderSnapshotRead, + DeleteContext: resourceMongoDBAtlasCloudProviderSnapshotDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasCloudProviderSnapshotImportState, + StateContext: resourceMongoDBAtlasCloudProviderSnapshotImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -83,7 +85,7 @@ func resourceMongoDBAtlasCloudProviderSnapshot() *schema.Resource { } } -func resourceMongoDBAtlasCloudProviderSnapshotRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderSnapshotRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -101,49 +103,49 @@ func resourceMongoDBAtlasCloudProviderSnapshotRead(d *schema.ResourceData, meta return nil } - return fmt.Errorf("error getting snapshot Information: %s", err) + return diag.FromErr(fmt.Errorf("error getting snapshot Information: %s", err)) } if err = d.Set("snapshot_id", snapshotReq.ID); err != nil { - return fmt.Errorf("error setting `snapshot_id` for snapshot (%s): %s", ids["snapshot_id"], err) + return diag.FromErr(fmt.Errorf("error setting `snapshot_id` for snapshot (%s): %s", ids["snapshot_id"], err)) } if err = d.Set("created_at", snapshotReq.CreatedAt); err != nil { - return fmt.Errorf("error setting `created_at` for snapshot (%s): %s", ids["snapshot_id"], err) + return diag.FromErr(fmt.Errorf("error setting `created_at` for snapshot (%s): %s", ids["snapshot_id"], err)) } if err = d.Set("expires_at", snapshotReq.ExpiresAt); err != nil { - return fmt.Errorf("error setting `expires_at` for snapshot (%s): %s", ids["snapshot_id"], err) + return diag.FromErr(fmt.Errorf("error setting `expires_at` for snapshot (%s): %s", ids["snapshot_id"], err)) } if err = d.Set("master_key_uuid", snapshotReq.MasterKeyUUID); err != nil { - return fmt.Errorf("error setting `master_key_uuid` for snapshot (%s): %s", ids["snapshot_id"], err) + return diag.FromErr(fmt.Errorf("error setting `master_key_uuid` for snapshot (%s): %s", ids["snapshot_id"], err)) } if err = d.Set("mongod_version", snapshotReq.MongodVersion); err != nil { - return fmt.Errorf("error setting `mongod_version` for snapshot (%s): %s", ids["snapshot_id"], err) + return diag.FromErr(fmt.Errorf("error setting `mongod_version` for snapshot (%s): %s", ids["snapshot_id"], err)) } if err = d.Set("snapshot_type", snapshotReq.SnapshotType); err != nil { - return fmt.Errorf("error setting `snapshot_type` for snapshot (%s): %s", ids["snapshot_id"], err) + return diag.FromErr(fmt.Errorf("error setting `snapshot_type` for snapshot (%s): %s", ids["snapshot_id"], err)) } if err = d.Set("status", snapshotReq.Status); err != nil { - return fmt.Errorf("error setting `status` for snapshot (%s): %s", ids["snapshot_id"], err) + return diag.FromErr(fmt.Errorf("error setting `status` for snapshot (%s): %s", ids["snapshot_id"], err)) } if err = d.Set("storage_size_bytes", snapshotReq.StorageSizeBytes); err != nil { - return fmt.Errorf("error setting `storage_size_bytes` for snapshot (%s): %s", ids["snapshot_id"], err) + return diag.FromErr(fmt.Errorf("error setting `storage_size_bytes` for snapshot (%s): %s", ids["snapshot_id"], err)) } if err = d.Set("type", snapshotReq.Type); err != nil { - return fmt.Errorf("error setting `type` for snapshot (%s): %s", ids["snapshot_id"], err) + return diag.FromErr(fmt.Errorf("error setting `type` for snapshot (%s): %s", ids["snapshot_id"], err)) } return nil } -func resourceMongoDBAtlasCloudProviderSnapshotCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderSnapshotCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas @@ -160,21 +162,21 @@ func resourceMongoDBAtlasCloudProviderSnapshotCreate(d *schema.ResourceData, met stateConf := &resource.StateChangeConf{ Pending: []string{"CREATING", "UPDATING", "REPAIRING", "REPEATING"}, Target: []string{"IDLE"}, - Refresh: resourceClusterRefreshFunc(d.Get("cluster_name").(string), d.Get("project_id").(string), conn), + Refresh: resourceClusterRefreshFunc(ctx, d.Get("cluster_name").(string), d.Get("project_id").(string), conn), Timeout: 10 * time.Minute, MinTimeout: 10 * time.Second, Delay: 3 * time.Minute, } // Wait, catching any errors - _, err := stateConf.WaitForState() + _, err := stateConf.WaitForStateContext(ctx) if err != nil { - return err + return diag.FromErr(err) } - snapshot, _, err := conn.CloudProviderSnapshots.Create(context.Background(), requestParameters, snapshotReq) + snapshot, _, err := conn.CloudProviderSnapshots.Create(ctx, requestParameters, snapshotReq) if err != nil { - return fmt.Errorf("error taking a snapshot: %s", err) + return diag.FromErr(fmt.Errorf("error taking a snapshot: %s", err)) } requestParameters.SnapshotID = snapshot.ID @@ -182,16 +184,16 @@ func resourceMongoDBAtlasCloudProviderSnapshotCreate(d *schema.ResourceData, met stateConf = &resource.StateChangeConf{ Pending: []string{"queued", "inProgress"}, Target: []string{"completed", "failed"}, - Refresh: resourceCloudProviderSnapshotRefreshFunc(requestParameters, conn), + Refresh: resourceCloudProviderSnapshotRefreshFunc(ctx, requestParameters, conn), Timeout: 1 * time.Hour, MinTimeout: 60 * time.Second, Delay: 1 * time.Minute, } // Wait, catching any errors - _, err = stateConf.WaitForState() + _, err = stateConf.WaitForStateContext(ctx) if err != nil { - return err + return diag.FromErr(err) } d.SetId(encodeStateID(map[string]string{ @@ -200,10 +202,10 @@ func resourceMongoDBAtlasCloudProviderSnapshotCreate(d *schema.ResourceData, met "snapshot_id": snapshot.ID, })) - return resourceMongoDBAtlasCloudProviderSnapshotRead(d, meta) + return resourceMongoDBAtlasCloudProviderSnapshotRead(ctx, d, meta) } -func resourceMongoDBAtlasCloudProviderSnapshotDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderSnapshotDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -214,17 +216,17 @@ func resourceMongoDBAtlasCloudProviderSnapshotDelete(d *schema.ResourceData, met ClusterName: ids["cluster_name"], } - _, err := conn.CloudProviderSnapshots.Delete(context.Background(), requestParameters) + _, err := conn.CloudProviderSnapshots.Delete(ctx, requestParameters) if err != nil { - return fmt.Errorf("error deleting a snapshot (%s): %s", ids["snapshot_id"], err) + return diag.FromErr(fmt.Errorf("error deleting a snapshot (%s): %s", ids["snapshot_id"], err)) } return nil } -func resourceCloudProviderSnapshotRefreshFunc(requestParameters *matlas.SnapshotReqPathParameters, client *matlas.Client) resource.StateRefreshFunc { +func resourceCloudProviderSnapshotRefreshFunc(ctx context.Context, requestParameters *matlas.SnapshotReqPathParameters, client *matlas.Client) resource.StateRefreshFunc { return func() (interface{}, string, error) { - c, resp, err := client.CloudProviderSnapshots.GetOneCloudProviderSnapshot(context.Background(), requestParameters) + c, resp, err := client.CloudProviderSnapshots.GetOneCloudProviderSnapshot(ctx, requestParameters) switch { case err != nil: @@ -243,7 +245,7 @@ func resourceCloudProviderSnapshotRefreshFunc(requestParameters *matlas.Snapshot } } -func resourceMongoDBAtlasCloudProviderSnapshotImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasCloudProviderSnapshotImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas requestParameters, err := splitSnapshotImportID(d.Id()) @@ -251,7 +253,7 @@ func resourceMongoDBAtlasCloudProviderSnapshotImportState(d *schema.ResourceData return nil, err } - u, _, err := conn.CloudProviderSnapshots.GetOneCloudProviderSnapshot(context.Background(), requestParameters) + u, _, err := conn.CloudProviderSnapshots.GetOneCloudProviderSnapshot(ctx, requestParameters) if err != nil { return nil, fmt.Errorf("couldn't import snapshot %s in project %s, error: %s", requestParameters.ClusterName, requestParameters.GroupID, err) } diff --git a/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_backup_policy.go b/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_backup_policy.go index 244a65661b..740379ae85 100644 --- a/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_backup_policy.go +++ b/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_backup_policy.go @@ -7,8 +7,9 @@ import ( "net/http" "strings" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/mwielbut/pointy" "github.com/spf13/cast" matlas "go.mongodb.org/atlas/mongodbatlas" @@ -22,12 +23,12 @@ const ( func resourceMongoDBAtlasCloudProviderSnapshotBackupPolicy() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyCreate, - Update: resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyUpdate, - Read: resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyRead, - Delete: resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyDelete, + CreateContext: resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyCreate, + UpdateContext: resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyUpdate, + ReadContext: resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyRead, + DeleteContext: resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyImportState, + StateContext: resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -127,14 +128,14 @@ func resourceMongoDBAtlasCloudProviderSnapshotBackupPolicy() *schema.Resource { } } -func resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) clusterName := d.Get("cluster_name").(string) // there is not an entry point to create a snapshot backup policy until it will use the update entry point - if err := snapshotScheduleUpdate(d, conn, projectID, clusterName); err != nil { - return err + if err := snapshotScheduleUpdate(ctx, d, conn, projectID, clusterName); err != nil { + return diag.FromErr(err) } d.SetId(encodeStateID(map[string]string{ @@ -142,10 +143,10 @@ func resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyCreate(d *schema.Resou "cluster_name": clusterName, })) - return resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyRead(d, meta) + return resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyRead(ctx, d, meta) } -func resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas @@ -160,60 +161,60 @@ func resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyRead(d *schema.Resourc return nil } - return fmt.Errorf(errorSnapshotBackupPolicyRead, clusterName, err) + return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicyRead, clusterName, err)) } if err := d.Set("cluster_id", backupPolicy.ClusterID); err != nil { - return fmt.Errorf(errorSnapshotBackupPolicySetting, "cluster_id", clusterName, err) + return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "cluster_id", clusterName, err)) } if err := d.Set("reference_hour_of_day", backupPolicy.ReferenceHourOfDay); err != nil { - return fmt.Errorf(errorSnapshotBackupPolicySetting, "reference_hour_of_day", clusterName, err) + return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "reference_hour_of_day", clusterName, err)) } if err := d.Set("reference_minute_of_hour", backupPolicy.ReferenceMinuteOfHour); err != nil { - return fmt.Errorf(errorSnapshotBackupPolicySetting, "reference_minute_of_hour", clusterName, err) + return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "reference_minute_of_hour", clusterName, err)) } if err := d.Set("restore_window_days", backupPolicy.RestoreWindowDays); err != nil { - return fmt.Errorf(errorSnapshotBackupPolicySetting, "restore_window_days", clusterName, err) + return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "restore_window_days", clusterName, err)) } if err := d.Set("update_snapshots", backupPolicy.UpdateSnapshots); err != nil { - return fmt.Errorf(errorSnapshotBackupPolicySetting, "update_snapshots", clusterName, err) + return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "update_snapshots", clusterName, err)) } if err := d.Set("next_snapshot", backupPolicy.NextSnapshot); err != nil { - return fmt.Errorf(errorSnapshotBackupPolicySetting, "next_snapshot", clusterName, err) + return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "next_snapshot", clusterName, err)) } if err := d.Set("policies", flattenPolicies(backupPolicy.Policies)); err != nil { - return fmt.Errorf(errorSnapshotBackupPolicySetting, "policies", clusterName, err) + return diag.FromErr(fmt.Errorf(errorSnapshotBackupPolicySetting, "policies", clusterName, err)) } return nil } -func resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) projectID := ids["project_id"] clusterName := ids["cluster_name"] - if err := snapshotScheduleUpdate(d, conn, projectID, clusterName); err != nil { - return err + if err := snapshotScheduleUpdate(ctx, d, conn, projectID, clusterName); err != nil { + return diag.FromErr(err) } - return resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyRead(d, meta) + return resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyRead(ctx, d, meta) } -func resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // There is no resource to delete a backup policy, it can only be updated. return nil } -func resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas parts := strings.SplitN(d.Id(), "-", 2) @@ -224,7 +225,7 @@ func resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyImportState(d *schema. projectID := parts[0] clusterName := parts[1] - _, _, err := conn.CloudProviderSnapshotBackupPolicies.Get(context.Background(), projectID, clusterName) + _, _, err := conn.CloudProviderSnapshotBackupPolicies.Get(ctx, projectID, clusterName) if err != nil { return nil, fmt.Errorf(errorSnapshotBackupPolicyRead, clusterName, err) } @@ -245,7 +246,7 @@ func resourceMongoDBAtlasCloudProviderSnapshotBackupPolicyImportState(d *schema. return []*schema.ResourceData{d}, nil } -func snapshotScheduleUpdate(d *schema.ResourceData, conn *matlas.Client, projectID, clusterName string) error { +func snapshotScheduleUpdate(ctx context.Context, d *schema.ResourceData, conn *matlas.Client, projectID, clusterName string) error { if restoreWindowDays, ok := d.GetOk("restore_window_days"); ok { if cast.ToInt64(restoreWindowDays) <= 0 { return fmt.Errorf("`restore_window_days` cannot be <= 0") @@ -263,7 +264,7 @@ func snapshotScheduleUpdate(d *schema.ResourceData, conn *matlas.Client, project req.RestoreWindowDays = pointy.Int64(cast.ToInt64(rwd)) } - _, _, err := conn.CloudProviderSnapshotBackupPolicies.Update(context.Background(), projectID, clusterName, req) + _, _, err := conn.CloudProviderSnapshotBackupPolicies.Update(ctx, projectID, clusterName, req) if err != nil { return fmt.Errorf(errorSnapshotBackupPolicyUpdate, err) } @@ -329,8 +330,8 @@ func flattenPolicyItems(items []matlas.PolicyItem) []map[string]interface{} { return policyItems } -func flattenCloudProviderSnapshotBackupPolicy(d *schema.ResourceData, conn *matlas.Client, projectID, clusterName string) ([]map[string]interface{}, error) { - backupPolicy, res, err := conn.CloudProviderSnapshotBackupPolicies.Get(context.Background(), projectID, clusterName) +func flattenCloudProviderSnapshotBackupPolicy(ctx context.Context, d *schema.ResourceData, conn *matlas.Client, projectID, clusterName string) ([]map[string]interface{}, error) { + backupPolicy, res, err := conn.CloudProviderSnapshotBackupPolicies.Get(ctx, projectID, clusterName) if err != nil { if res.StatusCode == http.StatusNotFound || strings.Contains(fmt.Sprint(err), "BACKUP_CONFIG_NOT_FOUND") || diff --git a/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_backup_policy_test.go b/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_backup_policy_test.go index 6dad807a0a..656e21371d 100644 --- a/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_backup_policy_test.go +++ b/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_backup_policy_test.go @@ -6,9 +6,9 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/mwielbut/pointy" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -21,9 +21,9 @@ func TestAccResourceMongoDBAtlasCloudProviderSnapshotBackupPolicy_basic(t *testi ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasCloudProviderSnapshotBackupPolicyDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasCloudProviderSnapshotBackupPolicyDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCloudProviderSnapshotBackupPolicyConfig(projectID, clusterName, &matlas.CloudProviderSnapshotBackupPolicy{ @@ -67,9 +67,9 @@ func TestAccResourceMongoDBAtlasCloudProviderSnapshotBackupPolicy_withoutRestore ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasCloudProviderSnapshotBackupPolicyDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasCloudProviderSnapshotBackupPolicyDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCloudProviderSnapshotBackupPolicyConfigWithoutRestoreDays(projectID, clusterName, &matlas.CloudProviderSnapshotBackupPolicy{ @@ -110,9 +110,9 @@ func TestAccResourceMongoDBAtlasCloudProviderSnapshotBackupPolicy_importBasic(t ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasCloudProviderSnapshotBackupPolicyDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasCloudProviderSnapshotBackupPolicyDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCloudProviderSnapshotBackupPolicyConfig(projectID, clusterName, &matlas.CloudProviderSnapshotBackupPolicy{ diff --git a/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_restore_job.go b/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_restore_job.go index 7b7a3b83d6..542591374e 100644 --- a/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_restore_job.go +++ b/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_restore_job.go @@ -8,18 +8,21 @@ import ( "net/http" "regexp" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/spf13/cast" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + matlas "go.mongodb.org/atlas/mongodbatlas" ) func resourceMongoDBAtlasCloudProviderSnapshotRestoreJob() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasCloudProviderSnapshotRestoreJobCreate, - Read: resourceMongoDBAtlasCloudProviderSnapshotRestoreJobRead, - Delete: resourceMongoDBAtlasCloudProviderSnapshotRestoreJobDelete, + CreateContext: resourceMongoDBAtlasCloudProviderSnapshotRestoreJobCreate, + ReadContext: resourceMongoDBAtlasCloudProviderSnapshotRestoreJobRead, + DeleteContext: resourceMongoDBAtlasCloudProviderSnapshotRestoreJobDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasCloudProviderSnapshotRestoreJobImportState, + StateContext: resourceMongoDBAtlasCloudProviderSnapshotRestoreJobImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -38,44 +41,13 @@ func resourceMongoDBAtlasCloudProviderSnapshotRestoreJob() *schema.Resource { ForceNew: true, }, "delivery_type": { - Type: schema.TypeMap, - Required: true, - ForceNew: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "download": { - Type: schema.TypeBool, - Optional: true, - }, - "automated": { - Type: schema.TypeBool, - Optional: true, - }, - "point_in_time": { - Type: schema.TypeBool, - Optional: true, - }, - "target_cluster_name": { - Type: schema.TypeString, - Optional: true, - }, - "target_project_id": { - Type: schema.TypeString, - Optional: true, - }, - "oplog_ts": { - Type: schema.TypeInt, - Optional: true, - }, - "point_in_time_utc_seconds": { - Type: schema.TypeInt, - Optional: true, - }, - "oplog_inc": { - Type: schema.TypeInt, - Optional: true, - }, - }, + Type: schema.TypeMap, + Optional: true, + ForceNew: true, + Deprecated: "use delivery_type_config instead", + ConflictsWith: []string{"delivery_type_config"}, + Elem: &schema.Schema{ + Type: schema.TypeString, }, ValidateFunc: func(val interface{}, key string) (warns []string, errs []error) { v := val.(map[string]interface{}) @@ -130,6 +102,57 @@ func resourceMongoDBAtlasCloudProviderSnapshotRestoreJob() *schema.Resource { return }, }, + "delivery_type_config": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + ForceNew: true, + ConflictsWith: []string{"delivery_type"}, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "download": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + }, + "automated": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + }, + "point_in_time": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + }, + "target_cluster_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "target_project_id": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "oplog_ts": { + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + }, + "point_in_time_utc_seconds": { + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + }, + "oplog_inc": { + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + }, + }, + }, + }, "delivery_url": { Type: schema.TypeList, Computed: true, @@ -169,7 +192,7 @@ func resourceMongoDBAtlasCloudProviderSnapshotRestoreJob() *schema.Resource { } } -func resourceMongoDBAtlasCloudProviderSnapshotRestoreJobCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderSnapshotRestoreJobCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas @@ -178,28 +201,37 @@ func resourceMongoDBAtlasCloudProviderSnapshotRestoreJobCreate(d *schema.Resourc ClusterName: d.Get("cluster_name").(string), } - deliveryType := "automated" - if aut, _ := d.Get("delivery_type.automated").(string); aut != "true" { - deliveryType = "download" + err := validateDeliveryType(d.Get("delivery_type_config").([]interface{})) + if err != nil { + return diag.FromErr(err) } - if aut, _ := d.Get("delivery_type.point_in_time").(string); aut == "true" { - deliveryType = "pointInTime" - } + snapshotReq := buildRequestSnapshotReq(d) - snapshotReq := &matlas.CloudProviderSnapshotRestoreJob{ - SnapshotID: getEncodedID(d.Get("snapshot_id").(string), "snapshot_id"), - DeliveryType: deliveryType, - TargetClusterName: d.Get("delivery_type.target_cluster_name").(string), - TargetGroupID: d.Get("delivery_type.target_project_id").(string), - OplogTs: cast.ToInt64(d.Get("delivery_type.oplog_ts")), - OplogInc: cast.ToInt64(d.Get("delivery_type.oplog_inc")), - PointInTimeUTCSeconds: cast.ToInt64(d.Get("delivery_type.point_in_time_utc_seconds")), + if _, ok := d.GetOk("delivery_type"); ok { + deliveryType := "automated" + if aut, _ := d.Get("delivery_type.download").(string); aut != "true" { + deliveryType = "download" + } + + if aut, _ := d.Get("delivery_type.point_in_time").(string); aut == "true" { + deliveryType = "pointInTime" + } + + snapshotReq = &matlas.CloudProviderSnapshotRestoreJob{ + SnapshotID: getEncodedID(d.Get("snapshot_id").(string), "snapshot_id"), + DeliveryType: deliveryType, + TargetClusterName: d.Get("delivery_type.target_cluster_name").(string), + TargetGroupID: d.Get("delivery_type.target_project_id").(string), + OplogTs: cast.ToInt64(d.Get("delivery_type.oplog_ts")), + OplogInc: cast.ToInt64(d.Get("delivery_type.oplog_inc")), + PointInTimeUTCSeconds: cast.ToInt64(d.Get("delivery_type.point_in_time_utc_seconds")), + } } - cloudProviderSnapshotRestoreJob, _, err := conn.CloudProviderSnapshotRestoreJobs.Create(context.Background(), requestParameters, snapshotReq) + cloudProviderSnapshotRestoreJob, _, err := conn.CloudProviderSnapshotRestoreJobs.Create(ctx, requestParameters, snapshotReq) if err != nil { - return fmt.Errorf("error restore a snapshot: %s", err) + return diag.FromErr(fmt.Errorf("error restore a snapshot: %s", err)) } d.SetId(encodeStateID(map[string]string{ @@ -208,10 +240,10 @@ func resourceMongoDBAtlasCloudProviderSnapshotRestoreJobCreate(d *schema.Resourc "snapshot_restore_job_id": cloudProviderSnapshotRestoreJob.ID, })) - return resourceMongoDBAtlasCloudProviderSnapshotRestoreJobRead(d, meta) + return resourceMongoDBAtlasCloudProviderSnapshotRestoreJobRead(ctx, d, meta) } -func resourceMongoDBAtlasCloudProviderSnapshotRestoreJobRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderSnapshotRestoreJobRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -229,45 +261,45 @@ func resourceMongoDBAtlasCloudProviderSnapshotRestoreJobRead(d *schema.ResourceD return nil } - return fmt.Errorf("error getting cloudProviderSnapshotRestoreJob Information: %s", err) + return diag.FromErr(fmt.Errorf("error getting cloudProviderSnapshotRestoreJob Information: %s", err)) } if err = d.Set("delivery_url", snapshotReq.DeliveryURL); err != nil { - return fmt.Errorf("error setting `delivery_url` for cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err) + return diag.FromErr(fmt.Errorf("error setting `delivery_url` for cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err)) } if err = d.Set("cancelled", snapshotReq.Cancelled); err != nil { - return fmt.Errorf("error setting `cancelled` for cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err) + return diag.FromErr(fmt.Errorf("error setting `cancelled` for cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err)) } if err = d.Set("created_at", snapshotReq.CreatedAt); err != nil { - return fmt.Errorf("error setting `created_at` for cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err) + return diag.FromErr(fmt.Errorf("error setting `created_at` for cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err)) } if err = d.Set("expired", snapshotReq.Expired); err != nil { - return fmt.Errorf("error setting `expired` for cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err) + return diag.FromErr(fmt.Errorf("error setting `expired` for cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err)) } if err = d.Set("expires_at", snapshotReq.ExpiresAt); err != nil { - return fmt.Errorf("error setting `expires_at` for cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err) + return diag.FromErr(fmt.Errorf("error setting `expires_at` for cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err)) } if err = d.Set("finished_at", snapshotReq.FinishedAt); err != nil { - return fmt.Errorf("error setting `Finished_at` for cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err) + return diag.FromErr(fmt.Errorf("error setting `Finished_at` for cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err)) } if err = d.Set("timestamp", snapshotReq.Timestamp); err != nil { - return fmt.Errorf("error setting `timestamp` for cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err) + return diag.FromErr(fmt.Errorf("error setting `timestamp` for cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err)) } if err = d.Set("snapshot_restore_job_id", snapshotReq.ID); err != nil { - return fmt.Errorf("error setting `snapshot_restore_job_id` for cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err) + return diag.FromErr(fmt.Errorf("error setting `snapshot_restore_job_id` for cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err)) } return nil } -func resourceMongoDBAtlasCloudProviderSnapshotRestoreJobDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCloudProviderSnapshotRestoreJobDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -277,20 +309,30 @@ func resourceMongoDBAtlasCloudProviderSnapshotRestoreJobDelete(d *schema.Resourc ClusterName: ids["cluster_name"], } + shouldDelete := true + // Validate because atomated restore can not be cancelled if aut, _ := d.Get("delivery_type.automated").(string); aut == "true" { log.Print("Automated restore cannot be cancelled") - } else { + shouldDelete = false + } + + if aut, _ := d.Get("delivery_type_config.0.automated").(bool); aut { + log.Print("Automated restore cannot be cancelled") + shouldDelete = false + } + + if shouldDelete { _, err := conn.CloudProviderSnapshotRestoreJobs.Delete(context.Background(), requestParameters) if err != nil { - return fmt.Errorf("error deleting a cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err) + return diag.FromErr(fmt.Errorf("error deleting a cloudProviderSnapshotRestoreJob (%s): %s", ids["snapshot_restore_job_id"], err)) } } return nil } -func resourceMongoDBAtlasCloudProviderSnapshotRestoreJobImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasCloudProviderSnapshotRestoreJobImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas projectID, clusterName, snapshotJobID, err := splitSnapshotRestoreJobImportID(d.Id()) @@ -304,7 +346,7 @@ func resourceMongoDBAtlasCloudProviderSnapshotRestoreJobImportState(d *schema.Re JobID: *snapshotJobID, } - u, _, err := conn.CloudProviderSnapshotRestoreJobs.Get(context.Background(), requestParameters) + u, _, err := conn.CloudProviderSnapshotRestoreJobs.Get(ctx, requestParameters) if err != nil { return nil, fmt.Errorf("couldn't import cloudProviderSnapshotRestoreJob %s in project %s, error: %s", requestParameters.ClusterName, requestParameters.GroupID, err) } @@ -322,14 +364,25 @@ func resourceMongoDBAtlasCloudProviderSnapshotRestoreJobImportState(d *schema.Re } deliveryType := make(map[string]interface{}) + deliveryTypeConfig := make(map[string]interface{}) if u.DeliveryType == "automated" { deliveryType["automated"] = "true" deliveryType["target_cluster_name"] = u.TargetClusterName deliveryType["target_project_id"] = u.TargetGroupID + // For delivery_type_config + deliveryTypeConfig["automated"] = true + deliveryTypeConfig["target_cluster_name"] = u.TargetClusterName + deliveryTypeConfig["target_project_id"] = u.TargetGroupID } - if err := d.Set("delivery_type", deliveryType); err != nil { + if _, ok := d.GetOk("delivery_type"); ok { + if err := d.Set("delivery_type", deliveryType); err != nil { + log.Printf("[WARN] Error setting delivery_type for (%s): %s", d.Id(), err) + } + } + + if err := d.Set("delivery_type_config", []interface{}{deliveryTypeConfig}); err != nil { log.Printf("[WARN] Error setting delivery_type for (%s): %s", d.Id(), err) } @@ -357,3 +410,89 @@ func splitSnapshotRestoreJobImportID(id string) (projectID, clusterName, snapsho return } + +func validateDeliveryType(d []interface{}) error { + if len(d) != 0 { + v := d[0].(map[string]interface{}) + key := "delivery_type_config" + + _, automated := v["automated"] + _, download := v["download"] + _, pointInTime := v["point_in_time"] + + if (v["automated"] == true && v["download"] == true && v["point_in_time"] == true) || + (v["automated"] == false && v["download"] == false && v["point_in_time"] == false) || + (!automated && !download && !pointInTime) { + return fmt.Errorf("%q you can only submit one type of restore job: automated, download or point_in_time", key) + } + if v["automated"] == true && (v["download"] == false || !download) { + if targetClusterName, ok := v["target_cluster_name"]; !ok || targetClusterName == "" { + return fmt.Errorf("%q target_cluster_name must be set", key) + } + if targetGroupID, ok := v["target_project_id"]; !ok || targetGroupID == "" { + return fmt.Errorf("%q target_project_id must be set", key) + } + } + if v["download"] == true && (v["automated"] == false || !automated) && + (v["point_in_time"] == false || !pointInTime) { + if targetClusterName, ok := v["target_cluster_name"]; ok && targetClusterName != "" { + return fmt.Errorf("%q it's not necessary implement target_cluster_name when you are using download delivery type", key) + } + if targetGroupID, ok := v["target_project_id"]; ok && targetGroupID != "" { + return fmt.Errorf("%q it's not necessary implement target_project_id when you are using download delivery type", key) + } + } + if v["point_in_time"] == true && (v["download"] == false || !download) && + (v["automated"] == false || !automated) { + _, oplogTS := v["oplog_ts"] + _, pointTimeUTC := v["point_in_time_utc_seconds"] + _, oplogInc := v["oplog_inc"] + if targetClusterName, ok := v["target_cluster_name"]; !ok || targetClusterName == "" { + return fmt.Errorf("%q target_cluster_name must be set", key) + } + if targetGroupID, ok := v["target_project_id"]; !ok || targetGroupID == "" { + return fmt.Errorf("%q target_project_id must be set", key) + } + if !pointTimeUTC && !oplogTS && !oplogInc { + return fmt.Errorf("%q point_in_time_utc_seconds or oplog_ts and oplog_inc must be set", key) + } + if (oplogTS && !oplogInc) || (!oplogTS && oplogInc) { + return fmt.Errorf("%q if oplog_ts or oplog_inc is provided, oplog_inc and oplog_ts must be set", key) + } + if pointTimeUTC && (oplogTS || oplogInc) { + return fmt.Errorf("%q you can't use both point_in_time_utc_seconds and oplog_ts or oplog_inc", key) + } + } + } + + return nil +} + +func buildRequestSnapshotReq(d *schema.ResourceData) *matlas.CloudProviderSnapshotRestoreJob { + if _, ok := d.GetOk("delivery_type_config"); ok { + deliveryList := d.Get("delivery_type_config").([]interface{}) + + delivery := deliveryList[0].(map[string]interface{}) + + deliveryType := "automated" + if aut, _ := delivery["download"].(bool); aut { + deliveryType = "download" + } + + if aut, _ := delivery["point_in_time"].(bool); aut { + deliveryType = "pointInTime" + } + + return &matlas.CloudProviderSnapshotRestoreJob{ + SnapshotID: getEncodedID(d.Get("snapshot_id").(string), "snapshot_id"), + DeliveryType: deliveryType, + TargetClusterName: delivery["target_cluster_name"].(string), + TargetGroupID: delivery["target_project_id"].(string), + OplogTs: cast.ToInt64(delivery["oplog_ts"]), + OplogInc: cast.ToInt64(delivery["oplog_inc"]), + PointInTimeUTCSeconds: cast.ToInt64(delivery["point_in_time_utc_seconds"]), + } + } + + return &matlas.CloudProviderSnapshotRestoreJob{} +} diff --git a/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_restore_job_test.go b/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_restore_job_test.go index cb438a338d..f421fd495b 100644 --- a/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_restore_job_test.go +++ b/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_restore_job_test.go @@ -7,9 +7,9 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -26,17 +26,17 @@ func TestAccResourceMongoDBAtlasCloudProviderSnapshotRestoreJob_basic(t *testing ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasCloudProviderSnapshotRestoreJobDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasCloudProviderSnapshotRestoreJobDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCloudProviderSnapshotRestoreJobConfigAutomated(projectID, clusterName, description, retentionInDays, targetClusterName, targetGroupID), Check: resource.ComposeTestCheckFunc( testAccCheckMongoDBAtlasCloudProviderSnapshotRestoreJobExists(resourceName, &cloudProviderSnapshotRestoreJob), testAccCheckMongoDBAtlasCloudProviderSnapshotRestoreJobAttributes(&cloudProviderSnapshotRestoreJob, "automated"), - resource.TestCheckResourceAttr(resourceName, "delivery_type.target_cluster_name", targetClusterName), - resource.TestCheckResourceAttr(resourceName, "delivery_type.target_project_id", targetGroupID), + resource.TestCheckResourceAttr(resourceName, "delivery_type_config.0.target_cluster_name", targetClusterName), + resource.TestCheckResourceAttr(resourceName, "delivery_type_config.0.target_project_id", targetGroupID), ), }, { @@ -44,7 +44,7 @@ func TestAccResourceMongoDBAtlasCloudProviderSnapshotRestoreJob_basic(t *testing Check: resource.ComposeTestCheckFunc( testAccCheckMongoDBAtlasCloudProviderSnapshotRestoreJobExists(resourceName, &cloudProviderSnapshotRestoreJob), testAccCheckMongoDBAtlasCloudProviderSnapshotRestoreJobAttributes(&cloudProviderSnapshotRestoreJob, "download"), - resource.TestCheckResourceAttr(resourceName, "delivery_type.download", "true"), + resource.TestCheckResourceAttr(resourceName, "delivery_type_config.0.download", "true"), ), }, }, @@ -63,9 +63,9 @@ func TestAccResourceMongoDBAtlasCloudProviderSnapshotRestoreJob_importBasic(t *t ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasCloudProviderSnapshotRestoreJobDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasCloudProviderSnapshotRestoreJobDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCloudProviderSnapshotRestoreJobConfigAutomated(projectID, clusterName, description, retentionInDays, targetClusterName, targetGroupID), @@ -94,9 +94,9 @@ func TestAccResourceMongoDBAtlasCloudProviderSnapshotRestoreJobWithPointTime_bas ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasCloudProviderSnapshotRestoreJobDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasCloudProviderSnapshotRestoreJobDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCloudProviderSnapshotRestoreJobConfigPointInTime(projectID, clusterName, description, retentionInDays, targetClusterName, targetGroupID, timeUtc), @@ -210,7 +210,7 @@ func testAccMongoDBAtlasCloudProviderSnapshotRestoreJobConfigAutomated(projectID project_id = mongodbatlas_cloud_provider_snapshot.test.project_id cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name snapshot_id = mongodbatlas_cloud_provider_snapshot.test.id - delivery_type = { + delivery_type_config { automated = true target_cluster_name = "%s" target_project_id = "%s" @@ -245,7 +245,7 @@ func testAccMongoDBAtlasCloudProviderSnapshotRestoreJobConfigDownload(projectID, project_id = mongodbatlas_cloud_provider_snapshot.test.project_id cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name snapshot_id = mongodbatlas_cloud_provider_snapshot.test.id - delivery_type = { + delivery_type_config { download = true } depends_on = ["mongodbatlas_cloud_provider_snapshot.test"] @@ -293,7 +293,7 @@ func testAccMongoDBAtlasCloudProviderSnapshotRestoreJobConfigPointInTime(project cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name snapshot_id = mongodbatlas_cloud_provider_snapshot.test.id - delivery_type = { + delivery_type_config { point_in_time = true target_cluster_name = mongodbatlas_cluster.target_cluster.name target_project_id = "%s" diff --git a/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_test.go b/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_test.go index cc7bed3fe1..48eb3f7397 100644 --- a/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_test.go +++ b/mongodbatlas/resource_mongodbatlas_cloud_provider_snapshot_test.go @@ -8,9 +8,9 @@ import ( "testing" "github.com/go-test/deep" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -25,9 +25,9 @@ func TestAccResourceMongoDBAtlasCloudProviderSnapshot_basic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasCloudProviderSnapshotDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasCloudProviderSnapshotDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCloudProviderSnapshotConfig(projectID, clusterName, description, retentionInDays), @@ -54,9 +54,9 @@ func TestAccResourceMongoDBAtlasCloudProviderSnapshot_importBasic(t *testing.T) ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasCloudProviderSnapshotDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasCloudProviderSnapshotDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCloudProviderSnapshotConfig(projectID, clusterName, description, retentionInDays), diff --git a/mongodbatlas/resource_mongodbatlas_cluster.go b/mongodbatlas/resource_mongodbatlas_cluster.go index 05c42bf544..9bc2cf3275 100644 --- a/mongodbatlas/resource_mongodbatlas_cluster.go +++ b/mongodbatlas/resource_mongodbatlas_cluster.go @@ -14,9 +14,9 @@ import ( "strconv" "strings" - "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mwielbut/pointy" "github.com/spf13/cast" @@ -38,12 +38,12 @@ var defaultLabel = matlas.Label{Key: "Infrastructure Tool", Value: "MongoDB Atla func resourceMongoDBAtlasCluster() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasClusterCreate, - Read: resourceMongoDBAtlasClusterRead, - Update: resourceMongoDBAtlasClusterUpdate, - Delete: resourceMongoDBAtlasClusterDelete, + CreateWithoutTimeout: resourceMongoDBAtlasClusterCreate, + ReadWithoutTimeout: resourceMongoDBAtlasClusterRead, + UpdateWithoutTimeout: resourceMongoDBAtlasClusterUpdate, + DeleteWithoutTimeout: resourceMongoDBAtlasClusterDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasClusterImportState, + StateContext: resourceMongoDBAtlasClusterImportState, }, SchemaVersion: 1, StateUpgraders: []schema.StateUpgrader{ @@ -88,17 +88,8 @@ func resourceMongoDBAtlasCluster() *schema.Resource { Optional: true, Deprecated: "use bi_connector_config instead", ConflictsWith: []string{"bi_connector_config"}, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "enabled": { - Type: schema.TypeString, - Optional: true, - }, - "read_preference": { - Type: schema.TypeString, - Optional: true, - }, - }, + Elem: &schema.Schema{ + Type: schema.TypeString, }, }, "bi_connector_config": { @@ -360,7 +351,7 @@ func resourceMongoDBAtlasCluster() *schema.Resource { m := v.(map[string]interface{}) buf.WriteString(m["key"].(string)) buf.WriteString(m["value"].(string)) - return hashcode.String(buf.String()) + return HashCodeString(buf.String()) }, Computed: true, Elem: &schema.Resource{ @@ -387,7 +378,7 @@ func resourceMongoDBAtlasCluster() *schema.Resource { } } -func resourceMongoDBAtlasClusterCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasClusterCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas @@ -400,15 +391,15 @@ func resourceMongoDBAtlasClusterCreate(d *schema.ResourceData, meta interface{}) maxInstanceSize := d.Get("provider_auto_scaling_compute_max_instance_size").(string) if scaleDownEnabled && !computeEnabled { - return fmt.Errorf("`auto_scaling_compute_scale_down_enabled` must be set when `auto_scaling_compute_enabled` is set") + return diag.FromErr(fmt.Errorf("`auto_scaling_compute_scale_down_enabled` must be set when `auto_scaling_compute_enabled` is set")) } if computeEnabled && maxInstanceSize == "" { - return fmt.Errorf("`provider_auto_scaling_compute_max_instance_size` must be set when `auto_scaling_compute_enabled` is set") + return diag.FromErr(fmt.Errorf("`provider_auto_scaling_compute_max_instance_size` must be set when `auto_scaling_compute_enabled` is set")) } if scaleDownEnabled && minInstanceSize == "" { - return fmt.Errorf("`provider_auto_scaling_compute_min_instance_size` must be set when `auto_scaling_compute_scale_down_enabled` is set") + return diag.FromErr(fmt.Errorf("`provider_auto_scaling_compute_min_instance_size` must be set when `auto_scaling_compute_scale_down_enabled` is set")) } autoScaling := &matlas.AutoScaling{ @@ -422,40 +413,40 @@ func resourceMongoDBAtlasClusterCreate(d *schema.ResourceData, meta interface{}) // validate cluster_type conditional if _, ok := d.GetOk("replication_specs"); ok { if _, ok1 := d.GetOk("cluster_type"); !ok1 { - return fmt.Errorf("`cluster_type` should be set when `replication_specs` is set") + return diag.FromErr(fmt.Errorf("`cluster_type` should be set when `replication_specs` is set")) } if _, ok1 := d.GetOk("num_shards"); !ok1 { - return fmt.Errorf("`num_shards` should be set when `replication_specs` is set") + return diag.FromErr(fmt.Errorf("`num_shards` should be set when `replication_specs` is set")) } } if providerName != "AWS" { if _, ok := d.GetOk("provider_disk_iops"); ok { - return fmt.Errorf("`provider_disk_iops` shouldn't be set when provider name is `GCP` or `AZURE`") + return diag.FromErr(fmt.Errorf("`provider_disk_iops` shouldn't be set when provider name is `GCP` or `AZURE`")) } if _, ok := d.GetOk("provider_volume_type"); ok { - return fmt.Errorf("`provider_volume_type` shouldn't be set when provider name is `GCP` or `AZURE`") + return diag.FromErr(fmt.Errorf("`provider_volume_type` shouldn't be set when provider name is `GCP` or `AZURE`")) } } if providerName != "AZURE" { if _, ok := d.GetOk("provider_disk_type_name"); ok { - return fmt.Errorf("`provider_disk_type_name` shouldn't be set when provider name is `GCP` or `AWS`") + return diag.FromErr(fmt.Errorf("`provider_disk_type_name` shouldn't be set when provider name is `GCP` or `AWS`")) } } if providerName == "AZURE" { if _, ok := d.GetOk("disk_size_gb"); ok { - return fmt.Errorf("`disk_size_gb` cannot be used with Azure clusters") + return diag.FromErr(fmt.Errorf("`disk_size_gb` cannot be used with Azure clusters")) } } tenantDisksize := pointy.Float64(0) if providerName == "TENANT" { if diskGBEnabled := d.Get("auto_scaling_disk_gb_enabled"); diskGBEnabled.(bool) { - return fmt.Errorf("`auto_scaling_disk_gb_enabled` cannot be true when provider name is TENANT") + return diag.FromErr(fmt.Errorf("`auto_scaling_disk_gb_enabled` cannot be true when provider name is TENANT")) } autoScaling = &matlas.AutoScaling{ @@ -465,14 +456,14 @@ func resourceMongoDBAtlasClusterCreate(d *schema.ResourceData, meta interface{}) if instanceSizeName == "M2" { if diskSizeGB, ok := d.GetOk("disk_size_gb"); ok { if cast.ToFloat64(diskSizeGB) != 2 { - return fmt.Errorf("`disk_size_gb` must be 2 for M2 shared tier") + return diag.FromErr(fmt.Errorf("`disk_size_gb` must be 2 for M2 shared tier")) } } } if instanceSizeName == "M5" { if diskSizeGB, ok := d.GetOk("disk_size_gb"); ok { if cast.ToFloat64(diskSizeGB) != 5 { - return fmt.Errorf("`disk_size_gb` must be 5 for M5 shared tier") + return diag.FromErr(fmt.Errorf("`disk_size_gb` must be 5 for M5 shared tier")) } } } @@ -483,18 +474,18 @@ func resourceMongoDBAtlasClusterCreate(d *schema.ResourceData, meta interface{}) // before that the cluster is created if oplogSizeMB, ok := d.GetOkExists("advanced_configuration.0.oplog_size_mb"); ok { if cast.ToInt64(oplogSizeMB) <= 0 { - return fmt.Errorf("`advanced_configuration.oplog_size_mb` cannot be <= 0") + return diag.FromErr(fmt.Errorf("`advanced_configuration.oplog_size_mb` cannot be <= 0")) } } providerSettings, err := expandProviderSetting(d) if err != nil { - return fmt.Errorf(errorClusterCreate, err) + return diag.FromErr(fmt.Errorf(errorClusterCreate, err)) } replicationSpecs, err := expandReplicationSpecs(d) if err != nil { - return fmt.Errorf(errorClusterCreate, err) + return diag.FromErr(fmt.Errorf(errorClusterCreate, err)) } clusterRequest := &matlas.Cluster{ @@ -512,21 +503,21 @@ func resourceMongoDBAtlasClusterCreate(d *schema.ResourceData, meta interface{}) if _, ok := d.GetOk("bi_connector"); ok { biConnector, err := expandBiConnector(d) if err != nil { - return fmt.Errorf(errorClusterCreate, err) + return diag.FromErr(fmt.Errorf(errorClusterCreate, err)) } clusterRequest.BiConnector = biConnector } if _, ok := d.GetOk("bi_connector_config"); ok { - biConnector, err := expandBiConnector(d) + biConnector, err := expandBiConnectorConfig(d) if err != nil { - return fmt.Errorf(errorClusterCreate, err) + return diag.FromErr(fmt.Errorf(errorClusterCreate, err)) } clusterRequest.BiConnector = biConnector } if containsLabelOrKey(expandLabelSliceFromSetSchema(d), defaultLabel) { - return fmt.Errorf("you should not set `Infrastructure Tool` label, it is used for internal purposes") + return diag.FromErr(fmt.Errorf("you should not set `Infrastructure Tool` label, it is used for internal purposes")) } clusterRequest.Labels = append(expandLabelSliceFromSetSchema(d), defaultLabel) @@ -549,24 +540,24 @@ func resourceMongoDBAtlasClusterCreate(d *schema.ResourceData, meta interface{}) clusterRequest.NumShards = pointy.Int64(cast.ToInt64(n)) } - cluster, _, err := conn.Clusters.Create(context.Background(), projectID, clusterRequest) + cluster, _, err := conn.Clusters.Create(ctx, projectID, clusterRequest) if err != nil { - return fmt.Errorf(errorClusterCreate, err) + return diag.FromErr(fmt.Errorf(errorClusterCreate, err)) } stateConf := &resource.StateChangeConf{ Pending: []string{"CREATING", "UPDATING", "REPAIRING", "REPEATING", "PENDING"}, Target: []string{"IDLE"}, - Refresh: resourceClusterRefreshFunc(d.Get("name").(string), projectID, conn), + Refresh: resourceClusterRefreshFunc(ctx, d.Get("name").(string), projectID, conn), Timeout: 3 * time.Hour, MinTimeout: 1 * time.Minute, Delay: 3 * time.Minute, } // Wait, catching any errors - _, err = stateConf.WaitForState() + _, err = stateConf.WaitForStateContext(ctx) if err != nil { - return fmt.Errorf(errorClusterCreate, err) + return diag.FromErr(fmt.Errorf(errorClusterCreate, err)) } /* @@ -578,9 +569,9 @@ func resourceMongoDBAtlasClusterCreate(d *schema.ResourceData, meta interface{}) advancedConfReq := expandProcessArgs(d, aclist[0].(map[string]interface{})) if ok { - _, _, err := conn.Clusters.UpdateProcessArgs(context.Background(), projectID, cluster.Name, advancedConfReq) + _, _, err := conn.Clusters.UpdateProcessArgs(ctx, projectID, cluster.Name, advancedConfReq) if err != nil { - return fmt.Errorf(errorAdvancedConfUpdate, cluster.Name, err) + return diag.FromErr(fmt.Errorf(errorAdvancedConfUpdate, cluster.Name, err)) } } } @@ -592,10 +583,10 @@ func resourceMongoDBAtlasClusterCreate(d *schema.ResourceData, meta interface{}) "provider_name": providerName, })) - return resourceMongoDBAtlasClusterRead(d, meta) + return resourceMongoDBAtlasClusterRead(ctx, d, meta) } -func resourceMongoDBAtlasClusterRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasClusterRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -603,117 +594,117 @@ func resourceMongoDBAtlasClusterRead(d *schema.ResourceData, meta interface{}) e clusterName := ids["cluster_name"] providerName := ids["provider_name"] - cluster, resp, err := conn.Clusters.Get(context.Background(), projectID, clusterName) + cluster, resp, err := conn.Clusters.Get(ctx, projectID, clusterName) if err != nil { if resp != nil && resp.StatusCode == http.StatusNotFound { d.SetId("") return nil } - return fmt.Errorf(errorClusterRead, clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterRead, clusterName, err)) } log.Printf("[DEBUG] GET Cluster %+v", cluster) if err := d.Set("cluster_id", cluster.ID); err != nil { - return fmt.Errorf(errorClusterSetting, "cluster_id", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "cluster_id", clusterName, err)) } if err := d.Set("auto_scaling_disk_gb_enabled", cluster.AutoScaling.DiskGBEnabled); err != nil { - return fmt.Errorf(errorClusterSetting, "auto_scaling_disk_gb_enabled", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "auto_scaling_disk_gb_enabled", clusterName, err)) } if err := d.Set("auto_scaling_compute_enabled", cluster.AutoScaling.Compute.Enabled); err != nil { - return fmt.Errorf(errorClusterSetting, "auto_scaling_compute_enabled", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "auto_scaling_compute_enabled", clusterName, err)) } if err := d.Set("auto_scaling_compute_scale_down_enabled", cluster.AutoScaling.Compute.ScaleDownEnabled); err != nil { - return fmt.Errorf(errorClusterSetting, "auto_scaling_compute_scale_down_enabled", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "auto_scaling_compute_scale_down_enabled", clusterName, err)) } if err := d.Set("provider_auto_scaling_compute_min_instance_size", cluster.ProviderSettings.AutoScaling.Compute.MinInstanceSize); err != nil { - return fmt.Errorf(errorClusterSetting, "provider_auto_scaling_compute_min_instance_size", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "provider_auto_scaling_compute_min_instance_size", clusterName, err)) } if err := d.Set("provider_auto_scaling_compute_max_instance_size", cluster.ProviderSettings.AutoScaling.Compute.MaxInstanceSize); err != nil { - return fmt.Errorf(errorClusterSetting, "provider_auto_scaling_compute_max_instance_size", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "provider_auto_scaling_compute_max_instance_size", clusterName, err)) } if err := d.Set("backup_enabled", cluster.BackupEnabled); err != nil { - return fmt.Errorf(errorClusterSetting, "backup_enabled", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "backup_enabled", clusterName, err)) } if err := d.Set("provider_backup_enabled", cluster.ProviderBackupEnabled); err != nil { - return fmt.Errorf(errorClusterSetting, "provider_backup_enabled", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "provider_backup_enabled", clusterName, err)) } if err := d.Set("cluster_type", cluster.ClusterType); err != nil { - return fmt.Errorf(errorClusterSetting, "cluster_type", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "cluster_type", clusterName, err)) } if err := d.Set("connection_strings", flattenConnectionStrings(cluster.ConnectionStrings)); err != nil { - return fmt.Errorf(errorClusterSetting, "connection_strings", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "connection_strings", clusterName, err)) } if err := d.Set("disk_size_gb", cluster.DiskSizeGB); err != nil { - return fmt.Errorf(errorClusterSetting, "disk_size_gb", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "disk_size_gb", clusterName, err)) } if err := d.Set("encryption_at_rest_provider", cluster.EncryptionAtRestProvider); err != nil { - return fmt.Errorf(errorClusterSetting, "encryption_at_rest_provider", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "encryption_at_rest_provider", clusterName, err)) } if err := d.Set("mongo_db_major_version", cluster.MongoDBMajorVersion); err != nil { - return fmt.Errorf(errorClusterSetting, "mongo_db_major_version", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "mongo_db_major_version", clusterName, err)) } // Avoid Global Cluster issues. (NumShards is not present in Global Clusters) if cluster.NumShards != nil { if err := d.Set("num_shards", cluster.NumShards); err != nil { - return fmt.Errorf(errorClusterSetting, "num_shards", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "num_shards", clusterName, err)) } } if err := d.Set("mongo_db_version", cluster.MongoDBVersion); err != nil { - return fmt.Errorf(errorClusterSetting, "mongo_db_version", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "mongo_db_version", clusterName, err)) } if err := d.Set("mongo_uri", cluster.MongoURI); err != nil { - return fmt.Errorf(errorClusterSetting, "mongo_uri", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "mongo_uri", clusterName, err)) } if err := d.Set("mongo_uri_updated", cluster.MongoURIUpdated); err != nil { - return fmt.Errorf(errorClusterSetting, "mongo_uri_updated", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "mongo_uri_updated", clusterName, err)) } if err := d.Set("mongo_uri_with_options", cluster.MongoURIWithOptions); err != nil { - return fmt.Errorf(errorClusterSetting, "mongo_uri_with_options", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "mongo_uri_with_options", clusterName, err)) } if err := d.Set("pit_enabled", cluster.PitEnabled); err != nil { - return fmt.Errorf(errorClusterSetting, "pit_enabled", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "pit_enabled", clusterName, err)) } if err := d.Set("paused", cluster.Paused); err != nil { - return fmt.Errorf(errorClusterSetting, "paused", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "paused", clusterName, err)) } if err := d.Set("srv_address", cluster.SrvAddress); err != nil { - return fmt.Errorf(errorClusterSetting, "srv_address", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "srv_address", clusterName, err)) } if err := d.Set("state_name", cluster.StateName); err != nil { - return fmt.Errorf(errorClusterSetting, "state_name", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "state_name", clusterName, err)) } if _, ok := d.GetOk("bi_connector"); ok { if err = d.Set("bi_connector", flattenBiConnector(cluster.BiConnector)); err != nil { - return fmt.Errorf(errorClusterSetting, "bi_connector", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "bi_connector", clusterName, err)) } } if err := d.Set("bi_connector_config", flattenBiConnectorConfig(cluster.BiConnector)); err != nil { - return fmt.Errorf(errorClusterSetting, "bi_connector_config", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "bi_connector_config", clusterName, err)) } if cluster.ProviderSettings != nil { @@ -721,55 +712,55 @@ func resourceMongoDBAtlasClusterRead(d *schema.ResourceData, meta interface{}) e } if err := d.Set("replication_specs", flattenReplicationSpecs(cluster.ReplicationSpecs)); err != nil { - return fmt.Errorf(errorClusterSetting, "replication_specs", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "replication_specs", clusterName, err)) } if err := d.Set("replication_factor", cluster.ReplicationFactor); err != nil { - return fmt.Errorf(errorClusterSetting, "replication_factor", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "replication_factor", clusterName, err)) } if err := d.Set("labels", flattenLabels(removeLabel(cluster.Labels, defaultLabel))); err != nil { - return fmt.Errorf(errorClusterSetting, "labels", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "labels", clusterName, err)) } if providerName != "TENANT" { - containers, _, err := conn.Containers.List(context.Background(), projectID, + containers, _, err := conn.Containers.List(ctx, projectID, &matlas.ContainersListOptions{ProviderName: providerName}) if err != nil { - return fmt.Errorf(errorClusterRead, clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterRead, clusterName, err)) } if err := d.Set("container_id", getContainerID(containers, cluster)); err != nil { - return fmt.Errorf(errorClusterSetting, "container_id", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "container_id", clusterName, err)) } } /* Get the advaced configuration options and set up to the terraform state */ - processArgs, _, err := conn.Clusters.GetProcessArgs(context.Background(), projectID, clusterName) + processArgs, _, err := conn.Clusters.GetProcessArgs(ctx, projectID, clusterName) if err != nil { - return fmt.Errorf(errorAdvancedConfRead, clusterName, err) + return diag.FromErr(fmt.Errorf(errorAdvancedConfRead, clusterName, err)) } if err := d.Set("advanced_configuration", flattenProcessArgs(processArgs)); err != nil { - return fmt.Errorf(errorClusterSetting, "advanced_configuration", clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterSetting, "advanced_configuration", clusterName, err)) } // Get the snapshot policy and set the data - snapshotBackupPolicy, err := flattenCloudProviderSnapshotBackupPolicy(d, conn, projectID, clusterName) + snapshotBackupPolicy, err := flattenCloudProviderSnapshotBackupPolicy(ctx, d, conn, projectID, clusterName) if err != nil { - return err + return diag.FromErr(err) } if err := d.Set("snapshot_backup_policy", snapshotBackupPolicy); err != nil { - return err + return diag.FromErr(err) } return nil } -func resourceMongoDBAtlasClusterUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasClusterUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -803,14 +794,14 @@ func resourceMongoDBAtlasClusterUpdate(d *schema.ResourceData, meta interface{}) var err error cluster.ProviderSettings, err = expandProviderSetting(d) if err != nil { - return fmt.Errorf(errorClusterUpdate, clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterUpdate, clusterName, err)) } } if d.HasChange("replication_specs") { replicationSpecs, err := expandReplicationSpecs(d) if err != nil { - return fmt.Errorf(errorClusterUpdate, clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterUpdate, clusterName, err)) } cluster.ReplicationSpecs = replicationSpecs @@ -868,7 +859,7 @@ func resourceMongoDBAtlasClusterUpdate(d *schema.ResourceData, meta interface{}) if d.HasChange("labels") { if containsLabelOrKey(expandLabelSliceFromSetSchema(d), defaultLabel) { - return fmt.Errorf("you should not set `Infrastructure Tool` label, it is used for internal purposes") + return diag.FromErr(fmt.Errorf("you should not set `Infrastructure Tool` label, it is used for internal purposes")) } cluster.Labels = append(expandLabelSliceFromSetSchema(d), defaultLabel) @@ -881,25 +872,25 @@ func resourceMongoDBAtlasClusterUpdate(d *schema.ResourceData, meta interface{}) // Has changes if !reflect.DeepEqual(cluster, matlas.Cluster{}) { - _, _, err := conn.Clusters.Update(context.Background(), projectID, clusterName, cluster) + _, _, err := conn.Clusters.Update(ctx, projectID, clusterName, cluster) if err != nil { - return fmt.Errorf(errorClusterUpdate, clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterUpdate, clusterName, err)) } } stateConf := &resource.StateChangeConf{ Pending: []string{"CREATING", "UPDATING", "REPAIRING"}, Target: []string{"IDLE"}, - Refresh: resourceClusterRefreshFunc(clusterName, projectID, conn), + Refresh: resourceClusterRefreshFunc(ctx, clusterName, projectID, conn), Timeout: 3 * time.Hour, MinTimeout: 30 * time.Second, Delay: 1 * time.Minute, } // Wait, catching any errors - _, err := stateConf.WaitForState() + _, err := stateConf.WaitForStateContext(ctx) if err != nil { - return fmt.Errorf(errorClusterUpdate, clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterUpdate, clusterName, err)) } /* @@ -910,28 +901,28 @@ func resourceMongoDBAtlasClusterUpdate(d *schema.ResourceData, meta interface{}) if aclist, ok1 := ac.([]interface{}); ok1 && len(aclist) > 0 { advancedConfReq := expandProcessArgs(d, aclist[0].(map[string]interface{})) if !reflect.DeepEqual(advancedConfReq, matlas.ProcessArgs{}) { - _, _, err := conn.Clusters.UpdateProcessArgs(context.Background(), projectID, clusterName, advancedConfReq) + _, _, err := conn.Clusters.UpdateProcessArgs(ctx, projectID, clusterName, advancedConfReq) if err != nil { - return fmt.Errorf(errorAdvancedConfUpdate, clusterName, err) + return diag.FromErr(fmt.Errorf(errorAdvancedConfUpdate, clusterName, err)) } } } } - return resourceMongoDBAtlasClusterRead(d, meta) + return resourceMongoDBAtlasClusterRead(ctx, d, meta) } -func resourceMongoDBAtlasClusterDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasClusterDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) projectID := ids["project_id"] clusterName := ids["cluster_name"] - _, err := conn.Clusters.Delete(context.Background(), projectID, clusterName) + _, err := conn.Clusters.Delete(ctx, projectID, clusterName) if err != nil { - return fmt.Errorf(errorClusterDelete, clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterDelete, clusterName, err)) } log.Println("[INFO] Waiting for MongoDB Cluster to be destroyed") @@ -939,22 +930,22 @@ func resourceMongoDBAtlasClusterDelete(d *schema.ResourceData, meta interface{}) stateConf := &resource.StateChangeConf{ Pending: []string{"IDLE", "CREATING", "UPDATING", "REPAIRING", "DELETING"}, Target: []string{"DELETED"}, - Refresh: resourceClusterRefreshFunc(clusterName, projectID, conn), + Refresh: resourceClusterRefreshFunc(ctx, clusterName, projectID, conn), Timeout: 3 * time.Hour, MinTimeout: 30 * time.Second, Delay: 1 * time.Minute, // Wait 30 secs before starting } // Wait, catching any errors - _, err = stateConf.WaitForState() + _, err = stateConf.WaitForStateContext(ctx) if err != nil { - return fmt.Errorf(errorClusterDelete, clusterName, err) + return diag.FromErr(fmt.Errorf(errorClusterDelete, clusterName, err)) } return nil } -func resourceMongoDBAtlasClusterImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasClusterImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas projectID, name, err := splitSClusterImportID(d.Id()) @@ -962,7 +953,7 @@ func resourceMongoDBAtlasClusterImportState(d *schema.ResourceData, meta interfa return nil, err } - u, _, err := conn.Clusters.Get(context.Background(), *projectID, *name) + u, _, err := conn.Clusters.Get(ctx, *projectID, *name) if err != nil { return nil, fmt.Errorf("couldn't import cluster %s in project %s, error: %s", *name, *projectID, err) } @@ -1326,9 +1317,9 @@ func flattenProcessArgs(p *matlas.ProcessArgs) []interface{} { } } -func resourceClusterRefreshFunc(name, projectID string, client *matlas.Client) resource.StateRefreshFunc { +func resourceClusterRefreshFunc(ctx context.Context, name, projectID string, client *matlas.Client) resource.StateRefreshFunc { return func() (interface{}, string, error) { - c, resp, err := client.Clusters.Get(context.Background(), projectID, name) + c, resp, err := client.Clusters.Get(ctx, projectID, name) if err != nil && strings.Contains(err.Error(), "reset by peer") { return nil, "REPEATING", nil @@ -1424,8 +1415,6 @@ func getContainerID(containers []matlas.Container, cluster *matlas.Cluster) stri func clusterConnectionStringsSchema() *schema.Schema { return &schema.Schema{ Type: schema.TypeList, - MinItems: 1, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/mongodbatlas/resource_mongodbatlas_cluster_migrate.go b/mongodbatlas/resource_mongodbatlas_cluster_migrate.go index cc96f7b68d..83e5f1ef1f 100644 --- a/mongodbatlas/resource_mongodbatlas_cluster_migrate.go +++ b/mongodbatlas/resource_mongodbatlas_cluster_migrate.go @@ -2,10 +2,10 @@ package mongodbatlas import ( "bytes" + "context" "log" - "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) func resourceMongoDBAtlasClusterResourceV0() *schema.Resource { @@ -304,7 +304,7 @@ func resourceMongoDBAtlasClusterResourceV0() *schema.Resource { m := v.(map[string]interface{}) buf.WriteString(m["key"].(string)) buf.WriteString(m["value"].(string)) - return hashcode.String(buf.String()) + return HashCodeString(buf.String()) }, Computed: true, Elem: &schema.Resource{ @@ -327,7 +327,7 @@ func resourceMongoDBAtlasClusterResourceV0() *schema.Resource { } } -func resourceMongoDBAtlasClusterStateUpgradeV0(rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { +func resourceMongoDBAtlasClusterStateUpgradeV0(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { log.Println("[INFO] Found MongoDB Cluser state v0; migrating to v1") return migrateAdvancedConfiguration(rawState), nil diff --git a/mongodbatlas/resource_mongodbatlas_cluster_migration_test.go b/mongodbatlas/resource_mongodbatlas_cluster_migration_test.go index c0113bf310..863c42c09a 100644 --- a/mongodbatlas/resource_mongodbatlas_cluster_migration_test.go +++ b/mongodbatlas/resource_mongodbatlas_cluster_migration_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func TestAccMongoDBAtlasClusterMigrateState_empty_advancedConfig(t *testing.T) { @@ -22,9 +22,9 @@ func TestAccMongoDBAtlasClusterMigrateState_empty_advancedConfig(t *testing.T) { } v0Config := terraform.NewResourceConfigRaw(v0State) - warns, errs := resourceMongoDBAtlasClusterResourceV0().Validate(v0Config) + diags := resourceMongoDBAtlasClusterResourceV0().Validate(v0Config) - if len(warns) > 0 || len(errs) > 0 { + if len(diags) > 0 { t.Error("test precondition failed - invalid mongodb cluster v0 config") return @@ -34,9 +34,9 @@ func TestAccMongoDBAtlasClusterMigrateState_empty_advancedConfig(t *testing.T) { v1State := migrateAdvancedConfiguration(v0State) v1Config := terraform.NewResourceConfigRaw(v1State) - warns, errs = resourceMongoDBAtlasCluster().Validate(v1Config) - if len(warns) > 0 || len(errs) > 0 { - fmt.Println(warns, errs) + diags = resourceMongoDBAtlasCluster().Validate(v1Config) + if len(diags) > 0 { + fmt.Println(diags) t.Error("migrated cluster advanced config is invalid") return @@ -66,8 +66,8 @@ func TestAccMongoDBAtlasClusterMigrateState_with_advancedConfig(t *testing.T) { } v0Config := terraform.NewResourceConfigRaw(v0State) - warns, errs := resourceMongoDBAtlasClusterResourceV0().Validate(v0Config) - if len(warns) > 0 || len(errs) > 0 { + diags := resourceMongoDBAtlasClusterResourceV0().Validate(v0Config) + if len(diags) > 0 { t.Error("test precondition failed - invalid mongodb cluster v0 config") return @@ -77,9 +77,9 @@ func TestAccMongoDBAtlasClusterMigrateState_with_advancedConfig(t *testing.T) { v1State := migrateAdvancedConfiguration(v0State) v1Config := terraform.NewResourceConfigRaw(v1State) - warns, errs = resourceMongoDBAtlasCluster().Validate(v1Config) - if len(warns) > 0 || len(errs) > 0 { - fmt.Println(warns, errs) + diags = resourceMongoDBAtlasCluster().Validate(v1Config) + if len(diags) > 0 { + fmt.Println(diags) t.Error("migrated cluster advanced config is invalid") return @@ -109,8 +109,8 @@ func TestAccMongoDBAtlasClusterMigrateState_with_defaultAdvancedConfig_v0_5_1(t } v0Config := terraform.NewResourceConfigRaw(v0State) - warns, errs := resourceMongoDBAtlasClusterResourceV0().Validate(v0Config) - if len(warns) > 0 || len(errs) > 0 { + diags := resourceMongoDBAtlasClusterResourceV0().Validate(v0Config) + if len(diags) > 0 { t.Error("test precondition failed - invalid mongodb cluster v0 config") return @@ -120,9 +120,9 @@ func TestAccMongoDBAtlasClusterMigrateState_with_defaultAdvancedConfig_v0_5_1(t v1State := migrateAdvancedConfiguration(v0State) v1Config := terraform.NewResourceConfigRaw(v1State) - warns, errs = resourceMongoDBAtlasCluster().Validate(v1Config) - if len(warns) > 0 || len(errs) > 0 { - fmt.Println(warns, errs) + diags = resourceMongoDBAtlasCluster().Validate(v1Config) + if len(diags) > 0 { + fmt.Println(diags) t.Error("migrated cluster advanced config is invalid") return diff --git a/mongodbatlas/resource_mongodbatlas_cluster_test.go b/mongodbatlas/resource_mongodbatlas_cluster_test.go index 92c99da673..61c5c75222 100644 --- a/mongodbatlas/resource_mongodbatlas_cluster_test.go +++ b/mongodbatlas/resource_mongodbatlas_cluster_test.go @@ -8,9 +8,9 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/mwielbut/pointy" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -24,9 +24,9 @@ func TestAccResourceMongoDBAtlasCluster_basicAWS(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigAWS(projectID, name, true, true), @@ -70,9 +70,9 @@ func TestAccResourceMongoDBAtlasCluster_basicAWS_instanceScale(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigAWS(projectID, name, true, false), @@ -117,9 +117,9 @@ func TestAccResourceMongoDBAtlasCluster_basic_Partial_AdvancedConf(t *testing.T) ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigAdvancedConf(projectID, name, "false", &matlas.ProcessArgs{ @@ -171,9 +171,9 @@ func TestAccResourceMongoDBAtlasCluster_emptyAdvancedConf(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigAdvancedConfPartial(projectID, name, "false", &matlas.ProcessArgs{ @@ -213,9 +213,9 @@ func TestAccResourceMongoDBAtlasCluster_basicAdvancedConf(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigAdvancedConf(projectID, name, "false", &matlas.ProcessArgs{ @@ -274,9 +274,9 @@ func TestAccResourceMongoDBAtlasCluster_basicAzure(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigAzure(projectID, name, "true"), @@ -315,9 +315,9 @@ func TestAccResourceMongoDBAtlasCluster_basicGCP(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigGCP(projectID, name, "true"), @@ -358,9 +358,9 @@ func TestAccResourceMongoDBAtlasCluster_WithBiConnectorGCP(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigGCPWithBiConnector(projectID, name, "true", false), @@ -403,9 +403,9 @@ func TestAccResourceMongoDBAtlasCluster_MultiRegion(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigMultiRegion(projectID, name, "true"), @@ -452,9 +452,9 @@ func TestAccResourceMongoDBAtlasCluster_Global(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigGlobal(projectID, name, "false"), @@ -487,9 +487,9 @@ func TestAccResourceMongoDBAtlasCluster_AWSWithLabels(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterAWSConfigdWithLabels(projectID, name, "false", "M10", "EU_CENTRAL_1", []matlas.Label{}), @@ -577,9 +577,9 @@ func TestAccResourceMongoDBAtlasCluster_withPrivateEndpointLink(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkAwsEnv(t); checkPeeringEnvAWS(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t); checkAwsEnv(t); checkPeeringEnvAWS(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigWithPrivateEndpointLink( @@ -612,9 +612,9 @@ func TestAccResourceMongoDBAtlasCluster_withAzureNetworkPeering(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigAzureWithNetworkPeering(projectID, providerName, directoryID, subcrptionID, resourceGroupName, vNetName, clusterName, atlasCidrBlock, region), @@ -643,9 +643,9 @@ func TestAccResourceMongoDBAtlasCluster_withGCPNetworkPeering(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkPeeringEnvGCP(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t); checkPeeringEnvGCP(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigGCPWithNetworkPeering(gcpProjectID, gcpRegion, projectID, providerName, gcpPeeringName, clusterName, gcpClusterRegion), @@ -679,9 +679,9 @@ func TestAccResourceMongoDBAtlasCluster_withAzureAndContainerID(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkPeeringEnvAzure(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t); checkPeeringEnvAzure(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigAzureWithContainerID(projectID, clusterName, providerName, region, directoryID, subcrptionID, resourceGroupName, vNetName), @@ -712,9 +712,9 @@ func TestAccResourceMongoDBAtlasCluster_withAWSAndContainerID(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigAWSWithContainerID(awsAccessKey, awsSecretKey, projectID, clusterName, providerName, awsRegion, vpcCIDRBlock, awsAccountID), @@ -742,9 +742,9 @@ func TestAccResourceMongoDBAtlasCluster_withGCPAndContainerID(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkPeeringEnvGCP(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t); checkPeeringEnvGCP(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigGCPWithContainerID(gcpProjectID, gcpRegion, projectID, clusterName, providerName, gcpClusterRegion, gcpPeeringName), @@ -778,9 +778,9 @@ func TestAccResourceMongoDBAtlasCluster_withAutoScalingAWS(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { // projectID, name, backupEnabled, autoDiskEnabled, autoScalingEnabled, scaleDownEnabled, minSizeName, maxSizeName, instanceSizeName @@ -819,9 +819,9 @@ func TestAccResourceMongoDBAtlasCluster_importBasic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigAWS(projectID, clusterName, true, false), @@ -847,9 +847,9 @@ func TestAccResourceMongoDBAtlasCluster_tenant(t *testing.T) { dbMajorVersion := testAccGetMongoDBAtlasMajorVersion() resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigTenant(projectID, name, "M2", "2", dbMajorVersion), @@ -886,9 +886,9 @@ func TestAccResourceMongoDBAtlasCluster_tenant_m5(t *testing.T) { dbMajorVersion := testAccGetMongoDBAtlasMajorVersion() resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigTenant(projectID, name, "M5", "5", dbMajorVersion), @@ -915,9 +915,9 @@ func TestAccResourceMongoDBAtlasCluster_basicGCPRegionName(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasClusterConfigGCPRegionName(projectID, clusterName, regionName), diff --git a/mongodbatlas/resource_mongodbatlas_custom_db_role.go b/mongodbatlas/resource_mongodbatlas_custom_db_role.go index 615a514a22..d565e6d0d7 100644 --- a/mongodbatlas/resource_mongodbatlas_custom_db_role.go +++ b/mongodbatlas/resource_mongodbatlas_custom_db_role.go @@ -10,9 +10,10 @@ import ( "strings" "time" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/mwielbut/pointy" "github.com/spf13/cast" matlas "go.mongodb.org/atlas/mongodbatlas" @@ -20,12 +21,12 @@ import ( func resourceMongoDBAtlasCustomDBRole() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasCustomDBRoleCreate, - Read: resourceMongoDBAtlasCustomDBRoleRead, - Update: resourceMongoDBAtlasCustomDBRoleUpdate, - Delete: resourceMongoDBAtlasCustomDBRoleDelete, + CreateContext: resourceMongoDBAtlasCustomDBRoleCreate, + ReadContext: resourceMongoDBAtlasCustomDBRoleRead, + UpdateContext: resourceMongoDBAtlasCustomDBRoleUpdate, + DeleteContext: resourceMongoDBAtlasCustomDBRoleDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasCustomDBRoleImportState, + StateContext: resourceMongoDBAtlasCustomDBRoleImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -100,7 +101,7 @@ func resourceMongoDBAtlasCustomDBRole() *schema.Resource { } } -func resourceMongoDBAtlasCustomDBRoleCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCustomDBRoleCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) @@ -114,7 +115,7 @@ func resourceMongoDBAtlasCustomDBRoleCreate(d *schema.ResourceData, meta interfa Pending: []string{"pending"}, Target: []string{"created", "failed"}, Refresh: func() (interface{}, string, error) { - customDBRoleRes, _, err := conn.CustomDBRoles.Create(context.Background(), projectID, customDBRoleReq) + customDBRoleRes, _, err := conn.CustomDBRoles.Create(ctx, projectID, customDBRoleReq) if err != nil { if strings.Contains(fmt.Sprint(err), "Unexpected error") || strings.Contains(fmt.Sprint(err), "UNEXPECTED_ERROR") || @@ -134,9 +135,9 @@ func resourceMongoDBAtlasCustomDBRoleCreate(d *schema.ResourceData, meta interfa } // Wait, catching any errors - _, err := stateConf.WaitForState() + _, err := stateConf.WaitForStateContext(ctx) if err != nil { - return fmt.Errorf("error creating custom db role: %s", err) + return diag.FromErr(fmt.Errorf("error creating custom db role: %s", err)) } d.SetId(encodeStateID(map[string]string{ @@ -144,10 +145,10 @@ func resourceMongoDBAtlasCustomDBRoleCreate(d *schema.ResourceData, meta interfa "role_name": customDBRoleReq.RoleName, })) - return resourceMongoDBAtlasCustomDBRoleRead(d, meta) + return resourceMongoDBAtlasCustomDBRoleRead(ctx, d, meta) } -func resourceMongoDBAtlasCustomDBRoleRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCustomDBRoleRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) projectID := ids["project_id"] @@ -160,33 +161,33 @@ func resourceMongoDBAtlasCustomDBRoleRead(d *schema.ResourceData, meta interface return nil } - return fmt.Errorf("error getting custom db role information: %s", err) + return diag.FromErr(fmt.Errorf("error getting custom db role information: %s", err)) } if err := d.Set("role_name", customDBRole.RoleName); err != nil { - return fmt.Errorf("error setting `role_name` for custom db role (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `role_name` for custom db role (%s): %s", d.Id(), err)) } if err := d.Set("actions", flattenActions(customDBRole.Actions)); err != nil { - return fmt.Errorf("error setting `actions` for custom db role (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `actions` for custom db role (%s): %s", d.Id(), err)) } if err := d.Set("inherited_roles", flattenInheritedRoles(customDBRole.InheritedRoles)); err != nil { - return fmt.Errorf("error setting `inherited_roles` for custom db role (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `inherited_roles` for custom db role (%s): %s", d.Id(), err)) } return nil } -func resourceMongoDBAtlasCustomDBRoleUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCustomDBRoleUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) projectID := ids["project_id"] roleName := ids["role_name"] - customDBRole, _, err := conn.CustomDBRoles.Get(context.Background(), projectID, roleName) + customDBRole, _, err := conn.CustomDBRoles.Get(ctx, projectID, roleName) if err != nil { - return fmt.Errorf("error getting custom db role information: %s", err) + return diag.FromErr(fmt.Errorf("error getting custom db role information: %s", err)) } // Clean the roleName because it can be sent into the update request to avoid an unexpected error 500 @@ -200,15 +201,15 @@ func resourceMongoDBAtlasCustomDBRoleUpdate(d *schema.ResourceData, meta interfa customDBRole.InheritedRoles = expandInheritedRoles(d) } - _, _, err = conn.CustomDBRoles.Update(context.Background(), projectID, roleName, customDBRole) + _, _, err = conn.CustomDBRoles.Update(ctx, projectID, roleName, customDBRole) if err != nil { - return fmt.Errorf("error updating custom db role (%s): %s", roleName, err) + return diag.FromErr(fmt.Errorf("error updating custom db role (%s): %s", roleName, err)) } - return resourceMongoDBAtlasCustomDBRoleRead(d, meta) + return resourceMongoDBAtlasCustomDBRoleRead(ctx, d, meta) } -func resourceMongoDBAtlasCustomDBRoleDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCustomDBRoleDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) projectID := ids["project_id"] @@ -218,7 +219,7 @@ func resourceMongoDBAtlasCustomDBRoleDelete(d *schema.ResourceData, meta interfa Pending: []string{"deleting"}, Target: []string{"deleted", "failed"}, Refresh: func() (interface{}, string, error) { - _, _, err := conn.CustomDBRoles.Get(context.Background(), projectID, roleName) + _, _, err := conn.CustomDBRoles.Get(ctx, projectID, roleName) if err != nil { if strings.Contains(fmt.Sprint(err), "404") || strings.Contains(fmt.Sprint(err), "ATLAS_CUSTOM_ROLE_NOT_FOUND") { @@ -227,7 +228,7 @@ func resourceMongoDBAtlasCustomDBRoleDelete(d *schema.ResourceData, meta interfa return nil, "failed", err } - _, err = conn.CustomDBRoles.Delete(context.Background(), projectID, roleName) + _, err = conn.CustomDBRoles.Delete(ctx, projectID, roleName) if err != nil { return nil, "failed", fmt.Errorf("error deleting custom db role (%s): %s", roleName, err) } @@ -240,15 +241,15 @@ func resourceMongoDBAtlasCustomDBRoleDelete(d *schema.ResourceData, meta interfa } // Wait, catching any errors - _, err := stateConf.WaitForState() + _, err := stateConf.WaitForStateContext(ctx) if err != nil { - return err + return diag.FromErr(err) } return nil } -func resourceMongoDBAtlasCustomDBRoleImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasCustomDBRoleImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas parts := strings.SplitN(d.Id(), "-", 2) @@ -259,7 +260,7 @@ func resourceMongoDBAtlasCustomDBRoleImportState(d *schema.ResourceData, meta in projectID := parts[0] roleName := parts[1] - r, _, err := conn.CustomDBRoles.Get(context.Background(), projectID, roleName) + r, _, err := conn.CustomDBRoles.Get(ctx, projectID, roleName) if err != nil { return nil, fmt.Errorf("couldn't import custom db role %s in project %s, error: %s", roleName, projectID, err) } diff --git a/mongodbatlas/resource_mongodbatlas_custom_db_role_test.go b/mongodbatlas/resource_mongodbatlas_custom_db_role_test.go index 294e48187d..5b2645ec21 100644 --- a/mongodbatlas/resource_mongodbatlas_custom_db_role_test.go +++ b/mongodbatlas/resource_mongodbatlas_custom_db_role_test.go @@ -6,9 +6,9 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/mwielbut/pointy" "github.com/spf13/cast" matlas "go.mongodb.org/atlas/mongodbatlas" @@ -22,9 +22,9 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_Basic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasCustomDBRolesDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasCustomDBRolesDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCustomDBRolesConfigBasic(projectID, roleName, "INSERT", fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))), @@ -130,9 +130,9 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_WithInheritedRoles(t *testing.T) { } resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasCustomDBRolesDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasCustomDBRolesDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCustomDBRolesConfigWithInheritedRoles(projectID, inheritRole, testRole), @@ -344,9 +344,9 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_MultipleCustomRoles(t *testing.T) } resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasCustomDBRolesDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasCustomDBRolesDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCustomDBRolesConfigMultiple(projectID, inheritRole, testRole), @@ -424,9 +424,9 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_MultipleResources(t *testing.T) { t.Run(roleName, func(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasCustomDBRolesDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasCustomDBRolesDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCustomDBRolesConfigBasic(projectID, roleName, "INSERT", fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))), @@ -458,9 +458,9 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_importBasic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasCustomDBRolesDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasCustomDBRolesDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCustomDBRolesConfigBasic(projectID, roleName, "INSERT", databaseName), @@ -554,9 +554,9 @@ func TestAccResourceMongoDBAtlasCustomDBRoles_UpdatedInheritRoles(t *testing.T) } resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasCustomDBRolesDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasCustomDBRolesDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCustomDBRolesConfigMultiple(projectID, inheritRole, testRole), diff --git a/mongodbatlas/resource_mongodbatlas_custom_dns_configuration_cluster_aws.go b/mongodbatlas/resource_mongodbatlas_custom_dns_configuration_cluster_aws.go index a6afd8ed95..e9cd1233ee 100644 --- a/mongodbatlas/resource_mongodbatlas_custom_dns_configuration_cluster_aws.go +++ b/mongodbatlas/resource_mongodbatlas_custom_dns_configuration_cluster_aws.go @@ -5,7 +5,9 @@ import ( "fmt" "net/http" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -19,12 +21,12 @@ const ( func resourceMongoDBAtlasCustomDNSConfiguration() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasCustomDNSConfigurationCreate, - Read: resourceMongoDBAtlasCustomDNSConfigurationRead, - Update: resourceMongoDBAtlasCustomDNSConfigurationUpdate, - Delete: resourceMongoDBAtlasCustomDNSConfigurationDelete, + CreateContext: resourceMongoDBAtlasCustomDNSConfigurationCreate, + ReadContext: resourceMongoDBAtlasCustomDNSConfigurationRead, + UpdateContext: resourceMongoDBAtlasCustomDNSConfigurationUpdate, + DeleteContext: resourceMongoDBAtlasCustomDNSConfigurationDelete, Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, + StateContext: schema.ImportStatePassthroughContext, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -40,25 +42,25 @@ func resourceMongoDBAtlasCustomDNSConfiguration() *schema.Resource { } } -func resourceMongoDBAtlasCustomDNSConfigurationCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCustomDNSConfigurationCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas orgID := d.Get("project_id").(string) // Creating(Updating) the Custom DNS Configuration for Atlas Clusters on AWS - _, _, err := conn.CustomAWSDNS.Update(context.Background(), orgID, + _, _, err := conn.CustomAWSDNS.Update(ctx, orgID, &matlas.AWSCustomDNSSetting{ Enabled: d.Get("enabled").(bool), }) if err != nil { - return fmt.Errorf(errorCustomDNSConfigurationCreate, err) + return diag.FromErr(fmt.Errorf(errorCustomDNSConfigurationCreate, err)) } d.SetId(orgID) - return resourceMongoDBAtlasCustomDNSConfigurationRead(d, meta) + return resourceMongoDBAtlasCustomDNSConfigurationRead(ctx, d, meta) } -func resourceMongoDBAtlasCustomDNSConfigurationRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCustomDNSConfigurationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas dnsResp, resp, err := conn.CustomAWSDNS.Get(context.Background(), d.Id()) @@ -68,43 +70,43 @@ func resourceMongoDBAtlasCustomDNSConfigurationRead(d *schema.ResourceData, meta return nil } - return fmt.Errorf(errorCustomDNSConfigurationRead, err) + return diag.FromErr(fmt.Errorf(errorCustomDNSConfigurationRead, err)) } if err = d.Set("enabled", dnsResp.Enabled); err != nil { - return fmt.Errorf(errorCustomDNSConfigurationSetting, "enabled", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorCustomDNSConfigurationSetting, "enabled", d.Id(), err)) } if err = d.Set("project_id", d.Id()); err != nil { - return fmt.Errorf(errorCustomDNSConfigurationSetting, "project_id", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorCustomDNSConfigurationSetting, "project_id", d.Id(), err)) } return nil } -func resourceMongoDBAtlasCustomDNSConfigurationUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCustomDNSConfigurationUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas if d.HasChange("enabled") { - _, _, err := conn.CustomAWSDNS.Update(context.Background(), d.Id(), &matlas.AWSCustomDNSSetting{ + _, _, err := conn.CustomAWSDNS.Update(ctx, d.Id(), &matlas.AWSCustomDNSSetting{ Enabled: d.Get("enabled").(bool), }) if err != nil { - return fmt.Errorf(errorCustomDNSConfigurationUpdate, err) + return diag.FromErr(fmt.Errorf(errorCustomDNSConfigurationUpdate, err)) } } - return resourceMongoDBAtlasCustomDNSConfigurationRead(d, meta) + return resourceMongoDBAtlasCustomDNSConfigurationRead(ctx, d, meta) } -func resourceMongoDBAtlasCustomDNSConfigurationDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasCustomDNSConfigurationDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas - _, _, err := conn.CustomAWSDNS.Update(context.Background(), d.Id(), &matlas.AWSCustomDNSSetting{ + _, _, err := conn.CustomAWSDNS.Update(ctx, d.Id(), &matlas.AWSCustomDNSSetting{ Enabled: false, }) if err != nil { - return fmt.Errorf(errorCustomDNSConfigurationDelete, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorCustomDNSConfigurationDelete, d.Id(), err)) } return nil diff --git a/mongodbatlas/resource_mongodbatlas_custom_dns_configuration_cluster_aws_test.go b/mongodbatlas/resource_mongodbatlas_custom_dns_configuration_cluster_aws_test.go index da33cccd77..2391793eda 100644 --- a/mongodbatlas/resource_mongodbatlas_custom_dns_configuration_cluster_aws_test.go +++ b/mongodbatlas/resource_mongodbatlas_custom_dns_configuration_cluster_aws_test.go @@ -6,8 +6,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func TestAccResourceMongoDBAtlasCustomDNSConfigurationAWS_basic(t *testing.T) { @@ -17,9 +17,9 @@ func TestAccResourceMongoDBAtlasCustomDNSConfigurationAWS_basic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasCustomDNSConfigurationAWSDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasCustomDNSConfigurationAWSDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCustomDNSConfigurationAWSConfig(projectID, true), @@ -56,9 +56,9 @@ func TestAccResourceMongoDBAtlasCustomDNSConfigurationAWS_importBasic(t *testing ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasCustomDNSConfigurationAWSDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasCustomDNSConfigurationAWSDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasCustomDNSConfigurationAWSConfig(projectID, true), diff --git a/mongodbatlas/resource_mongodbatlas_data_lake.go b/mongodbatlas/resource_mongodbatlas_data_lake.go index 24d9a06ee9..2e72590acc 100644 --- a/mongodbatlas/resource_mongodbatlas_data_lake.go +++ b/mongodbatlas/resource_mongodbatlas_data_lake.go @@ -7,9 +7,10 @@ import ( "net/http" "strings" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/spf13/cast" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -23,12 +24,12 @@ const ( func resourceMongoDBAtlasDataLake() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasDataLakeCreate, - Read: resourceMongoDBAtlasDataLakeRead, - Update: resourceMongoDBAtlasDataLakeUpdate, - Delete: resourceMongoDBAtlasDataLakeDelete, + CreateContext: resourceMongoDBAtlasDataLakeCreate, + ReadContext: resourceMongoDBAtlasDataLakeRead, + UpdateContext: resourceMongoDBAtlasDataLakeUpdate, + DeleteContext: resourceMongoDBAtlasDataLakeDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasDataLakeImportState, + StateContext: resourceMongoDBAtlasDataLakeImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -69,7 +70,8 @@ func resourceMongoDBAtlasDataLake() *schema.Resource { }, }, "data_process_region": { - Type: schema.TypeMap, + Type: schema.TypeList, + MaxItems: 1, Optional: true, Computed: true, Elem: &schema.Resource{ @@ -217,7 +219,7 @@ func schemaDataLakesStores() *schema.Schema { } } -func resourceMongoDBAtlasDataLakeCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasDataLakeCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) @@ -232,9 +234,9 @@ func resourceMongoDBAtlasDataLakeCreate(d *schema.ResourceData, meta interface{} Name: name, } - dataLake, _, err := conn.DataLakes.Create(context.Background(), projectID, dataLakeReq) + dataLake, _, err := conn.DataLakes.Create(ctx, projectID, dataLakeReq) if err != nil { - return fmt.Errorf(errorDataLakeCreate, err) + return diag.FromErr(fmt.Errorf(errorDataLakeCreate, err)) } dataLake.CloudProviderConfig.AWSConfig.TestS3Bucket = cloudConfig.AWSConfig.TestS3Bucket @@ -244,24 +246,24 @@ func resourceMongoDBAtlasDataLakeCreate(d *schema.ResourceData, meta interface{} "name": dataLake.Name, })) - return resourceMongoDBAtlasDataLakeRead(d, meta) + return resourceMongoDBAtlasDataLakeRead(ctx, d, meta) } -func resourceMongoDBAtlasDataLakeRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasDataLakeRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) projectID := ids["project_id"] name := ids["name"] - dataLake, resp, err := conn.DataLakes.Get(context.Background(), projectID, name) + dataLake, resp, err := conn.DataLakes.Get(ctx, projectID, name) if err != nil { if resp != nil && resp.StatusCode == http.StatusNotFound { d.SetId("") return nil } - return fmt.Errorf(errorDataLakeRead, name, err) + return diag.FromErr(fmt.Errorf(errorDataLakeRead, name, err)) } values := flattenAWSBlock(&dataLake.CloudProviderConfig) @@ -276,29 +278,29 @@ func resourceMongoDBAtlasDataLakeRead(d *schema.ResourceData, meta interface{}) } if err = d.Set("aws", values); err != nil { - return fmt.Errorf(errorDataLakeSetting, "aws", name, err) + return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "aws", name, err)) } } } if err := d.Set("data_process_region", flattenDataLakeProcessRegion(&dataLake.DataProcessRegion)); err != nil { - return fmt.Errorf(errorDataLakeSetting, "data_process_region", name, err) + return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "data_process_region", name, err)) } if err := d.Set("hostnames", dataLake.Hostnames); err != nil { - return fmt.Errorf(errorDataLakeSetting, "hostnames", name, err) + return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "hostnames", name, err)) } if err := d.Set("state", dataLake.State); err != nil { - return fmt.Errorf(errorDataLakeSetting, "state", name, err) + return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "state", name, err)) } if err := d.Set("storage_databases", flattenDataLakeStorageDatabases(dataLake.Storage.Databases)); err != nil { - return fmt.Errorf(errorDataLakeSetting, "storage_databases", name, err) + return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "storage_databases", name, err)) } if err := d.Set("storage_stores", flattenDataLakeStorageStores(dataLake.Storage.Stores)); err != nil { - return fmt.Errorf(errorDataLakeSetting, "storage_stores", name, err) + return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "storage_stores", name, err)) } d.SetId(encodeStateID(map[string]string{ @@ -309,7 +311,7 @@ func resourceMongoDBAtlasDataLakeRead(d *schema.ResourceData, meta interface{}) return nil } -func resourceMongoDBAtlasDataLakeUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasDataLakeUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -335,30 +337,30 @@ func resourceMongoDBAtlasDataLakeUpdate(d *schema.ResourceData, meta interface{} CloudProviderConfig: &matlas.CloudProviderConfig{AWSConfig: awsConfig}, DataProcessRegion: dataProcess, } - _, _, err := conn.DataLakes.Update(context.Background(), projectID, name, dataLakeReq) + _, _, err := conn.DataLakes.Update(ctx, projectID, name, dataLakeReq) if err != nil { - return fmt.Errorf(errorDataLakeUpdate, name, err) + return diag.FromErr(fmt.Errorf(errorDataLakeUpdate, name, err)) } - return resourceMongoDBAtlasDataLakeRead(d, meta) + return resourceMongoDBAtlasDataLakeRead(ctx, d, meta) } -func resourceMongoDBAtlasDataLakeDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasDataLakeDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) projectID := ids["project_id"] name := ids["name"] - _, err := conn.DataLakes.Delete(context.Background(), projectID, name) + _, err := conn.DataLakes.Delete(ctx, projectID, name) if err != nil { - return fmt.Errorf(errorDataLakeDelete, name, err) + return diag.FromErr(fmt.Errorf(errorDataLakeDelete, name, err)) } return nil } -func resourceMongoDBAtlasDataLakeImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasDataLakeImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas projectID, name, s3Bucket, err := splitDataLakeImportID(d.Id()) @@ -366,7 +368,7 @@ func resourceMongoDBAtlasDataLakeImportState(d *schema.ResourceData, meta interf return nil, err } - u, _, err := conn.DataLakes.Get(context.Background(), projectID, name) + u, _, err := conn.DataLakes.Get(ctx, projectID, name) if err != nil { return nil, fmt.Errorf("couldn't import data lake(%s) for project (%s), error: %s", name, projectID, err) } @@ -428,15 +430,15 @@ func flattenAWSBlock(aws *matlas.CloudProviderConfig) []map[string]interface{} { return database } -func flattenDataLakeProcessRegion(processRegion *matlas.DataProcessRegion) map[string]interface{} { +func flattenDataLakeProcessRegion(processRegion *matlas.DataProcessRegion) []interface{} { if processRegion != nil && (processRegion.Region != "" || processRegion.CloudProvider != "") { - return map[string]interface{}{ + return []interface{}{map[string]interface{}{ "cloud_provider": processRegion.CloudProvider, "region": processRegion.Region, - } + }} } - return map[string]interface{}{} + return []interface{}{} } func flattenDataLakeStorageDatabases(databases []matlas.DataLakeDatabase) []map[string]interface{} { @@ -530,11 +532,15 @@ func expandDataLakeAwsBlock(d *schema.ResourceData) matlas.AwsCloudProviderConfi func expandDataLakeDataProcessRegion(d *schema.ResourceData) *matlas.DataProcessRegion { if value, ok := d.GetOk("data_process_region"); ok { - v := value.(map[string]interface{}) + vL := value.([]interface{}) - return &matlas.DataProcessRegion{ - CloudProvider: cast.ToString(v["cloud_provider"]), - Region: cast.ToString(v["region"]), + if len(vL) != 0 { + v := vL[0].(map[string]interface{}) + + return &matlas.DataProcessRegion{ + CloudProvider: cast.ToString(v["cloud_provider"]), + Region: cast.ToString(v["region"]), + } } } return nil diff --git a/mongodbatlas/resource_mongodbatlas_data_lake_test.go b/mongodbatlas/resource_mongodbatlas_data_lake_test.go index e2e5199cb1..0833040b33 100644 --- a/mongodbatlas/resource_mongodbatlas_data_lake_test.go +++ b/mongodbatlas/resource_mongodbatlas_data_lake_test.go @@ -7,9 +7,9 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -28,9 +28,9 @@ func TestAccResourceMongoDBAtlasDataLake_basic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasDataLakeDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasDataLakeDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDataLakeConfig(policyName, roleName, projectName, orgID, name, testS3Bucket, dataLakeRegion, false), @@ -63,9 +63,9 @@ func TestAccResourceMongoDBAtlasDataLake_importBasic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasDataLakeDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasDataLakeDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDataLakeConfig(policyName, roleName, projectName, orgID, name, testS3Bucket, "", false), @@ -185,12 +185,12 @@ resource "aws_iam_role" "test_role" { { "Effect": "Allow", "Principal": { - "AWS": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_aws_account_arn}" + "AWS": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws_config.0.atlas_aws_account_arn}" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { - "sts:ExternalId": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws.atlas_assumed_role_external_id}" + "sts:ExternalId": "${mongodbatlas_cloud_provider_access_setup.setup_only.aws_config.0.atlas_assumed_role_external_id}" } } } @@ -215,7 +215,7 @@ resource "mongodbatlas_cloud_provider_access_authorization" "auth_role" { project_id = mongodbatlas_project.test.id role_id = mongodbatlas_cloud_provider_access_setup.setup_only.role_id - aws = { + aws { iam_assumed_role_arn = aws_iam_role.test_role.arn } } @@ -244,7 +244,7 @@ resource "mongodbatlas_data_lake" "test" { role_id = mongodbatlas_cloud_provider_access_authorization.auth_role.role_id test_s3_bucket = %[2]q } - data_process_region = { + data_process_region { cloud_provider = "AWS" region = %[3]q } diff --git a/mongodbatlas/resource_mongodbatlas_database_user.go b/mongodbatlas/resource_mongodbatlas_database_user.go index 57cee0ffa7..4f9fd1aada 100644 --- a/mongodbatlas/resource_mongodbatlas_database_user.go +++ b/mongodbatlas/resource_mongodbatlas_database_user.go @@ -7,19 +7,21 @@ import ( "net/http" "regexp" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) func resourceMongoDBAtlasDatabaseUser() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasDatabaseUserCreate, - Read: resourceMongoDBAtlasDatabaseUserRead, - Update: resourceMongoDBAtlasDatabaseUserUpdate, - Delete: resourceMongoDBAtlasDatabaseUserDelete, + CreateContext: resourceMongoDBAtlasDatabaseUserCreate, + ReadContext: resourceMongoDBAtlasDatabaseUserRead, + UpdateContext: resourceMongoDBAtlasDatabaseUserUpdate, + DeleteContext: resourceMongoDBAtlasDatabaseUserDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasDatabaseUserImportState, + StateContext: resourceMongoDBAtlasDatabaseUserImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -129,7 +131,7 @@ func resourceMongoDBAtlasDatabaseUser() *schema.Resource { } } -func resourceMongoDBAtlasDatabaseUserRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasDatabaseUserRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -154,45 +156,45 @@ func resourceMongoDBAtlasDatabaseUserRead(d *schema.ResourceData, meta interface return nil } - return fmt.Errorf("error getting database user information: %s", err) + return diag.FromErr(fmt.Errorf("error getting database user information: %s", err)) } if err := d.Set("username", dbUser.Username); err != nil { - return fmt.Errorf("error setting `username` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `username` for database user (%s): %s", d.Id(), err)) } if _, ok := d.GetOk("auth_database_name"); ok { if err := d.Set("auth_database_name", dbUser.DatabaseName); err != nil { - return fmt.Errorf("error setting `auth_database_name` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `auth_database_name` for database user (%s): %s", d.Id(), err)) } } else { if err := d.Set("database_name", dbUser.DatabaseName); err != nil { - return fmt.Errorf("error setting `database_name` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `database_name` for database user (%s): %s", d.Id(), err)) } } if err := d.Set("x509_type", dbUser.X509Type); err != nil { - return fmt.Errorf("error setting `x509_type` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `x509_type` for database user (%s): %s", d.Id(), err)) } if err := d.Set("aws_iam_type", dbUser.AWSIAMType); err != nil { - return fmt.Errorf("error setting `aws_iam_type` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `aws_iam_type` for database user (%s): %s", d.Id(), err)) } if err := d.Set("ldap_auth_type", dbUser.LDAPAuthType); err != nil { - return fmt.Errorf("error setting `ldap_auth_type` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `ldap_auth_type` for database user (%s): %s", d.Id(), err)) } if err := d.Set("roles", flattenRoles(dbUser.Roles)); err != nil { - return fmt.Errorf("error setting `roles` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `roles` for database user (%s): %s", d.Id(), err)) } if err := d.Set("labels", flattenLabels(dbUser.Labels)); err != nil { - return fmt.Errorf("error setting `labels` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `labels` for database user (%s): %s", d.Id(), err)) } if err := d.Set("scopes", flattenScopes(dbUser.Scopes)); err != nil { - return fmt.Errorf("error setting `scopes` for database user (%s): %s", d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `scopes` for database user (%s): %s", d.Id(), err)) } d.SetId(encodeStateID(map[string]string{ @@ -204,7 +206,7 @@ func resourceMongoDBAtlasDatabaseUserRead(d *schema.ResourceData, meta interface return nil } -func resourceMongoDBAtlasDatabaseUserCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasDatabaseUserCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) @@ -212,7 +214,7 @@ func resourceMongoDBAtlasDatabaseUserCreate(d *schema.ResourceData, meta interfa dbName, dbNameOk := d.GetOk("database_name") authDBName, authDBNameOk := d.GetOk("auth_database_name") if !dbNameOk && !authDBNameOk { - return errors.New("one of database_name or auth_database_name must be configured") + return diag.FromErr(errors.New("one of database_name or auth_database_name must be configured")) } var authDatabaseName string @@ -235,9 +237,9 @@ func resourceMongoDBAtlasDatabaseUserCreate(d *schema.ResourceData, meta interfa Scopes: expandScopes(d), } - dbUserRes, _, err := conn.DatabaseUsers.Create(context.Background(), projectID, dbUserReq) + dbUserRes, _, err := conn.DatabaseUsers.Create(ctx, projectID, dbUserReq) if err != nil { - return fmt.Errorf("error creating database user: %s", err) + return diag.FromErr(fmt.Errorf("error creating database user: %s", err)) } d.SetId(encodeStateID(map[string]string{ @@ -246,10 +248,10 @@ func resourceMongoDBAtlasDatabaseUserCreate(d *schema.ResourceData, meta interfa "auth_database_name": authDatabaseName, })) - return resourceMongoDBAtlasDatabaseUserRead(d, meta) + return resourceMongoDBAtlasDatabaseUserRead(ctx, d, meta) } -func resourceMongoDBAtlasDatabaseUserUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasDatabaseUserUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -257,9 +259,9 @@ func resourceMongoDBAtlasDatabaseUserUpdate(d *schema.ResourceData, meta interfa username := ids["username"] authDatabaseName := ids["auth_database_name"] - dbUser, _, err := conn.DatabaseUsers.Get(context.Background(), authDatabaseName, projectID, username) + dbUser, _, err := conn.DatabaseUsers.Get(ctx, authDatabaseName, projectID, username) if err != nil { - return fmt.Errorf("error getting database user information to update it: %s", err) + return diag.FromErr(fmt.Errorf("error getting database user information to update it: %s", err)) } if d.HasChange("password") { @@ -278,15 +280,15 @@ func resourceMongoDBAtlasDatabaseUserUpdate(d *schema.ResourceData, meta interfa dbUser.Scopes = expandScopes(d) } - _, _, err = conn.DatabaseUsers.Update(context.Background(), projectID, username, dbUser) + _, _, err = conn.DatabaseUsers.Update(ctx, projectID, username, dbUser) if err != nil { - return fmt.Errorf("error updating database user(%s): %s", username, err) + return diag.FromErr(fmt.Errorf("error updating database user(%s): %s", username, err)) } - return resourceMongoDBAtlasDatabaseUserRead(d, meta) + return resourceMongoDBAtlasDatabaseUserRead(ctx, d, meta) } -func resourceMongoDBAtlasDatabaseUserDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasDatabaseUserDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -294,15 +296,15 @@ func resourceMongoDBAtlasDatabaseUserDelete(d *schema.ResourceData, meta interfa username := ids["username"] authDatabaseName := ids["auth_database_name"] - _, err := conn.DatabaseUsers.Delete(context.Background(), authDatabaseName, projectID, username) + _, err := conn.DatabaseUsers.Delete(ctx, authDatabaseName, projectID, username) if err != nil { - return fmt.Errorf("error deleting database user (%s): %s", username, err) + return diag.FromErr(fmt.Errorf("error deleting database user (%s): %s", username, err)) } return nil } -func resourceMongoDBAtlasDatabaseUserImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasDatabaseUserImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas projectID, username, authDatabaseName, err := splitDatabaseUserImportID(d.Id()) @@ -310,7 +312,7 @@ func resourceMongoDBAtlasDatabaseUserImportState(d *schema.ResourceData, meta in return nil, err } - u, _, err := conn.DatabaseUsers.Get(context.Background(), *authDatabaseName, *projectID, *username) + u, _, err := conn.DatabaseUsers.Get(ctx, *authDatabaseName, *projectID, *username) if err != nil { return nil, fmt.Errorf("couldn't import user(%s) in project(%s), error: %s", *username, *projectID, err) } diff --git a/mongodbatlas/resource_mongodbatlas_database_user_test.go b/mongodbatlas/resource_mongodbatlas_database_user_test.go index 607352fc70..4688c6df1d 100644 --- a/mongodbatlas/resource_mongodbatlas_database_user_test.go +++ b/mongodbatlas/resource_mongodbatlas_database_user_test.go @@ -7,9 +7,9 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -23,9 +23,9 @@ func TestAccResourceMongoDBAtlasDatabaseUser_basic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDatabaseUserConfig(projectName, orgID, "atlasAdmin", username, "First Key", "First value"), @@ -66,9 +66,9 @@ func TestAccResourceMongoDBAtlasDatabaseUser_withX509TypeCustomer(t *testing.T) ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDatabaseUserWithX509TypeConfig(projectName, orgID, "atlasAdmin", username, "First Key", "First value", x509Type), @@ -97,9 +97,9 @@ func TestAccResourceMongoDBAtlasDatabaseUser_withX509TypeManaged(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDatabaseUserWithX509TypeConfig(projectName, orgID, "atlasAdmin", username, "First Key", "First value", x509Type), @@ -127,9 +127,9 @@ func TestAccResourceMongoDBAtlasDatabaseUser_withAWSIAMType(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDatabaseUserWithAWSIAMTypeConfig(projectName, orgID, "atlasAdmin", username, "First Key", "First value"), @@ -161,9 +161,9 @@ func TestAccResourceMongoDBAtlasDatabaseUser_withAWSIAMType_import(t *testing.T) } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDatabaseUserWithAWSIAMTypeConfig(projectName, orgID, "atlasAdmin", username, "First Key", "First value"), @@ -198,9 +198,9 @@ func TestAccResourceMongoDBAtlasDatabaseUser_WithLabels(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDatabaseUserWithLabelsConfig(projectName, orgID, "atlasAdmin", username, []matlas.Label{}), @@ -279,9 +279,9 @@ func TestAccResourceMongoDBAtlasDatabaseUser_withRoles(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDatabaseUserWithRoles(username, password, projectName, orgID, @@ -343,9 +343,9 @@ func TestAccResourceMongoDBAtlasDatabaseUser_withScopes(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDatabaseUserWithScopes(username, password, projectName, orgID, "atlasAdmin", clusterName, @@ -405,9 +405,9 @@ func TestAccResourceMongoDBAtlasDatabaseUser_withScopesAndEmpty(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDatabaseUserWithScopes(username, password, projectName, orgID, "atlasAdmin", clusterName, @@ -460,9 +460,9 @@ func TestAccResourceMongoDBAtlasDatabaseUser_withLDAPAuthType(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDatabaseUserWithLDAPAuthTypeConfig(projectName, orgID, "atlasAdmin", username, "First Key", "First value"), @@ -489,9 +489,9 @@ func TestAccResourceMongoDBAtlasDatabaseUser_importBasic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDatabaseUserConfig(projectName, orgID, "read", username, "First Key", "First value"), @@ -525,9 +525,9 @@ func TestAccResourceMongoDBAtlasDatabaseUser_importX509TypeCustomer(t *testing.T ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDatabaseUserWithX509TypeConfig(projectName, orgID, "atlasAdmin", username, "First Key", "First value", x509Type), @@ -562,9 +562,9 @@ func TestAccResourceMongoDBAtlasDatabaseUser_importLDAPAuthType(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasDatabaseUserWithLDAPAuthTypeConfig(projectName, orgID, "atlasAdmin", username, "First Key", "First value"), diff --git a/mongodbatlas/resource_mongodbatlas_encryption_at_rest.go b/mongodbatlas/resource_mongodbatlas_encryption_at_rest.go index 6753e8ddbf..328250e6e8 100644 --- a/mongodbatlas/resource_mongodbatlas_encryption_at_rest.go +++ b/mongodbatlas/resource_mongodbatlas_encryption_at_rest.go @@ -5,7 +5,8 @@ import ( "fmt" "net/http" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mwielbut/pointy" "github.com/spf13/cast" matlas "go.mongodb.org/atlas/mongodbatlas" @@ -21,11 +22,11 @@ const ( func resourceMongoDBAtlasEncryptionAtRest() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasEncryptionAtRestCreate, - Read: resourceMongoDBAtlasEncryptionAtRestRead, - Delete: resourceMongoDBAtlasEncryptionAtRestDelete, - Update: resourceMongoDBAtlasEncryptionAtRestUpdate, - Importer: &schema.ResourceImporter{}, + CreateContext: resourceMongoDBAtlasEncryptionAtRestCreate, + ReadContext: resourceMongoDBAtlasEncryptionAtRestRead, + DeleteContext: resourceMongoDBAtlasEncryptionAtRestDelete, + UpdateContext: resourceMongoDBAtlasEncryptionAtRestUpdate, + Importer: &schema.ResourceImporter{}, Schema: map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, @@ -33,9 +34,55 @@ func resourceMongoDBAtlasEncryptionAtRest() *schema.Resource { ForceNew: true, }, "aws_kms": { - Type: schema.TypeMap, - Optional: true, - Sensitive: true, + Type: schema.TypeMap, + Optional: true, + Sensitive: true, + Deprecated: "use aws_kms_config instead", + ConflictsWith: []string{"aws_kms_config"}, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + ValidateFunc: func(val interface{}, key string) (warns []string, errs []error) { + v := val.(map[string]interface{}) + + _, akOk := v["access_key_id"] + _, saOk := v["secret_access_key"] + _, rOk := v["role_id"] + + if (akOk && saOk && rOk) || (akOk && rOk) || (saOk && rOk) { + errs = append(errs, fmt.Errorf("%q For credentials: `access_key_id` and `secret_access_key` are allowed but not `role_id`."+ + " For roles: `access_key_id` and `secret_access_key` are not allowed but `role_id` is allowed", key)) + } + + return + }, + }, + "azure_key_vault": { + Type: schema.TypeMap, + Optional: true, + Sensitive: true, + Deprecated: "use azure_key_vault_config instead", + ConflictsWith: []string{"azure_key_vault_config"}, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "google_cloud_kms": { + Type: schema.TypeMap, + Optional: true, + Sensitive: true, + Deprecated: "use google_cloud_kms_config instead", + ConflictsWith: []string{"google_cloud_kms_config"}, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "aws_kms_config": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Sensitive: true, + ConflictsWith: []string{"aws_kms"}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "enabled": { @@ -67,25 +114,13 @@ func resourceMongoDBAtlasEncryptionAtRest() *schema.Resource { }, }, }, - ValidateFunc: func(val interface{}, key string) (warns []string, errs []error) { - v := val.(map[string]interface{}) - - _, akOk := v["access_key_id"] - _, saOk := v["secret_access_key"] - _, rOk := v["role_id"] - - if (akOk && saOk && rOk) || (akOk && rOk) || (saOk && rOk) { - errs = append(errs, fmt.Errorf("%q For credentials: `access_key_id` and `secret_access_key` are allowed but not `role_id`."+ - " For roles: `access_key_id` and `secret_access_key` are not allowed but `role_id` is allowed", key)) - } - - return - }, }, - "azure_key_vault": { - Type: schema.TypeMap, - Optional: true, - Sensitive: true, + "azure_key_vault_config": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Sensitive: true, + ConflictsWith: []string{"azure_key_vault"}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "enabled": { @@ -132,10 +167,12 @@ func resourceMongoDBAtlasEncryptionAtRest() *schema.Resource { }, }, }, - "google_cloud_kms": { - Type: schema.TypeMap, - Optional: true, - Sensitive: true, + "google_cloud_kms_config": { + Type: schema.TypeList, + MaxItems: 1, + Optional: true, + Sensitive: true, + ConflictsWith: []string{"google_cloud_kms"}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "enabled": { @@ -159,13 +196,14 @@ func resourceMongoDBAtlasEncryptionAtRest() *schema.Resource { } } -func resourceMongoDBAtlasEncryptionAtRestCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasEncryptionAtRestCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas encryptionAtRestReq := &matlas.EncryptionAtRest{ GroupID: d.Get("project_id").(string), } + // Deprecated workflows aws, awsOk := d.GetOk("aws_kms") if awsOk { encryptionAtRestReq.AwsKms = expandAwsKms(aws.(map[string]interface{})) @@ -179,17 +217,36 @@ func resourceMongoDBAtlasEncryptionAtRestCreate(d *schema.ResourceData, meta int encryptionAtRestReq.GoogleCloudKms = expandGCPKms(gcp.(map[string]interface{})) } - _, _, err := conn.EncryptionsAtRest.Create(context.Background(), encryptionAtRestReq) + // End Depprecated workflows + + awsC, awsCOk := d.GetOk("aws_kms_config") + if awsCOk { + err := validateAwsKms(awsC.([]interface{})) + if err != nil { + return diag.FromErr(err) + } + encryptionAtRestReq.AwsKms = expandAwsKmsConfig(awsC.([]interface{})) + } + azureC, azureCOk := d.GetOk("azure_key_vault_config") + if azureCOk { + encryptionAtRestReq.AzureKeyVault = expandAzureKeyVaultConfig(azureC.([]interface{})) + } + gcpC, gcpCOk := d.GetOk("google_cloud_kms_config") + if gcpCOk { + encryptionAtRestReq.GoogleCloudKms = expandGCPKmsConfig(gcpC.([]interface{})) + } + + _, _, err := conn.EncryptionsAtRest.Create(ctx, encryptionAtRestReq) if err != nil { - return fmt.Errorf(errorCreateEncryptionAtRest, err) + return diag.FromErr(fmt.Errorf(errorCreateEncryptionAtRest, err)) } d.SetId(d.Get("project_id").(string)) - return resourceMongoDBAtlasEncryptionAtRestRead(d, meta) + return resourceMongoDBAtlasEncryptionAtRestRead(ctx, d, meta) } -func resourceMongoDBAtlasEncryptionAtRestRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasEncryptionAtRestRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas resp, response, err := conn.EncryptionsAtRest.Get(context.Background(), d.Id()) @@ -199,9 +256,10 @@ func resourceMongoDBAtlasEncryptionAtRestRead(d *schema.ResourceData, meta inter return nil } - return fmt.Errorf(errorReadEncryptionAtRest, err) + return diag.FromErr(fmt.Errorf(errorReadEncryptionAtRest, err)) } + // Deprecated workflows values := flattenAWSKMS(&resp.AwsKms) if !counterEmptyValues(values) { aws, awsOk := d.GetOk("aws_kms") @@ -222,7 +280,7 @@ func resourceMongoDBAtlasEncryptionAtRestRead(d *schema.ResourceData, meta inter } if err = d.Set("aws_kms", values); err != nil { - return fmt.Errorf(errorAlertEncryptionAtRestSetting, "aws_kms", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorAlertEncryptionAtRestSetting, "aws_kms", d.Id(), err)) } } @@ -239,7 +297,7 @@ func resourceMongoDBAtlasEncryptionAtRestRead(d *schema.ResourceData, meta inter } } if err = d.Set("azure_key_vault", values); err != nil { - return fmt.Errorf(errorAlertEncryptionAtRestSetting, "azure_key_vault", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorAlertEncryptionAtRestSetting, "azure_key_vault", d.Id(), err)) } } @@ -256,23 +314,98 @@ func resourceMongoDBAtlasEncryptionAtRestRead(d *schema.ResourceData, meta inter } } if err = d.Set("google_cloud_kms", values); err != nil { - return fmt.Errorf(errorAlertEncryptionAtRestSetting, "google_cloud_kms", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorAlertEncryptionAtRestSetting, "google_cloud_kms", d.Id(), err)) } } + // End Deprecated workflows + + values2 := flattenAWSKMSConfig(&resp.AwsKms) + if len(values2) != 0 { + value := values2[0].(map[string]interface{}) + if !counterEmptyValues(value) { + aws, awsOk := d.GetOk("aws_kms") + if awsOk { + aws2 := aws.(map[string]interface{}) + value["secret_access_key"] = cast.ToString(aws2["secret_access_key"]) + if v, sa := value["role_id"]; sa { + if v.(string) == "" { + delete(value, "role_id") + } + } + if v, sa := value["access_key_id"]; sa { + if v.(string) == "" { + delete(value, "access_key_id") + delete(value, "secret_access_key") + } + } + } + values2[0] = value + + if err = d.Set("aws_kms_config", values2); err != nil { + return diag.FromErr(fmt.Errorf(errorAlertEncryptionAtRestSetting, "aws_kms_config", d.Id(), err)) + } + } + } + + values2 = flattenAzureVaultConfig(&resp.AzureKeyVault) + if len(values2) != 0 { + value := values2[0].(map[string]interface{}) + + if !counterEmptyValues(value) { + azure, azureOk := d.GetOk("azure_key_vault") + if azureOk { + azure2 := azure.(map[string]interface{}) + value["secret"] = cast.ToString(azure2["secret"]) + if v, sa := value["secret"]; sa { + if v.(string) == "" { + delete(value, "secret") + } + } + } + values2[0] = value + + if err = d.Set("azure_key_vault_config", values2); err != nil { + return diag.FromErr(fmt.Errorf(errorAlertEncryptionAtRestSetting, "azure_key_vault_config", d.Id(), err)) + } + } + } + + values2 = flattenGCPKmsConfig(&resp.GoogleCloudKms) + if len(values2) != 0 { + value := values2[0].(map[string]interface{}) + if !counterEmptyValues(value) { + gcp, gcpOk := d.GetOk("google_cloud_kms") + if gcpOk { + gcp2 := gcp.(map[string]interface{}) + value["service_account_key"] = cast.ToString(gcp2["service_account_key"]) + if v, sa := value["service_account_key"]; sa { + if v.(string) == "" { + delete(value, "service_account_key") + } + } + } + values2[0] = value + + if err = d.Set("google_cloud_kms_config", values2); err != nil { + return diag.FromErr(fmt.Errorf(errorAlertEncryptionAtRestSetting, "google_cloud_kms_config", d.Id(), err)) + } + } + } + if err = d.Set("project_id", d.Id()); err != nil { - return fmt.Errorf(errorAlertEncryptionAtRestSetting, "project_id", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorAlertEncryptionAtRestSetting, "project_id", d.Id(), err)) } return nil } -func resourceMongoDBAtlasEncryptionAtRestUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasEncryptionAtRestUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Id() - encrypt, _, err := conn.EncryptionsAtRest.Get(context.Background(), projectID) + encrypt, _, err := conn.EncryptionsAtRest.Get(ctx, projectID) if err != nil { - return fmt.Errorf(errorUpdateEncryptionAtRest, err) + return diag.FromErr(fmt.Errorf(errorUpdateEncryptionAtRest, err)) } encrypt.GroupID = projectID @@ -289,20 +422,32 @@ func resourceMongoDBAtlasEncryptionAtRestUpdate(d *schema.ResourceData, meta int encrypt.GoogleCloudKms = expandGCPKms(d.Get("google_cloud_kms").(map[string]interface{})) } - _, _, err = conn.EncryptionsAtRest.Create(context.Background(), encrypt) + if d.HasChange("aws_kms_config") { + encrypt.AwsKms = expandAwsKmsConfig(d.Get("aws_kms_config").([]interface{})) + } + + if d.HasChange("azure_key_vault_config") { + encrypt.AzureKeyVault = expandAzureKeyVaultConfig(d.Get("azure_key_vault_config").([]interface{})) + } + + if d.HasChange("google_cloud_kms_config") { + encrypt.GoogleCloudKms = expandGCPKmsConfig(d.Get("google_cloud_kms_config").([]interface{})) + } + + _, _, err = conn.EncryptionsAtRest.Create(ctx, encrypt) if err != nil { - return fmt.Errorf("error updating encryption at rest (%s): %s", projectID, err) + return diag.FromErr(fmt.Errorf("error updating encryption at rest (%s): %s", projectID, err)) } - return resourceMongoDBAtlasEncryptionAtRestRead(d, meta) + return resourceMongoDBAtlasEncryptionAtRestRead(ctx, d, meta) } -func resourceMongoDBAtlasEncryptionAtRestDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasEncryptionAtRestDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas - _, err := conn.EncryptionsAtRest.Delete(context.Background(), d.Id()) + _, err := conn.EncryptionsAtRest.Delete(ctx, d.Id()) if err != nil { - return fmt.Errorf(errorDeleteEncryptionAtRest, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorDeleteEncryptionAtRest, d.Id(), err)) } return nil @@ -375,6 +520,110 @@ func flattenGCPKms(m *matlas.GoogleCloudKms) map[string]interface{} { } } +func expandAwsKmsConfig(awsKms []interface{}) matlas.AwsKms { + if len(awsKms) == 0 { + return matlas.AwsKms{} + } + + awsKmsObj := awsKms[0].(map[string]interface{}) + + awsRegion, _ := valRegion(awsKmsObj["region"]) + + return matlas.AwsKms{ + Enabled: pointy.Bool(cast.ToBool(awsKmsObj["enabled"])), + AccessKeyID: cast.ToString(awsKmsObj["access_key_id"]), + SecretAccessKey: cast.ToString(awsKmsObj["secret_access_key"]), + CustomerMasterKeyID: cast.ToString(awsKmsObj["customer_master_key_id"]), + Region: awsRegion, + RoleID: cast.ToString(awsKmsObj["role_id"]), + } +} + +func validateAwsKms(awsKms []interface{}) error { + if len(awsKms) == 0 { + return fmt.Errorf("empty aws_kms_config") + } + + v := awsKms[0].(map[string]interface{}) + + ak, akOk := v["access_key_id"] + sa, saOk := v["secret_access_key"] + r, rOk := v["role_id"] + + if ((akOk && ak != "") && (saOk && sa != "") && (rOk && r != "")) || ((akOk && ak != "") && (rOk && r != "")) || ((saOk && sa != "") && (rOk && r != "")) { + return fmt.Errorf("for credentials: `access_key_id` and `secret_access_key` are allowed but not `role_id`." + + " For roles: `access_key_id` and `secret_access_key` are not allowed but `role_id` is allowed") + } + + return nil +} + +func expandAzureKeyVaultConfig(azure []interface{}) matlas.AzureKeyVault { + if len(azure) == 0 { + return matlas.AzureKeyVault{} + } + + azureObj := azure[0].(map[string]interface{}) + + return matlas.AzureKeyVault{ + Enabled: pointy.Bool(cast.ToBool(azureObj["enabled"])), + ClientID: cast.ToString(azureObj["client_id"]), + AzureEnvironment: cast.ToString(azureObj["azure_environment"]), + SubscriptionID: cast.ToString(azureObj["subscription_id"]), + ResourceGroupName: cast.ToString(azureObj["resource_group_name"]), + KeyVaultName: cast.ToString(azureObj["key_vault_name"]), + KeyIdentifier: cast.ToString(azureObj["key_identifier"]), + Secret: cast.ToString(azureObj["secret"]), + TenantID: cast.ToString(azureObj["tenant_id"]), + } +} + +func expandGCPKmsConfig(gcpKms []interface{}) matlas.GoogleCloudKms { + if len(gcpKms) == 0 { + return matlas.GoogleCloudKms{} + } + + gcpKmsObj := gcpKms[0].(map[string]interface{}) + + return matlas.GoogleCloudKms{ + Enabled: pointy.Bool(cast.ToBool(gcpKmsObj["enabled"])), + ServiceAccountKey: cast.ToString(gcpKmsObj["service_account_key"]), + KeyVersionResourceID: cast.ToString(gcpKmsObj["key_version_resource_id"]), + } +} + +func flattenAWSKMSConfig(m *matlas.AwsKms) []interface{} { + return []interface{}{map[string]interface{}{ + "enabled": cast.ToString(m.Enabled), + "access_key_id": m.AccessKeyID, + "customer_master_key_id": m.CustomerMasterKeyID, + "region": m.Region, + "role_id": m.RoleID, + }} +} + +func flattenAzureVaultConfig(m *matlas.AzureKeyVault) []interface{} { + return []interface{}{map[string]interface{}{ + "enabled": cast.ToString(m.Enabled), + "client_id": m.ClientID, + "azure_environment": m.AzureEnvironment, + "subscription_id": m.SubscriptionID, + "resource_group_name": m.ResourceGroupName, + "key_vault_name": m.KeyVaultName, + "key_identifier": m.KeyIdentifier, + "secret": m.Secret, + "tenant_id": m.TenantID, + }} +} + +func flattenGCPKmsConfig(m *matlas.GoogleCloudKms) []interface{} { + return []interface{}{map[string]interface{}{ + "enabled": cast.ToString(m.Enabled), + "service_account_key": m.ServiceAccountKey, + "key_version_resource_id": m.KeyVersionResourceID, + }} +} + func counterEmptyValues(values map[string]interface{}) bool { count := 0 for i := range values { diff --git a/mongodbatlas/resource_mongodbatlas_encryption_at_rest_test.go b/mongodbatlas/resource_mongodbatlas_encryption_at_rest_test.go index 5602b3c2fa..7833c2ae53 100644 --- a/mongodbatlas/resource_mongodbatlas_encryption_at_rest_test.go +++ b/mongodbatlas/resource_mongodbatlas_encryption_at_rest_test.go @@ -6,9 +6,10 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/mwielbut/pointy" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -80,7 +81,7 @@ EOF resource "mongodbatlas_encryption_at_rest" "test" { project_id = "%s" - aws_kms = { + aws_kms { enabled = %t customer_master_key_id = "%s" region = "%s" @@ -119,9 +120,9 @@ func TestAccResourceMongoDBAtlasEncryptionAtRest_basicAWS(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkAwsEnv(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasEncryptionAtRestDestroy, + PreCheck: func() { testAccPreCheck(t); checkAwsEnv(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasEncryptionAtRestDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasEncryptionAtRestConfigAwsKms(projectID, &awsKms), @@ -173,9 +174,9 @@ func TestAccResourceMongoDBAtlasEncryptionAtRest_basicAzure(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkEncryptionAtRestEnvAzure(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasEncryptionAtRestDestroy, + PreCheck: func() { testAccPreCheck(t); checkEncryptionAtRestEnvAzure(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasEncryptionAtRestDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasEncryptionAtRestConfigAzureKeyVault(projectID, &azureKeyVault), @@ -215,9 +216,9 @@ func TestAccResourceMongoDBAtlasEncryptionAtRest_basicGCP(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); testAccPreCheckGPCEnv(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasEncryptionAtRestDestroy, + PreCheck: func() { testAccPreCheck(t); testAccPreCheckGPCEnv(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasEncryptionAtRestDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasEncryptionAtRestConfigGoogleCloudKms(projectID, &googleCloudKms), @@ -256,9 +257,9 @@ func TestAccResourceMongoDBAtlasEncryptionAtRestWithRole_basicAWS(t *testing.T) ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkAwsEnv(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasEncryptionAtRestDestroy, + PreCheck: func() { testAccPreCheck(t); checkAwsEnv(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasEncryptionAtRestDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasEncryptionAtRestConfigAwsKmsWithRole(awsKms.Region, accessKeyID, secretKey, projectID, policyName, roleName, false, &awsKms), @@ -321,7 +322,7 @@ func testAccMongoDBAtlasEncryptionAtRestConfigAwsKms(projectID string, aws *matl resource "mongodbatlas_encryption_at_rest" "test" { project_id = "%s" - aws_kms = { + aws_kms_config { enabled = %t access_key_id = "%s" secret_access_key = "%s" @@ -337,7 +338,7 @@ func testAccMongoDBAtlasEncryptionAtRestConfigAzureKeyVault(projectID string, az resource "mongodbatlas_encryption_at_rest" "test" { project_id = "%s" - azure_key_vault = { + azure_key_vault_config { enabled = %t client_id = "%s" azure_environment = "%s" @@ -358,7 +359,7 @@ func testAccMongoDBAtlasEncryptionAtRestConfigGoogleCloudKms(projectID string, g resource "mongodbatlas_encryption_at_rest" "test" { project_id = "%s" - google_cloud_kms = { + google_cloud_kms_config { enabled = %t service_account_key = "%s" key_version_resource_id = "%s" diff --git a/mongodbatlas/resource_mongodbatlas_event_trigger.go b/mongodbatlas/resource_mongodbatlas_event_trigger.go index 20c5059e7c..dd21661d32 100644 --- a/mongodbatlas/resource_mongodbatlas_event_trigger.go +++ b/mongodbatlas/resource_mongodbatlas_event_trigger.go @@ -10,8 +10,9 @@ import ( "strings" "github.com/go-test/deep" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/mwielbut/pointy" "github.com/spf13/cast" "go.mongodb.org/realm/realm" @@ -27,12 +28,12 @@ const ( func resourceMongoDBAtlasEventTriggers() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasEventTriggersCreate, - Read: resourceMongoDBAtlasEventTriggersRead, - Update: resourceMongoDBAtlasEventTriggersUpdate, - Delete: resourceMongoDBAtlasEventTriggersDelete, + CreateContext: resourceMongoDBAtlasEventTriggersCreate, + ReadContext: resourceMongoDBAtlasEventTriggersRead, + UpdateContext: resourceMongoDBAtlasEventTriggersUpdate, + DeleteContext: resourceMongoDBAtlasEventTriggersDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasEventTriggerImportState, + StateContext: resourceMongoDBAtlasEventTriggerImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -199,7 +200,7 @@ func resourceMongoDBAtlasEventTriggers() *schema.Resource { } } -func resourceMongoDBAtlasEventTriggersCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasEventTriggersCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Realm projectID := d.Get("project_id").(string) @@ -227,17 +228,17 @@ func resourceMongoDBAtlasEventTriggersCreate(d *schema.ResourceData, meta interf if typeTrigger == "DATABASE" { if !okCots || !okD || !okC || !okSI { - return fmt.Errorf("`config_operation_types`, `config_database`,`config_collection`,`config_service_id` must be provided if type is DATABASE") + return diag.FromErr(fmt.Errorf("`config_operation_types`, `config_database`,`config_collection`,`config_service_id` must be provided if type is DATABASE")) } } if typeTrigger == "AUTHENTICATION" { if !okCot || !okP { - return fmt.Errorf("`config_operation_type`, `config_providers` must be provided if type is AUTHENTICATION") + return diag.FromErr(fmt.Errorf("`config_operation_type`, `config_providers` must be provided if type is AUTHENTICATION")) } } if typeTrigger == "SCHEDULED" { if !oksch { - return fmt.Errorf("`config_schedule` must be provided if type is SCHEDULED") + return diag.FromErr(fmt.Errorf("`config_schedule` must be provided if type is SCHEDULED")) } } @@ -280,7 +281,7 @@ func resourceMongoDBAtlasEventTriggersCreate(d *schema.ResourceData, meta interf eventResp, _, err := conn.EventTriggers.Create(context.Background(), projectID, appID, eventTriggerReq) if err != nil { - return fmt.Errorf(errorEventTriggersCreate, projectID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersCreate, projectID, err)) } d.SetId(encodeStateID(map[string]string{ @@ -289,10 +290,10 @@ func resourceMongoDBAtlasEventTriggersCreate(d *schema.ResourceData, meta interf "trigger_id": eventResp.ID, })) - return resourceMongoDBAtlasEventTriggersRead(d, meta) + return resourceMongoDBAtlasEventTriggersRead(ctx, d, meta) } -func resourceMongoDBAtlasEventTriggersRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasEventTriggersRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Realm ids := decodeStateID(d.Id()) @@ -300,81 +301,81 @@ func resourceMongoDBAtlasEventTriggersRead(d *schema.ResourceData, meta interfac appID := ids["app_id"] triggerID := ids["trigger_id"] - resp, recodes, err := conn.EventTriggers.Get(context.Background(), projectID, appID, triggerID) + resp, recodes, err := conn.EventTriggers.Get(ctx, projectID, appID, triggerID) if err != nil { if recodes != nil && recodes.StatusCode == http.StatusNotFound { d.SetId("") return nil } - return fmt.Errorf(errorEventTriggersRead, projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersRead, projectID, appID, err)) } if err = d.Set("trigger_id", resp.ID); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "trigger_id", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "trigger_id", projectID, appID, err)) } if err = d.Set("name", resp.Name); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "name", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "name", projectID, appID, err)) } if err = d.Set("type", resp.Type); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "type", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "type", projectID, appID, err)) } functionID := resp.FunctionID if resp.FunctionID == "000000000000000000000000" { functionID = "" } if err = d.Set("function_id", functionID); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "function_id", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "function_id", projectID, appID, err)) } if err = d.Set("function_name", resp.FunctionName); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "function_name", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "function_name", projectID, appID, err)) } if err = d.Set("disabled", resp.Disabled); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "disabled", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "disabled", projectID, appID, err)) } if err = d.Set("config_operation_types", resp.Config.OperationTypes); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_operation_types", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_operation_types", projectID, appID, err)) } if err = d.Set("config_operation_type", resp.Config.OperationType); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_operation_type", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_operation_type", projectID, appID, err)) } if err = d.Set("config_providers", resp.Config.Providers); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_providers", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_providers", projectID, appID, err)) } if err = d.Set("config_database", resp.Config.Database); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_database", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_database", projectID, appID, err)) } if err = d.Set("config_collection", resp.Config.Collection); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_collection", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_collection", projectID, appID, err)) } if err = d.Set("config_service_id", resp.Config.ServiceID); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_service_id", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_service_id", projectID, appID, err)) } if err = d.Set("config_match", matchToString(resp.Config.Match)); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_match", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_match", projectID, appID, err)) } if err = d.Set("config_project", matchToString(resp.Config.Project)); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_project", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_project", projectID, appID, err)) } if err = d.Set("config_full_document", resp.Config.FullDocument); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_full_document", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_full_document", projectID, appID, err)) } if err = d.Set("config_full_document_before", resp.Config.FullDocumentBeforeChange); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_full_document_before", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_full_document_before", projectID, appID, err)) } if err = d.Set("config_schedule", resp.Config.Schedule); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_schedule", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_schedule", projectID, appID, err)) } if err = d.Set("config_schedule_type", resp.Config.ScheduleType); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "config_schedule_type", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "config_schedule_type", projectID, appID, err)) } if err = d.Set("event_processors", flattenTriggerEventProcessorAWSEventBridge(resp.EventProcessors)); err != nil { - return fmt.Errorf(errorEventTriggersSetting, "event_processors", projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersSetting, "event_processors", projectID, appID, err)) } return nil } -func resourceMongoDBAtlasEventTriggersUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasEventTriggersUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get the client connection. conn := meta.(*MongoDBClient).Realm @@ -415,15 +416,15 @@ func resourceMongoDBAtlasEventTriggersUpdate(d *schema.ResourceData, meta interf eventReq.Config = eventTriggerConfig - _, _, err := conn.EventTriggers.Update(context.Background(), projectID, appID, triggerID, eventReq) + _, _, err := conn.EventTriggers.Update(ctx, projectID, appID, triggerID, eventReq) if err != nil { - return fmt.Errorf(errorEventTriggersUpdate, projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersUpdate, projectID, appID, err)) } return nil } -func resourceMongoDBAtlasEventTriggersDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasEventTriggersDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get the client connection. conn := meta.(*MongoDBClient).Realm ids := decodeStateID(d.Id()) @@ -432,9 +433,9 @@ func resourceMongoDBAtlasEventTriggersDelete(d *schema.ResourceData, meta interf appID := ids["app_id"] triggerID := ids["trigger_id"] - _, err := conn.EventTriggers.Delete(context.Background(), projectID, appID, triggerID) + _, err := conn.EventTriggers.Delete(ctx, projectID, appID, triggerID) if err != nil { - return fmt.Errorf(errorEventTriggersDelete, projectID, appID, err) + return diag.FromErr(fmt.Errorf(errorEventTriggersDelete, projectID, appID, err)) } return nil @@ -483,7 +484,7 @@ func flattenTriggerEventProcessorAWSEventBridge(eventProcessor map[string]interf return results } -func resourceMongoDBAtlasEventTriggerImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasEventTriggerImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Realm parts := strings.Split(d.Id(), "--") @@ -495,7 +496,7 @@ func resourceMongoDBAtlasEventTriggerImportState(d *schema.ResourceData, meta in appID := parts[1] triggerID := parts[2] - _, _, err := conn.EventTriggers.Get(context.Background(), projectID, appID, triggerID) + _, _, err := conn.EventTriggers.Get(ctx, projectID, appID, triggerID) if err != nil { return nil, fmt.Errorf("couldn't import event trigger %s in project %s, error: %s", triggerID, projectID, err) } diff --git a/mongodbatlas/resource_mongodbatlas_event_trigger_test.go b/mongodbatlas/resource_mongodbatlas_event_trigger_test.go index 0330e4839f..dc6537e7ef 100644 --- a/mongodbatlas/resource_mongodbatlas_event_trigger_test.go +++ b/mongodbatlas/resource_mongodbatlas_event_trigger_test.go @@ -7,9 +7,9 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/mwielbut/pointy" "go.mongodb.org/realm/realm" ) @@ -50,9 +50,9 @@ func TestAccResourceMongoDBAtlasEventTriggerDatabase_basic(t *testing.T) { } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasEventTriggerDatabaseConfigDatabase(projectID, appID, `"INSERT", "UPDATE"`, &event), @@ -116,9 +116,9 @@ func TestAccResourceMongoDBAtlasEventTriggerDatabase_eventProccesor(t *testing.T } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasEventTriggerDatabaseConfigDatabaseEP(projectID, appID, `"INSERT", "UPDATE"`, awsAccountID, awsRegion, &event), @@ -175,9 +175,9 @@ func TestAccResourceMongoDBAtlasEventTriggerAuth_basic(t *testing.T) { } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasEventTriggerDatabaseConfigAuthentication(projectID, appID, `"anon-user", "local-userpass"`, &event), @@ -236,9 +236,9 @@ func TestAccResourceMongoDBAtlasEventTriggerAuth_eventProcessor(t *testing.T) { } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasEventTriggerDatabaseConfigAuthenticationEP(projectID, appID, `"anon-user", "local-userpass"`, awsAccountID, awsRegion, &event), @@ -292,9 +292,9 @@ func TestAccResourceMongoDBAtlasEventTriggerSchedule_basic(t *testing.T) { } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasEventTriggerDatabaseConfigSchedule(projectID, appID, &event), @@ -350,9 +350,9 @@ func TestAccResourceMongoDBAtlasEventTriggerSchedule_eventProcessor(t *testing.T } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasEventTriggerDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasEventTriggerDatabaseConfigScheduleEP(projectID, appID, awsAccountID, awsRegion, &event), diff --git a/mongodbatlas/resource_mongodbatlas_global_cluster_config.go b/mongodbatlas/resource_mongodbatlas_global_cluster_config.go index 09f47e944a..3f1faec949 100644 --- a/mongodbatlas/resource_mongodbatlas_global_cluster_config.go +++ b/mongodbatlas/resource_mongodbatlas_global_cluster_config.go @@ -8,7 +8,9 @@ import ( "net/http" "strings" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -21,12 +23,12 @@ const ( func resourceMongoDBAtlasGlobalCluster() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasGlobalClusterCreate, - Read: resourceMongoDBAtlasGlobalClusterRead, - Update: resourceMongoDBAtlasGlobalClusterUpdate, - Delete: resourceMongoDBAtlasGlobalClusterDelete, + CreateContext: resourceMongoDBAtlasGlobalClusterCreate, + ReadContext: resourceMongoDBAtlasGlobalClusterRead, + UpdateContext: resourceMongoDBAtlasGlobalClusterUpdate, + DeleteContext: resourceMongoDBAtlasGlobalClusterDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasGlobalClusterImportState, + StateContext: resourceMongoDBAtlasGlobalClusterImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -87,7 +89,7 @@ func resourceMongoDBAtlasGlobalCluster() *schema.Resource { } } -func resourceMongoDBAtlasGlobalClusterCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasGlobalClusterCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) @@ -104,10 +106,10 @@ func resourceMongoDBAtlasGlobalClusterCreate(d *schema.ResourceData, meta interf Db: mn["db"].(string), CustomShardKey: mn["custom_shard_key"].(string), } - _, _, err := conn.GlobalClusters.AddManagedNamespace(context.Background(), projectID, clusterName, addManagedNamespace) + _, _, err := conn.GlobalClusters.AddManagedNamespace(ctx, projectID, clusterName, addManagedNamespace) if err != nil { - return fmt.Errorf(errorGlobalClusterCreate, err) + return diag.FromErr(fmt.Errorf(errorGlobalClusterCreate, err)) } } } @@ -129,12 +131,12 @@ func resourceMongoDBAtlasGlobalClusterCreate(d *schema.ResourceData, meta interf } if len(customZoneMappings) > 0 { - _, _, err := conn.GlobalClusters.AddCustomZoneMappings(context.Background(), projectID, clusterName, &matlas.CustomZoneMappingsRequest{ + _, _, err := conn.GlobalClusters.AddCustomZoneMappings(ctx, projectID, clusterName, &matlas.CustomZoneMappingsRequest{ CustomZoneMappings: customZoneMappings, }) if err != nil { - return fmt.Errorf(errorGlobalClusterCreate, err) + return diag.FromErr(fmt.Errorf(errorGlobalClusterCreate, err)) } } } @@ -144,38 +146,37 @@ func resourceMongoDBAtlasGlobalClusterCreate(d *schema.ResourceData, meta interf "cluster_name": clusterName, })) - return resourceMongoDBAtlasGlobalClusterRead(d, meta) + return resourceMongoDBAtlasGlobalClusterRead(ctx, d, meta) } - -func resourceMongoDBAtlasGlobalClusterRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasGlobalClusterRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) projectID := ids["project_id"] clusterName := ids["cluster_name"] - globalCluster, resp, err := conn.GlobalClusters.Get(context.Background(), projectID, clusterName) + globalCluster, resp, err := conn.GlobalClusters.Get(ctx, projectID, clusterName) if err != nil { if resp != nil && resp.StatusCode == http.StatusNotFound { d.SetId("") return nil } - return fmt.Errorf(errorGlobalClusterRead, clusterName, err) + return diag.FromErr(fmt.Errorf(errorGlobalClusterRead, clusterName, err)) } if err := d.Set("managed_namespaces", flattenManagedNamespaces(globalCluster.ManagedNamespaces)); err != nil { - return fmt.Errorf(errorGlobalClusterRead, clusterName, err) + return diag.FromErr(fmt.Errorf(errorGlobalClusterRead, clusterName, err)) } if err := d.Set("custom_zone_mapping", globalCluster.CustomZoneMapping); err != nil { - return fmt.Errorf(errorGlobalClusterRead, clusterName, err) + return diag.FromErr(fmt.Errorf(errorGlobalClusterRead, clusterName, err)) } return nil } -func resourceMongoDBAtlasGlobalClusterUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasGlobalClusterUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -191,22 +192,22 @@ func resourceMongoDBAtlasGlobalClusterUpdate(d *schema.ResourceData, meta interf add := newSet.Difference(oldSet).List() if len(add) > 0 { - if err := addManagedNamespaces(conn, add, projectID, clusterName); err != nil { - return fmt.Errorf(errorGlobalClusterUpdate, clusterName, err) + if err := addManagedNamespaces(ctx, conn, add, projectID, clusterName); err != nil { + return diag.FromErr(fmt.Errorf(errorGlobalClusterUpdate, clusterName, err)) } } if len(remove) > 0 { - if err := removeManagedNamespaces(conn, remove, projectID, clusterName); err != nil { - return fmt.Errorf(errorGlobalClusterUpdate, clusterName, err) + if err := removeManagedNamespaces(ctx, conn, remove, projectID, clusterName); err != nil { + return diag.FromErr(fmt.Errorf(errorGlobalClusterUpdate, clusterName, err)) } } } - return resourceMongoDBAtlasGlobalClusterRead(d, meta) + return resourceMongoDBAtlasGlobalClusterRead(ctx, d, meta) } -func resourceMongoDBAtlasGlobalClusterDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasGlobalClusterDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -214,15 +215,15 @@ func resourceMongoDBAtlasGlobalClusterDelete(d *schema.ResourceData, meta interf clusterName := ids["cluster_name"] if v, ok := d.GetOk("managed_namespaces"); ok { - if err := removeManagedNamespaces(conn, v.(*schema.Set).List(), projectID, clusterName); err != nil { - return fmt.Errorf(errorGlobalClusterDelete, clusterName, err) + if err := removeManagedNamespaces(ctx, conn, v.(*schema.Set).List(), projectID, clusterName); err != nil { + return diag.FromErr(fmt.Errorf(errorGlobalClusterDelete, clusterName, err)) } } if v, ok := d.GetOk("custom_zone_mappings"); ok { if v.(*schema.Set).Len() > 0 { - if _, _, err := conn.GlobalClusters.DeleteCustomZoneMappings(context.Background(), projectID, clusterName); err != nil { - return fmt.Errorf(errorGlobalClusterDelete, clusterName, err) + if _, _, err := conn.GlobalClusters.DeleteCustomZoneMappings(ctx, projectID, clusterName); err != nil { + return diag.FromErr(fmt.Errorf(errorGlobalClusterDelete, clusterName, err)) } } } @@ -248,7 +249,7 @@ func flattenManagedNamespaces(managedNamespaces []matlas.ManagedNamespace) []map return results } -func resourceMongoDBAtlasGlobalClusterImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasGlobalClusterImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { parts := strings.SplitN(d.Id(), "-", 2) if len(parts) != 2 { return nil, errors.New("import format error: to import a global cluster, use the format {project_id}-{cluster-name}") @@ -273,7 +274,7 @@ func resourceMongoDBAtlasGlobalClusterImportState(d *schema.ResourceData, meta i return []*schema.ResourceData{d}, nil } -func removeManagedNamespaces(conn *matlas.Client, remove []interface{}, projectID, clusterName string) error { +func removeManagedNamespaces(ctx context.Context, conn *matlas.Client, remove []interface{}, projectID, clusterName string) error { for _, m := range remove { mn := m.(map[string]interface{}) addManagedNamespace := &matlas.ManagedNamespace{ @@ -281,7 +282,7 @@ func removeManagedNamespaces(conn *matlas.Client, remove []interface{}, projectI Db: mn["db"].(string), CustomShardKey: mn["custom_shard_key"].(string), } - _, _, err := conn.GlobalClusters.DeleteManagedNamespace(context.Background(), projectID, clusterName, addManagedNamespace) + _, _, err := conn.GlobalClusters.DeleteManagedNamespace(ctx, projectID, clusterName, addManagedNamespace) if err != nil { return err @@ -291,7 +292,7 @@ func removeManagedNamespaces(conn *matlas.Client, remove []interface{}, projectI return nil } -func addManagedNamespaces(conn *matlas.Client, add []interface{}, projectID, clusterName string) error { +func addManagedNamespaces(ctx context.Context, conn *matlas.Client, add []interface{}, projectID, clusterName string) error { for _, m := range add { mn := m.(map[string]interface{}) @@ -300,7 +301,7 @@ func addManagedNamespaces(conn *matlas.Client, add []interface{}, projectID, clu Db: mn["db"].(string), CustomShardKey: mn["custom_shard_key"].(string), } - _, _, err := conn.GlobalClusters.AddManagedNamespace(context.Background(), projectID, clusterName, addManagedNamespace) + _, _, err := conn.GlobalClusters.AddManagedNamespace(ctx, projectID, clusterName, addManagedNamespace) if err != nil { return err diff --git a/mongodbatlas/resource_mongodbatlas_global_cluster_config_test.go b/mongodbatlas/resource_mongodbatlas_global_cluster_config_test.go index 466de42b34..e3dab59749 100644 --- a/mongodbatlas/resource_mongodbatlas_global_cluster_config_test.go +++ b/mongodbatlas/resource_mongodbatlas_global_cluster_config_test.go @@ -7,9 +7,9 @@ import ( "strings" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -22,9 +22,9 @@ func TestAccResourceMongoDBAtlasGlobalCluster_basic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasGlobalClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasGlobalClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasGlobalClusterConfig(projectID, name, "false"), @@ -52,9 +52,9 @@ func TestAccResourceMongoDBAtlasGlobalCluster_WithAWSCluster(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasGlobalClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasGlobalClusterDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasGlobalClusterWithAWSClusterConfig(projectID, name, "true"), @@ -81,9 +81,9 @@ func TestAccResourceMongoDBAtlasGlobalCluster_importBasic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasProjectIPAccessListDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasProjectIPAccessListDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasGlobalClusterConfig(projectID, name, "false"), @@ -234,21 +234,26 @@ func testAccMongoDBAtlasGlobalClusterConfig(projectID, name, backupEnabled strin func testAccMongoDBAtlasGlobalClusterWithAWSClusterConfig(projectID, name, backupEnabled string) string { return fmt.Sprintf(` resource "mongodbatlas_cluster" "test" { - project_id = "%s" - name = "%s" - disk_size_gb = 100 - num_shards = 1 - - replication_factor = 3 - auto_scaling_disk_gb_enabled = true - mongo_db_major_version = "4.0" + project_id = "%s" + name = "%s" + disk_size_gb = 80 + provider_backup_enabled = %s + cluster_type = "GEOSHARDED" // Provider Settings "block" provider_name = "AWS" - provider_encrypt_ebs_volume = false - provider_instance_size_name = "M30" - provider_region_name = "US_EAST_1" - provider_backup_enabled = %s + provider_instance_size_name = "M30" + + replication_specs { + zone_name = "Zone 1" + num_shards = 1 + regions_config { + region_name = "US_EAST_1" + electable_nodes = 3 + priority = 7 + read_only_nodes = 0 + } + } } resource "mongodbatlas_global_cluster_config" "config" { diff --git a/mongodbatlas/resource_mongodbatlas_ldap_configuration.go b/mongodbatlas/resource_mongodbatlas_ldap_configuration.go index 200566a2d2..9504e9531f 100644 --- a/mongodbatlas/resource_mongodbatlas_ldap_configuration.go +++ b/mongodbatlas/resource_mongodbatlas_ldap_configuration.go @@ -5,7 +5,8 @@ import ( "fmt" "net/http" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -19,12 +20,12 @@ const ( func resourceMongoDBAtlasLDAPConfiguration() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasLDAPConfigurationCreate, - Read: resourceMongoDBAtlasLDAPConfigurationRead, - Update: resourceMongoDBAtlasLDAPConfigurationUpdate, - Delete: resourceMongoDBAtlasLDAPConfigurationDelete, + CreateContext: resourceMongoDBAtlasLDAPConfigurationCreate, + ReadContext: resourceMongoDBAtlasLDAPConfigurationRead, + UpdateContext: resourceMongoDBAtlasLDAPConfigurationUpdate, + DeleteContext: resourceMongoDBAtlasLDAPConfigurationDelete, Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, + StateContext: schema.ImportStatePassthroughContext, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -96,7 +97,7 @@ func resourceMongoDBAtlasLDAPConfiguration() *schema.Resource { } } -func resourceMongoDBAtlasLDAPConfigurationCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasLDAPConfigurationCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) @@ -142,17 +143,17 @@ func resourceMongoDBAtlasLDAPConfigurationCreate(d *schema.ResourceData, meta in LDAP: ldap, } - _, _, err := conn.LDAPConfigurations.Save(context.Background(), projectID, ladpReq) + _, _, err := conn.LDAPConfigurations.Save(ctx, projectID, ladpReq) if err != nil { - return fmt.Errorf(errorLDAPConfigurationCreate, projectID, err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationCreate, projectID, err)) } d.SetId(projectID) - return resourceMongoDBAtlasLDAPConfigurationRead(d, meta) + return resourceMongoDBAtlasLDAPConfigurationRead(ctx, d, meta) } -func resourceMongoDBAtlasLDAPConfigurationRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasLDAPConfigurationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ldapResp, resp, err := conn.LDAPConfigurations.Get(context.Background(), d.Id()) @@ -162,38 +163,38 @@ func resourceMongoDBAtlasLDAPConfigurationRead(d *schema.ResourceData, meta inte return nil } - return fmt.Errorf(errorLDAPConfigurationRead, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationRead, d.Id(), err)) } if err = d.Set("authentication_enabled", ldapResp.LDAP.AuthenticationEnabled); err != nil { - return fmt.Errorf(errorLDAPConfigurationSetting, "authentication_enabled", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationSetting, "authentication_enabled", d.Id(), err)) } if err = d.Set("authorization_enabled", ldapResp.LDAP.AuthorizationEnabled); err != nil { - return fmt.Errorf(errorLDAPConfigurationSetting, "authorization_enabled", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationSetting, "authorization_enabled", d.Id(), err)) } if err = d.Set("hostname", ldapResp.LDAP.Hostname); err != nil { - return fmt.Errorf(errorLDAPConfigurationSetting, "hostname", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationSetting, "hostname", d.Id(), err)) } if err = d.Set("port", ldapResp.LDAP.Port); err != nil { - return fmt.Errorf(errorLDAPConfigurationSetting, "port", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationSetting, "port", d.Id(), err)) } if err = d.Set("bind_username", ldapResp.LDAP.BindUsername); err != nil { - return fmt.Errorf(errorLDAPConfigurationSetting, "bind_username", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationSetting, "bind_username", d.Id(), err)) } if err = d.Set("ca_certificate", ldapResp.LDAP.CaCertificate); err != nil { - return fmt.Errorf(errorLDAPConfigurationSetting, "ca_certificate", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationSetting, "ca_certificate", d.Id(), err)) } if err = d.Set("authz_query_template", ldapResp.LDAP.AuthzQueryTemplate); err != nil { - return fmt.Errorf(errorLDAPConfigurationSetting, "authz_query_template", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationSetting, "authz_query_template", d.Id(), err)) } if err = d.Set("user_to_dn_mapping", flattenDNMapping(ldapResp.LDAP.UserToDNMapping)); err != nil { - return fmt.Errorf(errorLDAPConfigurationSetting, "user_to_dn_mapping", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationSetting, "user_to_dn_mapping", d.Id(), err)) } return nil } -func resourceMongoDBAtlasLDAPConfigurationUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasLDAPConfigurationUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get the client connection. conn := meta.(*MongoDBClient).Atlas @@ -239,20 +240,20 @@ func resourceMongoDBAtlasLDAPConfigurationUpdate(d *schema.ResourceData, meta in LDAP: ldap, } - _, _, err := conn.LDAPConfigurations.Save(context.Background(), d.Id(), ldapReq) + _, _, err := conn.LDAPConfigurations.Save(ctx, d.Id(), ldapReq) if err != nil { - return fmt.Errorf(errorLDAPConfigurationUpdate, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationUpdate, d.Id(), err)) } return nil } -func resourceMongoDBAtlasLDAPConfigurationDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasLDAPConfigurationDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get the client connection. conn := meta.(*MongoDBClient).Atlas - _, _, err := conn.LDAPConfigurations.Delete(context.Background(), d.Id()) + _, _, err := conn.LDAPConfigurations.Delete(ctx, d.Id()) if err != nil { - return fmt.Errorf(errorLDAPConfigurationDelete, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPConfigurationDelete, d.Id(), err)) } return nil diff --git a/mongodbatlas/resource_mongodbatlas_ldap_configuration_test.go b/mongodbatlas/resource_mongodbatlas_ldap_configuration_test.go index 5419539a74..b3ee8f07ef 100644 --- a/mongodbatlas/resource_mongodbatlas_ldap_configuration_test.go +++ b/mongodbatlas/resource_mongodbatlas_ldap_configuration_test.go @@ -8,10 +8,10 @@ import ( "github.com/spf13/cast" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -30,9 +30,9 @@ func TestAccResourceMongoDBAtlasLDAPConfiguration_basic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkLDAP(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasLDAPConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t); checkLDAP(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasLDAPConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasLDAPConfigurationConfig(projectName, orgID, hostname, username, password, authEnabled, cast.ToInt(port)), @@ -67,9 +67,9 @@ func TestAccResourceMongoDBAtlasLDAPConfigurationWithVerify_CACertificateComplet ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkLDAP(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasLDAPConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t); checkLDAP(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasLDAPConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasLDAPConfigurationWithVerifyConfig(projectName, orgID, clusterName, hostname, username, password, caCertificate, cast.ToInt(port), true), @@ -115,9 +115,9 @@ func TestAccResourceMongoDBAtlasLDAPConfiguration_importBasic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkLDAP(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasLDAPConfigurationDestroy, + PreCheck: func() { testAccPreCheck(t); checkLDAP(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasLDAPConfigurationDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasLDAPConfigurationConfig(projectName, orgID, hostname, username, password, authEnabled, port), diff --git a/mongodbatlas/resource_mongodbatlas_ldap_verify.go b/mongodbatlas/resource_mongodbatlas_ldap_verify.go index 849c5dbfcc..4dda10b26d 100644 --- a/mongodbatlas/resource_mongodbatlas_ldap_verify.go +++ b/mongodbatlas/resource_mongodbatlas_ldap_verify.go @@ -8,8 +8,10 @@ import ( "strings" "time" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -21,11 +23,11 @@ const ( func resourceMongoDBAtlasLDAPVerify() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasLDAPVerifyCreate, - Read: resourceMongoDBAtlasLDAPVerifyRead, - Delete: resourceMongoDBAtlasLDAPVerifyDelete, + CreateContext: resourceMongoDBAtlasLDAPVerifyCreate, + ReadContext: resourceMongoDBAtlasLDAPVerifyRead, + DeleteContext: resourceMongoDBAtlasLDAPVerifyDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasLDAPVerifyImportState, + StateContext: resourceMongoDBAtlasLDAPVerifyImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -109,7 +111,7 @@ func resourceMongoDBAtlasLDAPVerify() *schema.Resource { } } -func resourceMongoDBAtlasLDAPVerifyCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasLDAPVerifyCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) @@ -134,24 +136,24 @@ func resourceMongoDBAtlasLDAPVerifyCreate(d *schema.ResourceData, meta interface ldapReq.AuthzQueryTemplate = v.(string) } - ldap, _, err := conn.LDAPConfigurations.Verify(context.Background(), projectID, ldapReq) + ldap, _, err := conn.LDAPConfigurations.Verify(ctx, projectID, ldapReq) if err != nil { - return fmt.Errorf(errorLDAPVerifyCreate, projectID, err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifyCreate, projectID, err)) } stateConf := &resource.StateChangeConf{ Pending: []string{"PENDING"}, Target: []string{"SUCCESS", "FAILED"}, - Refresh: resourceLDAPGetStatusRefreshFunc(projectID, ldap.RequestID, conn), + Refresh: resourceLDAPGetStatusRefreshFunc(ctx, projectID, ldap.RequestID, conn), Timeout: 3 * time.Hour, MinTimeout: 1 * time.Minute, Delay: 3 * time.Minute, } // Wait, catching any errors - _, err = stateConf.WaitForState() + _, err = stateConf.WaitForStateContext(ctx) if err != nil { - return fmt.Errorf(errorLDAPVerifyCreate, projectID, err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifyCreate, projectID, err)) } d.SetId(encodeStateID(map[string]string{ @@ -159,10 +161,10 @@ func resourceMongoDBAtlasLDAPVerifyCreate(d *schema.ResourceData, meta interface "request_id": ldap.RequestID, })) - return resourceMongoDBAtlasLDAPVerifyRead(d, meta) + return resourceMongoDBAtlasLDAPVerifyRead(ctx, d, meta) } -func resourceMongoDBAtlasLDAPVerifyRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasLDAPVerifyRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -176,35 +178,35 @@ func resourceMongoDBAtlasLDAPVerifyRead(d *schema.ResourceData, meta interface{} return nil } - return fmt.Errorf(errorLDAPVerifyRead, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifyRead, d.Id(), err)) } if err := d.Set("hostname", ldapResp.Request.Hostname); err != nil { - return fmt.Errorf(errorLDAPVerifySetting, "hostname", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifySetting, "hostname", d.Id(), err)) } if err := d.Set("port", ldapResp.Request.Port); err != nil { - return fmt.Errorf(errorLDAPVerifySetting, "port", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifySetting, "port", d.Id(), err)) } if err := d.Set("bind_username", ldapResp.Request.BindUsername); err != nil { - return fmt.Errorf(errorLDAPVerifySetting, "bind_username", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifySetting, "bind_username", d.Id(), err)) } if err := d.Set("links", flattenLinks(ldapResp.Links)); err != nil { - return fmt.Errorf(errorLDAPVerifySetting, "links", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifySetting, "links", d.Id(), err)) } if err := d.Set("validations", flattenValidations(ldapResp.Validations)); err != nil { - return fmt.Errorf(errorLDAPVerifySetting, "validations", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifySetting, "validations", d.Id(), err)) } if err := d.Set("request_id", ldapResp.RequestID); err != nil { - return fmt.Errorf(errorLDAPVerifySetting, "request_id", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifySetting, "request_id", d.Id(), err)) } if err := d.Set("status", ldapResp.Status); err != nil { - return fmt.Errorf(errorLDAPVerifySetting, "status", d.Id(), err) + return diag.FromErr(fmt.Errorf(errorLDAPVerifySetting, "status", d.Id(), err)) } return nil } -func resourceMongoDBAtlasLDAPVerifyDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasLDAPVerifyDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { d.SetId("") return nil @@ -234,7 +236,7 @@ func flattenValidations(validationsArray []*matlas.LDAPValidation) []map[string] return validations } -func resourceMongoDBAtlasLDAPVerifyImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasLDAPVerifyImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas parts := strings.SplitN(d.Id(), "-", 2) @@ -245,7 +247,7 @@ func resourceMongoDBAtlasLDAPVerifyImportState(d *schema.ResourceData, meta inte projectID := parts[0] requestID := parts[1] - _, _, err := conn.LDAPConfigurations.GetStatus(context.Background(), projectID, requestID) + _, _, err := conn.LDAPConfigurations.GetStatus(ctx, projectID, requestID) if err != nil { return nil, fmt.Errorf(errorLDAPVerifyRead, requestID, err) } @@ -266,9 +268,9 @@ func resourceMongoDBAtlasLDAPVerifyImportState(d *schema.ResourceData, meta inte return []*schema.ResourceData{d}, nil } -func resourceLDAPGetStatusRefreshFunc(projectID, requestID string, client *matlas.Client) resource.StateRefreshFunc { +func resourceLDAPGetStatusRefreshFunc(ctx context.Context, projectID, requestID string, client *matlas.Client) resource.StateRefreshFunc { return func() (interface{}, string, error) { - p, resp, err := client.LDAPConfigurations.GetStatus(context.Background(), projectID, requestID) + p, resp, err := client.LDAPConfigurations.GetStatus(ctx, projectID, requestID) if err != nil { if resp.Response.StatusCode == 404 { return "", "DELETED", nil diff --git a/mongodbatlas/resource_mongodbatlas_ldap_verify_test.go b/mongodbatlas/resource_mongodbatlas_ldap_verify_test.go index 26b17d790d..fbd3853b1e 100644 --- a/mongodbatlas/resource_mongodbatlas_ldap_verify_test.go +++ b/mongodbatlas/resource_mongodbatlas_ldap_verify_test.go @@ -8,10 +8,10 @@ import ( "github.com/spf13/cast" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -30,9 +30,9 @@ func TestAccResourceMongoDBAtlasLDAPVerify_basic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkLDAP(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasLDAPVerifyDestroy, + PreCheck: func() { testAccPreCheck(t); checkLDAP(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasLDAPVerifyDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasLDAPVerifyConfig(projectName, orgID, clusterName, hostname, username, password, cast.ToInt(port)), @@ -66,9 +66,9 @@ func TestAccResourceMongoDBAtlasLDAPVerifyWithConfiguration_CACertificate(t *tes ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkLDAP(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasLDAPVerifyDestroy, + PreCheck: func() { testAccPreCheck(t); checkLDAP(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasLDAPVerifyDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasLDAPVerifyWithConfigurationConfig(projectName, orgID, clusterName, hostname, username, password, caCertificate, cast.ToInt(port), true), @@ -108,9 +108,9 @@ func TestAccResourceMongoDBAtlasLDAPVerify_importBasic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkLDAP(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasLDAPVerifyDestroy, + PreCheck: func() { testAccPreCheck(t); checkLDAP(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasLDAPVerifyDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasLDAPVerifyConfig(projectName, orgID, clusterName, hostname, username, password, cast.ToInt(port)), diff --git a/mongodbatlas/resource_mongodbatlas_maintenance_window.go b/mongodbatlas/resource_mongodbatlas_maintenance_window.go index 6ffd313759..fd43f5a6a7 100644 --- a/mongodbatlas/resource_mongodbatlas_maintenance_window.go +++ b/mongodbatlas/resource_mongodbatlas_maintenance_window.go @@ -5,7 +5,8 @@ import ( "fmt" "net/http" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mwielbut/pointy" "github.com/spf13/cast" matlas "go.mongodb.org/atlas/mongodbatlas" @@ -21,12 +22,12 @@ const ( func resourceMongoDBAtlasMaintenanceWindow() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasMaintenanceWindowCreate, - Read: resourceMongoDBAtlasMaintenanceWindowRead, - Update: resourceMongoDBAtlasMaintenanceWindowUpdate, - Delete: resourceMongoDBAtlasMaintenanceWindowDelete, + CreateContext: resourceMongoDBAtlasMaintenanceWindowCreate, + ReadContext: resourceMongoDBAtlasMaintenanceWindowRead, + UpdateContext: resourceMongoDBAtlasMaintenanceWindowUpdate, + DeleteContext: resourceMongoDBAtlasMaintenanceWindowDelete, Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, + StateContext: schema.ImportStatePassthroughContext, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -76,16 +77,16 @@ func resourceMongoDBAtlasMaintenanceWindow() *schema.Resource { } } -func resourceMongoDBAtlasMaintenanceWindowCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasMaintenanceWindowCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get the client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) if deferValue := d.Get("defer").(bool); deferValue { - _, err := conn.MaintenanceWindows.Defer(context.Background(), projectID) + _, err := conn.MaintenanceWindows.Defer(ctx, projectID) if err != nil { - return fmt.Errorf(errorMaintenanceDefer, projectID, err) + return diag.FromErr(fmt.Errorf(errorMaintenanceDefer, projectID, err)) } } @@ -103,17 +104,17 @@ func resourceMongoDBAtlasMaintenanceWindowCreate(d *schema.ResourceData, meta in maintenanceWindowReq.NumberOfDeferrals = cast.ToInt(numberOfDeferrals) } - _, err := conn.MaintenanceWindows.Update(context.Background(), projectID, maintenanceWindowReq) + _, err := conn.MaintenanceWindows.Update(ctx, projectID, maintenanceWindowReq) if err != nil { - return fmt.Errorf(errorMaintenanceCreate, projectID, err) + return diag.FromErr(fmt.Errorf(errorMaintenanceCreate, projectID, err)) } d.SetId(projectID) - return resourceMongoDBAtlasMaintenanceWindowRead(d, meta) + return resourceMongoDBAtlasMaintenanceWindowRead(ctx, d, meta) } -func resourceMongoDBAtlasMaintenanceWindowRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasMaintenanceWindowRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get the client connection. conn := meta.(*MongoDBClient).Atlas @@ -124,44 +125,44 @@ func resourceMongoDBAtlasMaintenanceWindowRead(d *schema.ResourceData, meta inte return nil } - return fmt.Errorf(errorMaintenanceRead, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorMaintenanceRead, d.Id(), err)) } if err := d.Set("day_of_week", maintenanceWindow.DayOfWeek); err != nil { - return fmt.Errorf(errorMaintenanceRead, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorMaintenanceRead, d.Id(), err)) } if err := d.Set("hour_of_day", maintenanceWindow.HourOfDay); err != nil { - return fmt.Errorf(errorMaintenanceRead, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorMaintenanceRead, d.Id(), err)) } if err := d.Set("number_of_deferrals", maintenanceWindow.NumberOfDeferrals); err != nil { - return fmt.Errorf(errorMaintenanceRead, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorMaintenanceRead, d.Id(), err)) } // start_asap is just display the state of the maintenance, // and it doesn't able to set it because breacks the Terraform flow // it can be used via API if err := d.Set("start_asap", maintenanceWindow.StartASAP); err != nil { - return fmt.Errorf(errorMaintenanceRead, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorMaintenanceRead, d.Id(), err)) } if err := d.Set("project_id", d.Id()); err != nil { - return fmt.Errorf(errorMaintenanceRead, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorMaintenanceRead, d.Id(), err)) } return nil } -func resourceMongoDBAtlasMaintenanceWindowUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasMaintenanceWindowUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get the client connection. conn := meta.(*MongoDBClient).Atlas maintenanceWindowReq := &matlas.MaintenanceWindow{} if d.HasChange("defer") { - _, err := conn.MaintenanceWindows.Defer(context.Background(), d.Id()) + _, err := conn.MaintenanceWindows.Defer(ctx, d.Id()) if err != nil { - return fmt.Errorf(errorMaintenanceDefer, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorMaintenanceDefer, d.Id(), err)) } } @@ -177,21 +178,21 @@ func resourceMongoDBAtlasMaintenanceWindowUpdate(d *schema.ResourceData, meta in maintenanceWindowReq.NumberOfDeferrals = cast.ToInt(d.Get("number_of_deferrals")) } - _, err := conn.MaintenanceWindows.Update(context.Background(), d.Id(), maintenanceWindowReq) + _, err := conn.MaintenanceWindows.Update(ctx, d.Id(), maintenanceWindowReq) if err != nil { - return fmt.Errorf(errorMaintenanceUpdate, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorMaintenanceUpdate, d.Id(), err)) } return nil } -func resourceMongoDBAtlasMaintenanceWindowDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasMaintenanceWindowDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get the client connection. conn := meta.(*MongoDBClient).Atlas - _, err := conn.MaintenanceWindows.Reset(context.Background(), d.Id()) + _, err := conn.MaintenanceWindows.Reset(ctx, d.Id()) if err != nil { - return fmt.Errorf(errorMaintenanceDelete, d.Id(), err) + return diag.FromErr(fmt.Errorf(errorMaintenanceDelete, d.Id(), err)) } return nil diff --git a/mongodbatlas/resource_mongodbatlas_maintenance_window_test.go b/mongodbatlas/resource_mongodbatlas_maintenance_window_test.go index 679ba731e7..2c1aa6b689 100644 --- a/mongodbatlas/resource_mongodbatlas_maintenance_window_test.go +++ b/mongodbatlas/resource_mongodbatlas_maintenance_window_test.go @@ -8,8 +8,8 @@ import ( "testing" "github.com/go-test/deep" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/spf13/cast" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -26,9 +26,9 @@ func TestAccResourceMongoDBAtlasMaintenanceWindow_basic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasMaintenanceWindowDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasMaintenanceWindowDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasMaintenanceWindowConfig(projectID, dayOfWeek, hourOfDay), @@ -74,9 +74,9 @@ func TestAccResourceMongoDBAtlasMaintenanceWindow_importBasic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasMaintenanceWindowDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasMaintenanceWindowDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasMaintenanceWindowConfig(projectID, dayOfWeek, hourOfDay), diff --git a/mongodbatlas/resource_mongodbatlas_network_container.go b/mongodbatlas/resource_mongodbatlas_network_container.go index 9359f2224d..03858a690d 100644 --- a/mongodbatlas/resource_mongodbatlas_network_container.go +++ b/mongodbatlas/resource_mongodbatlas_network_container.go @@ -10,10 +10,12 @@ import ( "strings" "time" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/spf13/cast" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -26,12 +28,12 @@ const ( func resourceMongoDBAtlasNetworkContainer() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasNetworkContainerCreate, - Read: resourceMongoDBAtlasNetworkContainerRead, - Update: resourceMongoDBAtlasNetworkContainerUpdate, - Delete: resourceMongoDBAtlasNetworkContainerDelete, + CreateContext: resourceMongoDBAtlasNetworkContainerCreate, + ReadContext: resourceMongoDBAtlasNetworkContainerRead, + UpdateContext: resourceMongoDBAtlasNetworkContainerUpdate, + DeleteContext: resourceMongoDBAtlasNetworkContainerDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasNetworkContainerImportState, + StateContext: resourceMongoDBAtlasNetworkContainerImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -98,7 +100,7 @@ func resourceMongoDBAtlasNetworkContainer() *schema.Resource { } } -func resourceMongoDBAtlasNetworkContainerCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasNetworkContainerCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) @@ -112,7 +114,7 @@ func resourceMongoDBAtlasNetworkContainerCreate(d *schema.ResourceData, meta int if providerName == "AWS" { region, err := valRegion(d.Get("region_name")) if err != nil { - return fmt.Errorf("`region_name` must be set when `provider_name` is AWS") + return diag.FromErr(fmt.Errorf("`region_name` must be set when `provider_name` is AWS")) } containerRequest.RegionName = region @@ -121,7 +123,7 @@ func resourceMongoDBAtlasNetworkContainerCreate(d *schema.ResourceData, meta int if providerName == "AZURE" { region, err := valRegion(d.Get("region")) if err != nil { - return fmt.Errorf("`region` must be set when `provider_name` is AZURE") + return diag.FromErr(fmt.Errorf("`region` must be set when `provider_name` is AZURE")) } containerRequest.Region = region @@ -134,9 +136,9 @@ func resourceMongoDBAtlasNetworkContainerCreate(d *schema.ResourceData, meta int } } - container, _, err := conn.Containers.Create(context.Background(), projectID, containerRequest) + container, _, err := conn.Containers.Create(ctx, projectID, containerRequest) if err != nil { - return fmt.Errorf(errorContainterCreate, err) + return diag.FromErr(fmt.Errorf(errorContainterCreate, err)) } d.SetId(encodeStateID(map[string]string{ @@ -144,74 +146,74 @@ func resourceMongoDBAtlasNetworkContainerCreate(d *schema.ResourceData, meta int "container_id": container.ID, })) - return resourceMongoDBAtlasNetworkContainerRead(d, meta) + return resourceMongoDBAtlasNetworkContainerRead(ctx, d, meta) } -func resourceMongoDBAtlasNetworkContainerRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasNetworkContainerRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) projectID := ids["project_id"] containerID := ids["container_id"] - container, resp, err := conn.Containers.Get(context.Background(), projectID, containerID) + container, resp, err := conn.Containers.Get(ctx, projectID, containerID) if err != nil { if resp != nil && resp.StatusCode == http.StatusNotFound { d.SetId("") return nil } - return fmt.Errorf(errorContainerRead, containerID, err) + return diag.FromErr(fmt.Errorf(errorContainerRead, containerID, err)) } if err = d.Set("region_name", container.RegionName); err != nil { - return fmt.Errorf("error setting `region_name` for Network Container (%s): %s", containerID, err) + return diag.FromErr(fmt.Errorf("error setting `region_name` for Network Container (%s): %s", containerID, err)) } if err = d.Set("region", container.Region); err != nil { - return fmt.Errorf("error setting `region` for Network Container (%s): %s", containerID, err) + return diag.FromErr(fmt.Errorf("error setting `region` for Network Container (%s): %s", containerID, err)) } if err = d.Set("azure_subscription_id", container.AzureSubscriptionID); err != nil { - return fmt.Errorf("error setting `azure_subscription_id` for Network Container (%s): %s", containerID, err) + return diag.FromErr(fmt.Errorf("error setting `azure_subscription_id` for Network Container (%s): %s", containerID, err)) } if err = d.Set("provisioned", container.Provisioned); err != nil { - return fmt.Errorf("error setting `provisioned` for Network Container (%s): %s", containerID, err) + return diag.FromErr(fmt.Errorf("error setting `provisioned` for Network Container (%s): %s", containerID, err)) } if err = d.Set("gcp_project_id", container.GCPProjectID); err != nil { - return fmt.Errorf("error setting `gcp_project_id` for Network Container (%s): %s", containerID, err) + return diag.FromErr(fmt.Errorf("error setting `gcp_project_id` for Network Container (%s): %s", containerID, err)) } if err = d.Set("network_name", container.NetworkName); err != nil { - return fmt.Errorf("error setting `network_name` for Network Container (%s): %s", containerID, err) + return diag.FromErr(fmt.Errorf("error setting `network_name` for Network Container (%s): %s", containerID, err)) } if err = d.Set("gcp_project_id", container.GCPProjectID); err != nil { - return fmt.Errorf("error setting `gcp_project_id` for Network Container (%s): %s", containerID, err) + return diag.FromErr(fmt.Errorf("error setting `gcp_project_id` for Network Container (%s): %s", containerID, err)) } if err = d.Set("vpc_id", container.VPCID); err != nil { - return fmt.Errorf("error setting `vpc_id` for Network Container (%s): %s", containerID, err) + return diag.FromErr(fmt.Errorf("error setting `vpc_id` for Network Container (%s): %s", containerID, err)) } if err = d.Set("vnet_name", container.VNetName); err != nil { - return fmt.Errorf("error setting `vnet_name` for Network Container (%s): %s", containerID, err) + return diag.FromErr(fmt.Errorf("error setting `vnet_name` for Network Container (%s): %s", containerID, err)) } if err = d.Set("container_id", container.ID); err != nil { - return fmt.Errorf("error setting `container_id` for Network Container (%s): %s", containerID, err) + return diag.FromErr(fmt.Errorf("error setting `container_id` for Network Container (%s): %s", containerID, err)) } if err = d.Set("regions", container.Regions); err != nil { - return fmt.Errorf("error setting `regions` for Network Container (%s): %s", containerID, err) + return diag.FromErr(fmt.Errorf("error setting `regions` for Network Container (%s): %s", containerID, err)) } return nil } -func resourceMongoDBAtlasNetworkContainerUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasNetworkContainerUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -241,38 +243,38 @@ func resourceMongoDBAtlasNetworkContainerUpdate(d *schema.ResourceData, meta int // Has changes if !reflect.DeepEqual(container, matlas.Container{}) { - _, _, err := conn.Containers.Update(context.Background(), projectID, containerID, container) + _, _, err := conn.Containers.Update(ctx, projectID, containerID, container) if err != nil { - return fmt.Errorf(errorContainerUpdate, containerID, err) + return diag.FromErr(fmt.Errorf(errorContainerUpdate, containerID, err)) } } - return resourceMongoDBAtlasNetworkContainerRead(d, meta) + return resourceMongoDBAtlasNetworkContainerRead(ctx, d, meta) } -func resourceMongoDBAtlasNetworkContainerDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasNetworkContainerDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas stateConf := &resource.StateChangeConf{ Pending: []string{"provisioned_container"}, Target: []string{"deleted"}, - Refresh: resourceNetworkContainerRefreshFunc(d, conn), + Refresh: resourceNetworkContainerRefreshFunc(ctx, d, conn), Timeout: 1 * time.Hour, MinTimeout: 10 * time.Second, Delay: 2 * time.Minute, } // Wait, catching any errors - _, err := stateConf.WaitForState() + _, err := stateConf.WaitForStateContext(ctx) if err != nil { - return fmt.Errorf(errorContainerDelete, decodeStateID(d.Id())["container_id"], err) + return diag.FromErr(fmt.Errorf(errorContainerDelete, decodeStateID(d.Id())["container_id"], err)) } return nil } -func resourceMongoDBAtlasNetworkContainerImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasNetworkContainerImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas parts := strings.SplitN(d.Id(), "-", 2) @@ -283,7 +285,7 @@ func resourceMongoDBAtlasNetworkContainerImportState(d *schema.ResourceData, met projectID := parts[0] containerID := parts[1] - u, _, err := conn.Containers.Get(context.Background(), projectID, containerID) + u, _, err := conn.Containers.Get(ctx, projectID, containerID) if err != nil { return nil, fmt.Errorf("couldn't import container %s in project %s, error: %s", containerID, projectID, err) } @@ -312,14 +314,14 @@ func resourceMongoDBAtlasNetworkContainerImportState(d *schema.ResourceData, met return []*schema.ResourceData{d}, nil } -func resourceNetworkContainerRefreshFunc(d *schema.ResourceData, client *matlas.Client) resource.StateRefreshFunc { +func resourceNetworkContainerRefreshFunc(ctx context.Context, d *schema.ResourceData, client *matlas.Client) resource.StateRefreshFunc { return func() (interface{}, string, error) { ids := decodeStateID(d.Id()) projectID := ids["project_id"] containerID := ids["container_id"] var err error - container, res, err := client.Containers.Get(context.Background(), projectID, containerID) + container, res, err := client.Containers.Get(ctx, projectID, containerID) if err != nil { if res.StatusCode == 404 { return "", "deleted", nil @@ -332,7 +334,7 @@ func resourceNetworkContainerRefreshFunc(d *schema.ResourceData, client *matlas. return nil, "provisioned_container", nil } - _, err = client.Containers.Delete(context.Background(), projectID, containerID) + _, err = client.Containers.Delete(ctx, projectID, containerID) if err != nil { return nil, "provisioned_container", nil } diff --git a/mongodbatlas/resource_mongodbatlas_network_container_test.go b/mongodbatlas/resource_mongodbatlas_network_container_test.go index e1560c9584..b57246bac9 100644 --- a/mongodbatlas/resource_mongodbatlas_network_container_test.go +++ b/mongodbatlas/resource_mongodbatlas_network_container_test.go @@ -7,9 +7,9 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -27,9 +27,9 @@ func TestAccResourceMongoDBAtlasNetworkContainer_basicAWS(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasNetworkContainerConfigAWS(projectName, orgID, cidrBlock, providerName, "US_EAST_1"), @@ -69,9 +69,9 @@ func TestAccResourceMongoDBAtlasNetworkContainer_basicAzure(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasNetworkContainerConfigAzure(projectName, orgID, cidrBlock, providerName), @@ -111,9 +111,9 @@ func TestAccResourceMongoDBAtlasNetworkContainer_basicGCP(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasNetworkContainerConfigGCP(projectName, orgID, cidrBlock, providerName), @@ -151,9 +151,9 @@ func TestAccResourceMongoDBAtlasNetworkContainer_WithRegionsGCP(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasNetworkContainerConfigGCPWithRegions(projectName, orgID, cidrBlock, providerName), @@ -180,9 +180,9 @@ func TestAccResourceMongoDBAtlasNetworkContainer_importBasic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasNetworkContainerDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasNetworkContainerConfigAWS(projectName, orgID, cidrBlock, providerName, "US_EAST_1"), diff --git a/mongodbatlas/resource_mongodbatlas_network_peering.go b/mongodbatlas/resource_mongodbatlas_network_peering.go index e31fa1e806..3adf5f785a 100644 --- a/mongodbatlas/resource_mongodbatlas_network_peering.go +++ b/mongodbatlas/resource_mongodbatlas_network_peering.go @@ -10,9 +10,11 @@ import ( "strings" "time" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -25,12 +27,12 @@ const ( func resourceMongoDBAtlasNetworkPeering() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasNetworkPeeringCreate, - Read: resourceMongoDBAtlasNetworkPeeringRead, - Update: resourceMongoDBAtlasNetworkPeeringUpdate, - Delete: resourceMongoDBAtlasNetworkPeeringDelete, + CreateContext: resourceMongoDBAtlasNetworkPeeringCreate, + ReadContext: resourceMongoDBAtlasNetworkPeeringRead, + UpdateContext: resourceMongoDBAtlasNetworkPeeringUpdate, + DeleteContext: resourceMongoDBAtlasNetworkPeeringDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasNetworkPeeringImportState, + StateContext: resourceMongoDBAtlasNetworkPeeringImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -151,7 +153,7 @@ func resourceMongoDBAtlasNetworkPeering() *schema.Resource { } } -func resourceMongoDBAtlasNetworkPeeringCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasNetworkPeeringCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) @@ -166,22 +168,22 @@ func resourceMongoDBAtlasNetworkPeeringCreate(d *schema.ResourceData, meta inter if providerName == "AWS" { region, err := valRegion(d.Get("accepter_region_name"), "network_peering") if err != nil { - return errors.New("`accepter_region_name` must be set when `provider_name` is `AWS`") + return diag.FromErr(errors.New("`accepter_region_name` must be set when `provider_name` is `AWS`")) } awsAccountID, ok := d.GetOk("aws_account_id") if !ok { - return errors.New("`aws_account_id` must be set when `provider_name` is `AWS`") + return diag.FromErr(errors.New("`aws_account_id` must be set when `provider_name` is `AWS`")) } rtCIDR, ok := d.GetOk("route_table_cidr_block") if !ok { - return errors.New("`route_table_cidr_block` must be set when `provider_name` is `AWS`") + return diag.FromErr(errors.New("`route_table_cidr_block` must be set when `provider_name` is `AWS`")) } vpcID, ok := d.GetOk("vpc_id") if !ok { - return errors.New("`vpc_id` must be set when `provider_name` is `AWS`") + return diag.FromErr(errors.New("`vpc_id` must be set when `provider_name` is `AWS`")) } peerRequest.AccepterRegionName = region @@ -193,12 +195,12 @@ func resourceMongoDBAtlasNetworkPeeringCreate(d *schema.ResourceData, meta inter if providerName == "GCP" { gcpProjectID, ok := d.GetOk("gcp_project_id") if !ok { - return errors.New("`gcp_project_id` must be set when `provider_name` is `GCP`") + return diag.FromErr(errors.New("`gcp_project_id` must be set when `provider_name` is `GCP`")) } networkName, ok := d.GetOk("network_name") if !ok { - return errors.New("`network_name` must be set when `provider_name` is `GCP`") + return diag.FromErr(errors.New("`network_name` must be set when `provider_name` is `GCP`")) } peerRequest.GCPProjectID = gcpProjectID.(string) @@ -208,27 +210,27 @@ func resourceMongoDBAtlasNetworkPeeringCreate(d *schema.ResourceData, meta inter if providerName == "AZURE" { atlasCidrBlock, ok := d.GetOk("atlas_cidr_block") if !ok { - return errors.New("`atlas_cidr_block` must be set when `provider_name` is `AZURE`") + return diag.FromErr(errors.New("`atlas_cidr_block` must be set when `provider_name` is `AZURE`")) } azureDirectoryID, ok := d.GetOk("azure_directory_id") if !ok { - return errors.New("`azure_directory_id` must be set when `provider_name` is `AZURE`") + return diag.FromErr(errors.New("`azure_directory_id` must be set when `provider_name` is `AZURE`")) } azureSubscriptionID, ok := d.GetOk("azure_subscription_id") if !ok { - return errors.New("`azure_subscription_id` must be set when `provider_name` is `AZURE`") + return diag.FromErr(errors.New("`azure_subscription_id` must be set when `provider_name` is `AZURE`")) } resourceGroupName, ok := d.GetOk("resource_group_name") if !ok { - return errors.New("`resource_group_name` must be set when `provider_name` is `AZURE`") + return diag.FromErr(errors.New("`resource_group_name` must be set when `provider_name` is `AZURE`")) } vnetName, ok := d.GetOk("vnet_name") if !ok { - return errors.New("`vnet_name` must be set when `provider_name` is `AZURE`") + return diag.FromErr(errors.New("`vnet_name` must be set when `provider_name` is `AZURE`")) } peerRequest.AtlasCIDRBlock = atlasCidrBlock.(string) @@ -238,24 +240,24 @@ func resourceMongoDBAtlasNetworkPeeringCreate(d *schema.ResourceData, meta inter peerRequest.VNetName = vnetName.(string) } - peer, _, err := conn.Peers.Create(context.Background(), projectID, peerRequest) + peer, _, err := conn.Peers.Create(ctx, projectID, peerRequest) if err != nil { - return fmt.Errorf(errorPeersCreate, err) + return diag.FromErr(fmt.Errorf(errorPeersCreate, err)) } stateConf := &resource.StateChangeConf{ Pending: []string{"INITIATING", "FINALIZING", "ADDING_PEER", "WAITING_FOR_USER"}, Target: []string{"AVAILABLE", "PENDING_ACCEPTANCE"}, - Refresh: resourceNetworkPeeringRefreshFunc(peer.ID, projectID, peerRequest.ContainerID, conn), + Refresh: resourceNetworkPeeringRefreshFunc(ctx, peer.ID, projectID, peerRequest.ContainerID, conn), Timeout: 1 * time.Hour, MinTimeout: 10 * time.Second, Delay: 30 * time.Second, } // Wait, catching any errors - _, err = stateConf.WaitForState() + _, err = stateConf.WaitForStateContext(ctx) if err != nil { - return fmt.Errorf(errorPeersCreate, err) + return diag.FromErr(fmt.Errorf(errorPeersCreate, err)) } d.SetId(encodeStateID(map[string]string{ @@ -264,10 +266,10 @@ func resourceMongoDBAtlasNetworkPeeringCreate(d *schema.ResourceData, meta inter "provider_name": providerName, })) - return resourceMongoDBAtlasNetworkPeeringRead(d, meta) + return resourceMongoDBAtlasNetworkPeeringRead(ctx, d, meta) } -func resourceMongoDBAtlasNetworkPeeringRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasNetworkPeeringRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -275,14 +277,14 @@ func resourceMongoDBAtlasNetworkPeeringRead(d *schema.ResourceData, meta interfa peerID := ids["peer_id"] providerName := ids["provider_name"] - peer, resp, err := conn.Peers.Get(context.Background(), projectID, peerID) + peer, resp, err := conn.Peers.Get(ctx, projectID, peerID) if err != nil { if resp != nil && resp.StatusCode == http.StatusNotFound { d.SetId("") return nil } - return fmt.Errorf(errorPeersRead, peerID, err) + return diag.FromErr(fmt.Errorf(errorPeersRead, peerID, err)) } /* This fix the bug https://github.com/mongodb/terraform-provider-mongodbatlas/issues/53 @@ -293,83 +295,83 @@ func resourceMongoDBAtlasNetworkPeeringRead(d *schema.ResourceData, meta interfa if peer.AccepterRegionName != "" { acepterRegionName = peer.AccepterRegionName } else { - container, _, err := conn.Containers.Get(context.Background(), projectID, peer.ContainerID) + container, _, err := conn.Containers.Get(ctx, projectID, peer.ContainerID) if err != nil { - return err + return diag.FromErr(err) } acepterRegionName = strings.ToLower(strings.ReplaceAll(container.RegionName, "_", "-")) } if err := d.Set("accepter_region_name", acepterRegionName); err != nil { - return fmt.Errorf("error setting `accepter_region_name` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `accepter_region_name` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("aws_account_id", peer.AWSAccountID); err != nil { - return fmt.Errorf("error setting `aws_account_id` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `aws_account_id` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("route_table_cidr_block", peer.RouteTableCIDRBlock); err != nil { - return fmt.Errorf("error setting `route_table_cidr_block` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `route_table_cidr_block` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("vpc_id", peer.VpcID); err != nil { - return fmt.Errorf("error setting `vpc_id` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `vpc_id` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("connection_id", peer.ConnectionID); err != nil { - return fmt.Errorf("error setting `connection_id` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `connection_id` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("error_state_name", peer.ErrorStateName); err != nil { - return fmt.Errorf("error setting `error_state_name` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `error_state_name` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("atlas_id", peer.ID); err != nil { - return fmt.Errorf("error setting `atlas_id` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `atlas_id` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("status_name", peer.StatusName); err != nil { - return fmt.Errorf("error setting `status_name` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `status_name` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("azure_directory_id", peer.AzureDirectoryID); err != nil { - return fmt.Errorf("error setting `azure_directory_id` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `azure_directory_id` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("azure_subscription_id", peer.AzureSubscriptionID); err != nil { - return fmt.Errorf("error setting `azure_subscription_id` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `azure_subscription_id` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("resource_group_name", peer.ResourceGroupName); err != nil { - return fmt.Errorf("error setting `resource_group_name` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `resource_group_name` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("vnet_name", peer.VNetName); err != nil { - return fmt.Errorf("error setting `vnet_name` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `vnet_name` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("error_state", peer.ErrorState); err != nil { - return fmt.Errorf("error setting `error_state` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `error_state` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("status", peer.Status); err != nil { - return fmt.Errorf("error setting `status` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `status` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("gcp_project_id", peer.GCPProjectID); err != nil { - return fmt.Errorf("error setting `gcp_project_id` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `gcp_project_id` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("network_name", peer.NetworkName); err != nil { - return fmt.Errorf("error setting `network_name` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `network_name` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("error_message", peer.ErrorMessage); err != nil { - return fmt.Errorf("error setting `error_message` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `error_message` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("peer_id", peer.ID); err != nil { - return fmt.Errorf("error setting `peer_id` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `peer_id` for Network Peering Connection (%s): %s", peerID, err)) } // If provider name is GCP we need to get the parameters to configure the the reciprocal connection @@ -377,24 +379,24 @@ func resourceMongoDBAtlasNetworkPeeringRead(d *schema.ResourceData, meta interfa container := &matlas.Container{} if strings.EqualFold(providerName, "GCP") { - container, _, err = conn.Containers.Get(context.Background(), projectID, peer.ContainerID) + container, _, err = conn.Containers.Get(ctx, projectID, peer.ContainerID) if err != nil { - return err + return diag.FromErr(err) } } if err := d.Set("atlas_gcp_project_id", container.GCPProjectID); err != nil { - return fmt.Errorf("error setting `atlas_gcp_project_id` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `atlas_gcp_project_id` for Network Peering Connection (%s): %s", peerID, err)) } if err := d.Set("atlas_vpc_name", container.NetworkName); err != nil { - return fmt.Errorf("error setting `atlas_vpc_name` for Network Peering Connection (%s): %s", peerID, err) + return diag.FromErr(fmt.Errorf("error setting `atlas_vpc_name` for Network Peering Connection (%s): %s", peerID, err)) } return nil } -func resourceMongoDBAtlasNetworkPeeringUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasNetworkPeeringUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -438,40 +440,40 @@ func resourceMongoDBAtlasNetworkPeeringUpdate(d *schema.ResourceData, meta inter // Has changes if !reflect.DeepEqual(peer, matlas.Peer{}) { - _, _, err := conn.Peers.Update(context.Background(), projectID, peerID, peer) + _, _, err := conn.Peers.Update(ctx, projectID, peerID, peer) if err != nil { - return fmt.Errorf(errorPeersUpdate, peerID, err) + return diag.FromErr(fmt.Errorf(errorPeersUpdate, peerID, err)) } } stateConf := &resource.StateChangeConf{ Pending: []string{"INITIATING", "FINALIZING", "ADDING_PEER", "WAITING_FOR_USER"}, Target: []string{"AVAILABLE", "PENDING_ACCEPTANCE"}, - Refresh: resourceNetworkPeeringRefreshFunc(peerID, projectID, "", conn), + Refresh: resourceNetworkPeeringRefreshFunc(ctx, peerID, projectID, "", conn), Timeout: d.Timeout(schema.TimeoutCreate), MinTimeout: 30 * time.Second, Delay: 1 * time.Minute, } // Wait, catching any errors - _, err := stateConf.WaitForState() + _, err := stateConf.WaitForStateContext(ctx) if err != nil { - return fmt.Errorf(errorPeersCreate, err) + return diag.FromErr(fmt.Errorf(errorPeersCreate, err)) } - return resourceMongoDBAtlasNetworkPeeringRead(d, meta) + return resourceMongoDBAtlasNetworkPeeringRead(ctx, d, meta) } -func resourceMongoDBAtlasNetworkPeeringDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasNetworkPeeringDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) projectID := ids["project_id"] peerID := ids["peer_id"] - _, err := conn.Peers.Delete(context.Background(), projectID, peerID) + _, err := conn.Peers.Delete(ctx, projectID, peerID) if err != nil { - return fmt.Errorf(errorPeersDelete, peerID, err) + return diag.FromErr(fmt.Errorf(errorPeersDelete, peerID, err)) } log.Println("[INFO] Waiting for MongoDB Network Peering Connection to be destroyed") @@ -479,22 +481,22 @@ func resourceMongoDBAtlasNetworkPeeringDelete(d *schema.ResourceData, meta inter stateConf := &resource.StateChangeConf{ Pending: []string{"AVAILABLE", "INITIATING", "PENDING_ACCEPTANCE", "FINALIZING", "ADDING_PEER", "WAITING_FOR_USER", "TERMINATING", "DELETING"}, Target: []string{"DELETED"}, - Refresh: resourceNetworkPeeringRefreshFunc(peerID, projectID, "", conn), + Refresh: resourceNetworkPeeringRefreshFunc(ctx, peerID, projectID, "", conn), Timeout: 1 * time.Hour, MinTimeout: 30 * time.Second, Delay: 10 * time.Second, // Wait 10 secs before starting } // Wait, catching any errors - _, err = stateConf.WaitForState() + _, err = stateConf.WaitForStateContext(ctx) if err != nil { - return fmt.Errorf(errorPeersDelete, peerID, err) + return diag.FromErr(fmt.Errorf(errorPeersDelete, peerID, err)) } return nil } -func resourceMongoDBAtlasNetworkPeeringImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasNetworkPeeringImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas parts := strings.SplitN(d.Id(), "-", 3) @@ -506,7 +508,7 @@ func resourceMongoDBAtlasNetworkPeeringImportState(d *schema.ResourceData, meta peerID := parts[1] providerName := parts[2] - peer, _, err := conn.Peers.Get(context.Background(), projectID, peerID) + peer, _, err := conn.Peers.Get(ctx, projectID, peerID) if err != nil { return nil, fmt.Errorf("couldn't import peer %s in project %s, error: %s", peerID, projectID, err) } @@ -532,9 +534,9 @@ func resourceMongoDBAtlasNetworkPeeringImportState(d *schema.ResourceData, meta return []*schema.ResourceData{d}, nil } -func resourceNetworkPeeringRefreshFunc(peerID, projectID, containerID string, client *matlas.Client) resource.StateRefreshFunc { +func resourceNetworkPeeringRefreshFunc(ctx context.Context, peerID, projectID, containerID string, client *matlas.Client) resource.StateRefreshFunc { return func() (interface{}, string, error) { - c, resp, err := client.Peers.Get(context.Background(), projectID, peerID) + c, resp, err := client.Peers.Get(ctx, projectID, peerID) if err != nil { if resp != nil && resp.StatusCode == 404 { return "", "DELETED", nil @@ -558,7 +560,7 @@ func resourceNetworkPeeringRefreshFunc(peerID, projectID, containerID string, cl * is right, and the Mongo parameters used on the Google side to configure the reciprocal connection * are now available. */ if status == "WAITING_FOR_USER" { - container, _, err := client.Containers.Get(context.Background(), projectID, containerID) + container, _, err := client.Containers.Get(ctx, projectID, containerID) if err != nil { return nil, "", fmt.Errorf(errorContainerRead, containerID, err) diff --git a/mongodbatlas/resource_mongodbatlas_network_peering_test.go b/mongodbatlas/resource_mongodbatlas_network_peering_test.go index 9ce5c93a47..7d3f720098 100644 --- a/mongodbatlas/resource_mongodbatlas_network_peering_test.go +++ b/mongodbatlas/resource_mongodbatlas_network_peering_test.go @@ -8,9 +8,9 @@ import ( "strings" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -28,9 +28,9 @@ func TestAccResourceMongoDBAtlasNetworkPeering_basicAWS(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkPeeringEnvAWS(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, + PreCheck: func() { testAccPreCheck(t); checkPeeringEnvAWS(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasNetworkPeeringConfigAWS(projectID, providerName, vpcID, awsAccountID, vpcCIDRBlock, awsRegion), @@ -68,9 +68,9 @@ func TestAccResourceMongoDBAtlasNetworkPeering_basicAzure(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkPeeringEnvAzure(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, + PreCheck: func() { testAccPreCheck(t); checkPeeringEnvAzure(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasNetworkPeeringConfigAzure(projectID, providerName, directoryID, subscriptionID, resourceGroupName, vNetName), @@ -106,9 +106,9 @@ func TestAccResourceMongoDBAtlasNetworkPeering_basicGCP(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkPeeringEnvGCP(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, + PreCheck: func() { testAccPreCheck(t); checkPeeringEnvGCP(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasNetworkPeeringConfigGCP(projectID, providerName, gcpProjectID, networkName), @@ -158,8 +158,8 @@ func TestAccResourceMongoDBAtlasNetworkPeering_AWSDifferentRegionName(t *testing } }() }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasNetworkPeeringConfigAWSWithDifferentRegionName(projectID, providerName, containerRegion, peerRegion, vpcCIDRBlock, vpcID, awsAccountID), diff --git a/mongodbatlas/resource_mongodbatlas_online_archive.go b/mongodbatlas/resource_mongodbatlas_online_archive.go index bdb0cba184..dfafabec9c 100644 --- a/mongodbatlas/resource_mongodbatlas_online_archive.go +++ b/mongodbatlas/resource_mongodbatlas_online_archive.go @@ -9,9 +9,10 @@ import ( "strings" "time" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/mwielbut/pointy" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -23,13 +24,13 @@ const ( func resourceMongoDBAtlasOnlineArchive() *schema.Resource { return &schema.Resource{ - Schema: getMongoDBAtlasOnlineArchiveSchema(), - Create: resourceMongoDBAtlasOnlineArchiveCreate, - Read: resourceMongoDBAtlasOnlineArchiveRead, - Delete: resourceMongoDBAtlasOnlineArchiveDelete, - Update: resourceMongoDBAtlasOnlineArchiveUpdate, + Schema: getMongoDBAtlasOnlineArchiveSchema(), + CreateContext: resourceMongoDBAtlasOnlineArchiveCreate, + ReadContext: resourceMongoDBAtlasOnlineArchiveRead, + DeleteContext: resourceMongoDBAtlasOnlineArchiveDelete, + UpdateContext: resourceMongoDBAtlasOnlineArchiveUpdate, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasOnlineArchiveImportState, + StateContext: resourceMongoDBAtlasOnlineArchiveImportState, }, } } @@ -132,17 +133,17 @@ func getMongoDBAtlasOnlineArchiveSchema() map[string]*schema.Schema { } } -func resourceMongoDBAtlasOnlineArchiveCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasOnlineArchiveCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) clusterName := d.Get("cluster_name").(string) inputRequest := mapToArchivePayload(d) - outputRequest, _, err := conn.OnlineArchives.Create(context.Background(), projectID, clusterName, &inputRequest) + outputRequest, _, err := conn.OnlineArchives.Create(ctx, projectID, clusterName, &inputRequest) if err != nil { - return fmt.Errorf(errorOnlineArchivesCreate, err) + return diag.FromErr(fmt.Errorf(errorOnlineArchivesCreate, err)) } d.SetId(encodeStateID(map[string]string{ @@ -155,25 +156,25 @@ func resourceMongoDBAtlasOnlineArchiveCreate(d *schema.ResourceData, meta interf stateConf := &resource.StateChangeConf{ Pending: []string{"PENDING", "ARCHIVING", "PAUSING", "PAUSED", "ORPHANED", "REPEATING"}, Target: []string{"IDLE", "ACTIVE"}, - Refresh: resourceOnlineRefreshFunc(projectID, outputRequest.ClusterName, outputRequest.ID, conn), + Refresh: resourceOnlineRefreshFunc(ctx, projectID, outputRequest.ClusterName, outputRequest.ID, conn), Timeout: 3 * time.Hour, MinTimeout: 1 * time.Minute, Delay: 3 * time.Minute, } // Wait, catching any errors - _, err := stateConf.WaitForState() + _, err := stateConf.WaitForStateContext(ctx) if err != nil { - return fmt.Errorf("error updating the online archive status %s for cluster %s", outputRequest.ClusterName, outputRequest.ID) + return diag.FromErr(fmt.Errorf("error updating the online archive status %s for cluster %s", outputRequest.ClusterName, outputRequest.ID)) } } - return resourceMongoDBAtlasOnlineArchiveRead(d, meta) + return resourceMongoDBAtlasOnlineArchiveRead(ctx, d, meta) } -func resourceOnlineRefreshFunc(projectID, clusterName, archiveID string, client *matlas.Client) resource.StateRefreshFunc { +func resourceOnlineRefreshFunc(ctx context.Context, projectID, clusterName, archiveID string, client *matlas.Client) resource.StateRefreshFunc { return func() (interface{}, string, error) { - c, resp, err := client.OnlineArchives.Get(context.Background(), projectID, clusterName, archiveID) + c, resp, err := client.OnlineArchives.Get(ctx, projectID, clusterName, archiveID) if err != nil && strings.Contains(err.Error(), "reset by peer") { return nil, "REPEATING", nil @@ -199,7 +200,7 @@ func resourceOnlineRefreshFunc(projectID, clusterName, archiveID string, client } } -func resourceMongoDBAtlasOnlineArchiveRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasOnlineArchiveRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // getting the atlas id conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -214,28 +215,27 @@ func resourceMongoDBAtlasOnlineArchiveRead(d *schema.ResourceData, meta interfac d.SetId("") return nil } - - return fmt.Errorf("error MongoDB Atlas Online Archive with id %s, read error %s", atlasID, err.Error()) + return diag.FromErr(fmt.Errorf("error MongoDB Atlas Online Archive with id %s, read error %s", atlasID, err.Error())) } mapValues := fromOnlineArchiveToMapInCreate(onlineArchive) for key, val := range mapValues { if err := d.Set(key, val); err != nil { - return fmt.Errorf("error MongoDB Atlas Online Archive with id %s, read error %s", atlasID, err.Error()) + return diag.FromErr(fmt.Errorf("error MongoDB Atlas Online Archive with id %s, read error %s", atlasID, err.Error())) } } return nil } -func resourceMongoDBAtlasOnlineArchiveDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasOnlineArchiveDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) atlasID := ids["archive_id"] projectID := ids["project_id"] clusterName := ids["cluster_name"] - _, err := conn.OnlineArchives.Delete(context.Background(), projectID, clusterName, atlasID) + _, err := conn.OnlineArchives.Delete(ctx, projectID, clusterName, atlasID) if err != nil { alreadyDeleted := strings.Contains(err.Error(), "404") && !d.IsNewResource() @@ -243,12 +243,12 @@ func resourceMongoDBAtlasOnlineArchiveDelete(d *schema.ResourceData, meta interf return nil } - return fmt.Errorf(errorOnlineArchivesDelete, err, atlasID) + return diag.FromErr(fmt.Errorf(errorOnlineArchivesDelete, err, atlasID)) } return nil } -func resourceMongoDBAtlasOnlineArchiveImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasOnlineArchiveImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas parts := strings.Split(d.Id(), "-") @@ -266,7 +266,7 @@ func resourceMongoDBAtlasOnlineArchiveImportState(d *schema.ResourceData, meta i projectID, clusterName, atlasID = parts[0], parts[1], parts[2] } - outOnlineArchive, _, err := conn.OnlineArchives.Get(context.Background(), projectID, clusterName, atlasID) + outOnlineArchive, _, err := conn.OnlineArchives.Get(ctx, projectID, clusterName, atlasID) if err != nil { return nil, fmt.Errorf("could not import Online Archive %s in project %s, error %s", atlasID, projectID, err.Error()) @@ -326,7 +326,7 @@ func mapToArchivePayload(d *schema.ResourceData) matlas.OnlineArchive { return requestInput } -func resourceMongoDBAtlasOnlineArchiveUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasOnlineArchiveUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -355,13 +355,13 @@ func resourceMongoDBAtlasOnlineArchiveUpdate(d *schema.ResourceData, meta interf request.Criteria = mapCriteria(d) } - _, _, err := conn.OnlineArchives.Update(context.Background(), projectID, clusterName, atlasID, &request) + _, _, err := conn.OnlineArchives.Update(ctx, projectID, clusterName, atlasID, &request) if err != nil { - return fmt.Errorf("error updating Mongo Online Archive id: %s %s", atlasID, err.Error()) + return diag.FromErr(fmt.Errorf("error updating Mongo Online Archive id: %s %s", atlasID, err.Error())) } - return resourceMongoDBAtlasOnlineArchiveRead(d, meta) + return resourceMongoDBAtlasOnlineArchiveRead(ctx, d, meta) } func fromOnlineArchiveToMap(in *matlas.OnlineArchive) map[string]interface{} { diff --git a/mongodbatlas/resource_mongodbatlas_online_archive_test.go b/mongodbatlas/resource_mongodbatlas_online_archive_test.go index 393873ad92..fda2801389 100644 --- a/mongodbatlas/resource_mongodbatlas_online_archive_test.go +++ b/mongodbatlas/resource_mongodbatlas_online_archive_test.go @@ -8,9 +8,9 @@ import ( "testing" "time" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -49,8 +49,8 @@ const ( onlineArchiveConfig = ` resource "mongodbatlas_online_archive" "users_archive" { - project_id = "%s" - cluster_name = "%s" + project_id = mongodbatlas_cluster.online_archive_test.project_id + cluster_name = mongodbatlas_cluster.online_archive_test.name coll_name = "listingsAndReviews" db_name = "sample_airbnb" @@ -97,12 +97,11 @@ func TestAccResourceMongoDBAtlasOnlineArchive(t *testing.T) { ) initialConfig := fmt.Sprintf(clusterConfig, projectID, name, "false") - updateConfig := fmt.Sprintf(onlineArchiveConfig, projectID, name) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasClusterDestroy, Steps: []resource.TestStep{ { Config: initialConfig, @@ -111,7 +110,7 @@ func TestAccResourceMongoDBAtlasOnlineArchive(t *testing.T) { ), }, { - Config: initialConfig + updateConfig, + Config: initialConfig + onlineArchiveConfig, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(onlineArchiveResourceName, "state"), resource.TestCheckResourceAttrSet(onlineArchiveResourceName, "archive_id"), diff --git a/mongodbatlas/resource_mongodbatlas_private_ip_mode.go b/mongodbatlas/resource_mongodbatlas_private_ip_mode.go index 04301a899e..b72ea102f6 100644 --- a/mongodbatlas/resource_mongodbatlas_private_ip_mode.go +++ b/mongodbatlas/resource_mongodbatlas_private_ip_mode.go @@ -6,7 +6,9 @@ import ( "log" "net/http" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/mwielbut/pointy" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -19,12 +21,12 @@ const ( func resourceMongoDBAtlasPrivateIPMode() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasPrivateIPModeCreate, - Read: resourceMongoDBAtlasPrivateIPModeRead, - Update: resourceMongoDBAtlasPrivateIPModeCreate, - Delete: resourceMongoDBAtlasPrivateIPModeDelete, + CreateContext: resourceMongoDBAtlasPrivateIPModeCreate, + ReadContext: resourceMongoDBAtlasPrivateIPModeRead, + UpdateContext: resourceMongoDBAtlasPrivateIPModeCreate, + DeleteContext: resourceMongoDBAtlasPrivateIPModeDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasPrivateIPModeImportState, + StateContext: resourceMongoDBAtlasPrivateIPModeImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -40,7 +42,7 @@ func resourceMongoDBAtlasPrivateIPMode() *schema.Resource { } } -func resourceMongoDBAtlasPrivateIPModeCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasPrivateIPModeCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) @@ -50,40 +52,40 @@ func resourceMongoDBAtlasPrivateIPModeCreate(d *schema.ResourceData, meta interf Enabled: pointy.Bool(d.Get("enabled").(bool)), } - _, _, err := conn.PrivateIPMode.Update(context.Background(), projectID, privateIPModeRequest) + _, _, err := conn.PrivateIPMode.Update(ctx, projectID, privateIPModeRequest) if err != nil { - return fmt.Errorf(errorPrivateIPModeCreate, err) + return diag.FromErr(fmt.Errorf(errorPrivateIPModeCreate, err)) } d.SetId(projectID) - return resourceMongoDBAtlasPrivateIPModeRead(d, meta) + return resourceMongoDBAtlasPrivateIPModeRead(ctx, d, meta) } -func resourceMongoDBAtlasPrivateIPModeRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasPrivateIPModeRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Id() - privateIPMode, resp, err := conn.PrivateIPMode.Get(context.Background(), projectID) + privateIPMode, resp, err := conn.PrivateIPMode.Get(ctx, projectID) if err != nil { if resp != nil && resp.StatusCode == http.StatusNotFound { d.SetId("") return nil } - return fmt.Errorf(errorPrivateIPModeRead, projectID, err) + return diag.FromErr(fmt.Errorf(errorPrivateIPModeRead, projectID, err)) } if err := d.Set("enabled", privateIPMode.Enabled); err != nil { - return fmt.Errorf(errorPrivateIPModeRead, projectID, err) + return diag.FromErr(fmt.Errorf(errorPrivateIPModeRead, projectID, err)) } return nil } -func resourceMongoDBAtlasPrivateIPModeDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasPrivateIPModeDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas projectID := d.Id() @@ -93,16 +95,16 @@ func resourceMongoDBAtlasPrivateIPModeDelete(d *schema.ResourceData, meta interf Enabled: pointy.Bool(false), } - _, _, err := conn.PrivateIPMode.Update(context.Background(), projectID, privateIPModeRequest) + _, _, err := conn.PrivateIPMode.Update(ctx, projectID, privateIPModeRequest) if err != nil { - return fmt.Errorf(errorPrivateIPModeDelete, projectID, err) + return diag.FromErr(fmt.Errorf(errorPrivateIPModeDelete, projectID, err)) } return nil } -func resourceMongoDBAtlasPrivateIPModeImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasPrivateIPModeImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { if err := d.Set("project_id", d.Id()); err != nil { log.Printf("[WARN] Error setting project_id for private IP Mode: %s", err) } diff --git a/mongodbatlas/resource_mongodbatlas_private_ip_mode_test.go b/mongodbatlas/resource_mongodbatlas_private_ip_mode_test.go index 877b629b1b..42d5760b2b 100644 --- a/mongodbatlas/resource_mongodbatlas_private_ip_mode_test.go +++ b/mongodbatlas/resource_mongodbatlas_private_ip_mode_test.go @@ -7,8 +7,8 @@ import ( "strconv" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/mwielbut/pointy" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -21,9 +21,9 @@ func TestAccResourcePrivateIPMode_basic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckPrivateIPModeDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckPrivateIPModeDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasPrivateIPModeConfig(projectID), diff --git a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint.go b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint.go index d8cc4ea96e..ab5ac32d62 100644 --- a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint.go +++ b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint.go @@ -9,9 +9,11 @@ import ( "strings" "time" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -24,11 +26,11 @@ const ( func resourceMongoDBAtlasPrivateLinkEndpoint() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasPrivateLinkEndpointCreate, - Read: resourceMongoDBAtlasPrivateLinkEndpointRead, - Delete: resourceMongoDBAtlasPrivateLinkEndpointDelete, + CreateContext: resourceMongoDBAtlasPrivateLinkEndpointCreate, + ReadContext: resourceMongoDBAtlasPrivateLinkEndpointRead, + DeleteContext: resourceMongoDBAtlasPrivateLinkEndpointDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasPrivateLinkEndpointImportState, + StateContext: resourceMongoDBAtlasPrivateLinkEndpointImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -89,7 +91,7 @@ func resourceMongoDBAtlasPrivateLinkEndpoint() *schema.Resource { } } -func resourceMongoDBAtlasPrivateLinkEndpointCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasPrivateLinkEndpointCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) providerName := d.Get("provider_name").(string) @@ -100,24 +102,24 @@ func resourceMongoDBAtlasPrivateLinkEndpointCreate(d *schema.ResourceData, meta Region: region, } - privateEndpointConn, _, err := conn.PrivateEndpoints.Create(context.Background(), projectID, request) + privateEndpointConn, _, err := conn.PrivateEndpoints.Create(ctx, projectID, request) if err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsCreate, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsCreate, err)) } stateConf := &resource.StateChangeConf{ Pending: []string{"INITIATING", "DELETING"}, Target: []string{"WAITING_FOR_USER", "FAILED", "DELETED", "AVAILABLE"}, - Refresh: resourcePrivateLinkEndpointRefreshFunc(conn, projectID, providerName, privateEndpointConn.ID), + Refresh: resourcePrivateLinkEndpointRefreshFunc(ctx, conn, projectID, providerName, privateEndpointConn.ID), Timeout: 1 * time.Hour, MinTimeout: 5 * time.Second, Delay: 3 * time.Second, } // Wait, catching any errors - _, err = stateConf.WaitForState() + _, err = stateConf.WaitForStateContext(ctx) if err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsCreate, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsCreate, err)) } d.SetId(encodeStateID(map[string]string{ @@ -127,10 +129,10 @@ func resourceMongoDBAtlasPrivateLinkEndpointCreate(d *schema.ResourceData, meta "region": region, })) - return resourceMongoDBAtlasPrivateLinkEndpointRead(d, meta) + return resourceMongoDBAtlasPrivateLinkEndpointRead(ctx, d, meta) } -func resourceMongoDBAtlasPrivateLinkEndpointRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasPrivateLinkEndpointRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -146,53 +148,53 @@ func resourceMongoDBAtlasPrivateLinkEndpointRead(d *schema.ResourceData, meta in return nil } - return fmt.Errorf(errorPrivateLinkEndpointsRead, privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsRead, privateLinkID, err)) } if err := d.Set("private_link_id", privateEndpoint.ID); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "private_link_id", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "private_link_id", privateLinkID, err)) } if err := d.Set("endpoint_service_name", privateEndpoint.EndpointServiceName); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "endpoint_service_name", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "endpoint_service_name", privateLinkID, err)) } if err := d.Set("error_message", privateEndpoint.ErrorMessage); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "error_message", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "error_message", privateLinkID, err)) } if err := d.Set("interface_endpoints", privateEndpoint.InterfaceEndpoints); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "interface_endpoints", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "interface_endpoints", privateLinkID, err)) } if err := d.Set("private_endpoints", privateEndpoint.PrivateEndpoints); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "interface_endpoints", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "interface_endpoints", privateLinkID, err)) } if err := d.Set("private_link_service_name", privateEndpoint.PrivateLinkServiceName); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "interface_endpoints", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "interface_endpoints", privateLinkID, err)) } if err := d.Set("private_link_service_resource_id", privateEndpoint.PrivateLinkServiceResourceID); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "interface_endpoints", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "interface_endpoints", privateLinkID, err)) } if err := d.Set("status", privateEndpoint.Status); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "status", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "status", privateLinkID, err)) } if err := d.Set("provider_name", providerName); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "provider_name", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "provider_name", privateLinkID, err)) } if err := d.Set("region", region); err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsSetting, "region", privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsSetting, "region", privateLinkID, err)) } return nil } -func resourceMongoDBAtlasPrivateLinkEndpointDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasPrivateLinkEndpointDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -200,13 +202,13 @@ func resourceMongoDBAtlasPrivateLinkEndpointDelete(d *schema.ResourceData, meta projectID := ids["project_id"] providerName := ids["provider_name"] - resp, err := conn.PrivateEndpoints.Delete(context.Background(), projectID, providerName, privateLinkID) + resp, err := conn.PrivateEndpoints.Delete(ctx, projectID, providerName, privateLinkID) if err != nil { if resp.Response.StatusCode == 404 { return nil } - return fmt.Errorf(errorPrivateLinkEndpointsDelete, privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsDelete, privateLinkID, err)) } log.Println("[INFO] Waiting for MongoDB Private Endpoints Connection to be destroyed") @@ -214,21 +216,21 @@ func resourceMongoDBAtlasPrivateLinkEndpointDelete(d *schema.ResourceData, meta stateConf := &resource.StateChangeConf{ Pending: []string{"DELETING"}, Target: []string{"DELETED", "FAILED"}, - Refresh: resourcePrivateLinkEndpointRefreshFunc(conn, projectID, providerName, privateLinkID), + Refresh: resourcePrivateLinkEndpointRefreshFunc(ctx, conn, projectID, providerName, privateLinkID), Timeout: 10 * time.Minute, MinTimeout: 5 * time.Second, Delay: 3 * time.Second, } // Wait, catching any errors - _, err = stateConf.WaitForState() + _, err = stateConf.WaitForStateContext(ctx) if err != nil { - return fmt.Errorf(errorPrivateLinkEndpointsDelete, privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorPrivateLinkEndpointsDelete, privateLinkID, err)) } return nil } -func resourceMongoDBAtlasPrivateLinkEndpointImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasPrivateLinkEndpointImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas parts := strings.Split(d.Id(), "-") @@ -244,7 +246,7 @@ func resourceMongoDBAtlasPrivateLinkEndpointImportState(d *schema.ResourceData, region = fmt.Sprintf("%s-%s-%s", parts[3], parts[4], parts[5]) } - privateEndpoint, _, err := conn.PrivateEndpoints.Get(context.Background(), projectID, providerName, privateLinkID) + privateEndpoint, _, err := conn.PrivateEndpoints.Get(ctx, projectID, providerName, privateLinkID) if err != nil { return nil, fmt.Errorf("couldn't import peer %s in project %s with cloud provider name %s, error: %s", privateLinkID, projectID, providerName, err) } @@ -263,9 +265,9 @@ func resourceMongoDBAtlasPrivateLinkEndpointImportState(d *schema.ResourceData, return []*schema.ResourceData{d}, nil } -func resourcePrivateLinkEndpointRefreshFunc(client *matlas.Client, projectID, providerName, privateLinkID string) resource.StateRefreshFunc { +func resourcePrivateLinkEndpointRefreshFunc(ctx context.Context, client *matlas.Client, projectID, providerName, privateLinkID string) resource.StateRefreshFunc { return func() (interface{}, string, error) { - p, resp, err := client.PrivateEndpoints.Get(context.Background(), projectID, providerName, privateLinkID) + p, resp, err := client.PrivateEndpoints.Get(ctx, projectID, providerName, privateLinkID) if err != nil { if resp.Response.StatusCode == 404 { return "", "DELETED", nil diff --git a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service.go b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service.go index aaec9540a9..f436eabddc 100644 --- a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service.go +++ b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service.go @@ -8,9 +8,11 @@ import ( "strings" "time" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/spf13/cast" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -24,11 +26,11 @@ const ( func resourceMongoDBAtlasPrivateEndpointServiceLink() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasPrivateEndpointServiceLinkCreate, - Read: resourceMongoDBAtlasPrivateEndpointServiceLinkRead, - Delete: resourceMongoDBAtlasPrivateEndpointServiceLinkDelete, + CreateContext: resourceMongoDBAtlasPrivateEndpointServiceLinkCreate, + ReadContext: resourceMongoDBAtlasPrivateEndpointServiceLinkRead, + DeleteContext: resourceMongoDBAtlasPrivateEndpointServiceLinkDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasPrivateEndpointServiceLinkImportState, + StateContext: resourceMongoDBAtlasPrivateEndpointServiceLinkImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -89,7 +91,7 @@ func resourceMongoDBAtlasPrivateEndpointServiceLink() *schema.Resource { } } -func resourceMongoDBAtlasPrivateEndpointServiceLinkCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasPrivateEndpointServiceLinkCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) privateLinkID := getEncodedID(d.Get("private_link_id").(string), "private_link_id") @@ -101,23 +103,23 @@ func resourceMongoDBAtlasPrivateEndpointServiceLinkCreate(d *schema.ResourceData PrivateEndpointIPAddress: d.Get("private_endpoint_ip_address").(string), } - _, _, err := conn.PrivateEndpoints.AddOnePrivateEndpoint(context.Background(), projectID, providerName, privateLinkID, request) + _, _, err := conn.PrivateEndpoints.AddOnePrivateEndpoint(ctx, projectID, providerName, privateLinkID, request) if err != nil { - return fmt.Errorf(errorServiceEndpointAdd, providerName, privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorServiceEndpointAdd, providerName, privateLinkID, err)) } stateConf := &resource.StateChangeConf{ Pending: []string{"NONE", "INITIATING", "PENDING_ACCEPTANCE", "PENDING", "DELETING"}, Target: []string{"AVAILABLE", "REJECTED", "DELETED", "FAILED"}, - Refresh: resourceServiceEndpointRefreshFunc(conn, projectID, providerName, privateLinkID, endpointServiceID), + Refresh: resourceServiceEndpointRefreshFunc(ctx, conn, projectID, providerName, privateLinkID, endpointServiceID), Timeout: 1 * time.Hour, MinTimeout: 5 * time.Second, Delay: 3 * time.Second, } // Wait, catching any errors - _, err = stateConf.WaitForState() + _, err = stateConf.WaitForStateContext(ctx) if err != nil { - return fmt.Errorf(errorServiceEndpointAdd, endpointServiceID, privateLinkID, err) + return diag.FromErr(fmt.Errorf(errorServiceEndpointAdd, endpointServiceID, privateLinkID, err)) } d.SetId(encodeStateID(map[string]string{ @@ -127,10 +129,10 @@ func resourceMongoDBAtlasPrivateEndpointServiceLinkCreate(d *schema.ResourceData "provider_name": providerName, })) - return resourceMongoDBAtlasPrivateEndpointServiceLinkRead(d, meta) + return resourceMongoDBAtlasPrivateEndpointServiceLinkRead(ctx, d, meta) } -func resourceMongoDBAtlasPrivateEndpointServiceLinkRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasPrivateEndpointServiceLinkRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -146,49 +148,49 @@ func resourceMongoDBAtlasPrivateEndpointServiceLinkRead(d *schema.ResourceData, return nil } - return fmt.Errorf(errorServiceEndpointRead, endpointServiceID, err) + return diag.FromErr(fmt.Errorf(errorServiceEndpointRead, endpointServiceID, err)) } if err := d.Set("delete_requested", cast.ToBool(privateEndpoint.DeleteRequested)); err != nil { - return fmt.Errorf(errorEndpointSetting, "delete_requested", endpointServiceID, err) + return diag.FromErr(fmt.Errorf(errorEndpointSetting, "delete_requested", endpointServiceID, err)) } if err := d.Set("error_message", privateEndpoint.ErrorMessage); err != nil { - return fmt.Errorf(errorEndpointSetting, "error_message", endpointServiceID, err) + return diag.FromErr(fmt.Errorf(errorEndpointSetting, "error_message", endpointServiceID, err)) } if err := d.Set("aws_connection_status", privateEndpoint.AWSConnectionStatus); err != nil { - return fmt.Errorf(errorEndpointSetting, "aws_connection_status", endpointServiceID, err) + return diag.FromErr(fmt.Errorf(errorEndpointSetting, "aws_connection_status", endpointServiceID, err)) } if err := d.Set("azure_status", privateEndpoint.AzureStatus); err != nil { - return fmt.Errorf(errorEndpointSetting, "azure_status", endpointServiceID, err) + return diag.FromErr(fmt.Errorf(errorEndpointSetting, "azure_status", endpointServiceID, err)) } if err := d.Set("interface_endpoint_id", privateEndpoint.InterfaceEndpointID); err != nil { - return fmt.Errorf(errorEndpointSetting, "connection_status", endpointServiceID, err) + return diag.FromErr(fmt.Errorf(errorEndpointSetting, "connection_status", endpointServiceID, err)) } if err := d.Set("private_endpoint_connection_name", privateEndpoint.PrivateEndpointConnectionName); err != nil { - return fmt.Errorf(errorEndpointSetting, "connection_status", endpointServiceID, err) + return diag.FromErr(fmt.Errorf(errorEndpointSetting, "connection_status", endpointServiceID, err)) } if err := d.Set("private_endpoint_ip_address", privateEndpoint.PrivateEndpointIPAddress); err != nil { - return fmt.Errorf(errorEndpointSetting, "connection_status", endpointServiceID, err) + return diag.FromErr(fmt.Errorf(errorEndpointSetting, "connection_status", endpointServiceID, err)) } if err := d.Set("private_endpoint_resource_id", privateEndpoint.PrivateEndpointResourceID); err != nil { - return fmt.Errorf(errorEndpointSetting, "connection_status", endpointServiceID, err) + return diag.FromErr(fmt.Errorf(errorEndpointSetting, "connection_status", endpointServiceID, err)) } if err := d.Set("endpoint_service_id", endpointServiceID); err != nil { - return fmt.Errorf(errorEndpointSetting, "endpoint_service_id", endpointServiceID, err) + return diag.FromErr(fmt.Errorf(errorEndpointSetting, "endpoint_service_id", endpointServiceID, err)) } return nil } -func resourceMongoDBAtlasPrivateEndpointServiceLinkDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasPrivateEndpointServiceLinkDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -198,31 +200,31 @@ func resourceMongoDBAtlasPrivateEndpointServiceLinkDelete(d *schema.ResourceData providerName := ids["provider_name"] if endpointServiceID != "" { - _, err := conn.PrivateEndpoints.DeleteOnePrivateEndpoint(context.Background(), projectID, providerName, privateLinkID, endpointServiceID) + _, err := conn.PrivateEndpoints.DeleteOnePrivateEndpoint(ctx, projectID, providerName, privateLinkID, endpointServiceID) if err != nil { - return fmt.Errorf(errorEndpointDelete, endpointServiceID, err) + return diag.FromErr(fmt.Errorf(errorEndpointDelete, endpointServiceID, err)) } stateConf := &resource.StateChangeConf{ Pending: []string{"NONE", "PENDING_ACCEPTANCE", "PENDING", "DELETING", "INITIATING"}, Target: []string{"REJECTED", "DELETED", "FAILED"}, - Refresh: resourceServiceEndpointRefreshFunc(conn, projectID, providerName, privateLinkID, endpointServiceID), + Refresh: resourceServiceEndpointRefreshFunc(ctx, conn, projectID, providerName, privateLinkID, endpointServiceID), Timeout: 1 * time.Hour, MinTimeout: 5 * time.Second, Delay: 3 * time.Second, } // Wait, catching any errors - _, err = stateConf.WaitForState() + _, err = stateConf.WaitForStateContext(ctx) if err != nil { - return fmt.Errorf(errorEndpointDelete, endpointServiceID, err) + return diag.FromErr(fmt.Errorf(errorEndpointDelete, endpointServiceID, err)) } } return nil } -func resourceMongoDBAtlasPrivateEndpointServiceLinkImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasPrivateEndpointServiceLinkImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas parts := strings.SplitN(d.Id(), "--", 4) @@ -235,7 +237,7 @@ func resourceMongoDBAtlasPrivateEndpointServiceLinkImportState(d *schema.Resourc endpointServiceID := parts[2] providerName := parts[3] - _, _, err := conn.PrivateEndpoints.GetOnePrivateEndpoint(context.Background(), projectID, providerName, privateLinkID, endpointServiceID) + _, _, err := conn.PrivateEndpoints.GetOnePrivateEndpoint(ctx, projectID, providerName, privateLinkID, endpointServiceID) if err != nil { return nil, fmt.Errorf(errorServiceEndpointRead, endpointServiceID, err) } @@ -266,9 +268,9 @@ func resourceMongoDBAtlasPrivateEndpointServiceLinkImportState(d *schema.Resourc return []*schema.ResourceData{d}, nil } -func resourceServiceEndpointRefreshFunc(client *matlas.Client, projectID, providerName, privateLinkID, endpointServiceID string) resource.StateRefreshFunc { +func resourceServiceEndpointRefreshFunc(ctx context.Context, client *matlas.Client, projectID, providerName, privateLinkID, endpointServiceID string) resource.StateRefreshFunc { return func() (interface{}, string, error) { - i, resp, err := client.PrivateEndpoints.GetOnePrivateEndpoint(context.Background(), projectID, providerName, privateLinkID, endpointServiceID) + i, resp, err := client.PrivateEndpoints.GetOnePrivateEndpoint(ctx, projectID, providerName, privateLinkID, endpointServiceID) if err != nil { if resp != nil && resp.StatusCode == 404 { return "", "DELETED", nil diff --git a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_test.go b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_test.go index 228ac300b8..d0114af841 100644 --- a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_test.go +++ b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_test.go @@ -6,8 +6,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func TestAccResourceMongoDBAtlasPrivateLinkEndpointServiceAWS_Complete(t *testing.T) { @@ -27,9 +27,9 @@ func TestAccResourceMongoDBAtlasPrivateLinkEndpointServiceAWS_Complete(t *testin ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkAwsEnv(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointServiceDestroy, + PreCheck: func() { testAccPreCheck(t); checkAwsEnv(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointServiceDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasPrivateLinkEndpointServiceConfigCompleteAWS( @@ -63,9 +63,9 @@ func TestAccResourceMongoDBAtlasPrivateLinkEndpointServiceAWS_import(t *testing. ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkAwsEnv(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointServiceDestroy, + PreCheck: func() { testAccPreCheck(t); checkAwsEnv(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointServiceDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasPrivateLinkEndpointServiceConfigCompleteAWS( diff --git a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_test.go b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_test.go index bf61889a01..6b1bdae7bb 100644 --- a/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_test.go +++ b/mongodbatlas/resource_mongodbatlas_privatelink_endpoint_test.go @@ -6,8 +6,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func TestAccResourceMongoDBAtlasPrivateLinkEndpointAWS_basic(t *testing.T) { @@ -19,9 +19,9 @@ func TestAccResourceMongoDBAtlasPrivateLinkEndpointAWS_basic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasPrivateLinkEndpointConfigBasic(projectID, providerName, region), @@ -49,9 +49,9 @@ func TestAccResourceMongoDBAtlasPrivateLinkEndpointAWS_import(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasPrivateLinkEndpointConfigBasic(projectID, providerName, region), @@ -84,9 +84,9 @@ func TestAccResourceMongoDBAtlasPrivateLinkEndpointAzure_basic(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasPrivateLinkEndpointConfigBasic(projectID, providerName, region), @@ -114,9 +114,9 @@ func TestAccResourceMongoDBAtlasPrivateLinkEndpointAzure_import(t *testing.T) { ) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasPrivateLinkEndpointDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasPrivateLinkEndpointConfigBasic(projectID, providerName, region), diff --git a/mongodbatlas/resource_mongodbatlas_project.go b/mongodbatlas/resource_mongodbatlas_project.go index 7c0d6a50ed..f9084b5a69 100644 --- a/mongodbatlas/resource_mongodbatlas_project.go +++ b/mongodbatlas/resource_mongodbatlas_project.go @@ -5,7 +5,8 @@ import ( "fmt" "net/http" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -18,12 +19,12 @@ const ( func resourceMongoDBAtlasProject() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasProjectCreate, - Read: resourceMongoDBAtlasProjectRead, - Update: resourceMongoDBAtlasProjectUpdate, - Delete: resourceMongoDBAtlasProjectDelete, + CreateContext: resourceMongoDBAtlasProjectCreate, + ReadContext: resourceMongoDBAtlasProjectRead, + UpdateContext: resourceMongoDBAtlasProjectUpdate, + DeleteContext: resourceMongoDBAtlasProjectDelete, Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, + StateContext: schema.ImportStatePassthroughContext, }, Schema: map[string]*schema.Schema{ "name": { @@ -67,7 +68,7 @@ func resourceMongoDBAtlasProject() *schema.Resource { } } -func resourceMongoDBAtlasProjectCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasProjectCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get client connection. conn := meta.(*MongoDBClient).Atlas @@ -76,26 +77,26 @@ func resourceMongoDBAtlasProjectCreate(d *schema.ResourceData, meta interface{}) Name: d.Get("name").(string), } - project, _, err := conn.Projects.Create(context.Background(), projectReq) + project, _, err := conn.Projects.Create(ctx, projectReq) if err != nil { - return fmt.Errorf(errorProjectCreate, err) + return diag.FromErr(fmt.Errorf(errorProjectCreate, err)) } // Check if teams were set, if so we need to add the teams into the project if teams, ok := d.GetOk("teams"); ok { // adding the teams into the project - _, _, err := conn.Projects.AddTeamsToProject(context.Background(), project.ID, expandTeamsSet(teams.(*schema.Set))) + _, _, err := conn.Projects.AddTeamsToProject(ctx, project.ID, expandTeamsSet(teams.(*schema.Set))) if err != nil { - return fmt.Errorf("error adding teams into the project: %s", err) + return diag.FromErr(fmt.Errorf("error adding teams into the project: %s", err)) } } d.SetId(project.ID) - return resourceMongoDBAtlasProjectRead(d, meta) + return resourceMongoDBAtlasProjectRead(ctx, d, meta) } -func resourceMongoDBAtlasProjectRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasProjectRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Id() @@ -106,38 +107,38 @@ func resourceMongoDBAtlasProjectRead(d *schema.ResourceData, meta interface{}) e return nil } - return fmt.Errorf(errorProjectRead, projectID, err) + return diag.FromErr(fmt.Errorf(errorProjectRead, projectID, err)) } - teams, _, err := conn.Projects.GetProjectTeamsAssigned(context.Background(), projectID) + teams, _, err := conn.Projects.GetProjectTeamsAssigned(ctx, projectID) if err != nil { - return fmt.Errorf("error getting project's teams assigned (%s): %s", projectID, err) + return diag.FromErr(fmt.Errorf("error getting project's teams assigned (%s): %s", projectID, err)) } if err := d.Set("name", projectRes.Name); err != nil { - return fmt.Errorf(errorProjectSetting, `name`, projectID, err) + return diag.FromErr(fmt.Errorf(errorProjectSetting, `name`, projectID, err)) } if err := d.Set("org_id", projectRes.OrgID); err != nil { - return fmt.Errorf(errorProjectSetting, `org_id`, projectID, err) + return diag.FromErr(fmt.Errorf(errorProjectSetting, `org_id`, projectID, err)) } if err := d.Set("cluster_count", projectRes.ClusterCount); err != nil { - return fmt.Errorf(errorProjectSetting, `clusterCount`, projectID, err) + return diag.FromErr(fmt.Errorf(errorProjectSetting, `clusterCount`, projectID, err)) } if err := d.Set("created", projectRes.Created); err != nil { - return fmt.Errorf(errorProjectSetting, `created`, projectID, err) + return diag.FromErr(fmt.Errorf(errorProjectSetting, `created`, projectID, err)) } if err := d.Set("teams", flattenTeams(teams)); err != nil { - return fmt.Errorf(errorProjectSetting, `created`, projectID, err) + return diag.FromErr(fmt.Errorf(errorProjectSetting, `created`, projectID, err)) } return nil } -func resourceMongoDBAtlasProjectUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasProjectUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Id() @@ -147,9 +148,9 @@ func resourceMongoDBAtlasProjectUpdate(d *schema.ResourceData, meta interface{}) // adding new teans into the project if len(newTeams) > 0 { - _, _, err := conn.Projects.AddTeamsToProject(context.Background(), projectID, expandTeamsList(newTeams)) + _, _, err := conn.Projects.AddTeamsToProject(ctx, projectID, expandTeamsList(newTeams)) if err != nil { - return fmt.Errorf("error adding teams into the project(%s): %s", projectID, err) + return diag.FromErr(fmt.Errorf("error adding teams into the project(%s): %s", projectID, err)) } } @@ -157,9 +158,9 @@ func resourceMongoDBAtlasProjectUpdate(d *schema.ResourceData, meta interface{}) for _, team := range removedTeams { teamID := team.(map[string]interface{})["team_id"].(string) - _, err := conn.Teams.RemoveTeamFromProject(context.Background(), projectID, teamID) + _, err := conn.Teams.RemoveTeamFromProject(ctx, projectID, teamID) if err != nil { - return fmt.Errorf("error removing team(%s) from the project(%s): %s", teamID, projectID, err) + return diag.FromErr(fmt.Errorf("error removing team(%s) from the project(%s): %s", teamID, projectID, err)) } } @@ -167,27 +168,27 @@ func resourceMongoDBAtlasProjectUpdate(d *schema.ResourceData, meta interface{}) for _, t := range changedTeams { team := t.(map[string]interface{}) - _, _, err := conn.Teams.UpdateTeamRoles(context.Background(), projectID, team["team_id"].(string), + _, _, err := conn.Teams.UpdateTeamRoles(ctx, projectID, team["team_id"].(string), &matlas.TeamUpdateRoles{ RoleNames: expandStringList(team["role_names"].(*schema.Set).List()), }, ) if err != nil { - return fmt.Errorf("error updating role names for the team(%s): %s", team["team_id"], err) + return diag.FromErr(fmt.Errorf("error updating role names for the team(%s): %s", team["team_id"], err)) } } } - return resourceMongoDBAtlasProjectRead(d, meta) + return resourceMongoDBAtlasProjectRead(ctx, d, meta) } -func resourceMongoDBAtlasProjectDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasProjectDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Id() - _, err := conn.Projects.Delete(context.Background(), projectID) + _, err := conn.Projects.Delete(ctx, projectID) if err != nil { - return fmt.Errorf(errorProjectDelete, projectID, err) + return diag.FromErr(fmt.Errorf(errorProjectDelete, projectID, err)) } return nil diff --git a/mongodbatlas/resource_mongodbatlas_project_ip_access_list.go b/mongodbatlas/resource_mongodbatlas_project_ip_access_list.go index 2a7b701cd5..09a6c72a38 100644 --- a/mongodbatlas/resource_mongodbatlas_project_ip_access_list.go +++ b/mongodbatlas/resource_mongodbatlas_project_ip_access_list.go @@ -9,9 +9,10 @@ import ( "strings" "time" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -25,11 +26,11 @@ const ( func resourceMongoDBAtlasProjectIPAccessList() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasProjectIPAccessListCreate, - Read: resourceMongoDBAtlasProjectIPAccessListRead, - Delete: resourceMongoDBAtlasProjectIPAccessListDelete, + CreateContext: resourceMongoDBAtlasProjectIPAccessListCreate, + ReadContext: resourceMongoDBAtlasProjectIPAccessListRead, + DeleteContext: resourceMongoDBAtlasProjectIPAccessListDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasIPAccessListImportState, + StateContext: resourceMongoDBAtlasIPAccessListImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -94,7 +95,7 @@ func resourceMongoDBAtlasProjectIPAccessList() *schema.Resource { } } -func resourceMongoDBAtlasProjectIPAccessListCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasProjectIPAccessListCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) cidrBlock := d.Get("cidr_block").(string) @@ -102,14 +103,14 @@ func resourceMongoDBAtlasProjectIPAccessListCreate(d *schema.ResourceData, meta awsSecurityGroup := d.Get("aws_security_group").(string) if cidrBlock == "" && ipAddress == "" && awsSecurityGroup == "" { - return errors.New("cidr_block, ip_address or aws_security_group needs to contain a value") + return diag.FromErr(errors.New("cidr_block, ip_address or aws_security_group needs to contain a value")) } stateConf := &resource.StateChangeConf{ Pending: []string{"pending"}, Target: []string{"created", "failed"}, Refresh: func() (interface{}, string, error) { - accessList, _, err := conn.ProjectIPAccessList.Create(context.Background(), projectID, []*matlas.ProjectIPAccessList{ + accessList, _, err := conn.ProjectIPAccessList.Create(ctx, projectID, []*matlas.ProjectIPAccessList{ { AwsSecurityGroup: awsSecurityGroup, CIDRBlock: cidrBlock, @@ -148,9 +149,9 @@ func resourceMongoDBAtlasProjectIPAccessListCreate(d *schema.ResourceData, meta } // Wait, catching any errors - _, err := stateConf.WaitForState() + _, err := stateConf.WaitForStateContext(ctx) if err != nil { - return fmt.Errorf(errorAccessListCreate, err) + return diag.FromErr(fmt.Errorf(errorAccessListCreate, err)) } var entry string @@ -169,15 +170,15 @@ func resourceMongoDBAtlasProjectIPAccessListCreate(d *schema.ResourceData, meta "entry": entry, })) - return resourceMongoDBAtlasProjectIPAccessListRead(d, meta) + return resourceMongoDBAtlasProjectIPAccessListRead(ctx, d, meta) } -func resourceMongoDBAtlasProjectIPAccessListRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasProjectIPAccessListRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) - return resource.Retry(2*time.Minute, func() *resource.RetryError { - accessList, _, err := conn.ProjectIPAccessList.Get(context.Background(), ids["project_id"], ids["entry"]) + return diag.FromErr(resource.RetryContext(ctx, 2*time.Minute, func() *resource.RetryError { + accessList, _, err := conn.ProjectIPAccessList.Get(ctx, ids["project_id"], ids["entry"]) if err != nil { switch { case strings.Contains(fmt.Sprint(err), "500"): @@ -212,16 +213,16 @@ func resourceMongoDBAtlasProjectIPAccessListRead(d *schema.ResourceData, meta in } return nil - }) + })) } -func resourceMongoDBAtlasProjectIPAccessListDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasProjectIPAccessListDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { // Get the client connection. conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) - return resource.Retry(5*time.Minute, func() *resource.RetryError { - _, err := conn.ProjectIPAccessList.Delete(context.Background(), ids["project_id"], ids["entry"]) + return diag.FromErr(resource.RetryContext(ctx, 5*time.Minute, func() *resource.RetryError { + _, err := conn.ProjectIPAccessList.Delete(ctx, ids["project_id"], ids["entry"]) if err != nil { if strings.Contains(fmt.Sprint(err), "500") || strings.Contains(fmt.Sprint(err), "Unexpected error") || @@ -232,7 +233,7 @@ func resourceMongoDBAtlasProjectIPAccessListDelete(d *schema.ResourceData, meta return resource.NonRetryableError(fmt.Errorf(errorAccessListDelete, err)) } - entry, _, err := conn.ProjectIPAccessList.Get(context.Background(), ids["project_id"], ids["entry"]) + entry, _, err := conn.ProjectIPAccessList.Get(ctx, ids["project_id"], ids["entry"]) if err != nil { if strings.Contains(fmt.Sprint(err), "404") || strings.Contains(fmt.Sprint(err), "ATLAS_ACCESS_LIST_NOT_FOUND") { @@ -247,10 +248,10 @@ func resourceMongoDBAtlasProjectIPAccessListDelete(d *schema.ResourceData, meta } return nil - }) + })) } -func resourceMongoDBAtlasIPAccessListImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasIPAccessListImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas parts := strings.SplitN(d.Id(), "-", 2) @@ -261,7 +262,7 @@ func resourceMongoDBAtlasIPAccessListImportState(d *schema.ResourceData, meta in projectID := parts[0] entry := parts[1] - _, _, err := conn.ProjectIPAccessList.Get(context.Background(), projectID, entry) + _, _, err := conn.ProjectIPAccessList.Get(ctx, projectID, entry) if err != nil { return nil, fmt.Errorf("couldn't import entry access list %s in project %s, error: %s", entry, projectID, err) } diff --git a/mongodbatlas/resource_mongodbatlas_project_ip_access_list_test.go b/mongodbatlas/resource_mongodbatlas_project_ip_access_list_test.go index 6068894e6f..b73bccb779 100644 --- a/mongodbatlas/resource_mongodbatlas_project_ip_access_list_test.go +++ b/mongodbatlas/resource_mongodbatlas_project_ip_access_list_test.go @@ -6,9 +6,9 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) func TestAccResourceMongoDBAtlasProjectIPAccesslist_SettingIPAddress(t *testing.T) { @@ -21,9 +21,9 @@ func TestAccResourceMongoDBAtlasProjectIPAccesslist_SettingIPAddress(t *testing. updatedComment := fmt.Sprintf("TestAcc for ipAddress updated (%s)", updatedIPAddress) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasProjectIPAccessListDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasProjectIPAccessListDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasProjectIPAccessListConfigSettingIPAddress(projectID, ipAddress, comment), @@ -65,9 +65,9 @@ func TestAccResourceMongoDBAtlasProjectIPAccessList_SettingCIDRBlock(t *testing. updatedComment := fmt.Sprintf("TestAcc for cidrBlock updated (%s)", updatedCIDRBlock) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasProjectIPAccessListDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasProjectIPAccessListDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasProjectIPAccessListConfigSettingCIDRBlock(projectID, cidrBlock, comment), @@ -116,9 +116,9 @@ func TestAccResourceMongoDBAtlasProjectIPAccessList_SettingAWSSecurityGroup(t *t updatedComment := fmt.Sprintf("TestAcc for awsSecurityGroup updated (%s)", updatedAWSSgroup) resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasProjectIPAccessListDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasProjectIPAccessListDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasProjectIPAccessListConfigSettingAWSSecurityGroup(projectID, providerName, vpcID, awsAccountID, vpcCIDRBlock, awsRegion, awsSGroup, comment), @@ -176,9 +176,9 @@ func TestAccResourceMongoDBAtlasProjectIPAccessList_SettingMultiple(t *testing.T } //TODO: make testAccCheckMongoDBAtlasProjectIPAccessListExists dynamic resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasProjectIPAccessListDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasProjectIPAccessListDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasProjectIPAccessListConfigSettingMultiple(projectID, accessList, false), @@ -207,9 +207,9 @@ func TestAccResourceMongoDBAtlasProjectIPAccessList_importBasic(t *testing.T) { resourceName := "mongodbatlas_project_ip_access_list.test" resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasProjectIPAccessListDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasProjectIPAccessListDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasProjectIPAccessListConfigSettingIPAddress(projectID, ipAddress, comment), diff --git a/mongodbatlas/resource_mongodbatlas_project_test.go b/mongodbatlas/resource_mongodbatlas_project_test.go index 590c484ddf..092913cea9 100644 --- a/mongodbatlas/resource_mongodbatlas_project_test.go +++ b/mongodbatlas/resource_mongodbatlas_project_test.go @@ -8,9 +8,9 @@ import ( "strings" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -28,9 +28,9 @@ func TestAccResourceMongoDBAtlasProject_basic(t *testing.T) { } resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkTeamsIds(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasProjectDestroy, + PreCheck: func() { testAccPreCheck(t); checkTeamsIds(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasProjectDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasProjectConfig(projectName, orgID, @@ -127,9 +127,9 @@ func TestAccResourceMongoDBAtlasProject_withUpdatedRole(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t); checkTeamsIds(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasProjectDestroy, + PreCheck: func() { testAccPreCheck(t); checkTeamsIds(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasProjectDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasProjectConfigWithUpdatedRole(projectName, orgID, teamsIds[0], roleName), @@ -159,9 +159,9 @@ func TestAccResourceMongoDBAtlasProject_importBasic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasProjectDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasProjectDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasProjectConfig(projectName, orgID, diff --git a/mongodbatlas/resource_mongodbatlas_search_index.go b/mongodbatlas/resource_mongodbatlas_search_index.go index 6a21cdf279..edba8b4799 100644 --- a/mongodbatlas/resource_mongodbatlas_search_index.go +++ b/mongodbatlas/resource_mongodbatlas_search_index.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/go-test/deep" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mwielbut/pointy" matlas "go.mongodb.org/atlas/mongodbatlas" ) diff --git a/mongodbatlas/resource_mongodbatlas_search_index_test.go b/mongodbatlas/resource_mongodbatlas_search_index_test.go index 2ca39cb14a..0714e3a620 100644 --- a/mongodbatlas/resource_mongodbatlas_search_index_test.go +++ b/mongodbatlas/resource_mongodbatlas_search_index_test.go @@ -6,9 +6,9 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) diff --git a/mongodbatlas/resource_mongodbatlas_team.go b/mongodbatlas/resource_mongodbatlas_team.go index d382bdc1e8..55cad39a75 100644 --- a/mongodbatlas/resource_mongodbatlas_team.go +++ b/mongodbatlas/resource_mongodbatlas_team.go @@ -8,7 +8,9 @@ import ( "net/http" "strings" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -23,12 +25,12 @@ const ( func resourceMongoDBAtlasTeam() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasTeamCreate, - Read: resourceMongoDBAtlasTeamRead, - Update: resourceMongoDBAtlasTeamUpdate, - Delete: resourceMongoDBAtlasTeamDelete, + CreateContext: resourceMongoDBAtlasTeamCreate, + ReadContext: resourceMongoDBAtlasTeamRead, + UpdateContext: resourceMongoDBAtlasTeamUpdate, + DeleteContext: resourceMongoDBAtlasTeamDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasTeamImportState, + StateContext: resourceMongoDBAtlasTeamImportState, }, Schema: map[string]*schema.Schema{ "org_id": { @@ -55,18 +57,18 @@ func resourceMongoDBAtlasTeam() *schema.Resource { } } -func resourceMongoDBAtlasTeamCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasTeamCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas orgID := d.Get("org_id").(string) // Creating the team - teamsResp, _, err := conn.Teams.Create(context.Background(), orgID, + teamsResp, _, err := conn.Teams.Create(ctx, orgID, &matlas.Team{ Name: d.Get("name").(string), Usernames: expandStringListFromSetSchema(d.Get("usernames").(*schema.Set)), }) if err != nil { - return fmt.Errorf(errorTeamCreate, err) + return diag.FromErr(fmt.Errorf(errorTeamCreate, err)) } d.SetId(encodeStateID(map[string]string{ @@ -74,10 +76,10 @@ func resourceMongoDBAtlasTeamCreate(d *schema.ResourceData, meta interface{}) er "id": teamsResp.ID, })) - return resourceMongoDBAtlasTeamRead(d, meta) + return resourceMongoDBAtlasTeamRead(ctx, d, meta) } -func resourceMongoDBAtlasTeamRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasTeamRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -92,22 +94,21 @@ func resourceMongoDBAtlasTeamRead(d *schema.ResourceData, meta interface{}) erro d.SetId("") return nil } - - return fmt.Errorf(errorTeamRead, err) + return diag.FromErr(fmt.Errorf(errorTeamRead, err)) } if err = d.Set("name", team.Name); err != nil { - return fmt.Errorf(errorTeamSetting, "name", teamID, err) + return diag.FromErr(fmt.Errorf(errorTeamSetting, "name", teamID, err)) } if err = d.Set("team_id", team.ID); err != nil { - return fmt.Errorf(errorTeamSetting, "team_id", teamID, err) + return diag.FromErr(fmt.Errorf(errorTeamSetting, "team_id", teamID, err)) } // Set Usernames - users, _, err := conn.Teams.GetTeamUsersAssigned(context.Background(), orgID, teamID) + users, _, err := conn.Teams.GetTeamUsersAssigned(ctx, orgID, teamID) if err != nil { - return fmt.Errorf(errorTeamRead, err) + return diag.FromErr(fmt.Errorf(errorTeamRead, err)) } usernames := []string{} @@ -116,13 +117,13 @@ func resourceMongoDBAtlasTeamRead(d *schema.ResourceData, meta interface{}) erro } if err := d.Set("usernames", usernames); err != nil { - return fmt.Errorf(errorTeamSetting, "usernames", teamID, err) + return diag.FromErr(fmt.Errorf(errorTeamSetting, "usernames", teamID, err)) } return nil } -func resourceMongoDBAtlasTeamUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasTeamUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -130,19 +131,19 @@ func resourceMongoDBAtlasTeamUpdate(d *schema.ResourceData, meta interface{}) er teamID := ids["id"] if d.HasChange("name") { - _, _, err := conn.Teams.Rename(context.Background(), orgID, teamID, d.Get("name").(string)) + _, _, err := conn.Teams.Rename(ctx, orgID, teamID, d.Get("name").(string)) if err != nil { - return fmt.Errorf(errorTeamUpdate, err) + return diag.FromErr(fmt.Errorf(errorTeamUpdate, err)) } } if d.HasChange("usernames") { // First, we need to remove the current users of the team and later add the new users // Get the current team's users - users, _, err := conn.Teams.GetTeamUsersAssigned(context.Background(), orgID, teamID) + users, _, err := conn.Teams.GetTeamUsersAssigned(ctx, orgID, teamID) if err != nil { - return fmt.Errorf(errorTeamRead, err) + return diag.FromErr(fmt.Errorf(errorTeamRead, err)) } // Removing each user - Let's not modify the state before making sure we can continue @@ -155,7 +156,7 @@ func resourceMongoDBAtlasTeamUpdate(d *schema.ResourceData, meta interface{}) er cleanUsers := func() error { for i := range users { - _, err := conn.Teams.RemoveUserToTeam(context.Background(), orgID, teamID, users[i].ID) + _, err := conn.Teams.RemoveUserToTeam(ctx, orgID, teamID, users[i].ID) if err != nil { return fmt.Errorf("error deleting Atlas User (%s) information: %s", teamID, err) } @@ -169,7 +170,7 @@ func resourceMongoDBAtlasTeamUpdate(d *schema.ResourceData, meta interface{}) er var newUsers []string for _, username := range d.Get("usernames").(*schema.Set).List() { - user, _, err := conn.AtlasUsers.GetByName(context.Background(), username.(string)) + user, _, err := conn.AtlasUsers.GetByName(ctx, username.(string)) updatedUserData := user @@ -177,7 +178,7 @@ func resourceMongoDBAtlasTeamUpdate(d *schema.ResourceData, meta interface{}) er // this must be handle as a soft error if !strings.Contains(err.Error(), "401") { // In this case is a hard error doing a rollback from the initial operation - return fmt.Errorf("error getting Atlas User (%s) information: %s", username, err) + return diag.FromErr(fmt.Errorf("error getting Atlas User (%s) information: %s", username, err)) } log.Printf("[WARN] error fetching information user for (%s): %s\n", username, err) @@ -188,7 +189,7 @@ func resourceMongoDBAtlasTeamUpdate(d *schema.ResourceData, meta interface{}) er if !ok { log.Printf("[WARN] no information in cached for (%s)", username) - return fmt.Errorf("error getting Atlas User (%s) information: %s", username, err) + return diag.FromErr(fmt.Errorf("error getting Atlas User (%s) information: %s", username, err)) } updatedUserData = &cached } @@ -200,33 +201,33 @@ func resourceMongoDBAtlasTeamUpdate(d *schema.ResourceData, meta interface{}) er // Update the users, remove the old ones, add the new ones err = cleanUsers() if err != nil { - return err + return diag.FromErr(err) } - _, _, err = conn.Teams.AddUsersToTeam(context.Background(), orgID, teamID, newUsers) + _, _, err = conn.Teams.AddUsersToTeam(ctx, orgID, teamID, newUsers) if err != nil { - return fmt.Errorf(errorTeamAddUsers, err) + return diag.FromErr(fmt.Errorf(errorTeamAddUsers, err)) } } - return resourceMongoDBAtlasTeamRead(d, meta) + return resourceMongoDBAtlasTeamRead(ctx, d, meta) } -func resourceMongoDBAtlasTeamDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasTeamDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) orgID := ids["org_id"] id := ids["id"] - _, err := conn.Teams.RemoveTeamFromOrganization(context.Background(), orgID, id) + _, err := conn.Teams.RemoveTeamFromOrganization(ctx, orgID, id) if err != nil { - return fmt.Errorf(errorTeamDelete, id, err) + return diag.FromErr(fmt.Errorf(errorTeamDelete, id, err)) } return nil } -func resourceMongoDBAtlasTeamImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasTeamImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas parts := strings.SplitN(d.Id(), "-", 2) @@ -237,7 +238,7 @@ func resourceMongoDBAtlasTeamImportState(d *schema.ResourceData, meta interface{ orgID := parts[0] teamID := parts[1] - u, _, err := conn.Teams.Get(context.Background(), orgID, teamID) + u, _, err := conn.Teams.Get(ctx, orgID, teamID) if err != nil { return nil, fmt.Errorf("couldn't import team (%s) in organization(%s), error: %s", teamID, orgID, err) } diff --git a/mongodbatlas/resource_mongodbatlas_team_test.go b/mongodbatlas/resource_mongodbatlas_team_test.go index c8a4d44ae4..3f08e36ee4 100644 --- a/mongodbatlas/resource_mongodbatlas_team_test.go +++ b/mongodbatlas/resource_mongodbatlas_team_test.go @@ -8,9 +8,9 @@ import ( "strings" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -24,9 +24,9 @@ func TestAccResourceMongoDBAtlasTeam_basic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasTeamDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasTeamDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasTeamConfig(orgID, name, @@ -87,9 +87,9 @@ func TestAccResourceMongoDBAtlasTeam_importBasic(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasTeamDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasTeamDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasTeamConfig(orgID, name, []string{"mongodbatlas.testing@gmail.com"}), diff --git a/mongodbatlas/resource_mongodbatlas_third_party_integration.go b/mongodbatlas/resource_mongodbatlas_third_party_integration.go index 95ab233ead..bbb10a27c4 100644 --- a/mongodbatlas/resource_mongodbatlas_third_party_integration.go +++ b/mongodbatlas/resource_mongodbatlas_third_party_integration.go @@ -6,8 +6,9 @@ import ( "net/http" "regexp" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) var integrationTypes = []string{ @@ -32,12 +33,12 @@ var requiredPerType = map[string][]string{ func resourceMongoDBAtlasThirdPartyIntegration() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasThirdPartyIntegrationCreate, - Read: resourceMongoDBAtlasThirdPartyIntegrationRead, - Update: resourceMongoDBAtlasThirdPartyIntegrationUpdate, - Delete: resourceMongoDBAtlasThirdPartyIntegrationDelete, + CreateContext: resourceMongoDBAtlasThirdPartyIntegrationCreate, + ReadContext: resourceMongoDBAtlasThirdPartyIntegrationRead, + UpdateContext: resourceMongoDBAtlasThirdPartyIntegrationUpdate, + DeleteContext: resourceMongoDBAtlasThirdPartyIntegrationDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasThirdPartyIntegrationImportState, + StateContext: resourceMongoDBAtlasThirdPartyIntegrationImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -123,7 +124,7 @@ func resourceMongoDBAtlasThirdPartyIntegration() *schema.Resource { } } -func resourceMongoDBAtlasThirdPartyIntegrationCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasThirdPartyIntegrationCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) integrationType := d.Get("type").(string) @@ -134,17 +135,17 @@ func resourceMongoDBAtlasThirdPartyIntegrationCreate(d *schema.ResourceData, met _, valid := d.GetOk(key) if !valid { - return fmt.Errorf("error attribute for third party integration %s. please set it", key) + return diag.FromErr(fmt.Errorf("error attribute for third party integration %s. please set it", key)) } } } requestBody := schemaToIntegration(d) - _, _, err := conn.Integrations.Create(context.Background(), projectID, integrationType, requestBody) + _, _, err := conn.Integrations.Create(ctx, projectID, integrationType, requestBody) if err != nil { - return fmt.Errorf("error creating third party integration %s", err) + return diag.FromErr(fmt.Errorf("error creating third party integration %s", err)) } // ID is equal to project_id+type need to ask @@ -153,10 +154,10 @@ func resourceMongoDBAtlasThirdPartyIntegrationCreate(d *schema.ResourceData, met "type": integrationType, })) - return resourceMongoDBAtlasThirdPartyIntegrationRead(d, meta) + return resourceMongoDBAtlasThirdPartyIntegrationRead(ctx, d, meta) } -func resourceMongoDBAtlasThirdPartyIntegrationRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasThirdPartyIntegrationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -170,14 +171,14 @@ func resourceMongoDBAtlasThirdPartyIntegrationRead(d *schema.ResourceData, meta return nil } - return fmt.Errorf("error getting third party integration resource info %s %w", integrationType, err) + return diag.FromErr(fmt.Errorf("error getting third party integration resource info %s %w", integrationType, err)) } integrationMap := integrationToSchema(integration) for key, val := range integrationMap { if err := d.Set(key, val); err != nil { - return fmt.Errorf("error setting `%s` for third party integration (%s): %s", key, d.Id(), err) + return diag.FromErr(fmt.Errorf("error setting `%s` for third party integration (%s): %s", key, d.Id(), err)) } } @@ -189,49 +190,49 @@ func resourceMongoDBAtlasThirdPartyIntegrationRead(d *schema.ResourceData, meta return nil } -func resourceMongoDBAtlasThirdPartyIntegrationUpdate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasThirdPartyIntegrationUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) projectID := ids["project_id"] integrationType := ids["type"] - integration, _, err := conn.Integrations.Get(context.Background(), projectID, integrationType) + integration, _, err := conn.Integrations.Get(ctx, projectID, integrationType) if err != nil { - return fmt.Errorf("error getting third party integration resource info %s %w", integrationType, err) + return diag.FromErr(fmt.Errorf("error getting third party integration resource info %s %w", integrationType, err)) } // check for changed attributes per type updateIntegrationFromSchema(d, integration) - _, _, err = conn.Integrations.Replace(context.Background(), projectID, integrationType, integration) + _, _, err = conn.Integrations.Replace(ctx, projectID, integrationType, integration) if err != nil { - return fmt.Errorf("error updating third party integration type `%s` (%s): %w", integrationType, d.Id(), err) + return diag.FromErr(fmt.Errorf("error updating third party integration type `%s` (%s): %w", integrationType, d.Id(), err)) } - return resourceMongoDBAtlasThirdPartyIntegrationRead(d, meta) + return resourceMongoDBAtlasThirdPartyIntegrationRead(ctx, d, meta) } -func resourceMongoDBAtlasThirdPartyIntegrationDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasThirdPartyIntegrationDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) projectID := ids["project_id"] integrationType := ids["type"] - _, err := conn.Integrations.Delete(context.Background(), projectID, integrationType) + _, err := conn.Integrations.Delete(ctx, projectID, integrationType) if err != nil { - return fmt.Errorf("error deleting third party integration type `%s` (%s): %w", integrationType, d.Id(), err) + return diag.FromErr(fmt.Errorf("error deleting third party integration type `%s` (%s): %w", integrationType, d.Id(), err)) } return nil } -func resourceMongoDBAtlasThirdPartyIntegrationImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasThirdPartyIntegrationImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas projectID, integrationType, err := splitIntegrationTypeID(d.Id()) @@ -240,7 +241,7 @@ func resourceMongoDBAtlasThirdPartyIntegrationImportState(d *schema.ResourceData return nil, err } - integration, _, err := conn.Integrations.Get(context.Background(), projectID, integrationType) + integration, _, err := conn.Integrations.Get(ctx, projectID, integrationType) if err != nil { return nil, fmt.Errorf("couldn't import third party integration (%s) in project(%s), error: %w", integrationType, projectID, err) diff --git a/mongodbatlas/resource_mongodbatlas_third_party_integration_test.go b/mongodbatlas/resource_mongodbatlas_third_party_integration_test.go index a1b24505c4..c23ce5ca1f 100644 --- a/mongodbatlas/resource_mongodbatlas_third_party_integration_test.go +++ b/mongodbatlas/resource_mongodbatlas_third_party_integration_test.go @@ -6,8 +6,8 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -29,9 +29,9 @@ func TestAccResourceMongoDBAtlasThirdPartyIntegration_basic(t *testing.T) { } resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasThirdPartyIntegrationDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasThirdPartyIntegrationDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasThirdPartyIntegrationResourceConfig(&seedConfig), @@ -65,9 +65,9 @@ func TestAccResourceMongoDBAtlasThirdPartyIntegration_importBasic(t *testing.T) } resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasThirdPartyIntegrationDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasThirdPartyIntegrationDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasThirdPartyIntegrationResourceConfig(&seedConfig), @@ -117,9 +117,9 @@ func TestAccResourceMongoDBAtlasThirdPartyIntegration_updateBasic(t *testing.T) } resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasThirdPartyIntegrationDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasThirdPartyIntegrationDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasThirdPartyIntegrationResourceConfig(&seedInitialConfig), diff --git a/mongodbatlas/resource_mongodbatlas_x509_authentication_database_user.go b/mongodbatlas/resource_mongodbatlas_x509_authentication_database_user.go index e6998284b9..4980757ac5 100644 --- a/mongodbatlas/resource_mongodbatlas_x509_authentication_database_user.go +++ b/mongodbatlas/resource_mongodbatlas_x509_authentication_database_user.go @@ -6,7 +6,8 @@ import ( "fmt" "strings" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/spf13/cast" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -22,11 +23,11 @@ const ( func resourceMongoDBAtlasX509AuthDBUser() *schema.Resource { return &schema.Resource{ - Create: resourceMongoDBAtlasX509AuthDBUserCreate, - Read: resourceMongoDBAtlasX509AuthDBUserRead, - Delete: resourceMongoDBAtlasX509AuthDBUserDelete, + CreateContext: resourceMongoDBAtlasX509AuthDBUserCreate, + ReadContext: resourceMongoDBAtlasX509AuthDBUserRead, + DeleteContext: resourceMongoDBAtlasX509AuthDBUserDelete, Importer: &schema.ResourceImporter{ - State: resourceMongoDBAtlasX509AuthDBUserImportState, + StateContext: resourceMongoDBAtlasX509AuthDBUserImportState, }, Schema: map[string]*schema.Schema{ "project_id": { @@ -95,7 +96,7 @@ func resourceMongoDBAtlasX509AuthDBUser() *schema.Resource { } } -func resourceMongoDBAtlasX509AuthDBUserCreate(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasX509AuthDBUserCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas projectID := d.Get("project_id").(string) @@ -104,17 +105,17 @@ func resourceMongoDBAtlasX509AuthDBUserCreate(d *schema.ResourceData, meta inter var currentCertificate string if expirationMonths, ok := d.GetOk("months_until_expiration"); ok { - res, _, err := conn.X509AuthDBUsers.CreateUserCertificate(context.Background(), projectID, username, expirationMonths.(int)) + res, _, err := conn.X509AuthDBUsers.CreateUserCertificate(ctx, projectID, username, expirationMonths.(int)) if err != nil { - return fmt.Errorf(errorX509AuthDBUsersCreate, username, projectID, err) + return diag.FromErr(fmt.Errorf(errorX509AuthDBUsersCreate, username, projectID, err)) } currentCertificate = res.Certificate } else { customerX509Cas := d.Get("customer_x509_cas").(string) - _, _, err := conn.X509AuthDBUsers.SaveConfiguration(context.Background(), projectID, &matlas.CustomerX509{Cas: customerX509Cas}) + _, _, err := conn.X509AuthDBUsers.SaveConfiguration(ctx, projectID, &matlas.CustomerX509{Cas: customerX509Cas}) if err != nil { - return fmt.Errorf(errorCustomerX509AuthDBUsersCreate, projectID, err) + return diag.FromErr(fmt.Errorf(errorCustomerX509AuthDBUsersCreate, projectID, err)) } } @@ -124,10 +125,10 @@ func resourceMongoDBAtlasX509AuthDBUserCreate(d *schema.ResourceData, meta inter "current_certificate": currentCertificate, })) - return resourceMongoDBAtlasX509AuthDBUserRead(d, meta) + return resourceMongoDBAtlasX509AuthDBUserRead(ctx, d, meta) } -func resourceMongoDBAtlasX509AuthDBUserRead(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasX509AuthDBUserRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -141,7 +142,7 @@ func resourceMongoDBAtlasX509AuthDBUserRead(d *schema.ResourceData, meta interfa ) if username != "" { - certificates, _, err = conn.X509AuthDBUsers.GetUserCertificates(context.Background(), projectID, username) + certificates, _, err = conn.X509AuthDBUsers.GetUserCertificates(ctx, projectID, username) if err != nil { // new resource missing reset := strings.Contains(err.Error(), "404") && !d.IsNewResource() @@ -149,23 +150,22 @@ func resourceMongoDBAtlasX509AuthDBUserRead(d *schema.ResourceData, meta interfa d.SetId("") return nil } - - return fmt.Errorf(errorX509AuthDBUsersRead, username, projectID, err) + return diag.FromErr(fmt.Errorf(errorX509AuthDBUsersRead, username, projectID, err)) } } if err := d.Set("current_certificate", cast.ToString(currentCertificate)); err != nil { - return fmt.Errorf(errorX509AuthDBUsersSetting, "current_certificate", username, err) + return diag.FromErr(fmt.Errorf(errorX509AuthDBUsersSetting, "current_certificate", username, err)) } if err := d.Set("certificates", flattenCertificates(certificates)); err != nil { - return fmt.Errorf(errorX509AuthDBUsersSetting, "certificates", username, err) + return diag.FromErr(fmt.Errorf(errorX509AuthDBUsersSetting, "certificates", username, err)) } return nil } -func resourceMongoDBAtlasX509AuthDBUserDelete(d *schema.ResourceData, meta interface{}) error { +func resourceMongoDBAtlasX509AuthDBUserDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*MongoDBClient).Atlas ids := decodeStateID(d.Id()) @@ -173,9 +173,9 @@ func resourceMongoDBAtlasX509AuthDBUserDelete(d *schema.ResourceData, meta inter projectID := ids["project_id"] if currentCertificate == "" { - _, err := conn.X509AuthDBUsers.DisableCustomerX509(context.Background(), projectID) + _, err := conn.X509AuthDBUsers.DisableCustomerX509(ctx, projectID) if err != nil { - return fmt.Errorf(errorCustomerX509AuthDBUsersDelete, projectID, err) + return diag.FromErr(fmt.Errorf(errorCustomerX509AuthDBUsersDelete, projectID, err)) } } @@ -184,7 +184,7 @@ func resourceMongoDBAtlasX509AuthDBUserDelete(d *schema.ResourceData, meta inter return nil } -func resourceMongoDBAtlasX509AuthDBUserImportState(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceMongoDBAtlasX509AuthDBUserImportState(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { conn := meta.(*MongoDBClient).Atlas parts := strings.SplitN(d.Id(), "-", 2) @@ -200,7 +200,7 @@ func resourceMongoDBAtlasX509AuthDBUserImportState(d *schema.ResourceData, meta projectID := parts[0] if username != "" { - _, _, err := conn.X509AuthDBUsers.GetUserCertificates(context.Background(), projectID, username) + _, _, err := conn.X509AuthDBUsers.GetUserCertificates(ctx, projectID, username) if err != nil { return nil, fmt.Errorf(errorX509AuthDBUsersRead, username, projectID, err) } @@ -210,7 +210,7 @@ func resourceMongoDBAtlasX509AuthDBUserImportState(d *schema.ResourceData, meta } } - customerX509, _, err := conn.X509AuthDBUsers.GetCurrentX509Conf(context.Background(), projectID) + customerX509, _, err := conn.X509AuthDBUsers.GetCurrentX509Conf(ctx, projectID) if err != nil { return nil, fmt.Errorf(errorCustomerX509AuthDBUsersRead, projectID, err) } diff --git a/mongodbatlas/resource_mongodbatlas_x509_authentication_database_user_test.go b/mongodbatlas/resource_mongodbatlas_x509_authentication_database_user_test.go index 59187c77ef..54e471bdee 100644 --- a/mongodbatlas/resource_mongodbatlas_x509_authentication_database_user_test.go +++ b/mongodbatlas/resource_mongodbatlas_x509_authentication_database_user_test.go @@ -6,9 +6,9 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" "github.com/spf13/cast" ) @@ -29,8 +29,8 @@ func TestAccResourceMongoDBAtlasX509AuthDBUser_basic(t *testing.T) { } }() }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasX509AuthDBUserDestroy, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasX509AuthDBUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasX509AuthDBUserConfig(projectName, orgID, username), @@ -54,9 +54,9 @@ func TestAccResourceMongoDBAtlasX509AuthDBUser_WithCustomerX509(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasX509AuthDBUserDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasX509AuthDBUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasX509AuthDBUserConfigWithCustomerX509(projectName, orgID, cas), @@ -87,8 +87,8 @@ func TestAccResourceMongoDBAtlasX509AuthDBUser_importBasic(t *testing.T) { } }() }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasX509AuthDBUserDestroy, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasX509AuthDBUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasX509AuthDBUserConfig(projectName, orgID, username), @@ -112,9 +112,9 @@ func TestAccResourceMongoDBAtlasX509AuthDBUser_WithDatabaseUser(t *testing.T) { ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasX509AuthDBUserDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasX509AuthDBUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasX509AuthDBUserConfigWithDatabaseUser(projectName, orgID, username, months), @@ -140,9 +140,9 @@ func TestAccResourceMongoDBAtlasX509AuthDBUser_importWithCustomerX509(t *testing ) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckMongoDBAtlasX509AuthDBUserDestroy, + PreCheck: func() { testAccPreCheck(t) }, + ProviderFactories: testAccProviderFactories, + CheckDestroy: testAccCheckMongoDBAtlasX509AuthDBUserDestroy, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasX509AuthDBUserConfigWithCustomerX509(projectName, orgID, cas), diff --git a/website/docs/d/alert_configuration.html.markdown b/website/docs/d/alert_configuration.html.markdown index 745f3687fd..e0153c208e 100644 --- a/website/docs/d/alert_configuration.html.markdown +++ b/website/docs/d/alert_configuration.html.markdown @@ -35,7 +35,7 @@ resource "mongodbatlas_alert_configuration" "test" { value = "SECONDARY" } - metric_threshold = { + metric_threshold_config { metric_name = "ASSERT_REGULAR" operator = "LESS_THAN" threshold = 99.0 @@ -74,7 +74,7 @@ resource "mongodbatlas_alert_configuration" "test" { value = "SECONDARY" } - threshold = { + threshold_config { operator = "LESS_THAN" threshold = 1 units = "HOURS" @@ -143,7 +143,7 @@ Rules to apply when matching an object against this alert configuration. Only en - `CONFIG` - `MONGOS` -### Metric Threshold +### Metric Threshold Config The threshold that causes an alert to be triggered. Required if `event_type_name` : "OUTSIDE_METRIC_THRESHOLD". * `metric_name` - Name of the metric to check. The full list of current options is available [here](https://docs.atlas.mongodb.com/reference/alert-host-metrics/#measurement-types) @@ -175,7 +175,7 @@ The threshold that causes an alert to be triggered. Required if `event_type_name * `mode` - This must be set to AVERAGE. Atlas computes the current metric value as an average. -### Threshold +### Threshold Config * `operator` - Operator to apply when checking the current metric value against the threshold value. Accepted values are: - `GREATER_THAN` diff --git a/website/docs/d/cloud_provider_snapshot_restore_job.html.markdown b/website/docs/d/cloud_provider_snapshot_restore_job.html.markdown index 714a33cdda..0afd3d7807 100644 --- a/website/docs/d/cloud_provider_snapshot_restore_job.html.markdown +++ b/website/docs/d/cloud_provider_snapshot_restore_job.html.markdown @@ -27,7 +27,7 @@ resource "mongodbatlas_cloud_provider_snapshot_restore_job" "test" { project_id = "5cf5a45a9ccf6400e60981b6" cluster_name = "MyCluster" snapshot_id = "${mongodbatlas_cloud_provider_snapshot.test.id}" - delivery_type = { + delivery_type { automated = true target_cluster_name = "MyCluster" target_project_id = "5cf5a45a9ccf6400e60981b6" diff --git a/website/docs/d/cloud_provider_snapshot_restore_jobs.html.markdown b/website/docs/d/cloud_provider_snapshot_restore_jobs.html.markdown index 0d861b02c4..63c698fe58 100644 --- a/website/docs/d/cloud_provider_snapshot_restore_jobs.html.markdown +++ b/website/docs/d/cloud_provider_snapshot_restore_jobs.html.markdown @@ -27,7 +27,7 @@ resource "mongodbatlas_cloud_provider_snapshot_restore_job" "test" { project_id = "5cf5a45a9ccf6400e60981b6" cluster_name = "MyCluster" snapshot_id = mongodbatlas_cloud_provider_snapshot.test.id - delivery_type = { + delivery_type { automated = true target_cluster_name = "MyCluster" target_project_id = "5cf5a45a9ccf6400e60981b6" diff --git a/website/docs/d/data_lake.html.markdown b/website/docs/d/data_lake.html.markdown index af04b0572a..6df6037c19 100644 --- a/website/docs/d/data_lake.html.markdown +++ b/website/docs/d/data_lake.html.markdown @@ -63,8 +63,8 @@ In addition to all arguments above, the following attributes are exported: * `aws_external_id` - Unique identifier associated with the IAM Role that Data Lake assumes when accessing the data stores. * `data_process_region` - The cloud provider region to which Atlas Data Lake routes client connections for data processing. - * `data_process_region.cloud_provider` - Name of the cloud service provider. - * `data_process_region.region` -Name of the region to which Data Lake routes client connections for data processing. + * `data_process_region.0.cloud_provider` - Name of the cloud service provider. + * `data_process_region.0.region` -Name of the region to which Data Lake routes client connections for data processing. * `hostnames` - The list of hostnames assigned to the Atlas Data Lake. Each string in the array is a hostname assigned to the Atlas Data Lake. * `state` - Current state of the Atlas Data Lake: * `ACTIVE` - The Data Lake is active and verified. You can query the data stores associated with the Atlas Data Lake. diff --git a/website/docs/d/data_lakes.html.markdown b/website/docs/d/data_lakes.html.markdown index dd91af7e93..40b328e14e 100644 --- a/website/docs/d/data_lakes.html.markdown +++ b/website/docs/d/data_lakes.html.markdown @@ -38,8 +38,8 @@ In addition to all arguments above, the following attributes are exported: * `aws_role_id` - Unique identifier of the role that Data Lake can use to access the data stores. * `aws_test_s3_bucket` - Name of the S3 data bucket that the provided role ID is authorized to access. * `data_process_region` - The cloud provider region to which Atlas Data Lake routes client connections for data processing. - * `data_process_region.cloud_provider` - Name of the cloud service provider. - * `data_process_region.region` -Name of the region to which Data Lake routes client connections for data processing. + * `data_process_region.0.cloud_provider` - Name of the cloud service provider. + * `data_process_region.0.region` -Name of the region to which Data Lake routes client connections for data processing. * `aws_iam_assumed_role_arn` - Amazon Resource Name (ARN) of the IAM Role that Data Lake assumes when accessing S3 Bucket data stores. For more information on S3 actions, see [Actions, Resources, and Condition Keys for Amazon S3](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html). diff --git a/website/docs/guides/1.0.0-upgrade-guide.html.markdown b/website/docs/guides/1.0.0-upgrade-guide.html.markdown index b70800d785..f011236270 100644 --- a/website/docs/guides/1.0.0-upgrade-guide.html.markdown +++ b/website/docs/guides/1.0.0-upgrade-guide.html.markdown @@ -79,6 +79,155 @@ so no changes are needed. **NOTE** Doc links for [mongodbatlas_privatelink_endpoint](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/privatelink_endpoint) **NOTE** Doc links for [mongodbatlas_privatelink_endpoint_service](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/privatelink_endpoint_service) +## Migration to Terraform SDK v2 + +- Due to the migration to Terraform SDK v2 various resources and datasource(s) have been impacted and will require a change within your configuration. These resources and datasources used the now unsupported TypeMap object. In SDK v2 these must be TypeSet or TypeList with MaxItems set to 1. The following is the list of resources and datasources impacted by the migration. + +### Alert Configuration +- Fields Affected: + - metric_threshold (deprecated), use metric_threshold_config instead + - threshold (deprecated), use threshold_confing instead + +Old usage: +```terraform +metric_threshold = { + metric_name = "ASSERT_REGULAR" + operator = "LESS_THAN" + threshold = 1.0 + units = "RAW" + mode = "AVERAGE" +} + +threshold = { + operator = "LESS_THAN" + threshold = 72 + units = "HOURS" + } + +``` + +New usage: +```terraform +metric_threshold_config { + metric_name = "ASSERT_REGULAR" + operator = "LESS_THAN" + threshold = 1.0 + units = "RAW" + mode = "AVERAGE" +} + +threshold_config { + operator = "LESS_THAN" + threshold = 72 + units = "HOURS" + } + +``` + +### Cloud Provider Access Authorization +- Fields Affected: + - aws (deprecated), use aws_config instead + +Old usage: +```terraform +aws = { + iam_assumed_role_arn = aws_iam_role.test_role.arn +} +``` + +New usage: +```terraform +aws_config { + iam_assumed_role_arn = aws_iam_role.test_role.arn +} +``` + +### Cloud Provider Snapshot Restore Job +- Fields Affected: + - delivery_type (deprecated), use delivery_type_config instead + +Old usage: +```terraform +delivery_type = { + point_in_time = true + target_cluster_name = mongodbatlas_cluster.target_cluster.name + target_project_id = "" +} +``` + +New usage: +```terraform +delivery_type_config { + point_in_time = true + target_cluster_name = mongodbatlas_cluster.target_cluster.name + target_project_id = "" +} +``` + +### Encryption at rest +- Fields Affected: + - aws_kms (deprecated), use aws_kms instead + - azure_key_vault (deprecated), use azure_key_vault instead + - google_cloud_kms (deprecated), use google_cloud_kms instead + +Old usage: +```terraform + +aws_kms = { + enabled = true + access_key_id = "" + secret_access_key = "" + customer_master_key_id = "" + region = "" +} + +azure_key_vault = { + enabled = true + client_id = "" + azure_environment = "" + subscription_id = "" + resource_group_name = "" + key_vault_name = "" + key_identifier = "" + secret = "" + tenant_id = "" +} + +google_cloud_kms = { + enabled = true + service_account_key = "" + key_version_resource_id = "" +} +``` + +New usage: +```terraform +aws_kms_config { + enabled = true + access_key_id = "" + secret_access_key = "" + customer_master_key_id = "" + region = "" +} + +azure_key_vault_config { + enabled = true + client_id = "" + azure_environment = "" + subscription_id = "" + resource_group_name = "" + key_vault_name = "" + key_identifier = "" + secret = "" + tenant_id = "" +} + +google_cloud_kms_config { + enabled = true + service_account_key = "" + key_version_resource_id = "" +} +``` ### Helpful Links diff --git a/website/docs/r/alert_configuration.html.markdown b/website/docs/r/alert_configuration.html.markdown index f90437fe4c..5b83ea26d8 100644 --- a/website/docs/r/alert_configuration.html.markdown +++ b/website/docs/r/alert_configuration.html.markdown @@ -35,7 +35,7 @@ resource "mongodbatlas_alert_configuration" "test" { value = "SECONDARY" } - metric_threshold = { + metric_threshold_config { metric_name = "ASSERT_REGULAR" operator = "LESS_THAN" threshold = 99.0 @@ -69,7 +69,7 @@ resource "mongodbatlas_alert_configuration" "test" { value = "SECONDARY" } - threshold = { + threshold_config { operator = "LESS_THAN" threshold = 1 units = "HOURS" @@ -125,7 +125,7 @@ Rules to apply when matching an object against this alert configuration. Only en - `CONFIG` - `MONGOS` -### Metric Threshold +### Metric Threshold Config The threshold that causes an alert to be triggered. Required if `event_type_name` : "OUTSIDE_METRIC_THRESHOLD". * `metric_name` - Name of the metric to check. The full list of current options is available [here](https://docs.atlas.mongodb.com/reference/alert-host-metrics/#measurement-types) @@ -156,7 +156,7 @@ The threshold that causes an alert to be triggered. Required if `event_type_name * `mode` - This must be set to AVERAGE. Atlas computes the current metric value as an average. -### Threshold +### Threshold Config * `operator` - Operator to apply when checking the current metric value against the threshold value. Accepted values are: - `GREATER_THAN` diff --git a/website/docs/r/cloud_provider_access.markdown b/website/docs/r/cloud_provider_access.markdown index 2ec845a888..1c1e660068 100644 --- a/website/docs/r/cloud_provider_access.markdown +++ b/website/docs/r/cloud_provider_access.markdown @@ -137,7 +137,7 @@ resource "mongodbatlas_cloud_provider_access_authorization" "auth_role" { project_id = mongodbatlas_cloud_provider_access_setup.setup_only.project_id role_id = mongodbatlas_cloud_provider_access_setup.setup_only.role_id - aws = { + aws { iam_assumed_role_arn = "arn:aws:iam::772401394250:role/test-user-role" } } diff --git a/website/docs/r/cloud_provider_snapshot.html.markdown b/website/docs/r/cloud_provider_snapshot.html.markdown index 2add262b20..0df2484fc5 100644 --- a/website/docs/r/cloud_provider_snapshot.html.markdown +++ b/website/docs/r/cloud_provider_snapshot.html.markdown @@ -39,7 +39,7 @@ On-demand snapshots happen immediately, unlike scheduled snapshots which occur a project_id = mongodbatlas_cloud_provider_snapshot.test.project_id cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name snapshot_id = mongodbatlas_cloud_provider_snapshot.test.snapshot_id - delivery_type = { + delivery_type { download = true } } diff --git a/website/docs/r/cloud_provider_snapshot_restore_job.html.markdown b/website/docs/r/cloud_provider_snapshot_restore_job.html.markdown index 00cacefeda..53dd421d93 100644 --- a/website/docs/r/cloud_provider_snapshot_restore_job.html.markdown +++ b/website/docs/r/cloud_provider_snapshot_restore_job.html.markdown @@ -47,7 +47,7 @@ description: |- project_id = mongodbatlas_cloud_provider_snapshot.test.project_id cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name snapshot_id = mongodbatlas_cloud_provider_snapshot.test.snapshot_id - delivery_type = { + delivery_type_config { automated = true target_cluster_name = "MyCluster" target_project_id = "5cf5a45a9ccf6400e60981b6" @@ -82,7 +82,7 @@ description: |- project_id = mongodbatlas_cloud_provider_snapshot.test.project_id cluster_name = mongodbatlas_cloud_provider_snapshot.test.cluster_name snapshot_id = mongodbatlas_cloud_provider_snapshot.test.snapshot_id - delivery_type = { + delivery_type_config { download = true } } @@ -112,7 +112,7 @@ In addition to all arguments above, the following attributes are exported: * `snapshot_restore_job_id` - The unique identifier of the restore job. * `cancelled` - Indicates whether the restore job was canceled. * `created_at` - UTC ISO 8601 formatted point in time when Atlas created the restore job. -* `delivery_type` - Type of restore job to create. Possible values are: automated and download. +* `delivery_type_config` - Type of restore job to create. Possible values are: automated and download. * `delivery_url` - One or more URLs for the compressed snapshot files for manual download. Only visible if deliveryType is download. * `expired` - Indicates whether the restore job expired. * `expires_at` - UTC ISO 8601 formatted point in time when the restore job expires. diff --git a/website/docs/r/data_lake.html.markdown b/website/docs/r/data_lake.html.markdown index dd51e509d5..0a6d79885c 100644 --- a/website/docs/r/data_lake.html.markdown +++ b/website/docs/r/data_lake.html.markdown @@ -46,8 +46,8 @@ resource "mongodbatlas_data_lake" "basic_ds" { * `aws.0.role_id` - (Required) Unique identifier of the role that Data Lake can use to access the data stores. If necessary, use the Atlas [UI](https://docs.atlas.mongodb.com/security/manage-iam-roles/) or [API](https://docs.atlas.mongodb.com/reference/api/cloud-provider-access-get-roles/) to retrieve the role ID. You must also specify the `aws.0.test_s3_bucket`. * `aws.0.test_s3_bucket` - (Required) Name of the S3 data bucket that the provided role ID is authorized to access. You must also specify the `aws.0.role_id`. * `data_process_region` - (Optional) The cloud provider region to which Atlas Data Lake routes client connections for data processing. Set to `null` to direct Atlas Data Lake to route client connections to the region nearest to the client based on DNS resolution. - * `data_process_region.cloud_provider` - (Required) Name of the cloud service provider. Atlas Data Lake only supports AWS. - * `data_process_region.region` - (Required). Name of the region to which Data Lake routes client connections for data processing. Atlas Data Lake only supports the following regions: + * `data_process_region.0.cloud_provider` - (Required) Name of the cloud service provider. Atlas Data Lake only supports AWS. + * `data_process_region.0.region` - (Required). Name of the region to which Data Lake routes client connections for data processing. Atlas Data Lake only supports the following regions: * `SYDNEY_AUS` (ap-southeast-2) * `FRANKFURT_DEU` (eu-central-1) * `DUBLIN_IRL` (eu-west-1) diff --git a/website/docs/r/encryption_at_rest.html.markdown b/website/docs/r/encryption_at_rest.html.markdown index 383b8b7ade..66b4358992 100644 --- a/website/docs/r/encryption_at_rest.html.markdown +++ b/website/docs/r/encryption_at_rest.html.markdown @@ -30,14 +30,14 @@ See [Encryption at Rest](https://docs.atlas.mongodb.com/security-kms-encryption/ resource "mongodbatlas_encryption_at_rest" "test" { project_id = "" - aws_kms = { + aws_kms_config { enabled = true customer_master_key_id = "5ce83906-6563-46b7-8045-11c20e3a5766" region = "US_EAST_1" role_id = "60815e2fe01a49138a928ebb" } - azure_key_vault = { + azure_key_vault_config { enabled = true client_id = "g54f9e2-89e3-40fd-8188-EXAMPLEID" azure_environment = "AZURE" @@ -49,7 +49,7 @@ resource "mongodbatlas_encryption_at_rest" "test" { tenant_id = "e8e4b6ba-ff32-4c88-a9af-EXAMPLEID" } - google_cloud_kms = { + google_cloud_kms_config { enabled = true service_account_key = "{\"type\": \"service_account\",\"project_id\": \"my-project-common-0\",\"private_key_id\": \"e120598ea4f88249469fcdd75a9a785c1bb3\",\"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIEuwIBA(truncated)SfecnS0mT94D9\\n-----END PRIVATE KEY-----\\n\",\"client_email\": \"my-email-kms-0@my-project-common-0.iam.gserviceaccount.com\",\"client_id\": \"10180967717292066\",\"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\"token_uri\": \"https://accounts.google.com/o/oauth2/token\",\"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/my-email-kms-0%40my-project-common-0.iam.gserviceaccount.com\"}" key_version_resource_id = "projects/my-project-common-0/locations/us-east4/keyRings/my-key-ring-0/cryptoKeys/my-key-0/cryptoKeyVersions/1" @@ -73,14 +73,14 @@ resource "mongodbatlas_encryption_at_rest" "default" { * `azure_key_vault` - (Required) Specifies Azure Key Vault configuration details and whether Encryption at Rest is enabled for an Atlas project. * `google_cloud_kms` - (Required) Specifies GCP KMS configuration details and whether Encryption at Rest is enabled for an Atlas project. -### aws_kms +### aws_kms_config Refer to the example in the [official github repository](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/master/examples) to implement Encryption at Rest * `enabled` - Specifies whether Encryption at Rest is enabled for an Atlas project, To disable Encryption at Rest, pass only this parameter with a value of false, When you disable Encryption at Rest, Atlas also removes the configuration details. * `customer_master_key_id` - The AWS customer master key used to encrypt and decrypt the MongoDB master keys. * `region` - The AWS region in which the AWS customer master key exists: CA_CENTRAL_1, US_EAST_1, US_EAST_2, US_WEST_1, US_WEST_2, SA_EAST_1 * `role_id` - ID of an AWS IAM role authorized to manage an AWS customer master key. To find the ID for an existing IAM role check the `role_id` attribute of the `mongodbatlas_cloud_provider_access` resource. -### azure_key_vault +### azure_key_vault_config * `enabled` - Specifies whether Encryption at Rest is enabled for an Atlas project. To disable Encryption at Rest, pass only this parameter with a value of false. When you disable Encryption at Rest, Atlas also removes the configuration details. * `client_id` - The client ID, also known as the application ID, for an Azure application associated with the Azure AD tenant. * `azure_environment` - The Azure environment where the Azure account credentials reside. Valid values are the following: AZURE, AZURE_CHINA, AZURE_GERMANY @@ -91,7 +91,7 @@ Refer to the example in the [official github repository](https://github.com/mong * `secret` - The secret associated with the Azure Key Vault specified by azureKeyVault.tenantID. * `tenant_id` - The unique identifier for an Azure AD tenant within an Azure subscription. -### google_cloud_kms +### google_cloud_kms_config * `enabled` - Specifies whether Encryption at Rest is enabled for an Atlas project. To disable Encryption at Rest, pass only this parameter with a value of false. When you disable Encryption at Rest, Atlas also removes the configuration details. * `service_account_key` - String-formatted JSON object containing GCP KMS credentials from your GCP account. * `key_version_resource_id` - The Key Version Resource ID from your GCP account.