Skip to content

Commit

Permalink
refactor: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
DariuszPorowski committed Dec 26, 2024
1 parent e895e27 commit cc15df1
Show file tree
Hide file tree
Showing 32 changed files with 70 additions and 90 deletions.
2 changes: 1 addition & 1 deletion internal/services/environment/data_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func NewDataSourceEnvironment(ctx context.Context) datasource.DataSource {
ItemDocsSPNSupport,
IsDisplayNameUnique: true,
},
PropertiesAttributes: getDataSourcePropertiesAttributes(ctx),
PropertiesAttributes: getDataSourceEnvironmentPropertiesAttributes(ctx),
PropertiesSetter: propertiesSetter,
ItemGetter: itemGetter,
ItemListGetter: itemListGetter,
Expand Down
2 changes: 1 addition & 1 deletion internal/services/environment/data_environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func NewDataSourceEnvironments(ctx context.Context) datasource.DataSource {
"Use this data source to list [" + ItemsName + "](" + ItemDocsURL + ").\n\n" +
ItemDocsSPNSupport,
},
PropertiesAttributes: getDataSourcePropertiesAttributes(ctx),
PropertiesAttributes: getDataSourceEnvironmentPropertiesAttributes(ctx),
PropertiesSetter: propertiesSetter,
ItemListGetter: itemListGetter,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/services/environment/resource_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func NewResourceEnvironment(ctx context.Context) resource.Resource {
DisplayNameMaxLength: 123,
DescriptionMaxLength: 256,
},
PropertiesAttributes: getResourcePropertiesAttributes(ctx),
PropertiesAttributes: getResourceEnvironmentPropertiesAttributes(ctx),
PropertiesSetter: propertiesSetter,
ItemGetter: itemGetter,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/microsoft/terraform-provider-fabric/internal/pkg/utils"
)

