Skip to content

Commit

Permalink
feat: Migrates some resources to new file structure (#1704)
Browse files Browse the repository at this point in the history
* access_list_api_key

* api_key

* custom_db_role

* network_container

* network_peering

* maintenance_window

* auditing

* teams

* GH action
  • Loading branch information
lantoli authored Dec 4, 2023
1 parent f562923 commit 09730f0
Show file tree
Hide file tree
Showing 45 changed files with 150 additions and 133 deletions.
20 changes: 8 additions & 12 deletions .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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'
Expand Down
54 changes: 31 additions & 23 deletions internal/provider/provider_sdk2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
)
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package accesslistapikey

import (
"context"
Expand All @@ -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{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas_test
package accesslistapikey_test

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package accesslistapikey

import (
"context"
Expand All @@ -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{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas_test
package accesslistapikey_test

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package accesslistapikey

import (
"context"
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas_test
package accesslistapikey_test

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package apikey

import (
"context"
Expand All @@ -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{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas_test
package apikey_test

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package apikey

import (
"context"
Expand All @@ -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{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas_test
package apikey_test

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package apikey

import (
"context"
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas_test
package apikey_test

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package auditing

import (
"context"
Expand All @@ -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{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas_test
package auditing_test

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package auditing

import (
"context"
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas_test
package auditing_test

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package customdbrole

import (
"context"
Expand All @@ -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{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas_test
package customdbrole_test

import (
"fmt"
Expand All @@ -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))),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package customdbrole

import (
"context"
Expand All @@ -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{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas_test
package customdbrole_test

import (
"fmt"
Expand All @@ -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))),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package customdbrole

import (
"context"
Expand All @@ -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,
Expand Down
Loading

0 comments on commit 09730f0

Please sign in to comment.