diff --git a/.github/workflows/acceptance-tests.yml b/.github/workflows/acceptance-tests.yml index ce3788483e..a250e350f8 100644 --- a/.github/workflows/acceptance-tests.yml +++ b/.github/workflows/acceptance-tests.yml @@ -66,8 +66,8 @@ jobs: - 'internal/service/searchdeployment/*.go' generic: - 'internal/service/backupcompliancepolicy/*.go' + - 'internal/service/auditing/*.go' - 'mongodbatlas/resource_x509_authentication_database_user*.go' - - 'mongodbatlas/resource_auditing*.go' backup_online_archive: - 'mongodbatlas/**online_archive**.go' backup_snapshots: @@ -79,13 +79,14 @@ jobs: project: - 'internal/service/project/*.go' - 'internal/service/projectipaccesslist/*.go' + - 'internal/service/accesslistapikey/*.go' - 'mongodbatlas/data_source_project_invitation*.go' - - 'mongodbatlas/resource_access_list_api_key*.go' - 'mongodbatlas/resource_project_invitation*.go' serverless: - 'mongodbatlas/**_serverless**.go' network: - - 'mongodbatlas/**_network**.go' + - 'internal/service/networkcontainer/*.go' + - 'internal/service/networkpeering/*.go' - 'mongodbatlas/**_privatelink**.go' - 'mongodbatlas/**_private_endpoint**.go' federation: @@ -95,24 +96,19 @@ jobs: - 'internal/service/atlasuser/*.go' - 'internal/service/databaseuser/*.go' - 'internal/service/projectapikey/*.go' - - 'mongodbatlas/data_source_accesslist_api_key*.go' - - 'mongodbatlas/data_source_api_key*.go' + - 'internal/service/apikey/*.go' + - 'internal/service/teams/*.go' - 'internal/service/cloudprovideraccess/*.go' - - 'mongodbatlas/data_source_custom_db_role*.go' + - 'internal/service/customdbrole/*.go' + - 'internal/service/maintenancewindow/*.go' - 'mongodbatlas/data_source_custom_dns_configuration_cluster_aws*.go' - - 'mongodbatlas/data_source_maintenance_window*.go' - 'mongodbatlas/data_source_org_id*.go' - 'mongodbatlas/data_source_org_invitation*.go' - 'mongodbatlas/data_source_organization*.go' - - 'mongodbatlas/data_source_team*.go' - 'mongodbatlas/data_source_third_party_integration*.go' - - 'mongodbatlas/resource_api_key*.go' - - 'mongodbatlas/resource_custom_db_role*.go' - 'mongodbatlas/resource_custom_dns_configuration_cluster_aws*.go' - - 'mongodbatlas/resource_maintenance_window*.go' - 'mongodbatlas/resource_org_invitation*.go' - 'mongodbatlas/resource_organization*.go' - - 'mongodbatlas/resource_team*.go' - 'mongodbatlas/resource_third_party_integration*.go' event_trigger: - 'mongodbatlas/resource_event_trigger*.go' diff --git a/internal/provider/provider_sdk2.go b/internal/provider/provider_sdk2.go index 6101e825b4..f0f130894e 100644 --- a/internal/provider/provider_sdk2.go +++ b/internal/provider/provider_sdk2.go @@ -13,7 +13,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/accesslistapikey" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/apikey" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/auditing" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/backupcompliancepolicy" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/cloudbackupschedule" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/cloudbackupsnapshot" @@ -22,12 +25,17 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/cloudbackupsnapshotrestorejob" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/cloudprovideraccess" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/cluster" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/customdbrole" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/federateddatabaseinstance" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/federatedquerylimit" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/federatedsettingsidentityprovider" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/federatedsettingsorgconfig" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/federatedsettingsorgrolemapping" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/maintenancewindow" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/networkcontainer" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/networkpeering" "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/projectapikey" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/teams" "github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas" "github.com/mwielbut/pointy" ) @@ -115,25 +123,25 @@ func getDataSourcesMap() map[string]*schema.Resource { dataSourcesMap := map[string]*schema.Resource{ "mongodbatlas_advanced_cluster": advancedcluster.DataSource(), "mongodbatlas_advanced_clusters": advancedcluster.PluralDataSource(), - "mongodbatlas_custom_db_role": mongodbatlas.DataSourceCustomDBRole(), - "mongodbatlas_custom_db_roles": mongodbatlas.DataSourceCustomDBRoles(), - "mongodbatlas_api_key": mongodbatlas.DataSourceAPIKey(), - "mongodbatlas_api_keys": mongodbatlas.DataSourceAPIKeys(), - "mongodbatlas_access_list_api_key": mongodbatlas.DataSourceAccessListAPIKey(), - "mongodbatlas_access_list_api_keys": mongodbatlas.DataSourceAccessListAPIKeys(), + "mongodbatlas_custom_db_role": customdbrole.DataSource(), + "mongodbatlas_custom_db_roles": customdbrole.PluralDataSource(), + "mongodbatlas_api_key": apikey.DataSource(), + "mongodbatlas_api_keys": apikey.PluralDataSource(), + "mongodbatlas_access_list_api_key": accesslistapikey.DataSource(), + "mongodbatlas_access_list_api_keys": accesslistapikey.PluralDataSource(), "mongodbatlas_project_api_key": projectapikey.DataSource(), "mongodbatlas_project_api_keys": projectapikey.PluralDataSource(), "mongodbatlas_roles_org_id": mongodbatlas.DataSourceOrgID(), "mongodbatlas_cluster": cluster.DataSource(), "mongodbatlas_clusters": cluster.PluralDataSource(), - "mongodbatlas_network_container": mongodbatlas.DataSourceNetworkContainer(), - "mongodbatlas_network_containers": mongodbatlas.DataSourceNetworkContainers(), - "mongodbatlas_network_peering": mongodbatlas.DataSourceNetworkPeering(), - "mongodbatlas_network_peerings": mongodbatlas.DataSourceNetworkPeerings(), - "mongodbatlas_maintenance_window": mongodbatlas.DataSourceMaintenanceWindow(), - "mongodbatlas_auditing": mongodbatlas.DataSourceAuditing(), - "mongodbatlas_team": mongodbatlas.DataSourceTeam(), - "mongodbatlas_teams": mongodbatlas.DataSourceTeam(), + "mongodbatlas_network_container": networkcontainer.DataSource(), + "mongodbatlas_network_containers": networkcontainer.PluralDataSource(), + "mongodbatlas_network_peering": networkpeering.DataSource(), + "mongodbatlas_network_peerings": networkpeering.PluralDataSource(), + "mongodbatlas_maintenance_window": maintenancewindow.DataSource(), + "mongodbatlas_auditing": auditing.DataSource(), + "mongodbatlas_team": teams.DataSource(), + "mongodbatlas_teams": teams.DataSource(), "mongodbatlas_global_cluster_config": mongodbatlas.DataSourceGlobalCluster(), "mongodbatlas_x509_authentication_database_user": mongodbatlas.DataSourceX509AuthDBUser(), "mongodbatlas_private_endpoint_regional_mode": mongodbatlas.DataSourcePrivateEndpointRegionalMode(), @@ -199,17 +207,17 @@ func getDataSourcesMap() map[string]*schema.Resource { func getResourcesMap() map[string]*schema.Resource { resourcesMap := map[string]*schema.Resource{ "mongodbatlas_advanced_cluster": advancedcluster.Resource(), - "mongodbatlas_api_key": mongodbatlas.ResourceAPIKey(), - "mongodbatlas_access_list_api_key": mongodbatlas.ResourceAccessListAPIKey(), + "mongodbatlas_api_key": apikey.Resource(), + "mongodbatlas_access_list_api_key": accesslistapikey.Resource(), "mongodbatlas_project_api_key": projectapikey.Resource(), - "mongodbatlas_custom_db_role": mongodbatlas.ResourceCustomDBRole(), + "mongodbatlas_custom_db_role": customdbrole.Resource(), "mongodbatlas_cluster": cluster.Resource(), - "mongodbatlas_network_container": mongodbatlas.ResourceNetworkContainer(), - "mongodbatlas_network_peering": mongodbatlas.ResourceNetworkPeering(), - "mongodbatlas_maintenance_window": mongodbatlas.ResourceMaintenanceWindow(), - "mongodbatlas_auditing": mongodbatlas.ResourceAuditing(), - "mongodbatlas_team": mongodbatlas.ResourceTeam(), - "mongodbatlas_teams": mongodbatlas.ResourceTeam(), + "mongodbatlas_network_container": networkcontainer.Resource(), + "mongodbatlas_network_peering": networkpeering.Resource(), + "mongodbatlas_maintenance_window": maintenancewindow.Resource(), + "mongodbatlas_auditing": auditing.Resource(), + "mongodbatlas_team": teams.Resource(), + "mongodbatlas_teams": teams.Resource(), "mongodbatlas_global_cluster_config": mongodbatlas.ResourceGlobalCluster(), "mongodbatlas_x509_authentication_database_user": mongodbatlas.ResourceX509AuthDBUser(), "mongodbatlas_private_endpoint_regional_mode": mongodbatlas.ResourcePrivateEndpointRegionalMode(), diff --git a/mongodbatlas/data_source_accesslist_api_key.go b/internal/service/accesslistapikey/data_source_accesslist_api_key.go similarity index 97% rename from mongodbatlas/data_source_accesslist_api_key.go rename to internal/service/accesslistapikey/data_source_accesslist_api_key.go index 9476bdf90f..d1b4052705 100644 --- a/mongodbatlas/data_source_accesslist_api_key.go +++ b/internal/service/accesslistapikey/data_source_accesslist_api_key.go @@ -1,4 +1,4 @@ -package mongodbatlas +package accesslistapikey import ( "context" @@ -11,7 +11,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) -func DataSourceAccessListAPIKey() *schema.Resource { +func DataSource() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceMongoDBAtlasAccessListAPIKeyRead, Schema: map[string]*schema.Schema{ diff --git a/mongodbatlas/data_source_accesslist_api_key_test.go b/internal/service/accesslistapikey/data_source_accesslist_api_key_test.go similarity index 98% rename from mongodbatlas/data_source_accesslist_api_key_test.go rename to internal/service/accesslistapikey/data_source_accesslist_api_key_test.go index 20c9ce0a19..8406423eae 100644 --- a/mongodbatlas/data_source_accesslist_api_key_test.go +++ b/internal/service/accesslistapikey/data_source_accesslist_api_key_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package accesslistapikey_test import ( "fmt" diff --git a/mongodbatlas/data_source_accesslist_api_keys.go b/internal/service/accesslistapikey/data_source_accesslist_api_keys.go similarity index 96% rename from mongodbatlas/data_source_accesslist_api_keys.go rename to internal/service/accesslistapikey/data_source_accesslist_api_keys.go index 3a0c561c27..c01f6ec0be 100644 --- a/mongodbatlas/data_source_accesslist_api_keys.go +++ b/internal/service/accesslistapikey/data_source_accesslist_api_keys.go @@ -1,4 +1,4 @@ -package mongodbatlas +package accesslistapikey import ( "context" @@ -12,7 +12,7 @@ import ( matlas "go.mongodb.org/atlas/mongodbatlas" ) -func DataSourceAccessListAPIKeys() *schema.Resource { +func PluralDataSource() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceMongoDBAtlasAccessListAPIKeysRead, Schema: map[string]*schema.Schema{ diff --git a/mongodbatlas/data_source_accesslist_api_keys_test.go b/internal/service/accesslistapikey/data_source_accesslist_api_keys_test.go similarity index 98% rename from mongodbatlas/data_source_accesslist_api_keys_test.go rename to internal/service/accesslistapikey/data_source_accesslist_api_keys_test.go index 8f554a2db6..bbb235ddaf 100644 --- a/mongodbatlas/data_source_accesslist_api_keys_test.go +++ b/internal/service/accesslistapikey/data_source_accesslist_api_keys_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package accesslistapikey_test import ( "fmt" diff --git a/mongodbatlas/resource_access_list_api_key.go b/internal/service/accesslistapikey/resource_access_list_api_key.go similarity index 98% rename from mongodbatlas/resource_access_list_api_key.go rename to internal/service/accesslistapikey/resource_access_list_api_key.go index edd5a3cf5a..3f00117a2f 100644 --- a/mongodbatlas/resource_access_list_api_key.go +++ b/internal/service/accesslistapikey/resource_access_list_api_key.go @@ -1,4 +1,4 @@ -package mongodbatlas +package accesslistapikey import ( "context" @@ -16,7 +16,7 @@ import ( matlas "go.mongodb.org/atlas/mongodbatlas" ) -func ResourceAccessListAPIKey() *schema.Resource { +func Resource() *schema.Resource { return &schema.Resource{ CreateContext: resourceMongoDBAtlasAccessListAPIKeyCreate, ReadContext: resourceMongoDBAtlasAccessListAPIKeyRead, diff --git a/mongodbatlas/resource_access_list_api_key_test.go b/internal/service/accesslistapikey/resource_access_list_api_key_test.go similarity index 99% rename from mongodbatlas/resource_access_list_api_key_test.go rename to internal/service/accesslistapikey/resource_access_list_api_key_test.go index 7e5c2280b9..83d61cf932 100644 --- a/mongodbatlas/resource_access_list_api_key_test.go +++ b/internal/service/accesslistapikey/resource_access_list_api_key_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package accesslistapikey_test import ( "context" diff --git a/mongodbatlas/data_source_api_key.go b/internal/service/apikey/data_source_api_key.go similarity index 96% rename from mongodbatlas/data_source_api_key.go rename to internal/service/apikey/data_source_api_key.go index 9f857cb673..0dc17fbd12 100644 --- a/mongodbatlas/data_source_api_key.go +++ b/internal/service/apikey/data_source_api_key.go @@ -1,4 +1,4 @@ -package mongodbatlas +package apikey import ( "context" @@ -10,7 +10,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) -func DataSourceAPIKey() *schema.Resource { +func DataSource() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceMongoDBAtlasAPIKeyRead, Schema: map[string]*schema.Schema{ diff --git a/mongodbatlas/data_source_api_key_test.go b/internal/service/apikey/data_source_api_key_test.go similarity index 98% rename from mongodbatlas/data_source_api_key_test.go rename to internal/service/apikey/data_source_api_key_test.go index 835ba6329f..77e721b562 100644 --- a/mongodbatlas/data_source_api_key_test.go +++ b/internal/service/apikey/data_source_api_key_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package apikey_test import ( "fmt" diff --git a/mongodbatlas/data_source_api_keys.go b/internal/service/apikey/data_source_api_keys.go similarity index 96% rename from mongodbatlas/data_source_api_keys.go rename to internal/service/apikey/data_source_api_keys.go index 899ac1268f..ea4299d352 100644 --- a/mongodbatlas/data_source_api_keys.go +++ b/internal/service/apikey/data_source_api_keys.go @@ -1,4 +1,4 @@ -package mongodbatlas +package apikey import ( "context" @@ -12,7 +12,7 @@ import ( matlas "go.mongodb.org/atlas/mongodbatlas" ) -func DataSourceAPIKeys() *schema.Resource { +func PluralDataSource() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceMongoDBAtlasAPIKeysRead, Schema: map[string]*schema.Schema{ diff --git a/mongodbatlas/data_source_api_keys_test.go b/internal/service/apikey/data_source_api_keys_test.go similarity index 98% rename from mongodbatlas/data_source_api_keys_test.go rename to internal/service/apikey/data_source_api_keys_test.go index ff8cbfd3c1..0f193c7ec3 100644 --- a/mongodbatlas/data_source_api_keys_test.go +++ b/internal/service/apikey/data_source_api_keys_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package apikey_test import ( "fmt" diff --git a/mongodbatlas/resource_api_key.go b/internal/service/apikey/resource_api_key.go similarity index 99% rename from mongodbatlas/resource_api_key.go rename to internal/service/apikey/resource_api_key.go index 501555d9e0..15d9ca00a6 100644 --- a/mongodbatlas/resource_api_key.go +++ b/internal/service/apikey/resource_api_key.go @@ -1,4 +1,4 @@ -package mongodbatlas +package apikey import ( "context" @@ -15,7 +15,7 @@ import ( matlas "go.mongodb.org/atlas/mongodbatlas" ) -func ResourceAPIKey() *schema.Resource { +func Resource() *schema.Resource { return &schema.Resource{ CreateContext: resourceMongoDBAtlasAPIKeyCreate, ReadContext: resourceMongoDBAtlasAPIKeyRead, diff --git a/mongodbatlas/resource_api_key_test.go b/internal/service/apikey/resource_api_key_test.go similarity index 99% rename from mongodbatlas/resource_api_key_test.go rename to internal/service/apikey/resource_api_key_test.go index fa7209e618..bfe88cb366 100644 --- a/mongodbatlas/resource_api_key_test.go +++ b/internal/service/apikey/resource_api_key_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package apikey_test import ( "context" diff --git a/mongodbatlas/data_source_auditing.go b/internal/service/auditing/data_source_auditing.go similarity index 96% rename from mongodbatlas/data_source_auditing.go rename to internal/service/auditing/data_source_auditing.go index 7eb3127b22..777c0b8fc2 100644 --- a/mongodbatlas/data_source_auditing.go +++ b/internal/service/auditing/data_source_auditing.go @@ -1,4 +1,4 @@ -package mongodbatlas +package auditing import ( "context" @@ -9,7 +9,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) -func DataSourceAuditing() *schema.Resource { +func DataSource() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceMongoDBAtlasAuditingRead, Schema: map[string]*schema.Schema{ diff --git a/mongodbatlas/data_source_auditing_test.go b/internal/service/auditing/data_source_auditing_test.go similarity index 99% rename from mongodbatlas/data_source_auditing_test.go rename to internal/service/auditing/data_source_auditing_test.go index 505b0b7ec9..644a2e3aee 100644 --- a/mongodbatlas/data_source_auditing_test.go +++ b/internal/service/auditing/data_source_auditing_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package auditing_test import ( "fmt" diff --git a/mongodbatlas/resource_auditing.go b/internal/service/auditing/resource_auditing.go similarity index 98% rename from mongodbatlas/resource_auditing.go rename to internal/service/auditing/resource_auditing.go index 5e2566c0ae..246da24e3d 100644 --- a/mongodbatlas/resource_auditing.go +++ b/internal/service/auditing/resource_auditing.go @@ -1,4 +1,4 @@ -package mongodbatlas +package auditing import ( "context" @@ -18,7 +18,7 @@ const ( errorAuditingRead = "error reading MongoDB Auditing (%s): %s" ) -func ResourceAuditing() *schema.Resource { +func Resource() *schema.Resource { return &schema.Resource{ CreateContext: resourceMongoDBAtlasAuditingCreate, ReadContext: resourceMongoDBAtlasAuditingRead, diff --git a/mongodbatlas/resource_auditing_test.go b/internal/service/auditing/resource_auditing_test.go similarity index 99% rename from mongodbatlas/resource_auditing_test.go rename to internal/service/auditing/resource_auditing_test.go index c70b5ca648..63dbfec657 100644 --- a/mongodbatlas/resource_auditing_test.go +++ b/internal/service/auditing/resource_auditing_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package auditing_test import ( "context" diff --git a/mongodbatlas/data_source_custom_db_role.go b/internal/service/customdbrole/data_source_custom_db_role.go similarity index 97% rename from mongodbatlas/data_source_custom_db_role.go rename to internal/service/customdbrole/data_source_custom_db_role.go index 3d6bff3d6e..a45f009067 100644 --- a/mongodbatlas/data_source_custom_db_role.go +++ b/internal/service/customdbrole/data_source_custom_db_role.go @@ -1,4 +1,4 @@ -package mongodbatlas +package customdbrole import ( "context" @@ -10,7 +10,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) -func DataSourceCustomDBRole() *schema.Resource { +func DataSource() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceMongoDBAtlasCustomDBRoleRead, Schema: map[string]*schema.Schema{ diff --git a/mongodbatlas/data_source_custom_db_role_test.go b/internal/service/customdbrole/data_source_custom_db_role_test.go similarity index 96% rename from mongodbatlas/data_source_custom_db_role_test.go rename to internal/service/customdbrole/data_source_custom_db_role_test.go index 49ff03854d..986ea3cd3a 100644 --- a/mongodbatlas/data_source_custom_db_role_test.go +++ b/internal/service/customdbrole/data_source_custom_db_role_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package customdbrole_test import ( "fmt" @@ -20,7 +20,7 @@ func TestAccConfigDSCustomDBRole_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acc.PreCheckBasic(t) }, ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, + CheckDestroy: acc.CheckDestroyNetworkPeering, Steps: []resource.TestStep{ { Config: testAccDSMongoDBAtlasCustomDBRoleConfig(orgID, projectName, roleName, "INSERT", fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))), diff --git a/mongodbatlas/data_source_custom_db_roles.go b/internal/service/customdbrole/data_source_custom_db_roles.go similarity index 97% rename from mongodbatlas/data_source_custom_db_roles.go rename to internal/service/customdbrole/data_source_custom_db_roles.go index 3bf7142f65..7ee52cee91 100644 --- a/mongodbatlas/data_source_custom_db_roles.go +++ b/internal/service/customdbrole/data_source_custom_db_roles.go @@ -1,4 +1,4 @@ -package mongodbatlas +package customdbrole import ( "context" @@ -11,7 +11,7 @@ import ( matlas "go.mongodb.org/atlas/mongodbatlas" ) -func DataSourceCustomDBRoles() *schema.Resource { +func PluralDataSource() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceMongoDBAtlasCustomDBRolesRead, Schema: map[string]*schema.Schema{ diff --git a/mongodbatlas/data_source_custom_db_roles_test.go b/internal/service/customdbrole/data_source_custom_db_roles_test.go similarity index 95% rename from mongodbatlas/data_source_custom_db_roles_test.go rename to internal/service/customdbrole/data_source_custom_db_roles_test.go index acc0056b3d..9a12d9a251 100644 --- a/mongodbatlas/data_source_custom_db_roles_test.go +++ b/internal/service/customdbrole/data_source_custom_db_roles_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package customdbrole_test import ( "fmt" @@ -20,7 +20,7 @@ func TestAccConfigDSCustomDBRoles_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acc.PreCheckBasic(t) }, ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, + CheckDestroy: acc.CheckDestroyNetworkPeering, Steps: []resource.TestStep{ { Config: testAccDSMongoDBAtlasCustomDBRolesConfig(orgID, projectName, roleName, "INSERT", fmt.Sprintf("test-acc-db_name-%s", acctest.RandString(5))), diff --git a/mongodbatlas/resource_custom_db_role.go b/internal/service/customdbrole/resource_custom_db_role.go similarity index 99% rename from mongodbatlas/resource_custom_db_role.go rename to internal/service/customdbrole/resource_custom_db_role.go index 59f9f0c02f..0b28fb564e 100644 --- a/mongodbatlas/resource_custom_db_role.go +++ b/internal/service/customdbrole/resource_custom_db_role.go @@ -1,4 +1,4 @@ -package mongodbatlas +package customdbrole import ( "context" @@ -22,7 +22,7 @@ import ( matlas "go.mongodb.org/atlas/mongodbatlas" ) -func ResourceCustomDBRole() *schema.Resource { +func Resource() *schema.Resource { return &schema.Resource{ CreateContext: resourceMongoDBAtlasCustomDBRoleCreate, ReadContext: resourceMongoDBAtlasCustomDBRoleRead, diff --git a/mongodbatlas/resource_custom_db_role_test.go b/internal/service/customdbrole/resource_custom_db_role_test.go similarity index 99% rename from mongodbatlas/resource_custom_db_role_test.go rename to internal/service/customdbrole/resource_custom_db_role_test.go index db705c8dbb..b0891ea199 100644 --- a/mongodbatlas/resource_custom_db_role_test.go +++ b/internal/service/customdbrole/resource_custom_db_role_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package customdbrole_test import ( "context" diff --git a/mongodbatlas/data_source_maintenance_window.go b/internal/service/maintenancewindow/data_source_maintenance_window.go similarity index 96% rename from mongodbatlas/data_source_maintenance_window.go rename to internal/service/maintenancewindow/data_source_maintenance_window.go index f20c8423b5..8275b660f5 100644 --- a/mongodbatlas/data_source_maintenance_window.go +++ b/internal/service/maintenancewindow/data_source_maintenance_window.go @@ -1,4 +1,4 @@ -package mongodbatlas +package maintenancewindow import ( "context" @@ -9,7 +9,7 @@ import ( "github.com/spf13/cast" ) -func DataSourceMaintenanceWindow() *schema.Resource { +func DataSource() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceMongoDBAtlasMaintenanceWindowRead, Schema: map[string]*schema.Schema{ diff --git a/mongodbatlas/data_source_maintenance_window_test.go b/internal/service/maintenancewindow/data_source_maintenance_window_test.go similarity index 98% rename from mongodbatlas/data_source_maintenance_window_test.go rename to internal/service/maintenancewindow/data_source_maintenance_window_test.go index 4335430686..92eb2a76f6 100644 --- a/mongodbatlas/data_source_maintenance_window_test.go +++ b/internal/service/maintenancewindow/data_source_maintenance_window_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package maintenancewindow_test import ( "fmt" diff --git a/mongodbatlas/resource_maintenance_window.go b/internal/service/maintenancewindow/resource_maintenance_window.go similarity index 99% rename from mongodbatlas/resource_maintenance_window.go rename to internal/service/maintenancewindow/resource_maintenance_window.go index fe776f0994..4969677add 100644 --- a/mongodbatlas/resource_maintenance_window.go +++ b/internal/service/maintenancewindow/resource_maintenance_window.go @@ -1,4 +1,4 @@ -package mongodbatlas +package maintenancewindow import ( "context" @@ -22,7 +22,7 @@ const ( errorMaintenanceAutoDefer = "error auto deferring the MongoDB Atlas Maintenance Window (%s): %s" ) -func ResourceMaintenanceWindow() *schema.Resource { +func Resource() *schema.Resource { return &schema.Resource{ CreateContext: resourceMongoDBAtlasMaintenanceWindowCreate, ReadContext: resourceMongoDBAtlasMaintenanceWindowRead, diff --git a/mongodbatlas/resource_maintenance_window_test.go b/internal/service/maintenancewindow/resource_maintenance_window_test.go similarity index 99% rename from mongodbatlas/resource_maintenance_window_test.go rename to internal/service/maintenancewindow/resource_maintenance_window_test.go index 8c2755445c..b8cb61cd1d 100644 --- a/mongodbatlas/resource_maintenance_window_test.go +++ b/internal/service/maintenancewindow/resource_maintenance_window_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package maintenancewindow_test import ( "context" diff --git a/mongodbatlas/data_source_network_container.go b/internal/service/networkcontainer/data_source_network_container.go similarity index 96% rename from mongodbatlas/data_source_network_container.go rename to internal/service/networkcontainer/data_source_network_container.go index 2444bcdb79..0d22cbdcdf 100644 --- a/mongodbatlas/data_source_network_container.go +++ b/internal/service/networkcontainer/data_source_network_container.go @@ -1,4 +1,4 @@ -package mongodbatlas +package networkcontainer import ( "context" @@ -11,7 +11,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) -func DataSourceNetworkContainer() *schema.Resource { +func DataSource() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceMongoDBAtlasNetworkContainerRead, Schema: map[string]*schema.Schema{ @@ -86,7 +86,7 @@ func dataSourceMongoDBAtlasNetworkContainerRead(ctx context.Context, d *schema.R return nil } - return diag.FromErr(fmt.Errorf(errorContainerRead, containerID, err)) + return diag.FromErr(fmt.Errorf(ErrorContainerRead, containerID, err)) } if err := d.Set("atlas_cidr_block", container.AtlasCIDRBlock); err != nil { diff --git a/mongodbatlas/data_source_network_containers.go b/internal/service/networkcontainer/data_source_network_containers.go similarity index 97% rename from mongodbatlas/data_source_network_containers.go rename to internal/service/networkcontainer/data_source_network_containers.go index 1b7119c8c2..a475b58a5d 100644 --- a/mongodbatlas/data_source_network_containers.go +++ b/internal/service/networkcontainer/data_source_network_containers.go @@ -1,4 +1,4 @@ -package mongodbatlas +package networkcontainer import ( "context" @@ -11,7 +11,7 @@ import ( matlas "go.mongodb.org/atlas/mongodbatlas" ) -func DataSourceNetworkContainers() *schema.Resource { +func PluralDataSource() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceMongoDBAtlasNetworkContainersRead, Schema: map[string]*schema.Schema{ diff --git a/mongodbatlas/resource_network_container.go b/internal/service/networkcontainer/resource_network_container.go similarity index 98% rename from mongodbatlas/resource_network_container.go rename to internal/service/networkcontainer/resource_network_container.go index 3a1bd910ca..7a7a8dcd82 100644 --- a/mongodbatlas/resource_network_container.go +++ b/internal/service/networkcontainer/resource_network_container.go @@ -1,4 +1,4 @@ -package mongodbatlas +package networkcontainer import ( "context" @@ -22,12 +22,12 @@ import ( const ( errorContainterCreate = "error creating MongoDB Network Peering Container: %s" - errorContainerRead = "error reading MongoDB Network Peering Container (%s): %s" + ErrorContainerRead = "error reading MongoDB Network Peering Container (%s): %s" errorContainerDelete = "error deleting MongoDB Network Peering Container (%s): %s" errorContainerUpdate = "error updating MongoDB Network Peering Container (%s): %s" ) -func ResourceNetworkContainer() *schema.Resource { +func Resource() *schema.Resource { return &schema.Resource{ CreateContext: resourceMongoDBAtlasNetworkContainerCreate, ReadContext: resourceMongoDBAtlasNetworkContainerRead, @@ -164,7 +164,7 @@ func resourceMongoDBAtlasNetworkContainerRead(ctx context.Context, d *schema.Res return nil } - return diag.FromErr(fmt.Errorf(errorContainerRead, containerID, err)) + return diag.FromErr(fmt.Errorf(ErrorContainerRead, containerID, err)) } if err = d.Set("region_name", container.RegionName); err != nil { diff --git a/mongodbatlas/resource_network_container_test.go b/internal/service/networkcontainer/resource_network_container_test.go similarity index 99% rename from mongodbatlas/resource_network_container_test.go rename to internal/service/networkcontainer/resource_network_container_test.go index 4a1955df4a..11b590e446 100644 --- a/mongodbatlas/resource_network_container_test.go +++ b/internal/service/networkcontainer/resource_network_container_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package networkcontainer_test import ( "context" diff --git a/mongodbatlas/data_source_network_peering.go b/internal/service/networkpeering/data_source_network_peering.go similarity index 98% rename from mongodbatlas/data_source_network_peering.go rename to internal/service/networkpeering/data_source_network_peering.go index 1532aae453..38f7b1c4af 100644 --- a/mongodbatlas/data_source_network_peering.go +++ b/internal/service/networkpeering/data_source_network_peering.go @@ -1,4 +1,4 @@ -package mongodbatlas +package networkpeering import ( "context" @@ -11,7 +11,7 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" ) -func DataSourceNetworkPeering() *schema.Resource { +func DataSource() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceMongoDBAtlasNetworkPeeringRead, Schema: map[string]*schema.Schema{ diff --git a/mongodbatlas/data_source_network_peering_test.go b/internal/service/networkpeering/data_source_network_peering_test.go similarity index 96% rename from mongodbatlas/data_source_network_peering_test.go rename to internal/service/networkpeering/data_source_network_peering_test.go index cb318df00f..c3ecf2963c 100644 --- a/mongodbatlas/data_source_network_peering_test.go +++ b/internal/service/networkpeering/data_source_network_peering_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package networkpeering_test import ( "fmt" @@ -25,7 +25,7 @@ func TestAccNetworkDSNetworkPeering_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { acc.PreCheck(t); acc.PreCheckPeeringEnvAWS(t) }, ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, + CheckDestroy: acc.CheckDestroyNetworkPeering, Steps: []resource.TestStep{ { Config: testAccDSMongoDBAtlasNetworkPeeringConfig(projectID, vpcID, awsAccountID, vpcCIDRBlock, awsRegion), diff --git a/mongodbatlas/data_source_network_peerings.go b/internal/service/networkpeering/data_source_network_peerings.go similarity index 98% rename from mongodbatlas/data_source_network_peerings.go rename to internal/service/networkpeering/data_source_network_peerings.go index 4301cfbee4..581e57116c 100644 --- a/mongodbatlas/data_source_network_peerings.go +++ b/internal/service/networkpeering/data_source_network_peerings.go @@ -1,4 +1,4 @@ -package mongodbatlas +package networkpeering import ( "context" @@ -12,7 +12,7 @@ import ( matlas "go.mongodb.org/atlas/mongodbatlas" ) -func DataSourceNetworkPeerings() *schema.Resource { +func PluralDataSource() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceMongoDBAtlasNetworkPeeringsRead, Schema: map[string]*schema.Schema{ diff --git a/mongodbatlas/data_source_network_peerings_test.go b/internal/service/networkpeering/data_source_network_peerings_test.go similarity index 96% rename from mongodbatlas/data_source_network_peerings_test.go rename to internal/service/networkpeering/data_source_network_peerings_test.go index 777327120d..761f407a0d 100644 --- a/mongodbatlas/data_source_network_peerings_test.go +++ b/internal/service/networkpeering/data_source_network_peerings_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package networkpeering_test import ( "fmt" @@ -25,7 +25,7 @@ func TestAccNetworkDSNetworkPeerings_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { acc.PreCheck(t); acc.PreCheckPeeringEnvAWS(t) }, ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, + CheckDestroy: acc.CheckDestroyNetworkPeering, Steps: []resource.TestStep{ { Config: testAccDSMongoDBAtlasNetworkPeeringsConfig(projectID, vpcID, awsAccountID, vpcCIDRBlock, awsRegion), diff --git a/mongodbatlas/resource_network_peering.go b/internal/service/networkpeering/resource_network_peering.go similarity index 98% rename from mongodbatlas/resource_network_peering.go rename to internal/service/networkpeering/resource_network_peering.go index 6391821526..d670aa6a2f 100644 --- a/mongodbatlas/resource_network_peering.go +++ b/internal/service/networkpeering/resource_network_peering.go @@ -1,4 +1,4 @@ -package mongodbatlas +package networkpeering import ( "context" @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/networkcontainer" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -26,7 +27,7 @@ const ( errorPeersUpdate = "error updating MongoDB Network Peering Connection (%s): %s" ) -func ResourceNetworkPeering() *schema.Resource { +func Resource() *schema.Resource { return &schema.Resource{ CreateContext: resourceMongoDBAtlasNetworkPeeringCreate, ReadContext: resourceMongoDBAtlasNetworkPeeringRead, @@ -559,7 +560,7 @@ func resourceNetworkPeeringRefreshFunc(ctx context.Context, peerID, projectID, c container, _, err := client.Containers.Get(ctx, projectID, containerID) if err != nil { - return nil, "", fmt.Errorf(errorContainerRead, containerID, err) + return nil, "", fmt.Errorf(networkcontainer.ErrorContainerRead, containerID, err) } if *container.Provisioned { diff --git a/mongodbatlas/resource_network_peering_test.go b/internal/service/networkpeering/resource_network_peering_test.go similarity index 93% rename from mongodbatlas/resource_network_peering_test.go rename to internal/service/networkpeering/resource_network_peering_test.go index 8c34e68548..eeefc30195 100644 --- a/mongodbatlas/resource_network_peering_test.go +++ b/internal/service/networkpeering/resource_network_peering_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package networkpeering_test import ( "context" @@ -33,7 +33,7 @@ func TestAccNetworkRSNetworkPeering_basicAWS(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { acc.PreCheck(t); acc.PreCheckPeeringEnvAWS(t) }, ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, + CheckDestroy: acc.CheckDestroyNetworkPeering, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasNetworkPeeringConfigAWS(projectID, providerName, vpcID, awsAccountID, vpcCIDRBlock, awsRegion), @@ -73,7 +73,7 @@ func TestAccNetworkRSNetworkPeering_basicAzure(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { acc.PreCheck(t); acc.PreCheckPeeringEnvAzure(t) }, ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, + CheckDestroy: acc.CheckDestroyNetworkPeering, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasNetworkPeeringConfigAzure(projectID, providerName, directoryID, subscriptionID, resourceGroupName, vNetName), @@ -111,7 +111,7 @@ func TestAccNetworkRSNetworkPeering_basicGCP(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { acc.PreCheck(t); acc.PreCheckPeeringEnvGCP(t) }, ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, + CheckDestroy: acc.CheckDestroyNetworkPeering, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasNetworkPeeringConfigGCP(projectID, providerName, gcpProjectID, networkName), @@ -162,7 +162,7 @@ func TestAccNetworkRSNetworkPeering_AWSDifferentRegionName(t *testing.T) { }() }, ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, - CheckDestroy: testAccCheckMongoDBAtlasNetworkPeeringDestroy, + CheckDestroy: acc.CheckDestroyNetworkPeering, Steps: []resource.TestStep{ { Config: testAccMongoDBAtlasNetworkPeeringConfigAWSWithDifferentRegionName(projectID, providerName, containerRegion, peerRegion, vpcCIDRBlock, vpcID, awsAccountID), @@ -240,25 +240,6 @@ func testAccCheckMongoDBAtlasNetworkPeeringExists(resourceName string, peer *mat } } -func testAccCheckMongoDBAtlasNetworkPeeringDestroy(s *terraform.State) error { - conn := acc.TestAccProviderSdkV2.Meta().(*config.MongoDBClient).Atlas - - for _, rs := range s.RootModule().Resources { - if rs.Type != "mongodbatlas_network_peering" { - continue - } - - ids := conversion.DecodeStateID(rs.Primary.ID) - _, _, err := conn.Peers.Get(context.Background(), ids["project_id"], ids["peer_id"]) - - if err == nil { - return fmt.Errorf("peer (%s) still exists", ids["peer_id"]) - } - } - - return nil -} - func testAccMongoDBAtlasNetworkPeeringConfigAWS(projectID, providerName, vpcID, awsAccountID, vpcCIDRBlock, awsRegion string) string { return fmt.Sprintf(` resource "mongodbatlas_network_container" "test" { diff --git a/mongodbatlas/data_source_team.go b/internal/service/teams/data_source_teams.go similarity index 97% rename from mongodbatlas/data_source_team.go rename to internal/service/teams/data_source_teams.go index 48375350f2..ee2294a838 100644 --- a/mongodbatlas/data_source_team.go +++ b/internal/service/teams/data_source_teams.go @@ -1,4 +1,4 @@ -package mongodbatlas +package teams import ( "context" @@ -13,7 +13,7 @@ import ( matlas "go.mongodb.org/atlas/mongodbatlas" ) -func DataSourceTeam() *schema.Resource { +func DataSource() *schema.Resource { return &schema.Resource{ ReadContext: dataSourceMongoDBAtlasTeamRead, Schema: map[string]*schema.Schema{ diff --git a/mongodbatlas/data_source_team_test.go b/internal/service/teams/data_source_teams_test.go similarity index 99% rename from mongodbatlas/data_source_team_test.go rename to internal/service/teams/data_source_teams_test.go index b28c69126b..4931f007f3 100644 --- a/mongodbatlas/data_source_team_test.go +++ b/internal/service/teams/data_source_teams_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package teams_test import ( "fmt" diff --git a/mongodbatlas/resource_team.go b/internal/service/teams/resource_teams.go similarity index 97% rename from mongodbatlas/resource_team.go rename to internal/service/teams/resource_teams.go index e97038b736..1f390939d2 100644 --- a/mongodbatlas/resource_team.go +++ b/internal/service/teams/resource_teams.go @@ -1,4 +1,4 @@ -package mongodbatlas +package teams import ( "context" @@ -27,7 +27,7 @@ const ( errorTeamSetting = "error setting `%s` for Team (%s): %s" ) -func ResourceTeam() *schema.Resource { +func Resource() *schema.Resource { return &schema.Resource{ CreateContext: resourceMongoDBAtlasTeamCreate, ReadContext: resourceMongoDBAtlasTeamRead, @@ -69,7 +69,7 @@ func resourceMongoDBAtlasTeamCreate(ctx context.Context, d *schema.ResourceData, teamsResp, _, err := conn.Teams.Create(ctx, orgID, &matlas.Team{ Name: d.Get("name").(string), - Usernames: expandStringListFromSetSchema(d.Get("usernames").(*schema.Set)), + Usernames: ExpandStringListFromSetSchema(d.Get("usernames").(*schema.Set)), }) if err != nil { return diag.FromErr(fmt.Errorf(errorTeamCreate, err)) @@ -281,7 +281,7 @@ func resourceMongoDBAtlasTeamImportState(ctx context.Context, d *schema.Resource return []*schema.ResourceData{d}, nil } -func expandStringListFromSetSchema(list *schema.Set) []string { +func ExpandStringListFromSetSchema(list *schema.Set) []string { res := make([]string, list.Len()) for i, v := range list.List() { res[i] = v.(string) diff --git a/mongodbatlas/resource_team_test.go b/internal/service/teams/resource_teams_test.go similarity index 99% rename from mongodbatlas/resource_team_test.go rename to internal/service/teams/resource_teams_test.go index 1e6f53455c..b0ad87088f 100644 --- a/mongodbatlas/resource_team_test.go +++ b/internal/service/teams/resource_teams_test.go @@ -1,4 +1,4 @@ -package mongodbatlas_test +package teams_test import ( "context" diff --git a/internal/testutil/acc/network_peering.go b/internal/testutil/acc/network_peering.go new file mode 100644 index 0000000000..6feade264a --- /dev/null +++ b/internal/testutil/acc/network_peering.go @@ -0,0 +1,29 @@ +package acc + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-testing/terraform" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" +) + +func CheckDestroyNetworkPeering(s *terraform.State) error { + conn := TestAccProviderSdkV2.Meta().(*config.MongoDBClient).Atlas + + for _, rs := range s.RootModule().Resources { + if rs.Type != "mongodbatlas_network_peering" { + continue + } + + ids := conversion.DecodeStateID(rs.Primary.ID) + _, _, err := conn.Peers.Get(context.Background(), ids["project_id"], ids["peer_id"]) + + if err == nil { + return fmt.Errorf("peer (%s) still exists", ids["peer_id"]) + } + } + + return nil +} diff --git a/mongodbatlas/resource_org_invitation.go b/mongodbatlas/resource_org_invitation.go index 4c544cdaa7..4fc1f8aff5 100644 --- a/mongodbatlas/resource_org_invitation.go +++ b/mongodbatlas/resource_org_invitation.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/teams" matlas "go.mongodb.org/atlas/mongodbatlas" ) @@ -139,8 +140,8 @@ func resourceMongoDBAtlasOrgInvitationCreate(ctx context.Context, d *schema.Reso orgID := d.Get("org_id").(string) invitationReq := &matlas.Invitation{ - Roles: expandStringListFromSetSchema(d.Get("roles").(*schema.Set)), - TeamIDs: expandStringListFromSetSchema(d.Get("teams_ids").(*schema.Set)), + Roles: teams.ExpandStringListFromSetSchema(d.Get("roles").(*schema.Set)), + TeamIDs: teams.ExpandStringListFromSetSchema(d.Get("teams_ids").(*schema.Set)), Username: d.Get("username").(string), } @@ -203,7 +204,7 @@ func resourceMongoDBAtlasOrgInvitationUpdate(ctx context.Context, d *schema.Reso invitationID := ids["invitation_id"] invitationReq := &matlas.Invitation{ - Roles: expandStringListFromSetSchema(d.Get("roles").(*schema.Set)), + Roles: teams.ExpandStringListFromSetSchema(d.Get("roles").(*schema.Set)), } _, _, err := conn.Organizations.UpdateInvitationByID(ctx, orgID, invitationID, invitationReq) diff --git a/mongodbatlas/resource_project_invitation.go b/mongodbatlas/resource_project_invitation.go index 20efa02891..785642e0cd 100644 --- a/mongodbatlas/resource_project_invitation.go +++ b/mongodbatlas/resource_project_invitation.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion" "github.com/mongodb/terraform-provider-mongodbatlas/internal/config" + "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/teams" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" matlas "go.mongodb.org/atlas/mongodbatlas" @@ -165,7 +166,7 @@ func resourceMongoDBAtlasProjectInvitationUpdate(ctx context.Context, d *schema. invitationID := ids["invitation_id"] invitationReq := &matlas.Invitation{ - Roles: expandStringListFromSetSchema(d.Get("roles").(*schema.Set)), + Roles: teams.ExpandStringListFromSetSchema(d.Get("roles").(*schema.Set)), } _, _, err := conn.Projects.UpdateInvitationByID(ctx, projectID, invitationID, invitationReq)