Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Migrates some resources to new file structure #1705

Merged
merged 23 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 19 additions & 21 deletions .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ jobs:
with:
filters: |
assume_role:
- 'mongodbatlas/**provider**.go'
- 'internal/provider/*.go'
cluster_outage_simulation:
- 'mongodbatlas/**cluster_outage_simulation**.go'
- 'internal/service/clusteroutagesimulation/*.go'
advanced_cluster:
- 'internal/service/advancedcluster/*.go'
cluster:
Expand All @@ -67,9 +67,9 @@ jobs:
generic:
- 'internal/service/backupcompliancepolicy/*.go'
- 'internal/service/auditing/*.go'
- 'mongodbatlas/resource_x509_authentication_database_user*.go'
- 'internal/service/x509authenticationdatabaseuser/*.go'
backup_online_archive:
- 'mongodbatlas/**online_archive**.go'
- 'internal/service/onlinearchive/*.go'
backup_snapshots:
- 'internal/service/cloudbackupsnapshot/*.go'
- 'internal/service/cloudbackupsnapshotexportbucket/*.go'
Expand All @@ -80,15 +80,18 @@ jobs:
- 'internal/service/project/*.go'
- 'internal/service/projectipaccesslist/*.go'
- 'internal/service/accesslistapikey/*.go'
- 'mongodbatlas/data_source_project_invitation*.go'
- 'mongodbatlas/resource_project_invitation*.go'
- 'internal/service/projectinvitation/*.go'
serverless:
- 'mongodbatlas/**_serverless**.go'
- 'internal/service/serverlessinstance/*.go'
- 'internal/service/privatelinkendpointserverless/*.go'
- 'internal/service/privatelinkendpointserviceserverless/*.go'
network:
- 'internal/service/networkcontainer/*.go'
- 'internal/service/networkpeering/*.go'
- 'mongodbatlas/**_privatelink**.go'
- 'mongodbatlas/**_private_endpoint**.go'
- 'internal/service/privateendpointregionalmode/*.go'
- 'internal/service/privatelinkendpoint/*.go'
- 'internal/service/privatelinkendpointservice/*.go'
- 'internal/service/privatelinkendpointservicedatafederationonlinearchive/*.go'
federation:
- 'internal/service/federateddatabaseinstance/*.go'
config:
Expand All @@ -101,20 +104,15 @@ jobs:
- 'internal/service/cloudprovideraccess/*.go'
- 'internal/service/customdbrole/*.go'
- 'internal/service/maintenancewindow/*.go'
- 'mongodbatlas/data_source_custom_dns_configuration_cluster_aws*.go'
- 'mongodbatlas/data_source_org_id*.go'
- 'mongodbatlas/data_source_org_invitation*.go'
- 'mongodbatlas/data_source_organization*.go'
- 'mongodbatlas/data_source_third_party_integration*.go'
- 'mongodbatlas/resource_custom_dns_configuration_cluster_aws*.go'
- 'mongodbatlas/resource_org_invitation*.go'
- 'mongodbatlas/resource_organization*.go'
- 'mongodbatlas/resource_third_party_integration*.go'
- 'internal/service/customdnsconfigurationclusteraws/*.go'
- 'internal/service/rolesorgid/*.go'
- 'internal/service/orginvitation/*.go'
- 'internal/service/organization/*.go'
- 'internal/service/thirdpartyintegration/*.go'
event_trigger:
- 'mongodbatlas/resource_event_trigger*.go'
- 'mongodbatlas/data_source_event_trigger*.go'
- 'internal/service/eventtrigger/*.go'
search_index:
- 'mongodbatlas/resource_search_index*.go'
- 'internal/service/searchindex/*.go'

cluster_outage_simulation:
needs: [ change-detection ]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/migration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
- 'internal/service/databaseuser/*.go'
- 'internal/service/projectapikey/*.go'
backup_online_archive:
- 'mongodbatlas/**online_archive**.go'
- 'internal/service/onlinearchive/*.go'
advanced_cluster:
- 'internal/service/advancedcluster/*.go'

Expand Down
138 changes: 80 additions & 58 deletions internal/provider/provider_sdk2.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package clusteroutagesimulation

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

