From 26c69fbd0d250cafc2819c8d770676bc097557ed Mon Sep 17 00:00:00 2001 From: dgomez04 Date: Fri, 1 Nov 2024 12:16:59 -0600 Subject: [PATCH] added resource to rollout utils --- internal/providers/pluginfw/pluginfw.go | 19 +------------------ .../pluginfw/pluginfw_rollout_utils.go | 2 ++ .../pluginfw/resources/user/data_users.go | 4 +++- .../resources/user/data_users_acc_test.go | 4 ++-- 4 files changed, 8 insertions(+), 21 deletions(-) diff --git a/internal/providers/pluginfw/pluginfw.go b/internal/providers/pluginfw/pluginfw.go index bf1b4cce9..4eaecd993 100644 --- a/internal/providers/pluginfw/pluginfw.go +++ b/internal/providers/pluginfw/pluginfw.go @@ -16,14 +16,6 @@ import ( "github.com/databricks/terraform-provider-databricks/commands" "github.com/databricks/terraform-provider-databricks/common" providercommon "github.com/databricks/terraform-provider-databricks/internal/providers/common" - "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/resources/catalog" - "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/resources/cluster" - "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/resources/notificationdestinations" - "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/resources/registered_model" - "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/resources/sharing" - "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/resources/user" - "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/resources/volume" - "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/path" @@ -50,16 +42,7 @@ func (p *DatabricksProviderPluginFramework) Resources(ctx context.Context) []fun } func (p *DatabricksProviderPluginFramework) DataSources(ctx context.Context) []func() datasource.DataSource { - return []func() datasource.DataSource{ - cluster.DataSourceCluster, - volume.DataSourceVolumes, - registered_model.DataSourceRegisteredModel, - notificationdestinations.DataSourceNotificationDestinations, - sharing.DataSourceShare, - sharing.DataSourceShares, - catalog.DataSourceFunctions, - user.DataSourceUsers, - } + return getPluginFrameworkDataSourcesToRegister(p.sdkV2Fallbacks...) } func (p *DatabricksProviderPluginFramework) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) { diff --git a/internal/providers/pluginfw/pluginfw_rollout_utils.go b/internal/providers/pluginfw/pluginfw_rollout_utils.go index 90b782a51..5a74df8e7 100644 --- a/internal/providers/pluginfw/pluginfw_rollout_utils.go +++ b/internal/providers/pluginfw/pluginfw_rollout_utils.go @@ -19,6 +19,7 @@ import ( "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/resources/qualitymonitor" "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/resources/registered_model" "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/resources/sharing" + "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/resources/user" "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/resources/volume" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/resource" @@ -45,6 +46,7 @@ var pluginFwOnlyResources = []func() resource.Resource{ var pluginFwOnlyDataSources = []func() datasource.DataSource{ registered_model.DataSourceRegisteredModel, notificationdestinations.DataSourceNotificationDestinations, + user.DataSourceUsers, catalog.DataSourceFunctions, // TODO: Add DataSourceCluster into migratedDataSources after fixing unit tests. cluster.DataSourceCluster, // Using the staging name (with pluginframework suffix) diff --git a/internal/providers/pluginfw/resources/user/data_users.go b/internal/providers/pluginfw/resources/user/data_users.go index ce15767cc..5117d3bc5 100644 --- a/internal/providers/pluginfw/resources/user/data_users.go +++ b/internal/providers/pluginfw/resources/user/data_users.go @@ -14,6 +14,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/types" ) +const dataSourceName = "users" + func DataSourceUsers() datasource.DataSource { return &UsersDataSource{} } @@ -30,7 +32,7 @@ type UsersInfo struct { } func (d *UsersDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = "databricks_users" + resp.TypeName = pluginfwcommon.GetDatabricksProductionName(dataSourceName) } func (d *UsersDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { diff --git a/internal/providers/pluginfw/resources/user/data_users_acc_test.go b/internal/providers/pluginfw/resources/user/data_users_acc_test.go index a71b8cd9e..79f9eaeba 100644 --- a/internal/providers/pluginfw/resources/user/data_users_acc_test.go +++ b/internal/providers/pluginfw/resources/user/data_users_acc_test.go @@ -11,11 +11,11 @@ import ( const dataSourceTemplate = ` resource "databricks_user" "user1" { - user_name = "user-datasource-{var.STICKY_RANDOM}-1@databricks.com" + user_name = "tf-{var.STICKY_RANDOM}-1@databricks.com" } resource "databricks_user" "user2" { - user_name = "user-datasource-{var.STICKY_RANDOM}-2@databricks.com" + user_name = "tf-{var.STICKY_RANDOM}-2@databricks.com" } data "databricks_users" "this" {