Skip to content

chore: Removes all usages of MONGODB_ATLAS_ENABLE_PREVIEW #3285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/acceptance-tests-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ on:
mongodb_atlas_project_ear_pe_id:
type: string
required: true
mongodb_atlas_enable_preview:
type: string
required: true
azure_private_endpoint_region:
type: string
required: true
Expand Down Expand Up @@ -661,7 +658,6 @@ jobs:
AZURE_KEY_IDENTIFIER: ${{ secrets.azure_key_identifier }}
AZURE_KEY_VAULT_NAME_UPDATED: ${{ secrets.azure_key_vault_name_updated }}
AZURE_KEY_IDENTIFIER_UPDATED: ${{ secrets.azure_key_identifier_updated }}
MONGODB_ATLAS_ENABLE_PREVIEW: ${{ inputs.mongodb_atlas_enable_preview }}
AWS_REGION: ${{ vars.AWS_REGION_LOWERCASE }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ jobs:
mongodb_atlas_project_ear_pe_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_PROJECT_EAR_PE_ID_QA || vars.MONGODB_ATLAS_PROJECT_EAR_PE_ID_DEV }}
mongodb_atlas_project_ear_pe_aws_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_PROJECT_EAR_PE_AWS_ID_QA || vars.MONGODB_ATLAS_PROJECT_EAR_PE_AWS_ID_DEV }}
aws_ear_role_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.AWS_EAR_ROLE_ID_QA || vars.AWS_EAR_ROLE_ID_DEV }}
mongodb_atlas_enable_preview: ${{ vars.MONGODB_ATLAS_ENABLE_PREVIEW }}
azure_private_endpoint_region: ${{ vars.AZURE_PRIVATE_ENDPOINT_REGION }}
mongodb_atlas_rp_org_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_RP_ORG_ID_QA || vars.MONGODB_ATLAS_RP_ORG_ID_DEV }}
confluent_cloud_network_id: ${{ vars.CONFLUENT_CLOUD_NETWORK_ID }}
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ on:

env:
AWS_DEFAULT_REGION: us-west-2
MONGODB_ATLAS_ENABLE_PREVIEW: "true"

jobs:
tf-validate:
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ To use a released provider in your Terraform environment, run [`terraform init`]

Documentation about the provider specific configuration options can be found on the [provider's website](https://www.terraform.io/docs/providers/).

## Preview Features
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to keep some generic Preview features doc, like each feature will have their own env.var?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had the same thought. Since we don't have a general purpose env var think it is okay to just call out in each specific resource as we currently do for advanced_cluster tfp (reference).

In order to use and/or test preview resources and datasources in this provider you'll need to set the environment variable `MONGODB_ATLAS_ENABLE_PREVIEW` to true.


```bash
export MONGODB_ATLAS_ENABLE_PREVIEW=true
```
## Logs
To help with issues, you can turn on Logs with `export TF_LOG=TRACE`. Note: this is very noisy.

Expand Down
13 changes: 0 additions & 13 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"log"
"os"
"regexp"
"strconv"
"time"

"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
Expand Down Expand Up @@ -50,10 +49,6 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/version"
)

var (
providerEnablePreview, _ = strconv.ParseBool(os.Getenv("MONGODB_ATLAS_ENABLE_PREVIEW"))
)

const (
MongodbGovCloudURL = "https://cloud.mongodbgov.com"
MongodbGovCloudQAURL = "https://cloud-qa.mongodbgov.com"
Expand Down Expand Up @@ -462,10 +457,6 @@ func (p *MongodbtlasProvider) DataSources(context.Context) []func() datasource.D
if config.PreviewProviderV2AdvancedCluster() {
dataSources = append(dataSources, advancedclustertpf.DataSource, advancedclustertpf.PluralDataSource)
}
previewDataSources := []func() datasource.DataSource{} // Data sources not yet in GA
if providerEnablePreview {
dataSources = append(dataSources, previewDataSources...)
}
return dataSources
}

Expand All @@ -490,10 +481,6 @@ func (p *MongodbtlasProvider) Resources(context.Context) []func() resource.Resou
if config.PreviewProviderV2AdvancedCluster() {
resources = append(resources, advancedclustertpf.Resource)
}
previewResources := []func() resource.Resource{} // Resources not yet in GA
if providerEnablePreview {
resources = append(resources, previewResources...)
}
return resources
}

Expand Down
10 changes: 2 additions & 8 deletions internal/service/resourcepolicy/resource_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ import (
)