func DataSourceClusterOutageSimulation() *schema.Resource {
func DataSource() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceMongoDBAtlasClusterOutageSimulationRead,
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 clusteroutagesimulation_test

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

import (
"context"
Expand All @@ -24,7 +24,7 @@ const (
defaultOutageFilterType = "REGION"
)

func ResourceClusterOutageSimulation() *schema.Resource {
func Resource() *schema.Resource {
return &schema.Resource{
CreateContext: resourceMongoDBClusterOutageSimulationCreate,
ReadContext: resourceMongoDBAClusterOutageSimulationRead,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas_test
package clusteroutagesimulation_test

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

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

func DataSourceCustomDNSConfigurationAWS() *schema.Resource {
func DataSource() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceMongoDBAtlasCustomDNSConfigurationAWSRead,
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 customdnsconfigurationclusteraws_test

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

import (
"context"
Expand All @@ -20,7 +20,7 @@ const (
errorCustomDNSConfigurationSetting = "error setting `%s` for custom dns configuration cluster aws (%s): %s"
)

func ResourceCustomDNSConfiguration() *schema.Resource {
func Resource() *schema.Resource {
return &schema.Resource{
CreateContext: resourceMongoDBAtlasCustomDNSConfigurationCreate,
ReadContext: resourceMongoDBAtlasCustomDNSConfigurationRead,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas_test
package customdnsconfigurationclusteraws_test

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

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

func DataSourceDataLakePipeline() *schema.Resource {
func DataSource() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceMongoDBAtlasDataLakePipelineRead,
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -251,7 +251,7 @@ func setDataLakeResourceData(
snapshots *matlas.DataLakePipelineSnapshotsResponse,
ingestionSchedules []*matlas.DataLakePipelineIngestionSchedule) diag.Diagnostics {
if err := d.Set("id", pipeline.ID); err != nil {
return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "id", pipeline.Name, err))
return diag.FromErr(fmt.Errorf(ErrorDataLakeSetting, "id", pipeline.Name, err))
}

if err := d.Set("state", pipeline.State); err != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package datalakepipeline

import (
"context"
Expand All @@ -14,7 +14,7 @@ import (

const errorDataLakePipelineRunRead = "error reading MongoDB Atlas DataLake Run (%s): %s"

func DataSourceDataLakePipelineRun() *schema.Resource {
func DataSourceRun() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceMongoDBAtlasDataLakeRunRead,
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -104,47 +104,47 @@ func dataSourceMongoDBAtlasDataLakeRunRead(ctx context.Context, d *schema.Resour
}

if err := d.Set("id", dataLakeRun.ID); err != nil {
return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "hostnames", name, err))
return diag.FromErr(fmt.Errorf(ErrorDataLakeSetting, "hostnames", name, err))
}

if err := d.Set("project_id", dataLakeRun.GroupID); err != nil {
return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "state", name, err))
return diag.FromErr(fmt.Errorf(ErrorDataLakeSetting, "state", name, err))
}

if err := d.Set("created_date", dataLakeRun.CreatedDate); err != nil {
return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "storage_databases", name, err))
return diag.FromErr(fmt.Errorf(ErrorDataLakeSetting, "storage_databases", name, err))
}

if err := d.Set("last_updated_date", dataLakeRun.LastUpdatedDate); err != nil {
return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "storage_databases", name, err))
return diag.FromErr(fmt.Errorf(ErrorDataLakeSetting, "storage_databases", name, err))
}

if err := d.Set("state", dataLakeRun.State); err != nil {
return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "storage_databases", name, err))
return diag.FromErr(fmt.Errorf(ErrorDataLakeSetting, "storage_databases", name, err))
}

if err := d.Set("phase", dataLakeRun.Phase); err != nil {
return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "storage_databases", name, err))
return diag.FromErr(fmt.Errorf(ErrorDataLakeSetting, "storage_databases", name, err))
}

if err := d.Set("pipeline_id", dataLakeRun.PipelineID); err != nil {
return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "storage_stores", name, err))
return diag.FromErr(fmt.Errorf(ErrorDataLakeSetting, "storage_stores", name, err))
}

if err := d.Set("dataset_name", dataLakeRun.DatasetName); err != nil {
return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "storage_stores", name, err))
return diag.FromErr(fmt.Errorf(ErrorDataLakeSetting, "storage_stores", name, err))
}

