Skip to content

Commit

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

* cloud_provider_access GH action

* federated_database_instance

* federated_query_limit

* federated_settings_identity_provider

* federated_settings_org_config and federated_settings_org_role_mapping

* GH action
  • Loading branch information
lantoli authored Dec 4, 2023
1 parent 85773f3 commit f562923
Show file tree
Hide file tree
Showing 44 changed files with 146 additions and 131 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,15 @@ jobs:
- 'mongodbatlas/**_privatelink**.go'
- 'mongodbatlas/**_private_endpoint**.go'
federation:
- 'mongodbatlas/**_federated_database_instance**.go'
- 'internal/service/federateddatabaseinstance/*.go'
config:
- 'internal/service/alertconfiguration/*.go'
- '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'
- 'mongodbatlas/data_source_cloud_provider_access_setup*.go'
- 'mongodbatlas/data_source_cloud_provider_access*.go'
- 'internal/service/cloudprovideraccess/*.go'
- 'mongodbatlas/data_source_custom_db_role*.go'
- 'mongodbatlas/data_source_custom_dns_configuration_cluster_aws*.go'
- 'mongodbatlas/data_source_maintenance_window*.go'
Expand All @@ -108,8 +107,6 @@ jobs:
- 'mongodbatlas/data_source_team*.go'
- 'mongodbatlas/data_source_third_party_integration*.go'
- 'mongodbatlas/resource_api_key*.go'
- 'mongodbatlas/resource_cloud_provider_access_setup*.go'
- 'mongodbatlas/resource_cloud_provider_access*.go'
- 'mongodbatlas/resource_custom_db_role*.go'
- 'mongodbatlas/resource_custom_dns_configuration_cluster_aws*.go'
- 'mongodbatlas/resource_maintenance_window*.go'
Expand Down
48 changes: 27 additions & 21 deletions internal/provider/provider_sdk2.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/cloudbackupsnapshotexportbucket"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/cloudbackupsnapshotexportjob"
"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/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/projectapikey"
"github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas"
"github.com/mwielbut/pointy"
Expand Down Expand Up @@ -139,8 +145,8 @@ func getDataSourcesMap() map[string]*schema.Resource {
"mongodbatlas_privatelink_endpoints_service_serverless": mongodbatlas.DataSourcePrivateLinkEndpointsServiceServerless(),
"mongodbatlas_third_party_integration": mongodbatlas.DataSourceThirdPartyIntegration(),
"mongodbatlas_third_party_integrations": mongodbatlas.DataSourceThirdPartyIntegrations(),
"mongodbatlas_cloud_provider_access": mongodbatlas.DataSourceCloudProviderAccessList(),
"mongodbatlas_cloud_provider_access_setup": mongodbatlas.DataSourceCloudProviderAccessSetup(),
"mongodbatlas_cloud_provider_access": cloudprovideraccess.DataSource(),
"mongodbatlas_cloud_provider_access_setup": cloudprovideraccess.DataSourceSetup(),
"mongodbatlas_custom_dns_configuration_cluster_aws": mongodbatlas.DataSourceCustomDNSConfigurationAWS(),
"mongodbatlas_online_archive": mongodbatlas.DataSourceOnlineArchive(),
"mongodbatlas_online_archives": mongodbatlas.DataSourceOnlineArchives(),
Expand Down Expand Up @@ -168,17 +174,17 @@ func getDataSourcesMap() map[string]*schema.Resource {
"mongodbatlas_cloud_backup_snapshot_export_jobs": cloudbackupsnapshotexportjob.PluralDataSource(),
"mongodbatlas_cloud_backup_snapshot_restore_job": cloudbackupsnapshotrestorejob.DataSource(),
"mongodbatlas_cloud_backup_snapshot_restore_jobs": cloudbackupsnapshotrestorejob.PluralDataSource(),
"mongodbatlas_federated_settings": mongodbatlas.DataSourceFederatedSettings(),
"mongodbatlas_federated_settings_identity_provider": mongodbatlas.DataSourceFederatedSettingsIdentityProvider(),
"mongodbatlas_federated_settings_identity_providers": mongodbatlas.DataSourceFederatedSettingsIdentityProviders(),
"mongodbatlas_federated_settings_org_config": mongodbatlas.DataSourceFederatedSettingsOrganizationConfig(),
"mongodbatlas_federated_settings_org_configs": mongodbatlas.DataSourceFederatedSettingsOrganizationConfigs(),
"mongodbatlas_federated_settings_org_role_mapping": mongodbatlas.DataSourceFederatedSettingsOrganizationRoleMapping(),
"mongodbatlas_federated_settings_org_role_mappings": mongodbatlas.DataSourceFederatedSettingsOrganizationRoleMappings(),
"mongodbatlas_federated_database_instance": mongodbatlas.DataSourceFederatedDatabaseInstance(),
"mongodbatlas_federated_database_instances": mongodbatlas.DataSourceFederatedDatabaseInstances(),
"mongodbatlas_federated_query_limit": mongodbatlas.DataSourceFederatedDatabaseQueryLimit(),
"mongodbatlas_federated_query_limits": mongodbatlas.DataSourceFederatedDatabaseQueryLimits(),
"mongodbatlas_federated_settings_identity_provider": federatedsettingsidentityprovider.DataSource(),
"mongodbatlas_federated_settings_identity_providers": federatedsettingsidentityprovider.PluralDataSource(),
"mongodbatlas_federated_settings": federatedsettingsorgconfig.DataSourceSettings(),
"mongodbatlas_federated_settings_org_config": federatedsettingsorgconfig.DataSource(),
"mongodbatlas_federated_settings_org_configs": federatedsettingsorgconfig.PluralDataSource(),
"mongodbatlas_federated_settings_org_role_mapping": federatedsettingsorgrolemapping.DataSource(),
"mongodbatlas_federated_settings_org_role_mappings": federatedsettingsorgrolemapping.PluralDataSource(),
"mongodbatlas_federated_database_instance": federateddatabaseinstance.DataSource(),
"mongodbatlas_federated_database_instances": federateddatabaseinstance.PluralDataSource(),
"mongodbatlas_federated_query_limit": federatedquerylimit.DataSource(),
"mongodbatlas_federated_query_limits": federatedquerylimit.PluralDataSource(),
"mongodbatlas_serverless_instance": mongodbatlas.DataSourceServerlessInstance(),
"mongodbatlas_serverless_instances": mongodbatlas.DataSourceServerlessInstances(),
"mongodbatlas_cluster_outage_simulation": mongodbatlas.DataSourceClusterOutageSimulation(),
Expand Down Expand Up @@ -213,13 +219,13 @@ func getResourcesMap() map[string]*schema.Resource {
"mongodbatlas_privatelink_endpoint_service": mongodbatlas.ResourcePrivateEndpointServiceLink(),
"mongodbatlas_privatelink_endpoint_service_serverless": mongodbatlas.ResourcePrivateLinkEndpointServiceServerless(),
"mongodbatlas_third_party_integration": mongodbatlas.ResourceThirdPartyIntegration(),
"mongodbatlas_cloud_provider_access": mongodbatlas.ResourceCloudProviderAccess(),
"mongodbatlas_online_archive": mongodbatlas.ResourceOnlineArchive(),
"mongodbatlas_custom_dns_configuration_cluster_aws": mongodbatlas.ResourceCustomDNSConfiguration(),
"mongodbatlas_ldap_configuration": mongodbatlas.ResourceLDAPConfiguration(),
"mongodbatlas_ldap_verify": mongodbatlas.ResourceLDAPVerify(),
"mongodbatlas_cloud_provider_access_setup": mongodbatlas.ResourceCloudProviderAccessSetup(),
"mongodbatlas_cloud_provider_access_authorization": mongodbatlas.ResourceCloudProviderAccessAuthorization(),
"mongodbatlas_cloud_provider_access": cloudprovideraccess.Resource(),
"mongodbatlas_cloud_provider_access_setup": cloudprovideraccess.ResourceSetup(),
"mongodbatlas_cloud_provider_access_authorization": cloudprovideraccess.ResourceAuthorization(),
"mongodbatlas_search_index": mongodbatlas.ResourceSearchIndex(),
"mongodbatlas_data_lake_pipeline": mongodbatlas.ResourceDataLakePipeline(),
"mongodbatlas_event_trigger": mongodbatlas.ResourceEventTriggers(),
Expand All @@ -232,11 +238,11 @@ func getResourcesMap() map[string]*schema.Resource {
"mongodbatlas_cloud_backup_snapshot_export_bucket": cloudbackupsnapshotexportbucket.Resource(),
"mongodbatlas_cloud_backup_snapshot_export_job": cloudbackupsnapshotexportjob.Resource(),
"mongodbatlas_cloud_backup_snapshot_restore_job": cloudbackupsnapshotrestorejob.Resource(),
"mongodbatlas_federated_settings_org_config": mongodbatlas.ResourceFederatedSettingsOrganizationConfig(),
"mongodbatlas_federated_settings_org_role_mapping": mongodbatlas.ResourceFederatedSettingsOrganizationRoleMapping(),
"mongodbatlas_federated_settings_identity_provider": mongodbatlas.ResourceFederatedSettingsIdentityProvider(),
"mongodbatlas_federated_database_instance": mongodbatlas.ResourceFederatedDatabaseInstance(),
"mongodbatlas_federated_query_limit": mongodbatlas.ResourceFederatedDatabaseQueryLimit(),
"mongodbatlas_federated_settings_org_config": federatedsettingsorgconfig.Resource(),
"mongodbatlas_federated_settings_org_role_mapping": federatedsettingsorgrolemapping.Resource(),
"mongodbatlas_federated_settings_identity_provider": federatedsettingsidentityprovider.Resource(),
"mongodbatlas_federated_database_instance": federateddatabaseinstance.Resource(),
"mongodbatlas_federated_query_limit": federatedquerylimit.Resource(),
"mongodbatlas_serverless_instance": mongodbatlas.ResourceServerlessInstance(),
"mongodbatlas_cluster_outage_simulation": mongodbatlas.ResourceClusterOutageSimulation(),
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package cloudprovideraccess

import (
"context"
Expand All @@ -12,7 +12,7 @@ import (
matlas "go.mongodb.org/atlas/mongodbatlas"
)

func DataSourceCloudProviderAccessList() *schema.Resource {
func DataSource() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceMongoDBAtlasCloudProviderAccessRead,
DeprecationMessage: fmt.Sprintf(constant.DeprecationResourceByDateWithReplacement, "v1.14.0", "mongodbatlas_cloud_provider_access_setup"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package cloudprovideraccess

import (
"context"
Expand All @@ -11,7 +11,7 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
)

func DataSourceCloudProviderAccessSetup() *schema.Resource {
func DataSourceSetup() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceMongoDBAtlasCloudProviderAccessSetupRead,
Schema: map[string]*schema.Schema{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package cloudprovideraccess

import (
"context"
Expand All @@ -23,7 +23,7 @@ const (
ErrorCloudProviderGetRead = "error reading cloud provider access %s"
)

func ResourceCloudProviderAccess() *schema.Resource {
func Resource() *schema.Resource {
return &schema.Resource{
CreateContext: resourceMongoDBAtlasCloudProviderAccessCreate,
ReadContext: resourceMongoDBAtlasCloudProviderAccessRead,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package cloudprovideraccess

import (
"context"
Expand All @@ -19,7 +19,7 @@ import (
A cloud provider access authorization
*/

func ResourceCloudProviderAccessAuthorization() *schema.Resource {
func ResourceAuthorization() *schema.Resource {
return &schema.Resource{
ReadContext: resourceMongoDBAtlasCloudProviderAccessAuthorizationRead,
CreateContext: resourceMongoDBAtlasCloudProviderAccessAuthorizationCreate,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas_test
package cloudprovideraccess_test

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

import (
"context"
Expand All @@ -20,7 +20,7 @@ import (
-> The delete deletes and deauthorize the role
*/

func ResourceCloudProviderAccessSetup() *schema.Resource {
func ResourceSetup() *schema.Resource {
return &schema.Resource{
ReadContext: resourceMongoDBAtlasCloudProviderAccessSetupRead,
CreateContext: resourceMongoDBAtlasCloudProviderAccessSetupCreate,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas_test
package cloudprovideraccess_test

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

import (
"context"
Expand All @@ -11,8 +11,8 @@ import (
"github.com/hashicorp/terraform-plugin-testing/terraform"
"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/cloudprovideraccess"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc"
"github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas"
matlas "go.mongodb.org/atlas/mongodbatlas"
)

Expand Down Expand Up @@ -104,7 +104,7 @@ func testAccCheckMongoDBAtlasProviderAccessDestroy(s *terraform.State) error {
roles, _, err := conn.CloudProviderAccess.ListRoles(context.Background(), ids["project_id"])

if err != nil {
return fmt.Errorf(mongodbatlas.ErrorCloudProviderGetRead, err)
return fmt.Errorf(cloudprovideraccess.ErrorCloudProviderGetRead, err)
}

var targetRole matlas.CloudProviderAccessRole
Expand Down Expand Up @@ -147,7 +147,7 @@ func testAccCheckMongoDBAtlasProviderAccessExists(resourceName string, targetRol
roles, _, err := conn.CloudProviderAccess.ListRoles(context.Background(), ids["project_id"])

if err != nil {
return fmt.Errorf(mongodbatlas.ErrorCloudProviderGetRead, err)
return fmt.Errorf(cloudprovideraccess.ErrorCloudProviderGetRead, err)
}

if providerName == "AWS" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package federateddatabaseinstance

import (
"context"
Expand All @@ -11,7 +11,7 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
)

func DataSourceFederatedDatabaseInstance() *schema.Resource {
func DataSource() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceMongoDBAtlasFederatedDatabaseInstanceRead,
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 federateddatabaseinstance_test

import (
"context"
Expand Down Expand Up @@ -27,7 +27,7 @@ func TestAccDataSourceFederatedDatabaseInstance_basic(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
CheckDestroy: testAccCheckMongoDBAtlasFederatedDatabaseInstanceDestroy,
CheckDestroy: acc.CheckDestroyFederatedDatabaseInstance,
Steps: []resource.TestStep{
{
ExternalProviders: map[string]resource.ExternalProvider{
Expand Down Expand Up @@ -68,7 +68,7 @@ func TestAccDataSourceFederatedDatabaseInstance_S3Bucket(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
CheckDestroy: testAccCheckMongoDBAtlasFederatedDatabaseInstanceDestroy,
CheckDestroy: acc.CheckDestroyFederatedDatabaseInstance,
Steps: []resource.TestStep{
{
ExternalProviders: map[string]resource.ExternalProvider{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package federateddatabaseinstance

import (
"context"
Expand All @@ -12,7 +12,7 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
)

func DataSourceFederatedDatabaseInstances() *schema.Resource {
func PluralDataSource() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceMongoDBAtlasFederatedDatabaseInstancesRead,
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 federateddatabaseinstance_test

import (
"fmt"
Expand Down Expand Up @@ -26,7 +26,7 @@ func TestAccDataSourceFederatedDatabaseInstances_basic(t *testing.T) {

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
CheckDestroy: testAccCheckMongoDBAtlasFederatedDatabaseInstanceDestroy,
CheckDestroy: acc.CheckDestroyFederatedDatabaseInstance,
Steps: []resource.TestStep{
{
ExternalProviders: map[string]resource.ExternalProvider{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package federateddatabaseinstance

import (
"context"
Expand All @@ -24,7 +24,7 @@ const (
errorFederatedDatabaseInstanceSetting = "error setting `%s` for MongoDB Atlas Federated Database Instace (%s): %s"
)

func ResourceFederatedDatabaseInstance() *schema.Resource {
func Resource() *schema.Resource {
return &schema.Resource{
CreateContext: resourceMongoDBFederatedDatabaseInstanceCreate,
ReadContext: resourceMongoDBAFederatedDatabaseInstanceRead,
Expand Down
Loading

0 comments on commit f562923

Please sign in to comment.