diff --git a/.changelog/3034.txt b/.changelog/3034.txt new file mode 100644 index 0000000000..c3222663f9 --- /dev/null +++ b/.changelog/3034.txt @@ -0,0 +1,7 @@ +```release-note:bug +resource/mongodbatlas_advanced_cluster: Adds `PENDING` status for update and delete operations +``` + +```release-note:bug +resource/mongodbatlas_cluster: Adds `PENDING` status for update and delete operations +``` diff --git a/.changelog/3051.txt b/.changelog/3051.txt new file mode 100644 index 0000000000..ca3c17435f --- /dev/null +++ b/.changelog/3051.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/mongodbatlas_alert_configuration: Removes UseStateForUnknown plan modifier for interval_min +``` diff --git a/.github/workflows/acceptance-tests-runner.yml b/.github/workflows/acceptance-tests-runner.yml index 22d7069b65..0e5a213602 100644 --- a/.github/workflows/acceptance-tests-runner.yml +++ b/.github/workflows/acceptance-tests-runner.yml @@ -375,7 +375,7 @@ jobs: needs: [ change-detection, get-provider-version ] if: ${{ needs.change-detection.outputs.advanced_cluster_tpf == 'true' || inputs.test_group == 'advanced_cluster_tpf' }} env: - MONGODB_ATLAS_ADVANCED_CLUSTER_V2_SCHEMA: 'true' + MONGODB_ATLAS_PREVIEW_PROVIDER_V2_ADVANCED_CLUSTER: 'true' runs-on: ubuntu-latest permissions: {} steps: @@ -390,9 +390,9 @@ jobs: terraform_version: ${{ inputs.terraform_version }} terraform_wrapper: false - name: Prepare new advanced_cluster - run: make tools enable-advancedclustertpf - - name: Unit tests # delete after allowAdvancedClusterV2Schema is removed - run: go test -v ./internal/testutil/acc/advanced_cluster_schema_v2_test.go + run: make tools enable-preview-provider-v2 + - name: Unit tests # delete after allowPreviewProviderV2AdvancedCluster is removed + run: go test -v ./internal/testutil/acc/advanced_cluster_preview_provider_v2_test.go - name: Mocked Acceptance Tests env: ACCTEST_REGEX_RUN: '^TestAccMockable' @@ -412,7 +412,7 @@ jobs: needs: [ change-detection, get-provider-version ] if: ${{ (needs.change-detection.outputs.advanced_cluster_tpf == 'true' || inputs.test_group == 'advanced_cluster_tpf') && inputs.terraform_version == '1.10.x' && inputs.reduced_tests == false }} env: - MONGODB_ATLAS_ADVANCED_CLUSTER_V2_SCHEMA: 'true' + MONGODB_ATLAS_PREVIEW_PROVIDER_V2_ADVANCED_CLUSTER: 'true' strategy: max-parallel: 2 fail-fast: false @@ -433,7 +433,7 @@ jobs: terraform_version: ${{ matrix.terraform_version }} terraform_wrapper: false - name: Prepare new advanced_cluster - run: make tools enable-advancedclustertpf + run: make tools enable-preview-provider-v2 - name: Acceptance Tests env: ACCTEST_REGEX_RUN: '^TestAccAdvancedCluster_move' diff --git a/CHANGELOG.md b/CHANGELOG.md index a6154cf633..1b89c98a56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ ## (Unreleased) +BUG FIXES: + +* resource/mongodbatlas_alert_configuration: Removes UseStateForUnknown plan modifier for interval_min ([#3051](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/3051)) + +## 1.26.1 (February 07, 2025) + +BUG FIXES: + +* resource/mongodbatlas_advanced_cluster: Adds `PENDING` status for update and delete operations ([#3034](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/3034)) +* resource/mongodbatlas_cluster: Adds `PENDING` status for update and delete operations ([#3034](https://github.com/mongodb/terraform-provider-mongodbatlas/pull/3034)) + ## 1.26.0 (January 23, 2025) FEATURES: diff --git a/Makefile b/Makefile index cb0a54fb73..48d7b1b311 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ testmact: ## Run MacT tests (mocked acc tests) @$(eval export MONGODB_ATLAS_ORG_ID?=111111111111111111111111) @$(eval export MONGODB_ATLAS_PROJECT_ID?=111111111111111111111111) @$(eval export MONGODB_ATLAS_CLUSTER_NAME?=mocked-cluster) - @$(eval export MONGODB_ATLAS_ADVANCED_CLUSTER_V2_SCHEMA?=true) + @$(eval export MONGODB_ATLAS_PREVIEW_PROVIDER_V2_ADVANCED_CLUSTER?=true) @if [ "$(ACCTEST_PACKAGES)" = "./..." ]; then \ echo "Error: ACCTEST_PACKAGES must be explicitly set for testmact target, './...' is not allowed"; \ exit 1; \ @@ -191,9 +191,9 @@ check-changelog-entry-file: ## Check a changelog entry file in a PR jira-release-version: ## Update Jira version in a release go run ./tools/jira-release-version/*.go -.PHONY: enable-advancedclustertpf -enable-advancedclustertpf: ## Enable Advanced Cluster V2 Schema - make change-lines filename=./internal/config/advanced_cluster_v2_schema.go find="allowAdvancedClusterV2Schema = false" new="allowAdvancedClusterV2Schema = true" +.PHONY: enable-preview-provider-v2 +enable-preview-provider-v2: ## Enable Preview Provider V2 + make change-lines filename=./internal/config/preview_provider_v2.go find="allowPreviewProviderV2AdvancedCluster = false" new="allowPreviewProviderV2AdvancedCluster = true" .PHONY: delete-lines ${filename} ${delete} delete-lines: diff --git a/contributing/testing-best-practices.md b/contributing/testing-best-practices.md index 6b4406d88b..648157d9db 100644 --- a/contributing/testing-best-practices.md +++ b/contributing/testing-best-practices.md @@ -74,7 +74,7 @@ Acceptance and migration tests can reuse projects and clusters in order to be mo **Experimental** framework for hooking into the HTTP Client used by the Terraform provider and capture/replay traffic. - Works by mutating a `terraform-plugin-testing/helper/resource.TestCase` - Limited to `TestAccMockable*` tests in [`resource_advanced_cluster_test.go`](../internal/service/advancedcluster/resource_advanced_cluster_test.go): - - Remember to run `make enable-advancedclustertpf` and `export MONGODB_ATLAS_ADVANCED_CLUSTER_V2_SCHEMA=true` for the TPF implementation to be used and the tests to work. + - Remember to run `make enable-preview-provider-v2` and `export MONGODB_ATLAS_PREVIEW_PROVIDER_V2_ADVANCED_CLUSTER=true` for the TPF implementation to be used and the tests to work. - Enabled test cases should always be named with `TestAccMockable` prefix, e.g.: `TestAccMockableAdvancedCluster_tenantUpgrade` - To create a new `TestAccMockable` you would need to (see [example commit](https://github.com/mongodb/terraform-provider-mongodbatlas/commit/939244fcab95eca9c4c93993fc1b5118ab8bfddb#diff-f9c590f9ffc351d041a26ff474f91404ff394cbfb83f1e135b415998476ca62aR128)) - (1) Write the normal acceptance test diff --git a/docs/data-sources/resource_policies.md b/docs/data-sources/resource_policies.md index b1af9e290c..5445839eeb 100644 --- a/docs/data-sources/resource_policies.md +++ b/docs/data-sources/resource_policies.md @@ -2,7 +2,7 @@ `mongodbatlas_resource_policies` returns all resource policies in an organization. --> **NOTE**: Resource Policies are currently in Private Preview. To use this feature, you must take the following actions: +-> **NOTE**: Resource Policies are currently in Public Preview. To use this feature, you must take the following actions: 1. Enable the `Atlas Resource Policies` Preview Feature in your organization (contact [MongoDB Support](https://www.mongodb.com/services/support)). 2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. @@ -17,7 +17,7 @@ resource "mongodbatlas_resource_policy" "project_ip_access_list" { body = < **NOTE**: Resource Policies are currently in Private Preview. To use this feature, you must take the following actions: +-> **NOTE**: Resource Policies are currently in Public Preview. To use this feature, you must take the following actions: 1. Enable the `Atlas Resource Policies` Preview Feature in your organization (contact [MongoDB Support](https://www.mongodb.com/services/support)). 2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. @@ -17,7 +17,7 @@ resource "mongodbatlas_resource_policy" "project_ip_access_list" { body = < -We have [example configurations](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/v1.26.0/examples) +We have [example configurations](https://github.com/mongodb/terraform-provider-mongodbatlas/tree/v1.26.1/examples) in our GitHub repo that will help both beginner and more advanced users. Have a good example you've created and want to share? diff --git a/docs/resources/advanced_cluster.md b/docs/resources/advanced_cluster.md index 03a065ba21..215c784cb1 100644 --- a/docs/resources/advanced_cluster.md +++ b/docs/resources/advanced_cluster.md @@ -656,7 +656,7 @@ lifecycle { In addition to all arguments above, the following attributes are exported: * `cluster_id` - The cluster ID. -* `mongo_db_version` - Version of MongoDB the cluster runs, in `major-version`.`minor-version` format. +* `mongo_db_version` - Version of MongoDB the cluster runs, in `major-version`.`minor-version` format. * `id` - The Terraform's unique identifier used internally for state management. * `connection_strings` - Set of connection strings that your applications use to connect to this cluster. More info in [Connection-strings](https://docs.mongodb.com/manual/reference/connection-string/). Use the parameters in this object to connect your applications to this cluster. To learn more about the formats of connection strings, see [Connection String Options](https://docs.atlas.mongodb.com/reference/faq/connection-changes/). NOTE: Atlas returns the contents of this object after the cluster is operational, not while it builds the cluster. @@ -686,6 +686,7 @@ In addition to all arguments above, the following attributes are exported: - REPAIRING * `replication_specs.#.container_id` - A key-value map of the Network Peering Container ID(s) for the configuration specified in `region_configs`. The Container ID is the id of the container created when the first cluster in the region (AWS/Azure) or project (GCP) was created. The syntax is `"providerName:regionName" = "containerId"`. Example `AWS:US_EAST_1" = "61e0797dde08fb498ca11a71`. * `config_server_type` Describes a sharded cluster's config server type. Valid values are `DEDICATED` and `EMBEDDED`. To learn more, see the [Sharded Cluster Config Servers documentation](https://dochub.mongodb.org/docs/manual/core/sharded-cluster-config-servers/). +* `pinned_fcv.version` - Feature compatibility version of the cluster. ## Import diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md index e2ec8f8104..cea54769c0 100644 --- a/docs/resources/cluster.md +++ b/docs/resources/cluster.md @@ -539,7 +539,7 @@ To learn more, see [Resource Tags](https://dochub.mongodb.org/core/add-cluster-t In addition to all arguments above, the following attributes are exported: * `cluster_id` - The cluster ID. -* `mongo_db_version` - Version of MongoDB the cluster runs, in `major-version`.`minor-version` format. +* `mongo_db_version` - Version of MongoDB the cluster runs, in `major-version`.`minor-version` format. * `id` - The Terraform's unique identifier used internally for state management. * `mongo_uri` - Base connection string for the cluster. Atlas only displays this field after the cluster is operational, not while it builds the cluster. * `mongo_uri_updated` - Lists when the connection string was last updated. The connection string changes, for example, if you change a replica set to a sharded cluster. @@ -572,6 +572,7 @@ In addition to all arguments above, the following attributes are exported: - DELETING - DELETED - REPAIRING +* `pinned_fcv.version` - Feature compatibility version of the cluster. ### Cloud Backup Policy diff --git a/docs/resources/resource_policy.md b/docs/resources/resource_policy.md index ef3dc0e2b7..9961806d66 100644 --- a/docs/resources/resource_policy.md +++ b/docs/resources/resource_policy.md @@ -2,7 +2,7 @@ `mongodbatlas_resource_policy` provides a Resource Policy resource. The resource lets you create, edit and delete resource policies to prevent misconfigurations and reduce the need for corrective interventions in your organization. --> **NOTE**: Resource Policies are currently in Private Preview. To use this feature, you must take the following actions: +-> **NOTE**: Resource Policies are currently in Public Preview. To use this feature, you must take the following actions: 1. Enable the `Atlas Resource Policies` Preview Feature in your organization (contact [MongoDB Support](https://www.mongodb.com/services/support)). 2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. @@ -19,7 +19,7 @@ resource "mongodbatlas_resource_policy" "project_ip_access_list" { body = < 8.0 (always normalized to `major.minor`) + "state_name", // Cluster state can change from IDLE to UPDATING and risks making the test flaky ) // auto_scaling & specs (electable_specs, read_only_specs, etc.) are only set in state in SDKv2 if present in the definition. // However, as import doesn't have a previous state to compare with, import will always fill them. // This will make these fields differ in the state, although the plan change won't be shown to the user as they're computed values. - if !config.AdvancedClusterV2Schema() { - ignorePrefixFields = append(ignorePrefixFields, "replication_specs") + if !config.PreviewProviderV2AdvancedCluster() { + ignorePrefixFields = append(ignorePrefixFields, "replication_specs", "id") // TenantUpgrade changes the ID and can make the test flaky } return resource.TestStep{ ResourceName: resourceName, @@ -137,7 +139,7 @@ func CheckFCVPinningConfig(isAcc bool, resourceName, dataSourceName, pluralDataS additionalCheck := resource.TestCheckResourceAttrWith(resourceName, "mongo_db_version", MatchesExpression(fmt.Sprintf("%d..*", mongoDBMajorVersion))) - return CheckRSAndDSSchemaV2(isAcc, resourceName, admin.PtrString(dataSourceName), admin.PtrString(pluralDataSourceName), []string{}, mapChecks, additionalCheck) + return CheckRSAndDSPreviewProviderV2(isAcc, resourceName, admin.PtrString(dataSourceName), admin.PtrString(pluralDataSourceName), []string{}, mapChecks, additionalCheck) } func CheckIndependentShardScalingMode(resourceName, clusterName, expectedMode string) resource.TestCheckFunc { diff --git a/internal/testutil/acc/advanced_cluster_schema_v2.go b/internal/testutil/acc/advanced_cluster_preview_provider_v2.go similarity index 60% rename from internal/testutil/acc/advanced_cluster_schema_v2.go rename to internal/testutil/acc/advanced_cluster_preview_provider_v2.go index 3ee9bca22a..20e21731b0 100644 --- a/internal/testutil/acc/advanced_cluster_schema_v2.go +++ b/internal/testutil/acc/advanced_cluster_preview_provider_v2.go @@ -14,58 +14,58 @@ import ( "github.com/stretchr/testify/assert" ) -func CheckRSAndDSSchemaV2(isAcc bool, resourceName string, dataSourceName, pluralDataSourceName *string, attrsSet []string, attrsMap map[string]string, extra ...resource.TestCheckFunc) resource.TestCheckFunc { - modifiedSet := ConvertToSchemaV2AttrsSet(isAcc, attrsSet) - modifiedMap := ConvertToSchemaV2AttrsMap(isAcc, attrsMap) +func CheckRSAndDSPreviewProviderV2(isAcc bool, resourceName string, dataSourceName, pluralDataSourceName *string, attrsSet []string, attrsMap map[string]string, extra ...resource.TestCheckFunc) resource.TestCheckFunc { + modifiedSet := ConvertToPreviewProviderV2AttrsSet(isAcc, attrsSet) + modifiedMap := ConvertToPreviewProviderV2AttrsMap(isAcc, attrsMap) return CheckRSAndDS(resourceName, dataSourceName, pluralDataSourceName, modifiedSet, modifiedMap, extra...) } -func TestCheckResourceAttrSchemaV2(isAcc bool, name, key, value string) resource.TestCheckFunc { - return resource.TestCheckResourceAttr(name, AttrNameToSchemaV2(isAcc, key), value) +func TestCheckResourceAttrPreviewProviderV2(isAcc bool, name, key, value string) resource.TestCheckFunc { + return resource.TestCheckResourceAttr(name, AttrNameToPreviewProviderV2(isAcc, key), value) } -func TestCheckResourceAttrSetSchemaV2(isAcc bool, name, key string) resource.TestCheckFunc { - return resource.TestCheckResourceAttrSet(name, AttrNameToSchemaV2(isAcc, key)) +func TestCheckResourceAttrSetPreviewProviderV2(isAcc bool, name, key string) resource.TestCheckFunc { + return resource.TestCheckResourceAttrSet(name, AttrNameToPreviewProviderV2(isAcc, key)) } -func TestCheckResourceAttrWithSchemaV2(isAcc bool, name, key string, checkValueFunc resource.CheckResourceAttrWithFunc) resource.TestCheckFunc { - return resource.TestCheckResourceAttrWith(name, AttrNameToSchemaV2(isAcc, key), checkValueFunc) +func TestCheckResourceAttrWithPreviewProviderV2(isAcc bool, name, key string, checkValueFunc resource.CheckResourceAttrWithFunc) resource.TestCheckFunc { + return resource.TestCheckResourceAttrWith(name, AttrNameToPreviewProviderV2(isAcc, key), checkValueFunc) } -func TestCheckTypeSetElemNestedAttrsSchemaV2(isAcc bool, name, key string, values map[string]string) resource.TestCheckFunc { - return resource.TestCheckTypeSetElemNestedAttrs(name, AttrNameToSchemaV2(isAcc, key), values) +func TestCheckTypeSetElemNestedAttrsPreviewProviderV2(isAcc bool, name, key string, values map[string]string) resource.TestCheckFunc { + return resource.TestCheckTypeSetElemNestedAttrs(name, AttrNameToPreviewProviderV2(isAcc, key), values) } -func AddAttrChecksSchemaV2(isAcc bool, name string, checks []resource.TestCheckFunc, mapChecks map[string]string) []resource.TestCheckFunc { - return AddAttrChecks(name, checks, ConvertToSchemaV2AttrsMap(isAcc, mapChecks)) +func AddAttrChecksPreviewProviderV2(isAcc bool, name string, checks []resource.TestCheckFunc, mapChecks map[string]string) []resource.TestCheckFunc { + return AddAttrChecks(name, checks, ConvertToPreviewProviderV2AttrsMap(isAcc, mapChecks)) } -func AddAttrSetChecksSchemaV2(isAcc bool, name string, checks []resource.TestCheckFunc, attrNames ...string) []resource.TestCheckFunc { - return AddAttrSetChecks(name, checks, ConvertToSchemaV2AttrsSet(isAcc, attrNames)...) +func AddAttrSetChecksPreviewProviderV2(isAcc bool, name string, checks []resource.TestCheckFunc, attrNames ...string) []resource.TestCheckFunc { + return AddAttrSetChecks(name, checks, ConvertToPreviewProviderV2AttrsSet(isAcc, attrNames)...) } -func AddAttrChecksPrefixSchemaV2(isAcc bool, name string, checks []resource.TestCheckFunc, mapChecks map[string]string, prefix string, skipNames ...string) []resource.TestCheckFunc { - return AddAttrChecksPrefix(name, checks, ConvertToSchemaV2AttrsMap(isAcc, mapChecks), prefix, skipNames...) +func AddAttrChecksPrefixPreviewProviderV2(isAcc bool, name string, checks []resource.TestCheckFunc, mapChecks map[string]string, prefix string, skipNames ...string) []resource.TestCheckFunc { + return AddAttrChecksPrefix(name, checks, ConvertToPreviewProviderV2AttrsMap(isAcc, mapChecks), prefix, skipNames...) } -func ConvertToSchemaV2AttrsMap(isAcc bool, attrsMap map[string]string) map[string]string { - if skipSchemaV2Work(isAcc) { +func ConvertToPreviewProviderV2AttrsMap(isAcc bool, attrsMap map[string]string) map[string]string { + if skipPreviewProviderV2Work(isAcc) { return attrsMap } ret := make(map[string]string, len(attrsMap)) for name, value := range attrsMap { - ret[AttrNameToSchemaV2(isAcc, name)] = value + ret[AttrNameToPreviewProviderV2(isAcc, name)] = value } return ret } -func ConvertToSchemaV2AttrsSet(isAcc bool, attrsSet []string) []string { - if skipSchemaV2Work(isAcc) { +func ConvertToPreviewProviderV2AttrsSet(isAcc bool, attrsSet []string) []string { + if skipPreviewProviderV2Work(isAcc) { return attrsSet } ret := make([]string, 0, len(attrsSet)) for _, name := range attrsSet { - ret = append(ret, AttrNameToSchemaV2(isAcc, name)) + ret = append(ret, AttrNameToPreviewProviderV2(isAcc, name)) } return ret } @@ -83,8 +83,8 @@ var tpfSingleNestedAttrs = []string{ "tags", } -func AttrNameToSchemaV2(isAcc bool, name string) string { - if skipSchemaV2Work(isAcc) { +func AttrNameToPreviewProviderV2(isAcc bool, name string) string { + if skipPreviewProviderV2Work(isAcc) { return name } for _, singleAttrName := range tpfSingleNestedAttrs { @@ -93,9 +93,9 @@ func AttrNameToSchemaV2(isAcc bool, name string) string { return name } -func ConvertAdvancedClusterToSchemaV2(t *testing.T, isAcc bool, def string) string { +func ConvertAdvancedClusterToPreviewProviderV2(t *testing.T, isAcc bool, def string) string { t.Helper() - if skipSchemaV2Work(isAcc) { + if skipPreviewProviderV2Work(isAcc) { return def } parse := hcl.GetDefParser(t, def) @@ -118,8 +118,8 @@ func ConvertAdvancedClusterToSchemaV2(t *testing.T, isAcc bool, def string) stri return string(content) } -func skipSchemaV2Work(isAcc bool) bool { - return !config.AdvancedClusterV2Schema() || !isAcc +func skipPreviewProviderV2Work(isAcc bool) bool { + return !config.PreviewProviderV2AdvancedCluster() || !isAcc } func AssertEqualHCL(t *testing.T, expected, actual string, msgAndArgs ...interface{}) { diff --git a/internal/testutil/acc/advanced_cluster_schema_v2_test.go b/internal/testutil/acc/advanced_cluster_preview_provider_v2_test.go similarity index 90% rename from internal/testutil/acc/advanced_cluster_schema_v2_test.go rename to internal/testutil/acc/advanced_cluster_preview_provider_v2_test.go index c37799cfca..737a966ec4 100644 --- a/internal/testutil/acc/advanced_cluster_schema_v2_test.go +++ b/internal/testutil/acc/advanced_cluster_preview_provider_v2_test.go @@ -9,9 +9,9 @@ import ( "github.com/stretchr/testify/assert" ) -func TestConvertToSchemaV2AttrsMapAndAttrsSet(t *testing.T) { - if !config.AdvancedClusterV2Schema() { - t.Skip("Skipping test as not in AdvancedClusterV2Schema") +func TestConvertToPreviewProviderV2AttrsMapAndAttrsSet(t *testing.T) { + if !config.PreviewProviderV2AdvancedCluster() { + t.Skip("Skipping test as not in PreviewProviderV2AdvancedCluster") } attrsMap := map[string]string{ "attr": "val1", @@ -31,7 +31,7 @@ func TestConvertToSchemaV2AttrsMapAndAttrsSet(t *testing.T) { "connection_strings.standard": "val6", "connection_strings.standard_srv": "val6", } - actualMap := acc.ConvertToSchemaV2AttrsMap(true, attrsMap) + actualMap := acc.ConvertToPreviewProviderV2AttrsMap(true, attrsMap) assert.Equal(t, expectedMap, actualMap) attrsSet := make([]string, 0, len(attrsMap)) @@ -42,15 +42,15 @@ func TestConvertToSchemaV2AttrsMapAndAttrsSet(t *testing.T) { for name := range expectedMap { expectedSet = append(expectedSet, name) } - actualSet := acc.ConvertToSchemaV2AttrsSet(true, attrsSet) + actualSet := acc.ConvertToPreviewProviderV2AttrsSet(true, attrsSet) sort.Strings(expectedSet) sort.Strings(actualSet) assert.Equal(t, expectedSet, actualSet) } -func TestConvertAdvancedClusterToSchemaV2(t *testing.T) { - if !config.AdvancedClusterV2Schema() { - t.Skip("Skipping test as not in AdvancedClusterV2Schema") +func TestConvertAdvancedClusterToPreviewProviderV2(t *testing.T) { + if !config.PreviewProviderV2AdvancedCluster() { + t.Skip("Skipping test as not in PreviewProviderV2AdvancedCluster") } var ( input = ` @@ -161,7 +161,7 @@ func TestConvertAdvancedClusterToSchemaV2(t *testing.T) { } } ` - // expected has the attributes sorted alphabetically to match the output of ConvertAdvancedClusterToSchemaV2 + // expected has the attributes sorted alphabetically to match the output of ConvertAdvancedClusterToPreviewProviderV2 expected = ` resource "mongodbatlas_advanced_cluster" "cluster2" { project_id = "MY-PROJECT-ID" @@ -252,7 +252,7 @@ func TestConvertAdvancedClusterToSchemaV2(t *testing.T) { } ` ) - actual := acc.ConvertAdvancedClusterToSchemaV2(t, true, input) + actual := acc.ConvertAdvancedClusterToPreviewProviderV2(t, true, input) acc.AssertEqualHCL(t, expected, actual) } diff --git a/internal/testutil/acc/atlas.go b/internal/testutil/acc/atlas.go index 75397bfa8a..6613b2ddae 100644 --- a/internal/testutil/acc/atlas.go +++ b/internal/testutil/acc/atlas.go @@ -10,7 +10,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster" "github.com/stretchr/testify/require" - "go.mongodb.org/atlas-sdk/v20241113004/admin" + "go.mongodb.org/atlas-sdk/v20241113005/admin" ) func createProject(tb testing.TB, name string) string { diff --git a/internal/testutil/acc/cluster.go b/internal/testutil/acc/cluster.go index fac1084a7c..cda4d36d8e 100644 --- a/internal/testutil/acc/cluster.go +++ b/internal/testutil/acc/cluster.go @@ -7,7 +7,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" - "go.mongodb.org/atlas-sdk/v20241113004/admin" + "go.mongodb.org/atlas-sdk/v20241113005/admin" ) // ClusterRequest contains configuration for a cluster where all fields are optional and AddDefaults is used for required fields. diff --git a/internal/testutil/acc/config_cluster.go b/internal/testutil/acc/config_cluster.go index 1ce4340414..0dea91104d 100644 --- a/internal/testutil/acc/config_cluster.go +++ b/internal/testutil/acc/config_cluster.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/hcl/v2/hclwrite" "github.com/zclconf/go-cty/cty" - "go.mongodb.org/atlas-sdk/v20241113004/admin" + "go.mongodb.org/atlas-sdk/v20241113005/admin" ) func ClusterDatasourceHcl(req *ClusterRequest) (configStr, clusterName, resourceName string, err error) { diff --git a/internal/testutil/acc/database_user.go b/internal/testutil/acc/database_user.go index a9a55cdc71..f43ed8467e 100644 --- a/internal/testutil/acc/database_user.go +++ b/internal/testutil/acc/database_user.go @@ -3,7 +3,7 @@ package acc import ( "fmt" - "go.mongodb.org/atlas-sdk/v20241113004/admin" + "go.mongodb.org/atlas-sdk/v20241113005/admin" ) func ConfigDatabaseUserBasic(projectID, username, roleName, keyLabel, valueLabel string) string { diff --git a/internal/testutil/acc/encryption_at_rest.go b/internal/testutil/acc/encryption_at_rest.go index 15ec43fcb2..f3c1d7d3a1 100644 --- a/internal/testutil/acc/encryption_at_rest.go +++ b/internal/testutil/acc/encryption_at_rest.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "go.mongodb.org/atlas-sdk/v20241113004/admin" + "go.mongodb.org/atlas-sdk/v20241113005/admin" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" diff --git a/internal/testutil/acc/factory.go b/internal/testutil/acc/factory.go index ece5578d07..4cc32e2496 100644 --- a/internal/testutil/acc/factory.go +++ b/internal/testutil/acc/factory.go @@ -10,7 +10,7 @@ import ( adminpreview "github.com/mongodb/atlas-sdk-go/admin" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" "github.com/mongodb/terraform-provider-mongodbatlas/internal/provider" - "go.mongodb.org/atlas-sdk/v20241113004/admin" + "go.mongodb.org/atlas-sdk/v20241113005/admin" ) const ( diff --git a/internal/testutil/acc/pre_check.go b/internal/testutil/acc/pre_check.go index 1dcb7d39a2..011b6e4f1c 100644 --- a/internal/testutil/acc/pre_check.go +++ b/internal/testutil/acc/pre_check.go @@ -21,8 +21,8 @@ func PreCheckBasic(tb testing.TB) { func SkipIfAdvancedClusterV2Schema(tb testing.TB) { tb.Helper() - if config.AdvancedClusterV2Schema() { - tb.Skip("Skipping test in AdvancedClusterV2Schema as implementation is pending or test is not applicable") + if config.PreviewProviderV2AdvancedCluster() { + tb.Skip("Skipping test in PreviewProviderV2AdvancedCluster as implementation is pending or test is not applicable") } } diff --git a/internal/testutil/acc/project.go b/internal/testutil/acc/project.go index a8b350619d..e168cec2d4 100644 --- a/internal/testutil/acc/project.go +++ b/internal/testutil/acc/project.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" - "go.mongodb.org/atlas-sdk/v20241113004/admin" + "go.mongodb.org/atlas-sdk/v20241113005/admin" ) func CheckDestroyProject(s *terraform.State) error { diff --git a/internal/testutil/acc/serverless.go b/internal/testutil/acc/serverless.go index ba968eeb4d..20dc63a2a9 100644 --- a/internal/testutil/acc/serverless.go +++ b/internal/testutil/acc/serverless.go @@ -3,7 +3,7 @@ package acc import ( "fmt" - "go.mongodb.org/atlas-sdk/v20241113004/admin" + "go.mongodb.org/atlas-sdk/v20241113005/admin" ) func ConfigServerlessInstance(projectID, name string, ignoreConnectionStrings bool, autoIndexing *bool, tags []admin.ResourceTag) string { diff --git a/internal/testutil/clean/org_clean_test.go b/internal/testutil/clean/org_clean_test.go index def2314d01..6975a39852 100644 --- a/internal/testutil/clean/org_clean_test.go +++ b/internal/testutil/clean/org_clean_test.go @@ -15,7 +15,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/dsschema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" "github.com/stretchr/testify/require" - "go.mongodb.org/atlas-sdk/v20241113004/admin" + "go.mongodb.org/atlas-sdk/v20241113005/admin" ) const ( diff --git a/internal/testutil/mig/test_case.go b/internal/testutil/mig/test_case.go index b55954e72c..b91cfedf8c 100644 --- a/internal/testutil/mig/test_case.go +++ b/internal/testutil/mig/test_case.go @@ -42,7 +42,7 @@ func CreateTest(t *testing.T, test *resource.TestCase) resource.TestCase { firstStep := test.Steps[0] steps := []resource.TestStep{ useExternalProvider(&firstStep, ExternalProviders()), - TestStepCheckEmptyPlan(acc.ConvertAdvancedClusterToSchemaV2(t, true, firstStep.Config)), + TestStepCheckEmptyPlan(acc.ConvertAdvancedClusterToPreviewProviderV2(t, true, firstStep.Config)), } newTest := reuseCase(test, steps) return newTest @@ -57,7 +57,7 @@ func CreateTestUseExternalProvider(t *testing.T, test *resource.TestCase, extern validateReusableCase(t, test) firstStep := test.Steps[0] require.NotContains(t, additionalProviders, "mongodbatlas", "Will use the local provider, cannot specify mongodbatlas provider") - emptyPlanStep := TestStepCheckEmptyPlan(acc.ConvertAdvancedClusterToSchemaV2(t, true, firstStep.Config)) + emptyPlanStep := TestStepCheckEmptyPlan(acc.ConvertAdvancedClusterToPreviewProviderV2(t, true, firstStep.Config)) steps := []resource.TestStep{ useExternalProvider(&firstStep, externalProviders), useExternalProvider(&emptyPlanStep, additionalProviders), diff --git a/internal/testutil/unit/http_mocker_api_paths_test.go b/internal/testutil/unit/http_mocker_api_paths_test.go index e5239d9cf7..8bccf00231 100644 --- a/internal/testutil/unit/http_mocker_api_paths_test.go +++ b/internal/testutil/unit/http_mocker_api_paths_test.go @@ -10,7 +10,7 @@ import ( func TestApiPathsParsing(t *testing.T) { specParts := unit.ReadAPISpecPaths() - assert.Len(t, specParts, 5) + assert.GreaterOrEqual(t, len(specParts), 5) assert.Contains(t, specParts, "GET") processArgsPath := "/api/atlas/v2/groups/6746ceed6f62fc3c122a3e0e/clusters/test-acc-tf-c-7871793563057636102/processArgs" getPaths := specParts["GET"] diff --git a/internal/testutil/unit/http_mocker_round_tripper_test.go b/internal/testutil/unit/http_mocker_round_tripper_test.go index fb795273a0..80af5e482c 100644 --- a/internal/testutil/unit/http_mocker_round_tripper_test.go +++ b/internal/testutil/unit/http_mocker_round_tripper_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.mongodb.org/atlas-sdk/v20241113004/admin" + "go.mongodb.org/atlas-sdk/v20241113005/admin" ) const reqPoliciesCreateBody = `{ diff --git a/templates/data-sources/resource_policies.md.tmpl b/templates/data-sources/resource_policies.md.tmpl index c27421881e..d33600ae2e 100644 --- a/templates/data-sources/resource_policies.md.tmpl +++ b/templates/data-sources/resource_policies.md.tmpl @@ -2,7 +2,7 @@ `{{.Name}}` returns all resource policies in an organization. --> **NOTE**: Resource Policies are currently in Private Preview. To use this feature, you must take the following actions: +-> **NOTE**: Resource Policies are currently in Public Preview. To use this feature, you must take the following actions: 1. Enable the `Atlas Resource Policies` Preview Feature in your organization (contact [MongoDB Support](https://www.mongodb.com/services/support)). 2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. diff --git a/templates/data-sources/resource_policy.md.tmpl b/templates/data-sources/resource_policy.md.tmpl index bbb0f96896..2db73d1923 100644 --- a/templates/data-sources/resource_policy.md.tmpl +++ b/templates/data-sources/resource_policy.md.tmpl @@ -2,7 +2,7 @@ `{{.Name}}` describes a resource policy in an organization. --> **NOTE**: Resource Policies are currently in Private Preview. To use this feature, you must take the following actions: +-> **NOTE**: Resource Policies are currently in Public Preview. To use this feature, you must take the following actions: 1. Enable the `Atlas Resource Policies` Preview Feature in your organization (contact [MongoDB Support](https://www.mongodb.com/services/support)). 2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. diff --git a/templates/resources/resource_policy.md.tmpl b/templates/resources/resource_policy.md.tmpl index 9466d22e97..f3d7fbe8e5 100644 --- a/templates/resources/resource_policy.md.tmpl +++ b/templates/resources/resource_policy.md.tmpl @@ -2,7 +2,7 @@ `{{.Name}}` provides a Resource Policy resource. The resource lets you create, edit and delete resource policies to prevent misconfigurations and reduce the need for corrective interventions in your organization. --> **NOTE**: Resource Policies are currently in Private Preview. To use this feature, you must take the following actions: +-> **NOTE**: Resource Policies are currently in Public Preview. To use this feature, you must take the following actions: 1. Enable the `Atlas Resource Policies` Preview Feature in your organization (contact [MongoDB Support](https://www.mongodb.com/services/support)). 2. Enable the [Preview Features](https://github.com/mongodb/terraform-provider-mongodbatlas?tab=readme-ov-file#preview-features) when running `terraform` commands. diff --git a/tools/scaffold/template/resource.tmpl b/tools/scaffold/template/resource.tmpl index 2a73237ffa..c2c0d2a342 100644 --- a/tools/scaffold/template/resource.tmpl +++ b/tools/scaffold/template/resource.tmpl @@ -7,6 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/validate" + ) const resourceName = "{{.NameSnakeCase}}" @@ -73,7 +75,7 @@ func (r *rs) Read(ctx context.Context, req resource.ReadRequest, resp *resource. // connV2 := r.Client.AtlasV2 //if err != nil { - // if apiResp != nil && apiResp.StatusCode == http.StatusNotFound { + // if validate.StatusNotFound(apiResp) { // resp.State.RemoveResource(ctx) // return // }