Skip to content

Commit 8020aa8

Browse files
authored
chore: Remove advancedcluster folder (#3698)
1 parent 38dbff6 commit 8020aa8

File tree

86 files changed

+977
-1901
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+977
-1901
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ jobs:
277277
with:
278278
filters: |
279279
advanced_cluster:
280-
- 'internal/service/advancedclustertpf/*.go'
280+
- 'internal/service/advancedcluster/*.go'
281281
assume_role:
282282
- 'internal/provider/*.go'
283283
autogen:
@@ -404,7 +404,7 @@ jobs:
404404
HTTP_MOCKER_CAPTURE: 'true'
405405
ACCTEST_REGEX_RUN: ${{ inputs.reduced_tests && '^TestAccMockable' || env.ACCTEST_REGEX_RUN }}
406406
ACCTEST_PACKAGES: |
407-
./internal/service/advancedclustertpf
407+
./internal/service/advancedcluster
408408
run: make testacc
409409

410410
advanced_cluster_tpf_mig_from_sdkv2:
@@ -430,7 +430,7 @@ jobs:
430430
MONGODB_ATLAS_TEST_SDKV2_TO_TPF: 'true'
431431
ACCTEST_REGEX_RUN: '^TestV1xMig'
432432
ACCTEST_PACKAGES: |
433-
./internal/service/advancedclustertpf
433+
./internal/service/advancedcluster
434434
run: make testacc
435435

436436
advanced_cluster_tpf_mig_from_tpf_preview:
@@ -457,7 +457,7 @@ jobs:
457457
MONGODB_ATLAS_TEST_SDKV2_TO_TPF: 'false'
458458
ACCTEST_REGEX_RUN: '^TestV1xMig'
459459
ACCTEST_PACKAGES: |
460-
./internal/service/advancedclustertpf
460+
./internal/service/advancedcluster
461461
run: make testacc
462462

463463
assume_role:

contributing/testing-best-practices.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,7 @@ It is advised to only run a **single** test at a time when a plural data source
136136
1. Import state with a fixed `.tf` file
137137
2. Run terraform plan with an updated `*.tf` file and perform plan checks, for example check for known/unknown values in the plan. The actual update is not performed. See [Hashicorp docs](https://pkg.go.dev/github.com/hashicorp/[email protected]/plancheck#PlanCheck) for plan check options.
138138

139-
For a full example see [plan_modifier_test.go](../internal/service/advancedclustertpf/plan_modifier_test.go).
140-
141-
### File generation
142-
For a full example of generation see [`http_mocker_plan_checks_test.go`](../internal/testutil/unit/http_mocker_plan_checks_test.go)
139+
For a full example see [plan_modifier_test.go](../internal/service/advancedcluster/plan_modifier_test.go).
143140

144141
1. Stores the last `GET` response from an existing [MacT](#mact---mocked-acceptance-tests) test case step. For example the last GET of `/api/atlas/v2/groups/{groupId}/clusters/{clusterName}`
145142
1. ImportName: `ClusterTwoRepSpecsWithAutoScalingAndSpecs`

internal/common/update/patch_framework.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/hashicorp/terraform-plugin-framework/diag"
88
)
99

10-
func PatchPayloadTpf[TFModel any, SDKRequest any](ctx context.Context, diags *diag.Diagnostics, state, plan *TFModel, converter func(ctx context.Context, input *TFModel, diags *diag.Diagnostics) *SDKRequest) *SDKRequest {
10+
func PatchPayloadCluster[TFModel any, SDKRequest any](ctx context.Context, diags *diag.Diagnostics, state, plan *TFModel, converter func(ctx context.Context, input *TFModel, diags *diag.Diagnostics) *SDKRequest) *SDKRequest {
1111
stateReq := converter(ctx, state, diags)
1212
planReq := converter(ctx, plan, diags)
1313
if diags.HasError() {

internal/provider/provider.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
2727
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/validate"
2828
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
29-
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedclustertpf"
29+
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster"
3030
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/alertconfiguration"
3131
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/apikeyprojectassignment"
3232
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/atlasuser"
@@ -495,8 +495,8 @@ func (p *MongodbtlasProvider) DataSources(context.Context) []func() datasource.D
495495
teamprojectassignment.DataSource,
496496
apikeyprojectassignment.DataSource,
497497
apikeyprojectassignment.PluralDataSource,
498-
advancedclustertpf.DataSource,
499-
advancedclustertpf.PluralDataSource,
498+
advancedcluster.DataSource,
499+
advancedcluster.PluralDataSource,
500500
}
501501
return dataSources
502502
}
@@ -523,7 +523,7 @@ func (p *MongodbtlasProvider) Resources(context.Context) []func() resource.Resou
523523
clouduserprojectassignment.Resource,
524524
teamprojectassignment.Resource,
525525
clouduserteamassignment.Resource,
526-
advancedclustertpf.Resource,
526+
advancedcluster.Resource,
527527
}
528528
return resources
529529
}

internal/service/advancedclustertpf/common.go renamed to internal/service/advancedcluster/common.go

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
package advancedclustertpf
1+
package advancedcluster
22

33
import (
4+
"context"
45
"fmt"
56
"strings"
67
"time"
@@ -9,9 +10,11 @@ import (
910
"go.mongodb.org/atlas-sdk/v20250312007/admin"
1011

1112
"github.com/hashicorp/terraform-plugin-framework/diag"
13+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
1214
"github.com/spf13/cast"
1315

1416
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant"
17+
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/validate"
1518
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/flexcluster"
1619
)
1720

@@ -114,3 +117,35 @@ func GetPriorityOfFlexReplicationSpecs(replicationSpecs *[]admin.ReplicationSpec
114117
}
115118
return regionConfig.Priority
116119
}
120+
121+
func ResourceClusterListAdvancedRefreshFunc(ctx context.Context, projectID string, clustersAPI admin.ClustersApi) retry.StateRefreshFunc {
122+
return func() (any, string, error) {
123+
clusters, resp, err := clustersAPI.ListClusters(ctx, projectID).Execute()
124+
125+
if err != nil && strings.Contains(err.Error(), "reset by peer") {
126+
return nil, "REPEATING", nil
127+
}
128+
129+
if err != nil && clusters == nil && resp == nil {
130+
return nil, "", err
131+
}
132+
133+
if err != nil {
134+
if validate.StatusNotFound(resp) {
135+
return "", "DELETED", nil
136+
}
137+
if validate.StatusServiceUnavailable(resp) {
138+
return "", "PENDING", nil
139+
}
140+
return nil, "", err
141+
}
142+
143+
for i := range clusters.GetResults() {
144+
cluster := clusters.GetResults()[i]
145+
if cluster.GetStateName() != "IDLE" {
146+
return cluster, "PENDING", nil
147+
}
148+
}
149+
return clusters, "IDLE", nil
150+
}
151+
}

internal/service/advancedclustertpf/common_admin_sdk.go renamed to internal/service/advancedcluster/common_admin_sdk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package advancedclustertpf
1+
package advancedcluster
22

33
import (
44
"context"

internal/service/advancedclustertpf/common_await_changes.go renamed to internal/service/advancedcluster/common_await_changes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package advancedclustertpf
1+
package advancedcluster
22

33
import (
44
"context"

internal/service/advancedclustertpf/common_model_sdk_version_conversion.go renamed to internal/service/advancedcluster/common_model_sdk_version_conversion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package advancedclustertpf
1+
package advancedcluster
22

33
import (
44
admin20240530 "go.mongodb.org/atlas-sdk/v20240530005/admin"

internal/service/advancedclustertpf/common_model_sdk_version_conversion_test.go renamed to internal/service/advancedcluster/common_model_sdk_version_conversion_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package advancedclustertpf_test
1+
package advancedcluster_test
22

33
import (
44
"testing"
55

66
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
7-
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedclustertpf"
7+
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster"
88
"github.com/stretchr/testify/assert"
99
admin20240805 "go.mongodb.org/atlas-sdk/v20240805005/admin"
1010
"go.mongodb.org/atlas-sdk/v20250312007/admin"
@@ -186,7 +186,7 @@ func TestConvertClusterDescription20241023to20240805(t *testing.T) {
186186

187187
for _, tc := range testCases {
188188
t.Run(tc.name, func(t *testing.T) {
189-
result := advancedclustertpf.ConvertClusterDescription20241023to20240805(tc.input)
189+
result := advancedcluster.ConvertClusterDescription20241023to20240805(tc.input)
190190
assert.Equal(t, tc.expectedOutput, result)
191191
})
192192
}

0 commit comments

Comments
 (0)