if err := d.Set("snapshot_id", dataLakeRun.SnapshotID); err != nil {
return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "storage_stores", name, err))
return diag.FromErr(fmt.Errorf(ErrorDataLakeSetting, "storage_stores", name, err))
}

if err := d.Set("backup_frequency_type", dataLakeRun.BackupFrequencyType); err != nil {
return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "storage_stores", name, err))
return diag.FromErr(fmt.Errorf(ErrorDataLakeSetting, "storage_stores", name, err))
}

if err := d.Set("stats", flattenDataLakePipelineRunStats(dataLakeRun.Stats)); err != nil {
return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "storage_stores", name, err))
return diag.FromErr(fmt.Errorf(ErrorDataLakeSetting, "storage_stores", name, err))
}

d.SetId(conversion.EncodeStateID(map[string]string{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas_test
package datalakepipeline_test

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

import (
"context"
Expand All @@ -13,7 +13,7 @@ import (

const errorDataLakePipelineRunList = "error reading MongoDB Atlas DataLake Runs (%s): %s"

func DataSourceDataLakePipelineRuns() *schema.Resource {
func PluralDataSourceRun() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceMongoDBAtlasDataLakeRunsRead,
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -101,7 +101,7 @@ func dataSourceMongoDBAtlasDataLakeRunsRead(ctx context.Context, d *schema.Resou
}

if err := d.Set("results", flattenDataLakePipelineRunResult(dataLakeRuns.Results)); err != nil {
return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "results", projectID, err))
return diag.FromErr(fmt.Errorf(ErrorDataLakeSetting, "results", projectID, err))
}

d.SetId(id.UniqueId())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas_test
package datalakepipeline_test

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

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

import (
"context"
Expand All @@ -13,7 +13,7 @@ import (

const errorDataLakePipelineList = "error creating MongoDB Atlas DataLake Pipelines: %s"

func DataSourceDataLakePipelines() *schema.Resource {
func PluralDataSource() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceMongoDBAtlasDataLakePipelinesRead,
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 datalakepipeline_test

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

import (
"context"
Expand All @@ -22,10 +22,10 @@ const (
errorDataLakePipelineDelete = "error deleting MongoDB Atlas DataLake Pipeline (%s): %s"
errorDataLakePipelineUpdate = "error updating MongoDB Atlas DataLake Pipeline: %s"
errorDataLakePipelineSetting = "error setting `%s` for MongoDB Atlas DataLake Pipeline (%s): %s"
errorDataLakeSetting = "error setting `%s` for MongoDB Atlas DataLake (%s): %s"
ErrorDataLakeSetting = "error setting `%s` for MongoDB Atlas DataLake (%s): %s"
)

func ResourceDataLakePipeline() *schema.Resource {
func Resource() *schema.Resource {
return &schema.Resource{
CreateContext: resourceMongoDBAtlasDataLakePipelineCreate,
ReadContext: resourceMongoDBAtlasDataLakePipelineRead,
Expand Down Expand Up @@ -298,7 +298,7 @@ func resourceMongoDBAtlasDataLakePipelineRead(ctx context.Context, d *schema.Res
}

if err := d.Set("id", dataLakePipeline.ID); err != nil {
return diag.FromErr(fmt.Errorf(errorDataLakeSetting, "id", name, err))
return diag.FromErr(fmt.Errorf(ErrorDataLakeSetting, "id", name, err))
}

if err := d.Set("state", dataLakePipeline.State); err != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas_test
package datalakepipeline_test

import (
"context"
Expand Down Expand Up @@ -26,7 +26,7 @@ func TestAccClusterRSDataLakePipeline_basic(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheck(t) },
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: testAccCheckMongoDBAtlasSearchIndexDestroy,
CheckDestroy: acc.CheckDestroySearchIndex,
Steps: []resource.TestStep{
{
Config: testAccMongoDBAtlasDataLakePipelineConfig(projectID, clusterName, name),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package mongodbatlas
package eventtrigger

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

func DataSourceEventTrigger() *schema.Resource {
func DataSource() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceMongoDBAtlasEventTriggerRead,
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 eventtrigger_test

import (
"fmt"
Expand Down
Loading