func getDataSourcePropertiesAttributes(ctx context.Context) map[string]schema.Attribute {
func getDataSourceEnvironmentPropertiesAttributes(ctx context.Context) map[string]schema.Attribute {
publishStatePossibleValuesMarkdown := "Publish state. Possible values: " + utils.ConvertStringSlicesToString(fabenvironment.PossibleEnvironmentPublishStateValues(), true, true) + "."

result := map[string]schema.Attribute{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/microsoft/terraform-provider-fabric/internal/pkg/utils"
)

func getResourcePropertiesAttributes(ctx context.Context) map[string]schema.Attribute {
func getResourceEnvironmentPropertiesAttributes(ctx context.Context) map[string]schema.Attribute {
publishStatePossibleValuesMarkdown := "Publish state. Possible values: " + utils.ConvertStringSlicesToString(fabenvironment.PossibleEnvironmentPublishStateValues(), true, true) + "."

result := map[string]schema.Attribute{
Expand Down
2 changes: 1 addition & 1 deletion internal/services/eventhouse/data_eventhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func NewDataSourceEventhouse(ctx context.Context) datasource.DataSource {
FormatTypes: ItemFormatTypes,
DefinitionPathKeys: ItemDefinitionPaths,
},
PropertiesAttributes: getDataSourcePropertiesAttributes(ctx),
PropertiesAttributes: getDataSourceEventhousePropertiesAttributes(ctx),
PropertiesSetter: propertiesSetter,
ItemGetter: itemGetter,
ItemListGetter: itemListGetter,
Expand Down
2 changes: 1 addition & 1 deletion internal/services/eventhouse/data_eventhouses.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewDataSourceEventhouses(ctx context.Context) datasource.DataSource {
"Use this data source to list [" + ItemsName + "](" + ItemDocsURL + ").\n\n" +
ItemDocsSPNSupport,
},
PropertiesAttributes: getDataSourcePropertiesAttributes(ctx),
PropertiesAttributes: getDataSourceEventhousePropertiesAttributes(ctx),
PropertiesSetter: propertiesSetter,
ItemListGetter: itemListGetter,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/services/eventhouse/resource_eventhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func NewResourceEventhouse(ctx context.Context) resource.Resource {
DefinitionRequired: false,
DefinitionEmpty: ItemDefinitionEmpty,
},
PropertiesAttributes: getResourcePropertiesAttributes(ctx),
PropertiesAttributes: getResourceEventhousePropertiesAttributes(ctx),
PropertiesSetter: propertiesSetter,
ItemGetter: itemGetter,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
)

func getDataSourcePropertiesAttributes(ctx context.Context) map[string]schema.Attribute {
func getDataSourceEventhousePropertiesAttributes(ctx context.Context) map[string]schema.Attribute {
result := map[string]schema.Attribute{
"ingestion_service_uri": schema.StringAttribute{
MarkdownDescription: "Ingestion service URI.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
)

func getResourcePropertiesAttributes(ctx context.Context) map[string]schema.Attribute {
func getResourceEventhousePropertiesAttributes(ctx context.Context) map[string]schema.Attribute {
result := map[string]schema.Attribute{
"ingestion_service_uri": schema.StringAttribute{
MarkdownDescription: "Ingestion service URI.",
Expand Down
2 changes: 1 addition & 1 deletion internal/services/kqldatabase/data_kql_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func NewDataSourceKQLDatabase() datasource.DataSource {
ItemDocsSPNSupport,
IsDisplayNameUnique: true,
},
PropertiesAttributes: getDataSourcePropertiesAttributes(),
PropertiesAttributes: getDataSourceKQLDatabasePropertiesAttributes(),
PropertiesSetter: propertiesSetter,
ItemGetter: itemGetter,
ItemListGetter: itemListGetter,
Expand Down
2 changes: 1 addition & 1 deletion internal/services/kqldatabase/data_kql_databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewDataSourceKQLDatabases() datasource.DataSource {
"Use this data source to list [" + ItemsName + "](" + ItemDocsURL + ").\n\n" +
ItemDocsSPNSupport,
},
PropertiesAttributes: getDataSourcePropertiesAttributes(),
PropertiesAttributes: getDataSourceKQLDatabasePropertiesAttributes(),
PropertiesSetter: propertiesSetter,
ItemListGetter: itemListGetter,
}
Expand Down
4 changes: 2 additions & 2 deletions internal/services/kqldatabase/resource_kql_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ func NewResourceKQLDatabase() resource.Resource {
DescriptionMaxLength: 256,
},
IsConfigRequired: true,
ConfigAttributes: getResourceConfigurationAttributes(),
ConfigAttributes: getResourceKQLDatabaseConfigurationAttributes(),
CreationPayloadSetter: creationPayloadSetter,
PropertiesAttributes: getResourcePropertiesAttributes(),
PropertiesAttributes: getResourceKQLDatabasePropertiesAttributes(),
PropertiesSetter: propertiesSetter,
ItemGetter: itemGetter,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/microsoft/terraform-provider-fabric/internal/pkg/utils"
)

func getDataSourcePropertiesAttributes() map[string]schema.Attribute {
func getDataSourceKQLDatabasePropertiesAttributes() map[string]schema.Attribute {
result := map[string]schema.Attribute{
"database_type": schema.StringAttribute{
MarkdownDescription: "The type of the database. Possible values:" + utils.ConvertStringSlicesToString(fabkqldatabase.PossibleKqlDatabaseTypeValues(), true, true) + ".",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,31 @@ import (
"github.com/microsoft/terraform-provider-fabric/internal/pkg/utils"
)

func getResourceConfigurationAttributes() map[string]schema.Attribute {
func getResourceKQLDatabasePropertiesAttributes() map[string]schema.Attribute {
return map[string]schema.Attribute{
"database_type": schema.StringAttribute{
MarkdownDescription: "The type of the database. Possible values:" + utils.ConvertStringSlicesToString(fabkqldatabase.PossibleKqlDatabaseTypeValues(), true, true) + ".",
Computed: true,
},
"eventhouse_id": schema.StringAttribute{
MarkdownDescription: "Parent Eventhouse ID.",
Computed: true,
CustomType: customtypes.UUIDType{},
},
"ingestion_service_uri": schema.StringAttribute{
MarkdownDescription: "Ingestion service URI.",
Computed: true,
CustomType: customtypes.URLType{},
},
"query_service_uri": schema.StringAttribute{
MarkdownDescription: "Query service URI.",
Computed: true,
CustomType: customtypes.URLType{},
},
}
}

func getResourceKQLDatabaseConfigurationAttributes() map[string]schema.Attribute {
return map[string]schema.Attribute{
"database_type": schema.StringAttribute{
MarkdownDescription: "The type of the KQL database. Accepted values: " + utils.ConvertStringSlicesToString(fabkqldatabase.PossibleKqlDatabaseTypeValues(), true, true) + ".\n\n" +
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion internal/services/lakehouse/data_lakehouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func NewDataSourceLakehouse(ctx context.Context) datasource.DataSource {
ItemDocsSPNSupport,
IsDisplayNameUnique: true,
},
PropertiesAttributes: getDataSourcePropertiesAttributes(ctx),
PropertiesAttributes: getDataSourceLakehousePropertiesAttributes(ctx),
PropertiesSetter: propertiesSetter,
ItemGetter: itemGetter,
ItemListGetter: itemListGetter,
Expand Down
2 changes: 1 addition & 1 deletion internal/services/lakehouse/data_lakehouses.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func NewDataSourceLakehouses(ctx context.Context) datasource.DataSource {
"Use this data source to list [" + ItemsName + "](" + ItemDocsURL + ").\n\n" +
ItemDocsSPNSupport,
},
PropertiesAttributes: getDataSourcePropertiesAttributes(ctx),
PropertiesAttributes: getDataSourceLakehousePropertiesAttributes(ctx),
PropertiesSetter: propertiesSetter,
ItemListGetter: itemListGetter,
}
Expand Down
4 changes: 2 additions & 2 deletions internal/services/lakehouse/resource_lakehouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ func NewResourceLakehouse(ctx context.Context) resource.Resource {
DescriptionMaxLength: 256,
},
IsConfigRequired: false,
ConfigAttributes: getResourceConfigurationAttributes(),
ConfigAttributes: getResourceLakehouseConfigurationAttributes(),
CreationPayloadSetter: creationPayloadSetter,
PropertiesAttributes: getResourcePropertiesAttributes(ctx),
PropertiesAttributes: getResourceLakehousePropertiesAttributes(ctx),
PropertiesSetter: propertiesSetter,
ItemGetter: itemGetter,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/microsoft/terraform-provider-fabric/internal/framework/customtypes"
)

func getDataSourcePropertiesAttributes(ctx context.Context) map[string]schema.Attribute {
func getDataSourceLakehousePropertiesAttributes(ctx context.Context) map[string]schema.Attribute {
return map[string]schema.Attribute{
"onelake_files_path": schema.StringAttribute{
MarkdownDescription: "OneLake path to the Lakehouse files directory",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import (

supertypes "github.com/FrangipaneTeam/terraform-plugin-framework-supertypes"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"

"github.com/microsoft/terraform-provider-fabric/internal/framework/customtypes"
)

func getResourcePropertiesAttributes(ctx context.Context) map[string]schema.Attribute {
func getResourceLakehousePropertiesAttributes(ctx context.Context) map[string]schema.Attribute {
return map[string]schema.Attribute{
"onelake_files_path": schema.StringAttribute{
MarkdownDescription: "OneLake path to the Lakehouse files directory",
Expand Down Expand Up @@ -48,3 +50,15 @@ func getResourcePropertiesAttributes(ctx context.Context) map[string]schema.Attr
},
}
}

func getResourceLakehouseConfigurationAttributes() map[string]schema.Attribute {
return map[string]schema.Attribute{
"enable_schemas": schema.BoolAttribute{
MarkdownDescription: "Schema enabled Lakehouse.",
Required: true,
PlanModifiers: []planmodifier.Bool{
boolplanmodifier.RequiresReplace(),
},
},
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func NewDataSourceSparkJobDefinition() datasource.DataSource {
FormatTypes: ItemFormatTypes,
DefinitionPathKeys: ItemDefinitionPaths,
},
PropertiesAttributes: getDataSourcePropertiesAttributes(),
PropertiesAttributes: getDataSourceSparkJobDefinitionPropertiesAttributes(),
PropertiesSetter: propertiesSetter,
ItemGetter: itemGetter,
ItemListGetter: itemListGetter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewDataSourceSparkJobDefinitions() datasource.DataSource {
"Use this data source to list [" + ItemsName + "](" + ItemDocsURL + ").\n\n" +
ItemDocsSPNSupport,
},
PropertiesAttributes: getDataSourcePropertiesAttributes(),
PropertiesAttributes: getDataSourceSparkJobDefinitionPropertiesAttributes(),
PropertiesSetter: propertiesSetter,
ItemListGetter: itemListGetter,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func NewResourceSparkJobDefinition() resource.Resource {
DefinitionRequired: false,
DefinitionEmpty: ItemDefinitionEmpty,
},
PropertiesAttributes: getResourcePropertiesAttributes(),
PropertiesAttributes: getResourceSparkJobDefinitionPropertiesAttributes(),
PropertiesSetter: propertiesSetter,
ItemGetter: itemGetter,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
)

func getDataSourcePropertiesAttributes() map[string]schema.Attribute {
func getDataSourceSparkJobDefinitionPropertiesAttributes() map[string]schema.Attribute {
result := map[string]schema.Attribute{
"onelake_root_path": schema.StringAttribute{
MarkdownDescription: "OneLake path to the Spark Job Definition root directory.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
)

func getResourcePropertiesAttributes() map[string]schema.Attribute {
func getResourceSparkJobDefinitionPropertiesAttributes() map[string]schema.Attribute {
result := map[string]schema.Attribute{
"onelake_root_path": schema.StringAttribute{
MarkdownDescription: "OneLake path to the Spark Job Definition root directory.",
Expand Down
2 changes: 1 addition & 1 deletion internal/services/warehouse/data_warehouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func NewDataSourceWarehouse() datasource.DataSource {
ItemDocsSPNSupport,
IsDisplayNameUnique: true,
},
PropertiesAttributes: getDataSourcePropertiesAttributes(),
PropertiesAttributes: getDataSourceWarehousePropertiesAttributes(),
PropertiesSetter: propertiesSetter,
ItemGetter: itemGetter,
ItemListGetter: itemListGetter,
Expand Down
2 changes: 1 addition & 1 deletion internal/services/warehouse/data_warehouses.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewDataSourceWarehouses() datasource.DataSource {
"Use this data source to list [" + ItemsName + "](" + ItemDocsURL + ").\n\n" +
ItemDocsSPNSupport,
},
PropertiesAttributes: getDataSourcePropertiesAttributes(),
PropertiesAttributes: getDataSourceWarehousePropertiesAttributes(),
PropertiesSetter: propertiesSetter,
ItemListGetter: itemListGetter,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/services/warehouse/resource_warehouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewResourceWarehouse() resource.Resource {
DisplayNameMaxLength: 123,
DescriptionMaxLength: 256,
},
PropertiesAttributes: getResourcePropertiesAttributes(),
PropertiesAttributes: getResourceWarehousePropertiesAttributes(),
PropertiesSetter: propertiesSetter,
ItemGetter: itemGetter,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
)

func getDataSourcePropertiesAttributes() map[string]schema.Attribute {
func getDataSourceWarehousePropertiesAttributes() map[string]schema.Attribute {
result := map[string]schema.Attribute{
"connection_string": schema.StringAttribute{
MarkdownDescription: "The SQL connection string connected to the workspace containing this warehouse.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
)

func getResourcePropertiesAttributes() map[string]schema.Attribute {
func getResourceWarehousePropertiesAttributes() map[string]schema.Attribute {
result := map[string]schema.Attribute{
"connection_string": schema.StringAttribute{
MarkdownDescription: "The SQL connection string connected to the workspace containing this warehouse.",
Expand Down

0 comments on commit cc15df1

Please sign in to comment.