func TestMigResourcePolicy_basic(t *testing.T) {
mig.SkipIfVersionBelow(t, "1.22.0") // this feature was introduced in provider version 1.21.0, plural data source schema was changed in 1.22.0

var description *string
if mig.IsProviderVersionAtLeast("1.32.0") {
description = descriptionPtr
}

mig.CreateAndRunTestNonParallel(t, basicTestCase(t, description))
Comment on lines -10 to -17
Copy link
Member Author

@AgustinBettati AgustinBettati Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a test failure in our CI that was detected today (reference failure, #3276 which caused failure).
Older versions require the env variable to be defined, since this PR completely remove the usages of legacy env variable this test would start running again after 1.33.0 release. Don't see significant concern as this test has been passing up until today, and will start running again as soon as we do our next release.

mig.SkipIfVersionBelow(t, "1.33.0") // this feature was GA (no need of MONGODB_ATLAS_ENABLE_PREVIEW env variable) in 1.33.0
mig.CreateAndRunTestNonParallel(t, basicTestCase(t))
}
17 changes: 7 additions & 10 deletions internal/service/resourcepolicy/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"

"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
)

Expand Down Expand Up @@ -52,33 +51,31 @@ var (
when {
context.project.ipAccessList.contains(ip("0.0.0.0/0"))
};`
descriptionPtr = conversion.StringPtr("test-description")
description = "test-description"
)

func TestAccResourcePolicy_basic(t *testing.T) {
tc := basicTestCase(t, descriptionPtr)
tc := basicTestCase(t)
resource.Test(t, *tc)
}

func basicTestCase(t *testing.T, description *string) *resource.TestCase {
func basicTestCase(t *testing.T) *resource.TestCase {
t.Helper()
var (
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
policyName = "test-policy"
updatedName = "updated-policy"
)
var updatedDescription string
if description != nil {
updatedDescription = fmt.Sprintf("updated-%s", *description)
}
updatedDescription := fmt.Sprintf("updated-%s", description)

return &resource.TestCase{ // Need sequential execution for assertions to be deterministic (plural data source)
PreCheck: func() { acc.PreCheckBasic(t) },
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: checkDestroy,
Steps: []resource.TestStep{
{
Config: configBasic(orgID, policyName, description),
Check: checksResourcePolicy(orgID, policyName, description, 1),
Config: configBasic(orgID, policyName, &description),
Check: checksResourcePolicy(orgID, policyName, &description, 1),
},
{
Config: configBasic(orgID, updatedName, nil),
Expand Down
8 changes: 0 additions & 8 deletions internal/testutil/acc/pre_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,6 @@ func PreCheckCert(tb testing.TB) {
}
}

// PreCheckPreviewFlag is used for resources not yet in GA
func PreCheckPreviewFlag(tb testing.TB) {
tb.Helper()
if os.Getenv("MONGODB_ATLAS_ENABLE_PREVIEW") == "" {
tb.Fatal("`MONGODB_ATLAS_ENABLE_PREVIEW` must be set for running this acceptance test")
}
}

func PreCheckCloudProviderAccessAzure(tb testing.TB) {
tb.Helper()
PreCheckBasic(tb)
Expand Down
3 changes: 0 additions & 3 deletions scripts/generate-doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ if [ ! -f "${TEMPLATE_FOLDER_PATH}/data-sources/${resource_name}s.md.tmpl" ]; th
printf "Skipping this check: We assume that the resource does not have a plural data source.\n\n"
fi

# ensure preview resource and data sources are also included during generation
export MONGODB_ATLAS_ENABLE_PREVIEW="true"

trap 'rm -R docs-out/' EXIT # temp dir cleanup when script exits

tfplugindocs generate --tf-version "${TF_VERSION}" --website-source-dir "${TEMPLATE_FOLDER_PATH}" --rendered-website-dir "docs-out"
Expand Down
3 changes: 0 additions & 3 deletions scripts/generate-docs-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ set -euo pipefail
TF_VERSION="${TF_VERSION:-"1.11.4"}" # TF version to use when running tfplugindocs. Default: 1.11.4
TEMPLATE_FOLDER_PATH="${TEMPLATE_FOLDER_PATH:-"templates"}" # PATH to the templates folder. Default: templates

# ensure preview resource and data sources are also included during generation
export MONGODB_ATLAS_ENABLE_PREVIEW="true"

trap 'rm -R docs-out/' EXIT # temp dir cleanup when script exits

tfplugindocs generate --tf-version "${TF_VERSION}" --website-source-dir "${TEMPLATE_FOLDER_PATH}" --rendered-website-dir "docs-out" --provider-name "mongodbatlas"
Expand Down