Skip to content

Commit 11601e6

Browse files
committed
rename schema v2 names
1 parent 584a9b7 commit 11601e6

15 files changed

+174
-174
lines changed

.github/workflows/acceptance-tests-runner.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,9 @@ jobs:
390390
terraform_version: ${{ inputs.terraform_version }}
391391
terraform_wrapper: false
392392
- name: Prepare new advanced_cluster
393-
run: make tools enable-advancedclustertpf
394-
- name: Unit tests # delete after allowAdvancedClusterV2Schema is removed
395-
run: go test -v ./internal/testutil/acc/advanced_cluster_schema_v2_test.go
393+
run: make tools enable-preview-provider-v2
394+
- name: Unit tests # delete after allowPreviewProviderV2 is removed
395+
run: go test -v ./internal/testutil/acc/advanced_cluster_preview_provider_v2_test.go
396396
- name: Mocked Acceptance Tests
397397
env:
398398
ACCTEST_REGEX_RUN: '^TestAccMockable'
@@ -433,7 +433,7 @@ jobs:
433433
terraform_version: ${{ matrix.terraform_version }}
434434
terraform_wrapper: false
435435
- name: Prepare new advanced_cluster
436-
run: make tools enable-advancedclustertpf
436+
run: make tools enable-preview-provider-v2
437437
- name: Acceptance Tests
438438
env:
439439
ACCTEST_REGEX_RUN: '^TestAccAdvancedCluster_move'

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ check-changelog-entry-file: ## Check a changelog entry file in a PR
191191
jira-release-version: ## Update Jira version in a release
192192
go run ./tools/jira-release-version/*.go
193193

194-
.PHONY: enable-advancedclustertpf
195-
enable-advancedclustertpf: ## Enable Advanced Cluster V2 Schema
196-
make change-lines filename=./internal/config/advanced_cluster_v2_schema.go find="allowAdvancedClusterV2Schema = false" new="allowAdvancedClusterV2Schema = true"
194+
.PHONY: enable-preview-provider-v2
195+
enable-preview-provider-v2: ## Enable Preview Provider V2
196+
make change-lines filename=./internal/config/advanced_cluster_preview_provider_v2.go find="allowPreviewProviderV2 = false" new="allowPreviewProviderV2 = true"
197197

198198
.PHONY: delete-lines ${filename} ${delete}
199199
delete-lines:

contributing/testing-best-practices.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Acceptance and migration tests can reuse projects and clusters in order to be mo
7474
**Experimental** framework for hooking into the HTTP Client used by the Terraform provider and capture/replay traffic.
7575
- Works by mutating a `terraform-plugin-testing/helper/resource.TestCase`
7676
- Limited to `TestAccMockable*` tests in [`resource_advanced_cluster_test.go`](../internal/service/advancedcluster/resource_advanced_cluster_test.go):
77-
- Remember to run `make enable-advancedclustertpf` and `export MONGODB_ATLAS_PREVIEW_PROVIDER_V2_ENABLED=true` for the TPF implementation to be used and the tests to work.
77+
- Remember to run `make enable-preview-provider-v2` and `export MONGODB_ATLAS_PREVIEW_PROVIDER_V2_ENABLED=true` for the TPF implementation to be used and the tests to work.
7878
- Enabled test cases should always be named with `TestAccMockable` prefix, e.g.: `TestAccMockableAdvancedCluster_tenantUpgrade`
7979
- To create a new `TestAccMockable` you would need to (see [example commit](https://github.com/mongodb/terraform-provider-mongodbatlas/commit/939244fcab95eca9c4c93993fc1b5118ab8bfddb#diff-f9c590f9ffc351d041a26ff474f91404ff394cbfb83f1e135b415998476ca62aR128))
8080
- (1) Write the normal acceptance test

internal/config/advanced_cluster_v2_schema.go

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package config
2+
3+
import (
4+
"os"
5+
"strconv"
6+
)
7+
8+
const PreviewProviderV2EnvVar = "MONGODB_ATLAS_PREVIEW_PROVIDER_V2_ENABLED"
9+
const allowPreviewProviderV2 = true // Don't allow in master branch yet, not in const block to allow automatic change
10+
11+
// Environment variable is read only once to avoid possible changes during runtime
12+
var previewProviderV2, _ = strconv.ParseBool(os.Getenv(PreviewProviderV2EnvVar))
13+
14+
func PreviewProviderV2() bool {
15+
return allowPreviewProviderV2 && previewProviderV2
16+
}

internal/config/advanced_cluster_v2_schema_test.go renamed to internal/config/preview_provider_v2_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ import (
88
)
99

1010
func TestAdvancedClusterV2Schema_notEnabled(t *testing.T) {
11-
t.Setenv(config.AdvancedClusterV2SchemaEnvVar, "true")
12-
assert.False(t, config.AdvancedClusterV2Schema(), "AdvancedClusterV2Schema can't be enabled yet")
11+
t.Setenv(config.PreviewProviderV2EnvVar, "true")
12+
assert.False(t, config.PreviewProviderV2(), "PreviewProviderV2 can't be enabled yet")
1313
}

internal/provider/provider.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ func (p *MongodbtlasProvider) DataSources(context.Context) []func() datasource.D
451451
streamprivatelinkendpoint.DataSource,
452452
streamprivatelinkendpoint.PluralDataSource,
453453
}
454-
if config.AdvancedClusterV2Schema() {
454+
if config.PreviewProviderV2() {
455455
dataSources = append(dataSources, advancedclustertpf.DataSource, advancedclustertpf.PluralDataSource)
456456
}
457457
previewDataSources := []func() datasource.DataSource{
@@ -482,7 +482,7 @@ func (p *MongodbtlasProvider) Resources(context.Context) []func() resource.Resou
482482
mongodbemployeeaccessgrant.Resource,
483483
streamprivatelinkendpoint.Resource,
484484
}
485-
if config.AdvancedClusterV2Schema() {
485+
if config.PreviewProviderV2() {
486486
resources = append(resources, advancedclustertpf.Resource)
487487
}
488488
previewResources := []func() resource.Resource{

internal/provider/provider_sdk2.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func getDataSourcesMap() map[string]*schema.Resource {
213213
"mongodbatlas_shared_tier_snapshot": sharedtier.DataSourceSnapshot(),
214214
"mongodbatlas_shared_tier_snapshots": sharedtier.PluralDataSourceSnapshot(),
215215
}
216-
if !config.AdvancedClusterV2Schema() {
216+
if !config.PreviewProviderV2() {
217217
dataSourcesMap["mongodbatlas_advanced_cluster"] = advancedcluster.DataSource()
218218
dataSourcesMap["mongodbatlas_advanced_clusters"] = advancedcluster.PluralDataSource()
219219
}
@@ -268,7 +268,7 @@ func getResourcesMap() map[string]*schema.Resource {
268268
"mongodbatlas_serverless_instance": serverlessinstance.Resource(),
269269
"mongodbatlas_cluster_outage_simulation": clusteroutagesimulation.Resource(),
270270
}
271-
if !config.AdvancedClusterV2Schema() {
271+
if !config.PreviewProviderV2() {
272272
resourcesMap["mongodbatlas_advanced_cluster"] = advancedcluster.Resource()
273273
}
274274
return resourcesMap

0 commit comments

Comments
 (0)