diff --git a/.changes/unreleased/breaking-20250107-233638.yaml b/.changes/unreleased/breaking-20250107-233638.yaml new file mode 100644 index 00000000..da32043b --- /dev/null +++ b/.changes/unreleased/breaking-20250107-233638.yaml @@ -0,0 +1,8 @@ +kind: breaking +body: | + Using preview resources or data sources now needs explicit opt-in at the provider level configuration by setting the `preview` attribute to `true`. + This is to ensure that users are aware of the risks of using preview resources or data sources in production environments. + Usage of any preview feature will result in a warning message in the Terraform output. +time: 2025-01-07T23:36:38.8482843-08:00 +custom: + Issue: "185" diff --git a/Taskfile.yml b/Taskfile.yml index 7d447422..f8388814 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -21,6 +21,9 @@ vars: BUILD_DEV_OUTPUT_DIR: "bin/{{OS}}-{{ARCH}}" BUILD_DEV_ARTIFACT: "{{.BUILD_DEV_OUTPUT_DIR}}/{{.PROJECT_NAME}}{{exeExt}}" +env: + FABRIC_PREVIEW: true + tasks: # ---------------------- # Development diff --git a/docs/data-sources/data_pipeline.md b/docs/data-sources/data_pipeline.md index 938264b3..10ec91e0 100644 --- a/docs/data-sources/data_pipeline.md +++ b/docs/data-sources/data_pipeline.md @@ -6,6 +6,7 @@ description: |- Get a Fabric Data Pipeline. Use this data source to fetch a Data Pipeline https://learn.microsoft.com/fabric/data-factory/data-factory-overview#data-pipelines. -> This item does not support Service Principal. Please use a User context authentication. + ~> This data-source is in preview. To access it, you must explicitly enable the preview mode in the provider level configuration. --- # fabric_data_pipeline (Data Source) @@ -16,6 +17,8 @@ Use this data source to fetch a [Data Pipeline](https://learn.microsoft.com/fabr -> This item does not support Service Principal. Please use a User context authentication. +~> This data-source is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration. + ## Example Usage ```terraform diff --git a/docs/data-sources/domain.md b/docs/data-sources/domain.md index 453d0fea..e90f40d6 100644 --- a/docs/data-sources/domain.md +++ b/docs/data-sources/domain.md @@ -6,6 +6,7 @@ description: |- Get a Fabric Domain. Use this data source to get Domain https://learn.microsoft.com/fabric/governance/domains. -> This item does not support Service Principal. Please use a User context authentication. + ~> This data-source is in preview. To access it, you must explicitly enable the preview mode in the provider level configuration. --- # fabric_domain (Data Source) @@ -16,6 +17,8 @@ Use this data source to get [Domain](https://learn.microsoft.com/fabric/governan -> This item does not support Service Principal. Please use a User context authentication. +~> This data-source is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration. + ## Example Usage ```terraform diff --git a/docs/data-sources/domain_workspace_assignments.md b/docs/data-sources/domain_workspace_assignments.md index 97773fce..073a7e7f 100644 --- a/docs/data-sources/domain_workspace_assignments.md +++ b/docs/data-sources/domain_workspace_assignments.md @@ -4,18 +4,21 @@ page_title: "fabric_domain_workspace_assignments Data Source - terraform-provide subcategory: "" description: |- List a Fabric Domain Workspace Assignments. - See Domain https://learn.microsoft.com/fabric/governance/domains for more information. + Use this data source to list Domain Workspace Assignments https://learn.microsoft.com/fabric/governance/domains. -> This item does not support Service Principal. Please use a User context authentication. + ~> This data-source is in preview. To access it, you must explicitly enable the preview mode in the provider level configuration. --- # fabric_domain_workspace_assignments (Data Source) List a Fabric Domain Workspace Assignments. -See [Domain](https://learn.microsoft.com/fabric/governance/domains) for more information. +Use this data source to list [Domain Workspace Assignments](https://learn.microsoft.com/fabric/governance/domains). -> This item does not support Service Principal. Please use a User context authentication. +~> This data-source is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration. + ## Example Usage ```terraform diff --git a/docs/data-sources/ml_experiment.md b/docs/data-sources/ml_experiment.md index ff0b24fe..c78f66b0 100644 --- a/docs/data-sources/ml_experiment.md +++ b/docs/data-sources/ml_experiment.md @@ -6,6 +6,7 @@ description: |- Get a Fabric ML Experiment. Use this data source to fetch a ML Experiment https://learn.microsoft.com/fabric/data-science/machine-learning-experiment. -> This item does not support Service Principal. Please use a User context authentication. + ~> This data-source is in preview. To access it, you must explicitly enable the preview mode in the provider level configuration. --- # fabric_ml_experiment (Data Source) @@ -16,6 +17,8 @@ Use this data source to fetch a [ML Experiment](https://learn.microsoft.com/fabr -> This item does not support Service Principal. Please use a User context authentication. +~> This data-source is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration. + ## Example Usage ```terraform diff --git a/docs/data-sources/ml_model.md b/docs/data-sources/ml_model.md index a8af7d68..9d1cec2b 100644 --- a/docs/data-sources/ml_model.md +++ b/docs/data-sources/ml_model.md @@ -6,6 +6,7 @@ description: |- Get a Fabric ML Model. Use this data source to fetch a ML Model https://learn.microsoft.com/fabric/data-science/machine-learning-model. -> This item does not support Service Principal. Please use a User context authentication. + ~> This data-source is in preview. To access it, you must explicitly enable the preview mode in the provider level configuration. --- # fabric_ml_model (Data Source) @@ -16,6 +17,8 @@ Use this data source to fetch a [ML Model](https://learn.microsoft.com/fabric/da -> This item does not support Service Principal. Please use a User context authentication. +~> This data-source is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration. + ## Example Usage ```terraform diff --git a/docs/data-sources/warehouse.md b/docs/data-sources/warehouse.md index d270948f..dff51ba6 100644 --- a/docs/data-sources/warehouse.md +++ b/docs/data-sources/warehouse.md @@ -6,6 +6,7 @@ description: |- Get a Fabric Warehouse. Use this data source to fetch a Warehouse https://learn.microsoft.com/fabric/data-warehouse/data-warehousing. -> This item does not support Service Principal. Please use a User context authentication. + ~> This data-source is in preview. To access it, you must explicitly enable the preview mode in the provider level configuration. --- # fabric_warehouse (Data Source) @@ -16,6 +17,8 @@ Use this data source to fetch a [Warehouse](https://learn.microsoft.com/fabric/d -> This item does not support Service Principal. Please use a User context authentication. +~> This data-source is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration. + ## Example Usage ```terraform diff --git a/docs/index.md b/docs/index.md index f1d2ed16..d37c270e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -92,6 +92,7 @@ You can find more information on how to do this in the following guides: - `oidc_request_url` (String) The URL for the OIDC provider from which to request an ID token. For use when authenticating as a Service Principal using OpenID Connect. - `oidc_token` (String, Sensitive) The OIDC token for use when authenticating as a Service Principal using OpenID Connect. - `oidc_token_file_path` (String) The path to a file containing an OIDC token for use when authenticating as a Service Principal using OpenID Connect. +- `preview` (Boolean) Enable preview mode to use preview features. - `tenant_id` (String) The ID of the Microsoft Entra ID tenant that Fabric API uses to authenticate with. - `timeout` (String) Default timeout for all requests. It can be overridden at any Resource/Data-Source A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as `30s` or `2h45m`. Valid time units are "s" (seconds), "m" (minutes), "h" (hours) diff --git a/docs/resources/data_pipeline.md b/docs/resources/data_pipeline.md index 4e13f1eb..e7e11fc9 100644 --- a/docs/resources/data_pipeline.md +++ b/docs/resources/data_pipeline.md @@ -6,6 +6,7 @@ description: |- Manage a Fabric Data Pipeline. Use this resource to manage Data Pipeline https://learn.microsoft.com/fabric/data-factory/data-factory-overview#data-pipelines. -> This item does not support Service Principal. Please use a User context authentication. + ~> This resource is in preview. To access it, you must explicitly enable the preview mode in the provider level configuration. --- # fabric_data_pipeline (Resource) @@ -16,6 +17,8 @@ Use this resource to manage [Data Pipeline](https://learn.microsoft.com/fabric/d -> This item does not support Service Principal. Please use a User context authentication. +~> This resource is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration. + ## Example Usage ```terraform diff --git a/docs/resources/domain.md b/docs/resources/domain.md index 67d434e2..97222f14 100644 --- a/docs/resources/domain.md +++ b/docs/resources/domain.md @@ -3,19 +3,22 @@ page_title: "fabric_domain Resource - terraform-provider-fabric" subcategory: "" description: |- - This resource manages a Fabric Domain. - See Domains https://learn.microsoft.com/fabric/governance/domains for more information. + Manage a Fabric Domain. + Use this resource to manage Domain https://learn.microsoft.com/fabric/governance/domains. -> This item does not support Service Principal. Please use a User context authentication. + ~> This resource is in preview. To access it, you must explicitly enable the preview mode in the provider level configuration. --- # fabric_domain (Resource) -This resource manages a Fabric Domain. +Manage a Fabric Domain. -See [Domains](https://learn.microsoft.com/fabric/governance/domains) for more information. +Use this resource to manage [Domain](https://learn.microsoft.com/fabric/governance/domains). -> This item does not support Service Principal. Please use a User context authentication. +~> This resource is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration. + ## Example Usage ```terraform diff --git a/docs/resources/domain_role_assignments.md b/docs/resources/domain_role_assignments.md index 18d97171..d1a35121 100644 --- a/docs/resources/domain_role_assignments.md +++ b/docs/resources/domain_role_assignments.md @@ -4,18 +4,21 @@ page_title: "fabric_domain_role_assignments Resource - terraform-provider-fabric subcategory: "" description: |- Manage a Fabric Domain Role Assignments. - See Domain https://learn.microsoft.com/fabric/governance/domains for more information. + Use this resource to manage Domain Role Assignments https://learn.microsoft.com/fabric/governance/domains. -> This item does not support Service Principal. Please use a User context authentication. + ~> This resource is in preview. To access it, you must explicitly enable the preview mode in the provider level configuration. --- # fabric_domain_role_assignments (Resource) Manage a Fabric Domain Role Assignments. -See [Domain](https://learn.microsoft.com/fabric/governance/domains) for more information. +Use this resource to manage [Domain Role Assignments](https://learn.microsoft.com/fabric/governance/domains). -> This item does not support Service Principal. Please use a User context authentication. +~> This resource is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration. + ## Example Usage ```terraform diff --git a/docs/resources/domain_workspace_assignments.md b/docs/resources/domain_workspace_assignments.md index b9ec6e17..d73b28f2 100644 --- a/docs/resources/domain_workspace_assignments.md +++ b/docs/resources/domain_workspace_assignments.md @@ -4,18 +4,21 @@ page_title: "fabric_domain_workspace_assignments Resource - terraform-provider-f subcategory: "" description: |- Manage a Fabric Domain Workspace Assignments. - See Domain https://learn.microsoft.com/fabric/governance/domains for more information. + Use this resource to manage Domain Workspace Assignments https://learn.microsoft.com/fabric/governance/domains. -> This item does not support Service Principal. Please use a User context authentication. + ~> This resource is in preview. To access it, you must explicitly enable the preview mode in the provider level configuration. --- # fabric_domain_workspace_assignments (Resource) Manage a Fabric Domain Workspace Assignments. -See [Domain](https://learn.microsoft.com/fabric/governance/domains) for more information. +Use this resource to manage [Domain Workspace Assignments](https://learn.microsoft.com/fabric/governance/domains). -> This item does not support Service Principal. Please use a User context authentication. +~> This resource is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration. + ## Example Usage ```terraform diff --git a/docs/resources/ml_experiment.md b/docs/resources/ml_experiment.md index 1065e527..aacd530e 100644 --- a/docs/resources/ml_experiment.md +++ b/docs/resources/ml_experiment.md @@ -6,6 +6,7 @@ description: |- Manage a Fabric ML Experiment. Use this resource to manage ML Experiment https://learn.microsoft.com/fabric/data-science/machine-learning-experiment. -> This item does not support Service Principal. Please use a User context authentication. + ~> This resource is in preview. To access it, you must explicitly enable the preview mode in the provider level configuration. --- # fabric_ml_experiment (Resource) @@ -16,6 +17,8 @@ Use this resource to manage [ML Experiment](https://learn.microsoft.com/fabric/d -> This item does not support Service Principal. Please use a User context authentication. +~> This resource is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration. + ## Example Usage ```terraform diff --git a/docs/resources/ml_model.md b/docs/resources/ml_model.md index 404f6ff3..65cacfec 100644 --- a/docs/resources/ml_model.md +++ b/docs/resources/ml_model.md @@ -6,6 +6,7 @@ description: |- Manage a Fabric ML Model. Use this resource to manage ML Model https://learn.microsoft.com/fabric/data-science/machine-learning-model. -> This item does not support Service Principal. Please use a User context authentication. + ~> This resource is in preview. To access it, you must explicitly enable the preview mode in the provider level configuration. --- # fabric_ml_model (Resource) @@ -16,6 +17,8 @@ Use this resource to manage [ML Model](https://learn.microsoft.com/fabric/data-s -> This item does not support Service Principal. Please use a User context authentication. +~> This resource is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration. + ## Schema diff --git a/docs/resources/warehouse.md b/docs/resources/warehouse.md index 90a79530..3fd72754 100644 --- a/docs/resources/warehouse.md +++ b/docs/resources/warehouse.md @@ -6,6 +6,7 @@ description: |- Manage a Fabric Warehouse. Use this resource to manage a Warehouse https://learn.microsoft.com/fabric/data-warehouse/data-warehousing. -> This item does not support Service Principal. Please use a User context authentication. + ~> This resource is in preview. To access it, you must explicitly enable the preview mode in the provider level configuration. --- # fabric_warehouse (Resource) @@ -16,6 +17,8 @@ Use this resource to manage a [Warehouse](https://learn.microsoft.com/fabric/dat -> This item does not support Service Principal. Please use a User context authentication. +~> This resource is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration. + ## Example Usage ```terraform diff --git a/docs/resources/workspace_git.md b/docs/resources/workspace_git.md index 13704c1b..4d8b577b 100644 --- a/docs/resources/workspace_git.md +++ b/docs/resources/workspace_git.md @@ -6,6 +6,7 @@ description: |- Manage a Fabric Workspace Git integration. See Workspace Git integration https://learn.microsoft.com/fabric/cicd/git-integration/intro-to-git-integration for more information. -> This item does not support Service Principal. Please use a User context authentication. + ~> This resource is in preview. To access it, you must explicitly enable the preview mode in the provider level configuration. --- # fabric_workspace_git (Resource) @@ -16,6 +17,8 @@ See [Workspace Git integration](https://learn.microsoft.com/fabric/cicd/git-inte -> This item does not support Service Principal. Please use a User context authentication. +~> This resource is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration. + ## Example Usage ```terraform diff --git a/internal/common/errors.go b/internal/common/errors.go index b983fe15..961bddeb 100644 --- a/internal/common/errors.go +++ b/internal/common/errors.go @@ -37,11 +37,15 @@ const ( ErrorBase64GzipEncodeHeader string = "Base64 Gzip encode operation" ErrorJSONNormalizeHeader string = "JSON normalize operation" ErrorFileReadHeader string = "File read operation" - ErrorTmplParseHeader string = "template parse operation" + ErrorTmplParseHeader string = "Template parse operation" + ErrorPreviewModeHeader string = "Preview mode not enabled" + ErrorPreviewModeDetails string = "'%s' is not available without explicitly opt-in to the preview mode on the provider level configuration." ) // Warnings. const ( WarningItemDefinitionUpdateHeader = "Fabric Item definition update" WarningItemDefinitionUpdateDetails = "%s definition update operation will overwrite the existing definition on the Fabric side." + WarningPreviewModeHeader = "'%s' preview mode" + WarningPreviewModeDetails = "The behavior of '%s' may change in future releases without notice." ) diff --git a/internal/pkg/fabricitem/base.go b/internal/pkg/fabricitem/base.go index 45c8c196..bcb57633 100644 --- a/internal/pkg/fabricitem/base.go +++ b/internal/pkg/fabricitem/base.go @@ -3,4 +3,8 @@ package fabricitem -const DefinitionFormatNotApplicable = "NotApplicable" +const ( + DefinitionFormatNotApplicable = "NotApplicable" + PreviewDataSource = "\n\n~> This data-source is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration." + PreviewResource = "\n\n~> This resource is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration." +) diff --git a/internal/pkg/fabricitem/data_item.go b/internal/pkg/fabricitem/data_item.go index 5e6d6d4e..2f743ccd 100644 --- a/internal/pkg/fabricitem/data_item.go +++ b/internal/pkg/fabricitem/data_item.go @@ -34,6 +34,7 @@ type DataSourceFabricItem struct { TFName string MarkdownDescription string IsDisplayNameUnique bool + IsPreview bool } func NewDataSourceFabricItem(config DataSourceFabricItem) datasource.DataSource { @@ -82,6 +83,15 @@ func (d *DataSourceFabricItem) Configure(_ context.Context, req datasource.Confi d.pConfigData = pConfigData d.client = fabcore.NewClientFactoryWithClient(*pConfigData.FabricClient).NewItemsClient() + + diags := IsPreviewMode(d.Name, d.IsPreview, d.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (d *DataSourceFabricItem) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/pkg/fabricitem/data_item_definition.go b/internal/pkg/fabricitem/data_item_definition.go index 41dd22d6..c7c73f0f 100644 --- a/internal/pkg/fabricitem/data_item_definition.go +++ b/internal/pkg/fabricitem/data_item_definition.go @@ -38,6 +38,7 @@ type DataSourceFabricItemDefinition struct { FormatTypeDefault string FormatTypes []string DefinitionPathKeys []string + IsPreview bool } func NewDataSourceFabricItemDefinition(config DataSourceFabricItemDefinition) datasource.DataSource { @@ -86,6 +87,15 @@ func (d *DataSourceFabricItemDefinition) Configure(_ context.Context, req dataso d.pConfigData = pConfigData d.client = fabcore.NewClientFactoryWithClient(*pConfigData.FabricClient).NewItemsClient() + + diags := IsPreviewMode(d.Name, d.IsPreview, d.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (d *DataSourceFabricItemDefinition) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/pkg/fabricitem/data_item_definition_properties.go b/internal/pkg/fabricitem/data_item_definition_properties.go index 7ca644d2..2ff9fa1a 100644 --- a/internal/pkg/fabricitem/data_item_definition_properties.go +++ b/internal/pkg/fabricitem/data_item_definition_properties.go @@ -83,6 +83,15 @@ func (d *DataSourceFabricItemDefinitionProperties[Ttfprop, Titemprop]) Configure d.pConfigData = pConfigData d.client = fabcore.NewClientFactoryWithClient(*pConfigData.FabricClient).NewItemsClient() + + diags := IsPreviewMode(d.Name, d.IsPreview, d.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (d *DataSourceFabricItemDefinitionProperties[Ttfprop, Titemprop]) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { //revive:disable-line:confusing-naming diff --git a/internal/pkg/fabricitem/data_item_properties.go b/internal/pkg/fabricitem/data_item_properties.go index 122aeb7e..2cc73685 100644 --- a/internal/pkg/fabricitem/data_item_properties.go +++ b/internal/pkg/fabricitem/data_item_properties.go @@ -82,6 +82,15 @@ func (d *DataSourceFabricItemProperties[Ttfprop, Titemprop]) Configure(_ context d.pConfigData = pConfigData d.client = fabcore.NewClientFactoryWithClient(*pConfigData.FabricClient).NewItemsClient() + + diags := IsPreviewMode(d.Name, d.IsPreview, d.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (d *DataSourceFabricItemProperties[Ttfprop, Titemprop]) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { //revive:disable-line:confusing-naming diff --git a/internal/pkg/fabricitem/data_items.go b/internal/pkg/fabricitem/data_items.go index 08276f6f..303f685c 100644 --- a/internal/pkg/fabricitem/data_items.go +++ b/internal/pkg/fabricitem/data_items.go @@ -35,6 +35,7 @@ type DataSourceFabricItems struct { Names string TFName string MarkdownDescription string + IsPreview bool } func NewDataSourceFabricItems(config DataSourceFabricItems) datasource.DataSource { @@ -103,6 +104,15 @@ func (d *DataSourceFabricItems) Configure(_ context.Context, req datasource.Conf d.pConfigData = pConfigData d.client = fabcore.NewClientFactoryWithClient(*pConfigData.FabricClient).NewItemsClient() + + diags := IsPreviewMode(d.Name, d.IsPreview, d.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (d *DataSourceFabricItems) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/pkg/fabricitem/data_items_properties.go b/internal/pkg/fabricitem/data_items_properties.go index 01888e67..ba83d190 100644 --- a/internal/pkg/fabricitem/data_items_properties.go +++ b/internal/pkg/fabricitem/data_items_properties.go @@ -102,6 +102,15 @@ func (d *DataSourceFabricItemsProperties[Ttfprop, Titemprop]) Configure(_ contex } d.pConfigData = pConfigData + + diags := IsPreviewMode(d.Name, d.IsPreview, d.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (d *DataSourceFabricItemsProperties[Ttfprop, Titemprop]) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { //revive:disable-line:confusing-naming diff --git a/internal/pkg/fabricitem/data_schema.go b/internal/pkg/fabricitem/data_schema.go index 69d3761c..9746769f 100644 --- a/internal/pkg/fabricitem/data_schema.go +++ b/internal/pkg/fabricitem/data_schema.go @@ -19,7 +19,7 @@ func getDataSourceFabricItemSchema(ctx context.Context, d DataSourceFabricItem) attributes := getDataSourceFabricItemBaseAttributes(ctx, d.Name, d.IsDisplayNameUnique) return schema.Schema{ - MarkdownDescription: d.MarkdownDescription, + MarkdownDescription: GetDataSourcePreviewNote(d.MarkdownDescription, d.IsPreview), Attributes: attributes, } } @@ -32,7 +32,7 @@ func getDataSourceFabricItemDefinitionSchema(ctx context.Context, d DataSourceFa } return schema.Schema{ - MarkdownDescription: d.MarkdownDescription, + MarkdownDescription: GetDataSourcePreviewNote(d.MarkdownDescription, d.IsPreview), Attributes: attributes, } } @@ -42,7 +42,7 @@ func getDataSourceFabricItemPropertiesSchema[Ttfprop, Titemprop any](ctx context attributes["properties"] = getDataSourceFabricItemPropertiesNestedAttr[Ttfprop](ctx, d.Name, d.PropertiesAttributes) return schema.Schema{ - MarkdownDescription: d.MarkdownDescription, + MarkdownDescription: GetDataSourcePreviewNote(d.MarkdownDescription, d.IsPreview), Attributes: attributes, } } @@ -56,7 +56,7 @@ func getDataSourceFabricItemDefinitionPropertiesSchema[Ttfprop, Titemprop any](c } return schema.Schema{ - MarkdownDescription: d.MarkdownDescription, + MarkdownDescription: GetDataSourcePreviewNote(d.MarkdownDescription, d.IsPreview), Attributes: attributes, } } diff --git a/internal/pkg/fabricitem/helpers.go b/internal/pkg/fabricitem/helpers.go new file mode 100644 index 00000000..c217a83b --- /dev/null +++ b/internal/pkg/fabricitem/helpers.go @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation +// SPDX-License-Identifier: MPL-2.0 + +package fabricitem + +import ( + "fmt" + + "github.com/hashicorp/terraform-plugin-framework/diag" + + "github.com/microsoft/terraform-provider-fabric/internal/common" +) + +func GetDataSourcePreviewNote(md string, preview bool) string { //revive:disable-line:flag-parameter + if preview { + return md + PreviewDataSource + } + + return md +} + +func GetResourcePreviewNote(md string, preview bool) string { //revive:disable-line:flag-parameter + if preview { + return md + PreviewResource + } + + return md +} + +func IsPreviewMode(name string, itemIsPreview, providerPreviewMode bool) diag.Diagnostics { //revive:disable-line:flag-parameter + var diags diag.Diagnostics + + if itemIsPreview && !providerPreviewMode { + diags.AddError( + common.ErrorPreviewModeHeader, + fmt.Sprintf(common.ErrorPreviewModeDetails, name), + ) + + return diags + } + + if itemIsPreview && providerPreviewMode { + diags.AddWarning( + common.WarningPreviewModeHeader, + fmt.Sprintf(common.WarningPreviewModeDetails, name), + ) + + return diags + } + + return nil +} diff --git a/internal/pkg/fabricitem/helpers_test.go b/internal/pkg/fabricitem/helpers_test.go new file mode 100644 index 00000000..859a46ec --- /dev/null +++ b/internal/pkg/fabricitem/helpers_test.go @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation +// SPDX-License-Identifier: MPL-2.0 + +package fabricitem_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/stretchr/testify/assert" + + "github.com/microsoft/terraform-provider-fabric/internal/common" + "github.com/microsoft/terraform-provider-fabric/internal/pkg/fabricitem" + "github.com/microsoft/terraform-provider-fabric/internal/testhelp" +) + +func TestUnit_GetDataSourcePreviewNote_PreviewEnabled(t *testing.T) { + md := "This is a test data-source." + expected := md + fabricitem.PreviewDataSource + result := fabricitem.GetDataSourcePreviewNote(md, true) + + assert.Equal(t, expected, result) +} + +func TestUnit_GetDataSourcePreviewNote_PreviewDisabled(t *testing.T) { + md := "This is a test data-source." + expected := md + result := fabricitem.GetDataSourcePreviewNote(md, false) + + assert.Equal(t, expected, result) +} + +func TestUnit_GetResourcePreviewNote_PreviewEnabled(t *testing.T) { + md := "This is a test resource." + expected := md + fabricitem.PreviewResource + result := fabricitem.GetResourcePreviewNote(md, true) + + assert.Equal(t, expected, result) +} + +func TestUnit_GetResourcePreviewNote_PreviewDisabled(t *testing.T) { + md := "This is a test resource." + expected := md + result := fabricitem.GetResourcePreviewNote(md, false) + + assert.Equal(t, expected, result) +} + +func TestUnit_IsPreviewMode_ItemIsPreview_ProviderPreviewModeDisabled(t *testing.T) { + name := testhelp.RandomName() + itemIsPreview := true + providerPreviewMode := false + + diags := fabricitem.IsPreviewMode(name, itemIsPreview, providerPreviewMode) + + assert.Len(t, diags, 1) + assert.Equal(t, diag.SeverityError, diags[0].Severity()) + assert.Equal(t, common.ErrorPreviewModeHeader, diags[0].Summary()) + assert.Equal(t, fmt.Sprintf(common.ErrorPreviewModeDetails, name), diags[0].Detail()) +} + +func TestUnit_IsPreviewMode_ItemIsPreview_ProviderPreviewModeEnabled(t *testing.T) { + name := testhelp.RandomName() + itemIsPreview := true + providerPreviewMode := true + + diags := fabricitem.IsPreviewMode(name, itemIsPreview, providerPreviewMode) + + assert.Len(t, diags, 1) + assert.Equal(t, diag.SeverityWarning, diags[0].Severity()) + assert.Equal(t, common.WarningPreviewModeHeader, diags[0].Summary()) + assert.Equal(t, fmt.Sprintf(common.WarningPreviewModeDetails, name), diags[0].Detail()) +} + +func TestUnit_IsPreviewMode_ItemIsNotPreview(t *testing.T) { + name := testhelp.RandomName() + itemIsPreview := false + providerPreviewMode := false + + diags := fabricitem.IsPreviewMode(name, itemIsPreview, providerPreviewMode) + + assert.Empty(t, diags) +} diff --git a/internal/pkg/fabricitem/resource_item.go b/internal/pkg/fabricitem/resource_item.go index 72951173..6d7ac36f 100644 --- a/internal/pkg/fabricitem/resource_item.go +++ b/internal/pkg/fabricitem/resource_item.go @@ -37,6 +37,7 @@ type ResourceFabricItem struct { MarkdownDescription string DisplayNameMaxLength int DescriptionMaxLength int + IsPreview bool } func NewResourceFabricItem(config ResourceFabricItem) resource.Resource { @@ -68,6 +69,15 @@ func (r *ResourceFabricItem) Configure(_ context.Context, req resource.Configure r.pConfigData = pConfigData r.client = fabcore.NewClientFactoryWithClient(*pConfigData.FabricClient).NewItemsClient() + + diags := IsPreviewMode(r.Name, r.IsPreview, r.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (r *ResourceFabricItem) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { diff --git a/internal/pkg/fabricitem/resource_item_config_definition_properties.go b/internal/pkg/fabricitem/resource_item_config_definition_properties.go index 2c80ac5b..fa8d73d9 100644 --- a/internal/pkg/fabricitem/resource_item_config_definition_properties.go +++ b/internal/pkg/fabricitem/resource_item_config_definition_properties.go @@ -126,6 +126,15 @@ func (r *ResourceFabricItemConfigDefinitionProperties[Ttfprop, Titemprop, Ttfcon r.pConfigData = pConfigData r.client = fabcore.NewClientFactoryWithClient(*pConfigData.FabricClient).NewItemsClient() + + diags := IsPreviewMode(r.Name, r.IsPreview, r.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (r *ResourceFabricItemConfigDefinitionProperties[Ttfprop, Titemprop, Ttfconfig, Titemconfig]) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { //revive:disable-line:confusing-naming diff --git a/internal/pkg/fabricitem/resource_item_config_properties.go b/internal/pkg/fabricitem/resource_item_config_properties.go index 1a572679..0e2dfa5f 100644 --- a/internal/pkg/fabricitem/resource_item_config_properties.go +++ b/internal/pkg/fabricitem/resource_item_config_properties.go @@ -69,6 +69,15 @@ func (r *ResourceFabricItemConfigProperties[Ttfprop, Titemprop, Ttfconfig, Titem r.pConfigData = pConfigData r.client = fabcore.NewClientFactoryWithClient(*pConfigData.FabricClient).NewItemsClient() + + diags := IsPreviewMode(r.Name, r.IsPreview, r.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (r *ResourceFabricItemConfigProperties[Ttfprop, Titemprop, Ttfconfig, Titemconfig]) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { //revive:disable-line:confusing-naming diff --git a/internal/pkg/fabricitem/resource_item_definition.go b/internal/pkg/fabricitem/resource_item_definition.go index 2b864ef6..e843c81c 100644 --- a/internal/pkg/fabricitem/resource_item_definition.go +++ b/internal/pkg/fabricitem/resource_item_definition.go @@ -48,6 +48,7 @@ type ResourceFabricItemDefinition struct { DefinitionPathKeysValidator []validator.Map DefinitionRequired bool DefinitionEmpty string + IsPreview bool } func NewResourceFabricItemDefinition(config ResourceFabricItemDefinition) resource.Resource { @@ -119,6 +120,15 @@ func (r *ResourceFabricItemDefinition) Configure(_ context.Context, req resource r.pConfigData = pConfigData r.client = fabcore.NewClientFactoryWithClient(*pConfigData.FabricClient).NewItemsClient() + + diags := IsPreviewMode(r.Name, r.IsPreview, r.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (r *ResourceFabricItemDefinition) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { diff --git a/internal/pkg/fabricitem/resource_item_definition_properties.go b/internal/pkg/fabricitem/resource_item_definition_properties.go index 37e2d440..a31e65ca 100644 --- a/internal/pkg/fabricitem/resource_item_definition_properties.go +++ b/internal/pkg/fabricitem/resource_item_definition_properties.go @@ -108,6 +108,15 @@ func (r *ResourceFabricItemDefinitionProperties[Ttfprop, Titemprop]) Configure(_ r.pConfigData = pConfigData r.client = fabcore.NewClientFactoryWithClient(*pConfigData.FabricClient).NewItemsClient() + + diags := IsPreviewMode(r.Name, r.IsPreview, r.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (r *ResourceFabricItemDefinitionProperties[Ttfprop, Titemprop]) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { //revive:disable-line:confusing-naming diff --git a/internal/pkg/fabricitem/resource_item_properties.go b/internal/pkg/fabricitem/resource_item_properties.go index ece1bff2..d8b4364e 100644 --- a/internal/pkg/fabricitem/resource_item_properties.go +++ b/internal/pkg/fabricitem/resource_item_properties.go @@ -65,6 +65,15 @@ func (r *ResourceFabricItemProperties[Ttfprop, Titemprop]) Configure(_ context.C r.pConfigData = pConfigData r.client = fabcore.NewClientFactoryWithClient(*pConfigData.FabricClient).NewItemsClient() + + diags := IsPreviewMode(r.Name, r.IsPreview, r.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (r *ResourceFabricItemProperties[Ttfprop, Titemprop]) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { //revive:disable-line:confusing-naming diff --git a/internal/pkg/fabricitem/resource_schema.go b/internal/pkg/fabricitem/resource_schema.go index dcc03955..dc07252e 100644 --- a/internal/pkg/fabricitem/resource_schema.go +++ b/internal/pkg/fabricitem/resource_schema.go @@ -32,7 +32,7 @@ func getResourceFabricItemSchema(ctx context.Context, r ResourceFabricItem) sche attributes := getResourceFabricItemBaseAttributes(ctx, r.Name, r.DisplayNameMaxLength, r.DescriptionMaxLength, r.NameRenameAllowed) return schema.Schema{ - MarkdownDescription: r.MarkdownDescription, + MarkdownDescription: GetResourcePreviewNote(r.MarkdownDescription, r.IsPreview), Attributes: attributes, } } @@ -45,7 +45,7 @@ func getResourceFabricItemDefinitionSchema(ctx context.Context, r ResourceFabric } return schema.Schema{ - MarkdownDescription: r.MarkdownDescription, + MarkdownDescription: GetResourcePreviewNote(r.MarkdownDescription, r.IsPreview), Attributes: attributes, } } @@ -55,7 +55,7 @@ func getResourceFabricItemPropertiesSchema[Ttfprop, Titemprop any](ctx context.C attributes["properties"] = getResourceFabricItemPropertiesNestedAttr[Ttfprop](ctx, r.Name, r.PropertiesAttributes) return schema.Schema{ - MarkdownDescription: r.MarkdownDescription, + MarkdownDescription: GetResourcePreviewNote(r.MarkdownDescription, r.IsPreview), Attributes: attributes, } } @@ -69,7 +69,7 @@ func getResourceFabricItemDefinitionPropertiesSchema[Ttfprop, Titemprop any](ctx } return schema.Schema{ - MarkdownDescription: r.MarkdownDescription, + MarkdownDescription: GetResourcePreviewNote(r.MarkdownDescription, r.IsPreview), Attributes: attributes, } } @@ -80,7 +80,7 @@ func getResourceFabricItemConfigPropertiesSchema[Ttfprop, Titemprop, Ttfconfig, attributes["properties"] = getResourceFabricItemPropertiesNestedAttr[Ttfprop](ctx, r.Name, r.PropertiesAttributes) return schema.Schema{ - MarkdownDescription: r.MarkdownDescription, + MarkdownDescription: GetResourcePreviewNote(r.MarkdownDescription, r.IsPreview), Attributes: attributes, } } @@ -103,7 +103,7 @@ func getResourceFabricItemConfigDefinitionPropertiesSchema[Ttfprop, Titemprop, T } return schema.Schema{ - MarkdownDescription: r.MarkdownDescription, + MarkdownDescription: GetResourcePreviewNote(r.MarkdownDescription, r.IsPreview), Attributes: attributes, } } diff --git a/internal/provider/config/envvars.go b/internal/provider/config/envvars.go index 7fcbecfb..c10be89b 100644 --- a/internal/provider/config/envvars.go +++ b/internal/provider/config/envvars.go @@ -94,3 +94,7 @@ func GetEnvVarsUseDevCLI() []string { func GetEnvVarsUseCLI() []string { return []string{"FABRIC_USE_CLI", "ARM_USE_CLI"} } + +func GetEnvVarsPreview() []string { + return []string{"FABRIC_PREVIEW"} +} diff --git a/internal/provider/config/model.go b/internal/provider/config/model.go index 73a5c51c..d1137789 100644 --- a/internal/provider/config/model.go +++ b/internal/provider/config/model.go @@ -19,6 +19,7 @@ type ProviderData struct { Timeout time.Duration Endpoint string Version string + Preview bool } type ProviderConfig struct { @@ -51,4 +52,5 @@ type ProviderConfigModel struct { UseCLI types.Bool `tfsdk:"use_cli"` UseDevCLI types.Bool `tfsdk:"use_dev_cli"` UseMSI types.Bool `tfsdk:"use_msi"` + Preview types.Bool `tfsdk:"preview"` } diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 12b191b4..02d3bfeb 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -286,6 +286,12 @@ func (p *FabricProvider) Schema(ctx context.Context, _ provider.SchemaRequest, r MarkdownDescription: "Allow Managed Service Identity (MSI) to be used for authentication.", Optional: true, }, + + // Use preview features + "preview": schema.BoolAttribute{ + MarkdownDescription: "Enable preview mode to use preview features.", + Optional: true, + }, }, } } @@ -603,6 +609,17 @@ func (p *FabricProvider) setConfig(ctx *context.Context, config *pconfig.Provide return } + + config.Preview = putils.GetBoolValue(config.Preview, pconfig.GetEnvVarsPreview(), false) + *ctx = tflog.SetField(*ctx, "preview", config.Preview.ValueBool()) + + if config.Preview.ValueBool() { + resp.Diagnostics.AddWarning( + "Preview mode enabled", + "Features available in preview mode are not yet generally available and may change without notice include breaking changes. "+ + "Production use is not recommended. Use at your own risk!", + ) + } } func (p *FabricProvider) mapConfig(ctx *context.Context, config *pconfig.ProviderConfigModel, resp *provider.ConfigureResponse) { @@ -699,6 +716,8 @@ func (p *FabricProvider) mapConfig(ctx *context.Context, config *pconfig.Provide p.validateConfigAuthMSI(resp) p.validateConfigAuthCertificate(resp) p.validateConfigAuthSecret(resp) + + p.config.Preview = config.Preview.ValueBool() } func (p *FabricProvider) validateConfigAuthOIDC(resp *provider.ConfigureResponse) { diff --git a/internal/provider/utils/envvars.go b/internal/provider/utils/envvars.go index e597222f..96fdc623 100644 --- a/internal/provider/utils/envvars.go +++ b/internal/provider/utils/envvars.go @@ -5,6 +5,7 @@ package utils import ( "os" + "strconv" "strings" "github.com/hashicorp/terraform-plugin-framework/attr" @@ -64,19 +65,13 @@ func GetBoolValue(value types.Bool, envVarKeys []string, defaultValue bool) type } func getEnvBool(envVarKeys []string, defaultValue bool) bool { - truthyValues := map[string]bool{ - "true": true, - "1": true, - "yes": true, - "on": true, - "y": true, - "t": true, - } - if v, ok := getMultiEnvVar(envVarKeys); ok { - _, ok := truthyValues[strings.ToLower(strings.TrimSpace(v))] + strBool, err := strconv.ParseBool(v) + if err != nil { + return defaultValue + } - return ok + return strBool } return defaultValue diff --git a/internal/services/dashboard/base.go b/internal/services/dashboard/base.go index a9ddcf0e..f7208178 100644 --- a/internal/services/dashboard/base.go +++ b/internal/services/dashboard/base.go @@ -17,4 +17,5 @@ const ( ItemType = fabcore.ItemTypeDashboard ItemDocsSPNSupport = common.DocsSPNNotSupported ItemDocsURL = "https://learn.microsoft.com/power-bi/consumer/end-user-dashboards" + ItemPreview = true ) diff --git a/internal/services/datamart/base.go b/internal/services/datamart/base.go index ec07f72e..6a1a639b 100644 --- a/internal/services/datamart/base.go +++ b/internal/services/datamart/base.go @@ -17,4 +17,5 @@ const ( ItemType = fabcore.ItemTypeDatamart ItemDocsSPNSupport = common.DocsSPNNotSupported ItemDocsURL = "https://learn.microsoft.com/power-bi/transform-model/datamarts/datamarts-overview" + ItemPreview = true ) diff --git a/internal/services/datapipeline/base.go b/internal/services/datapipeline/base.go index 89ec5804..9468b355 100644 --- a/internal/services/datapipeline/base.go +++ b/internal/services/datapipeline/base.go @@ -19,6 +19,7 @@ const ( ItemDocsURL = "https://learn.microsoft.com/fabric/data-factory/data-factory-overview#data-pipelines" ItemDefinitionEmpty = `{"properties":{"activities":[]}}` ItemDefinitionPathDocsURL = "https://learn.microsoft.com/fabric/data-factory/pipeline-rest-api" + ItemPreview = true ) var ItemDefinitionPaths = []string{"pipeline-content.json"} //nolint:gochecknoglobals diff --git a/internal/services/datapipeline/data_data_pipeline.go b/internal/services/datapipeline/data_data_pipeline.go index ea7d4bc9..838dcf24 100644 --- a/internal/services/datapipeline/data_data_pipeline.go +++ b/internal/services/datapipeline/data_data_pipeline.go @@ -18,6 +18,7 @@ func NewDataSourceDataPipeline() datasource.DataSource { "Use this data source to fetch a [" + ItemName + "](" + ItemDocsURL + ").\n\n" + ItemDocsSPNSupport, IsDisplayNameUnique: true, + IsPreview: ItemPreview, } return fabricitem.NewDataSourceFabricItem(config) diff --git a/internal/services/datapipeline/data_data_pipelines.go b/internal/services/datapipeline/data_data_pipelines.go index a5040763..d07098a7 100644 --- a/internal/services/datapipeline/data_data_pipelines.go +++ b/internal/services/datapipeline/data_data_pipelines.go @@ -18,6 +18,7 @@ func NewDataSourceDataPipelines() datasource.DataSource { MarkdownDescription: "List a Fabric " + ItemsName + ".\n\n" + "Use this data source to list [" + ItemsName + "](" + ItemDocsURL + ").\n\n" + ItemDocsSPNSupport, + IsPreview: ItemPreview, } return fabricitem.NewDataSourceFabricItems(config) diff --git a/internal/services/datapipeline/resource_data_pipeline.go b/internal/services/datapipeline/resource_data_pipeline.go index 2730140b..cea02ff1 100644 --- a/internal/services/datapipeline/resource_data_pipeline.go +++ b/internal/services/datapipeline/resource_data_pipeline.go @@ -33,6 +33,7 @@ func NewResourceDataPipeline() resource.Resource { }, DefinitionRequired: false, DefinitionEmpty: ItemDefinitionEmpty, + IsPreview: ItemPreview, } return fabricitem.NewResourceFabricItemDefinition(config) diff --git a/internal/services/domain/base.go b/internal/services/domain/base.go index 785f62ae..16a1a0ea 100644 --- a/internal/services/domain/base.go +++ b/internal/services/domain/base.go @@ -16,4 +16,7 @@ const ( ItemDocsURL = "https://learn.microsoft.com/fabric/governance/domains" DomainWorkspaceAssignmentsName = "Domain Workspace Assignments" DomainWorkspaceAssignmentsTFName = "domain_workspace_assignments" + DomainRoleAssignmentsName = "Domain Role Assignments" + DomainRoleAssignmentsTFName = "domain_role_assignments" + ItemPreview = true ) diff --git a/internal/services/domain/data_domain.go b/internal/services/domain/data_domain.go index 8e0d2844..f45c725c 100644 --- a/internal/services/domain/data_domain.go +++ b/internal/services/domain/data_domain.go @@ -16,6 +16,7 @@ import ( "github.com/microsoft/terraform-provider-fabric/internal/common" "github.com/microsoft/terraform-provider-fabric/internal/framework/customtypes" + "github.com/microsoft/terraform-provider-fabric/internal/pkg/fabricitem" "github.com/microsoft/terraform-provider-fabric/internal/pkg/utils" pconfig "github.com/microsoft/terraform-provider-fabric/internal/provider/config" ) @@ -23,44 +24,55 @@ import ( var _ datasource.DataSourceWithConfigure = (*dataSourceDomain)(nil) type dataSourceDomain struct { - pConfigData *pconfig.ProviderData - client *fabadmin.DomainsClient + pConfigData *pconfig.ProviderData + client *fabadmin.DomainsClient + Name string + TFName string + MarkdownDescription string + IsPreview bool } func NewDataSourceDomain() datasource.DataSource { - return &dataSourceDomain{} + markdownDescription := "Get a Fabric " + ItemName + ".\n\n" + + "Use this data source to get [" + ItemName + "](" + ItemDocsURL + ").\n\n" + + ItemDocsSPNSupport + + return &dataSourceDomain{ + Name: ItemName, + TFName: ItemTFName, + MarkdownDescription: fabricitem.GetDataSourcePreviewNote(markdownDescription, ItemPreview), + IsPreview: ItemPreview, + } } func (d *dataSourceDomain) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_" + ItemTFName + resp.TypeName = req.ProviderTypeName + "_" + d.TFName } func (d *dataSourceDomain) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "Get a Fabric " + ItemName + ".\n\n" + - "Use this data source to get [" + ItemName + "](" + ItemDocsURL + ").\n\n" + - ItemDocsSPNSupport, + MarkdownDescription: d.MarkdownDescription, Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - MarkdownDescription: "The " + ItemName + " ID.", + MarkdownDescription: "The " + d.Name + " ID.", Required: true, CustomType: customtypes.UUIDType{}, }, "display_name": schema.StringAttribute{ - MarkdownDescription: "The " + ItemName + " display name.", + MarkdownDescription: "The " + d.Name + " display name.", Computed: true, }, "description": schema.StringAttribute{ - MarkdownDescription: "The " + ItemName + " description.", + MarkdownDescription: "The " + d.Name + " description.", Computed: true, }, "parent_domain_id": schema.StringAttribute{ - MarkdownDescription: "The " + ItemName + " parent ID.", + MarkdownDescription: "The " + d.Name + " parent ID.", Computed: true, CustomType: customtypes.UUIDType{}, }, "contributors_scope": schema.StringAttribute{ - MarkdownDescription: "The " + ItemName + " contributors scope. Possible values: " + utils.ConvertStringSlicesToString(fabadmin.PossibleContributorsScopeTypeValues(), true, true) + ".", + MarkdownDescription: "The " + d.Name + " contributors scope. Possible values: " + utils.ConvertStringSlicesToString(fabadmin.PossibleContributorsScopeTypeValues(), true, true) + ".", Computed: true, }, "timeouts": timeouts.Attributes(ctx), @@ -85,6 +97,15 @@ func (d *dataSourceDomain) Configure(_ context.Context, req datasource.Configure d.pConfigData = pConfigData d.client = fabadmin.NewClientFactoryWithClient(*pConfigData.FabricClient).NewDomainsClient() + + diags := fabricitem.IsPreviewMode(d.Name, d.IsPreview, d.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (d *dataSourceDomain) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/services/domain/data_domain_workspace_assignments.go b/internal/services/domain/data_domain_workspace_assignments.go index b42dd57c..50126b7e 100644 --- a/internal/services/domain/data_domain_workspace_assignments.go +++ b/internal/services/domain/data_domain_workspace_assignments.go @@ -17,6 +17,7 @@ import ( "github.com/microsoft/terraform-provider-fabric/internal/common" "github.com/microsoft/terraform-provider-fabric/internal/framework/customtypes" + "github.com/microsoft/terraform-provider-fabric/internal/pkg/fabricitem" "github.com/microsoft/terraform-provider-fabric/internal/pkg/utils" pconfig "github.com/microsoft/terraform-provider-fabric/internal/provider/config" ) @@ -24,23 +25,34 @@ import ( var _ datasource.DataSourceWithConfigure = (*dataSourceDomainWorkspaceAssignments)(nil) type dataSourceDomainWorkspaceAssignments struct { - pConfigData *pconfig.ProviderData - client *fabadmin.DomainsClient + pConfigData *pconfig.ProviderData + client *fabadmin.DomainsClient + Name string + TFName string + MarkdownDescription string + IsPreview bool } func NewDataSourceDomainWorkspaceAssignments() datasource.DataSource { - return &dataSourceDomainWorkspaceAssignments{} + markdownDescription := "List a Fabric " + DomainWorkspaceAssignmentsName + ".\n\n" + + "Use this data source to list [" + DomainWorkspaceAssignmentsName + "](" + ItemDocsURL + ").\n\n" + + ItemDocsSPNSupport + + return &dataSourceDomainWorkspaceAssignments{ + Name: DomainWorkspaceAssignmentsName, + TFName: DomainWorkspaceAssignmentsTFName, + MarkdownDescription: fabricitem.GetDataSourcePreviewNote(markdownDescription, ItemPreview), + IsPreview: ItemPreview, + } } func (d *dataSourceDomainWorkspaceAssignments) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_" + DomainWorkspaceAssignmentsTFName + resp.TypeName = req.ProviderTypeName + "_" + d.TFName } func (d *dataSourceDomainWorkspaceAssignments) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "List a Fabric " + DomainWorkspaceAssignmentsName + ".\n\n" + - "See [" + ItemName + "](" + ItemDocsURL + ") for more information.\n\n" + - ItemDocsSPNSupport, + MarkdownDescription: d.MarkdownDescription, Attributes: map[string]schema.Attribute{ "domain_id": schema.StringAttribute{ MarkdownDescription: "The Domain ID.", @@ -48,7 +60,7 @@ func (d *dataSourceDomainWorkspaceAssignments) Schema(ctx context.Context, _ dat CustomType: customtypes.UUIDType{}, }, "values": schema.ListNestedAttribute{ - MarkdownDescription: "The list of " + DomainWorkspaceAssignmentsName + ".", + MarkdownDescription: "The list of " + d.Name + ".", Computed: true, CustomType: supertypes.NewListNestedObjectTypeOf[workspaceModel](ctx), NestedObject: schema.NestedAttributeObject{ @@ -86,6 +98,15 @@ func (d *dataSourceDomainWorkspaceAssignments) Configure(_ context.Context, req d.pConfigData = pConfigData d.client = fabadmin.NewClientFactoryWithClient(*pConfigData.FabricClient).NewDomainsClient() + + diags := fabricitem.IsPreviewMode(d.Name, d.IsPreview, d.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (d *dataSourceDomainWorkspaceAssignments) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/services/domain/data_domains.go b/internal/services/domain/data_domains.go index 2b62bec3..63bd260f 100644 --- a/internal/services/domain/data_domains.go +++ b/internal/services/domain/data_domains.go @@ -17,6 +17,7 @@ import ( "github.com/microsoft/terraform-provider-fabric/internal/common" "github.com/microsoft/terraform-provider-fabric/internal/framework/customtypes" + "github.com/microsoft/terraform-provider-fabric/internal/pkg/fabricitem" "github.com/microsoft/terraform-provider-fabric/internal/pkg/utils" pconfig "github.com/microsoft/terraform-provider-fabric/internal/provider/config" ) @@ -24,26 +25,39 @@ import ( var _ datasource.DataSourceWithConfigure = (*dataSourceDomains)(nil) type dataSourceDomains struct { - pConfigData *pconfig.ProviderData - client *fabadmin.DomainsClient + pConfigData *pconfig.ProviderData + client *fabadmin.DomainsClient + Name string + TFName string + MarkdownDescription string + IsPreview bool } func NewDataSourceDomains() datasource.DataSource { - return &dataSourceDomains{} + markdownDescription := "List a Fabric " + ItemsName + ".\n\n" + + "Use this data source to list [" + ItemsName + "](" + ItemDocsURL + ").\n\n" + + ItemDocsSPNSupport + + return &dataSourceDomains{ + Name: ItemsName, + TFName: ItemsTFName, + MarkdownDescription: fabricitem.GetDataSourcePreviewNote(markdownDescription, ItemPreview), + IsPreview: ItemPreview, + } } func (d *dataSourceDomains) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_" + ItemsTFName + resp.TypeName = req.ProviderTypeName + "_" + d.TFName } func (d *dataSourceDomains) Schema(ctx context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "List a Fabric " + ItemsName + ".\n\n" + - "Use this data source to list [" + ItemsName + "](" + ItemDocsURL + ").\n\n" + + MarkdownDescription: "List a Fabric " + d.Name + ".\n\n" + + "Use this data source to list [" + d.Name + "](" + ItemDocsURL + ").\n\n" + ItemDocsSPNSupport, Attributes: map[string]schema.Attribute{ "values": schema.ListNestedAttribute{ - MarkdownDescription: "The list of " + ItemsName + ".", + MarkdownDescription: "The list of " + d.Name + ".", Computed: true, CustomType: supertypes.NewListNestedObjectTypeOf[baseDomainModel](ctx), NestedObject: schema.NestedAttributeObject{ @@ -95,6 +109,15 @@ func (d *dataSourceDomains) Configure(_ context.Context, req datasource.Configur d.pConfigData = pConfigData d.client = fabadmin.NewClientFactoryWithClient(*pConfigData.FabricClient).NewDomainsClient() + + diags := fabricitem.IsPreviewMode(d.Name, d.IsPreview, d.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (d *dataSourceDomains) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { diff --git a/internal/services/domain/resource_domain.go b/internal/services/domain/resource_domain.go index 2d611c27..457bc9e3 100644 --- a/internal/services/domain/resource_domain.go +++ b/internal/services/domain/resource_domain.go @@ -22,6 +22,7 @@ import ( "github.com/microsoft/terraform-provider-fabric/internal/common" "github.com/microsoft/terraform-provider-fabric/internal/framework/customtypes" + "github.com/microsoft/terraform-provider-fabric/internal/pkg/fabricitem" "github.com/microsoft/terraform-provider-fabric/internal/pkg/utils" pconfig "github.com/microsoft/terraform-provider-fabric/internal/provider/config" ) @@ -33,26 +34,37 @@ var ( ) type resourceDomain struct { - pConfigData *pconfig.ProviderData - client *fabadmin.DomainsClient + pConfigData *pconfig.ProviderData + client *fabadmin.DomainsClient + Name string + TFName string + MarkdownDescription string + IsPreview bool } func NewResourceDomain() resource.Resource { - return &resourceDomain{} + markdownDescription := "Manage a Fabric " + ItemName + ".\n\n" + + "Use this resource to manage [" + ItemName + "](" + ItemDocsURL + ").\n\n" + + ItemDocsSPNSupport + + return &resourceDomain{ + Name: ItemName, + TFName: ItemTFName, + MarkdownDescription: fabricitem.GetResourcePreviewNote(markdownDescription, ItemPreview), + IsPreview: ItemPreview, + } } func (r *resourceDomain) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_" + ItemTFName + resp.TypeName = req.ProviderTypeName + "_" + r.TFName } func (r *resourceDomain) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "This resource manages a Fabric " + ItemName + ".\n\n" + - "See [" + ItemName + "s](" + ItemDocsURL + ") for more information.\n\n" + - ItemDocsSPNSupport, + MarkdownDescription: r.MarkdownDescription, Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - MarkdownDescription: "The " + ItemName + " ID.", + MarkdownDescription: "The " + r.Name + " ID.", Computed: true, CustomType: customtypes.UUIDType{}, PlanModifiers: []planmodifier.String{ @@ -60,14 +72,14 @@ func (r *resourceDomain) Schema(ctx context.Context, _ resource.SchemaRequest, r }, }, "display_name": schema.StringAttribute{ - MarkdownDescription: "The " + ItemName + " display name.", + MarkdownDescription: "The " + r.Name + " display name.", Required: true, Validators: []validator.String{ stringvalidator.LengthAtMost(40), }, }, "description": schema.StringAttribute{ - MarkdownDescription: "The " + ItemName + " description.", + MarkdownDescription: "The " + r.Name + " description.", Optional: true, Computed: true, Default: stringdefault.StaticString(""), @@ -76,7 +88,7 @@ func (r *resourceDomain) Schema(ctx context.Context, _ resource.SchemaRequest, r }, }, "parent_domain_id": schema.StringAttribute{ - MarkdownDescription: "The " + ItemName + " parent ID.", + MarkdownDescription: "The " + r.Name + " parent ID.", Optional: true, CustomType: customtypes.UUIDType{}, Validators: []validator.String{ @@ -87,7 +99,7 @@ func (r *resourceDomain) Schema(ctx context.Context, _ resource.SchemaRequest, r }, }, "contributors_scope": schema.StringAttribute{ - MarkdownDescription: "The " + ItemName + " contributors scope. Possible values: " + utils.ConvertStringSlicesToString(fabadmin.PossibleContributorsScopeTypeValues(), true, true) + ".\n\n" + + MarkdownDescription: "The " + r.Name + " contributors scope. Possible values: " + utils.ConvertStringSlicesToString(fabadmin.PossibleContributorsScopeTypeValues(), true, true) + ".\n\n" + "-> Contributors scope can only be set at the root domain level.", Optional: true, Computed: true, @@ -117,6 +129,15 @@ func (r *resourceDomain) Configure(_ context.Context, req resource.ConfigureRequ r.pConfigData = pConfigData r.client = fabadmin.NewClientFactoryWithClient(*pConfigData.FabricClient).NewDomainsClient() + + diags := fabricitem.IsPreviewMode(r.Name, r.IsPreview, r.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (r *resourceDomain) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { diff --git a/internal/services/domain/resource_domain_role_assignments.go b/internal/services/domain/resource_domain_role_assignments.go index cce63b88..a52fa760 100644 --- a/internal/services/domain/resource_domain_role_assignments.go +++ b/internal/services/domain/resource_domain_role_assignments.go @@ -21,41 +21,48 @@ import ( "github.com/microsoft/terraform-provider-fabric/internal/common" "github.com/microsoft/terraform-provider-fabric/internal/framework/customtypes" + "github.com/microsoft/terraform-provider-fabric/internal/pkg/fabricitem" "github.com/microsoft/terraform-provider-fabric/internal/pkg/utils" pconfig "github.com/microsoft/terraform-provider-fabric/internal/provider/config" ) -const ( - DomainRoleAssignmentsName = "Domain Role Assignments" - DomainRoleAssignmentsTFName = "domain_role_assignments" -) - // Ensure the implementation satisfies the expected interfaces. var _ resource.ResourceWithConfigure = (*resourceDomainRoleAssignments)(nil) type resourceDomainRoleAssignments struct { - pConfigData *pconfig.ProviderData - client *fabadmin.DomainsClient + pConfigData *pconfig.ProviderData + client *fabadmin.DomainsClient + Name string + TFName string + MarkdownDescription string + IsPreview bool } func NewResourceDomainRoleAssignments() resource.Resource { - return &resourceDomainRoleAssignments{} + markdownDescription := "Manage a Fabric " + DomainRoleAssignmentsName + ".\n\n" + + "Use this resource to manage [" + DomainRoleAssignmentsName + "](" + ItemDocsURL + ").\n\n" + + ItemDocsSPNSupport + + return &resourceDomainRoleAssignments{ + Name: DomainRoleAssignmentsName, + TFName: DomainRoleAssignmentsTFName, + MarkdownDescription: fabricitem.GetResourcePreviewNote(markdownDescription, ItemPreview), + IsPreview: ItemPreview, + } } func (r *resourceDomainRoleAssignments) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_" + DomainRoleAssignmentsTFName + resp.TypeName = req.ProviderTypeName + "_" + r.TFName } func (r *resourceDomainRoleAssignments) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { possiblePrincipalTypeValues := utils.RemoveSlicesByValues(fabadmin.PossiblePrincipalTypeValues(), []fabadmin.PrincipalType{fabadmin.PrincipalTypeServicePrincipal, fabadmin.PrincipalTypeServicePrincipalProfile}) resp.Schema = schema.Schema{ - MarkdownDescription: "Manage a Fabric " + DomainRoleAssignmentsName + ".\n\n" + - "See [" + ItemName + "](" + ItemDocsURL + ") for more information.\n\n" + - ItemDocsSPNSupport, + MarkdownDescription: r.MarkdownDescription, Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - MarkdownDescription: "The " + DomainRoleAssignmentsName + " ID.", + MarkdownDescription: "The " + r.Name + " ID.", Computed: true, CustomType: customtypes.UUIDType{}, PlanModifiers: []planmodifier.String{ @@ -123,6 +130,15 @@ func (r *resourceDomainRoleAssignments) Configure(_ context.Context, req resourc r.pConfigData = pConfigData r.client = fabadmin.NewClientFactoryWithClient(*pConfigData.FabricClient).NewDomainsClient() + + diags := fabricitem.IsPreviewMode(r.Name, r.IsPreview, r.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (r *resourceDomainRoleAssignments) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { diff --git a/internal/services/domain/resource_domain_workspace_assignments.go b/internal/services/domain/resource_domain_workspace_assignments.go index 88ec68d0..5ef29708 100644 --- a/internal/services/domain/resource_domain_workspace_assignments.go +++ b/internal/services/domain/resource_domain_workspace_assignments.go @@ -20,6 +20,7 @@ import ( "github.com/microsoft/terraform-provider-fabric/internal/common" "github.com/microsoft/terraform-provider-fabric/internal/framework/customtypes" + "github.com/microsoft/terraform-provider-fabric/internal/pkg/fabricitem" "github.com/microsoft/terraform-provider-fabric/internal/pkg/utils" pconfig "github.com/microsoft/terraform-provider-fabric/internal/provider/config" ) @@ -28,26 +29,37 @@ import ( var _ resource.ResourceWithConfigure = (*resourceDomainWorkspaceAssignments)(nil) type resourceDomainWorkspaceAssignments struct { - pConfigData *pconfig.ProviderData - client *fabadmin.DomainsClient + pConfigData *pconfig.ProviderData + client *fabadmin.DomainsClient + Name string + TFName string + MarkdownDescription string + IsPreview bool } func NewResourceDomainWorkspaceAssignments() resource.Resource { - return &resourceDomainWorkspaceAssignments{} + markdownDescription := "Manage a Fabric " + DomainWorkspaceAssignmentsName + ".\n\n" + + "Use this resource to manage [" + DomainWorkspaceAssignmentsName + "](" + ItemDocsURL + ").\n\n" + + ItemDocsSPNSupport + + return &resourceDomainWorkspaceAssignments{ + Name: DomainWorkspaceAssignmentsName, + TFName: DomainWorkspaceAssignmentsTFName, + MarkdownDescription: fabricitem.GetResourcePreviewNote(markdownDescription, ItemPreview), + IsPreview: ItemPreview, + } } func (r *resourceDomainWorkspaceAssignments) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_" + DomainWorkspaceAssignmentsTFName + resp.TypeName = req.ProviderTypeName + "_" + r.TFName } func (r *resourceDomainWorkspaceAssignments) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "Manage a Fabric " + DomainWorkspaceAssignmentsName + ".\n\n" + - "See [" + ItemName + "](" + ItemDocsURL + ") for more information.\n\n" + - ItemDocsSPNSupport, + MarkdownDescription: r.MarkdownDescription, Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - MarkdownDescription: "The " + DomainWorkspaceAssignmentsName + " ID.", + MarkdownDescription: "The " + r.Name + " ID.", Computed: true, CustomType: customtypes.UUIDType{}, PlanModifiers: []planmodifier.String{ @@ -89,6 +101,15 @@ func (r *resourceDomainWorkspaceAssignments) Configure(_ context.Context, req re r.pConfigData = pConfigData r.client = fabadmin.NewClientFactoryWithClient(*pConfigData.FabricClient).NewDomainsClient() + + diags := fabricitem.IsPreviewMode(r.Name, r.IsPreview, r.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (r *resourceDomainWorkspaceAssignments) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { diff --git a/internal/services/mirroredwarehouse/base.go b/internal/services/mirroredwarehouse/base.go index 1bfe360a..e8f2b111 100644 --- a/internal/services/mirroredwarehouse/base.go +++ b/internal/services/mirroredwarehouse/base.go @@ -17,4 +17,5 @@ const ( ItemType = fabcore.ItemTypeMirroredWarehouse ItemDocsSPNSupport = common.DocsSPNNotSupported ItemDocsURL = "https://learn.microsoft.com/fabric/database/mirrored-database/overview" + ItemPreview = true ) diff --git a/internal/services/mirroredwarehouse/data_mirrored_warehouses.go b/internal/services/mirroredwarehouse/data_mirrored_warehouses.go index 2effd6c9..cb7a8043 100644 --- a/internal/services/mirroredwarehouse/data_mirrored_warehouses.go +++ b/internal/services/mirroredwarehouse/data_mirrored_warehouses.go @@ -18,6 +18,7 @@ func NewDataSourceMirroredWarehouses() datasource.DataSource { MarkdownDescription: "List a Fabric " + ItemsName + ".\n\n" + "Use this data source to list [" + ItemsName + "](" + ItemDocsURL + ").\n\n" + ItemDocsSPNSupport, + IsPreview: ItemPreview, } return fabricitem.NewDataSourceFabricItems(config) diff --git a/internal/services/mlexperiment/base.go b/internal/services/mlexperiment/base.go index 0f67f8c4..717c691f 100644 --- a/internal/services/mlexperiment/base.go +++ b/internal/services/mlexperiment/base.go @@ -17,4 +17,5 @@ const ( ItemType = fabcore.ItemTypeMLExperiment ItemDocsSPNSupport = common.DocsSPNNotSupported ItemDocsURL = "https://learn.microsoft.com/fabric/data-science/machine-learning-experiment" + ItemPreview = true ) diff --git a/internal/services/mlexperiment/data_ml_experiment.go b/internal/services/mlexperiment/data_ml_experiment.go index bd2ba828..07942932 100644 --- a/internal/services/mlexperiment/data_ml_experiment.go +++ b/internal/services/mlexperiment/data_ml_experiment.go @@ -18,6 +18,7 @@ func NewDataSourceMLExperiment() datasource.DataSource { "Use this data source to fetch a [" + ItemName + "](" + ItemDocsURL + ").\n\n" + ItemDocsSPNSupport, IsDisplayNameUnique: true, + IsPreview: ItemPreview, } return fabricitem.NewDataSourceFabricItem(config) diff --git a/internal/services/mlexperiment/data_ml_experiments.go b/internal/services/mlexperiment/data_ml_experiments.go index b462d012..4cc9494c 100644 --- a/internal/services/mlexperiment/data_ml_experiments.go +++ b/internal/services/mlexperiment/data_ml_experiments.go @@ -18,6 +18,7 @@ func NewDataSourceMLExperiments() datasource.DataSource { MarkdownDescription: "List a Fabric " + ItemsName + ".\n\n" + "Use this data source to list [" + ItemsName + "](" + ItemDocsURL + ").\n\n" + ItemDocsSPNSupport, + IsPreview: ItemPreview, } return fabricitem.NewDataSourceFabricItems(config) diff --git a/internal/services/mlexperiment/resource_ml_experiment.go b/internal/services/mlexperiment/resource_ml_experiment.go index 40dca5fb..f9f09248 100644 --- a/internal/services/mlexperiment/resource_ml_experiment.go +++ b/internal/services/mlexperiment/resource_ml_experiment.go @@ -20,6 +20,7 @@ func NewResourceMLExperiment() resource.Resource { ItemDocsSPNSupport, DisplayNameMaxLength: 123, DescriptionMaxLength: 256, + IsPreview: ItemPreview, } return fabricitem.NewResourceFabricItem(config) diff --git a/internal/services/mlmodel/base.go b/internal/services/mlmodel/base.go index e35809a1..e02c9108 100644 --- a/internal/services/mlmodel/base.go +++ b/internal/services/mlmodel/base.go @@ -17,4 +17,5 @@ const ( ItemType = fabcore.ItemTypeMLModel ItemDocsSPNSupport = common.DocsSPNNotSupported ItemDocsURL = "https://learn.microsoft.com/fabric/data-science/machine-learning-model" + ItemPreview = true ) diff --git a/internal/services/mlmodel/data_ml_model.go b/internal/services/mlmodel/data_ml_model.go index 27f105ba..09a87cd9 100644 --- a/internal/services/mlmodel/data_ml_model.go +++ b/internal/services/mlmodel/data_ml_model.go @@ -18,6 +18,7 @@ func NewDataSourceMLModel() datasource.DataSource { "Use this data source to fetch a [" + ItemName + "](" + ItemDocsURL + ").\n\n" + ItemDocsSPNSupport, IsDisplayNameUnique: true, + IsPreview: ItemPreview, } return fabricitem.NewDataSourceFabricItem(config) diff --git a/internal/services/mlmodel/data_ml_models.go b/internal/services/mlmodel/data_ml_models.go index 928cdd66..73b45ee5 100644 --- a/internal/services/mlmodel/data_ml_models.go +++ b/internal/services/mlmodel/data_ml_models.go @@ -18,6 +18,7 @@ func NewDataSourceMLModels() datasource.DataSource { MarkdownDescription: "List a Fabric " + ItemsName + ".\n\n" + "Use this data source to list [" + ItemsName + "](" + ItemDocsURL + ").\n\n" + ItemDocsSPNSupport, + IsPreview: ItemPreview, } return fabricitem.NewDataSourceFabricItems(config) diff --git a/internal/services/mlmodel/resource_ml_model.go b/internal/services/mlmodel/resource_ml_model.go index 62e431ba..3e437407 100644 --- a/internal/services/mlmodel/resource_ml_model.go +++ b/internal/services/mlmodel/resource_ml_model.go @@ -20,6 +20,7 @@ func NewResourceMLModel() resource.Resource { ItemDocsSPNSupport, DisplayNameMaxLength: 123, DescriptionMaxLength: 256, + IsPreview: ItemPreview, } return fabricitem.NewResourceFabricItem(config) diff --git a/internal/services/paginatedreport/base.go b/internal/services/paginatedreport/base.go index af2b3a9f..3b5b2c4b 100644 --- a/internal/services/paginatedreport/base.go +++ b/internal/services/paginatedreport/base.go @@ -17,4 +17,5 @@ const ( ItemType = fabcore.ItemTypePaginatedReport ItemDocsSPNSupport = common.DocsSPNNotSupported ItemDocsURL = "https://learn.microsoft.com/power-bi/paginated-reports/web-authoring/get-started-paginated-formatted-table" + ItemPreview = true ) diff --git a/internal/services/paginatedreport/data_paginated_reports.go b/internal/services/paginatedreport/data_paginated_reports.go index 1d3ebed2..37e6be6e 100644 --- a/internal/services/paginatedreport/data_paginated_reports.go +++ b/internal/services/paginatedreport/data_paginated_reports.go @@ -18,6 +18,7 @@ func NewDataSourcePaginatedReports() datasource.DataSource { MarkdownDescription: "List a Fabric " + ItemsName + ".\n\n" + "Use this data source to list [" + ItemsName + "](" + ItemDocsURL + ").\n\n" + ItemDocsSPNSupport, + IsPreview: ItemPreview, } return fabricitem.NewDataSourceFabricItems(config) diff --git a/internal/services/sqlendpoint/base.go b/internal/services/sqlendpoint/base.go index d2a6318e..0cf407cd 100644 --- a/internal/services/sqlendpoint/base.go +++ b/internal/services/sqlendpoint/base.go @@ -17,4 +17,5 @@ const ( ItemType = fabcore.ItemTypeSQLEndpoint ItemDocsSPNSupport = common.DocsSPNNotSupported ItemDocsURL = "https://learn.microsoft.com/fabric/data-warehouse/data-warehousing#sql-analytics-endpoint-of-the-lakehouse" + ItemPreview = true ) diff --git a/internal/services/sqlendpoint/data_sql_endpoints.go b/internal/services/sqlendpoint/data_sql_endpoints.go index d8d67052..83bd41fb 100644 --- a/internal/services/sqlendpoint/data_sql_endpoints.go +++ b/internal/services/sqlendpoint/data_sql_endpoints.go @@ -18,6 +18,7 @@ func NewDataSourceSQLEndpoints() datasource.DataSource { MarkdownDescription: "List a Fabric " + ItemsName + ".\n\n" + "Use this data source to list [" + ItemsName + "](" + ItemDocsURL + ").\n\n" + ItemDocsSPNSupport, + IsPreview: ItemPreview, } return fabricitem.NewDataSourceFabricItems(config) diff --git a/internal/services/warehouse/base.go b/internal/services/warehouse/base.go index 84ddb2aa..6e54cbb0 100644 --- a/internal/services/warehouse/base.go +++ b/internal/services/warehouse/base.go @@ -17,4 +17,5 @@ const ( ItemType = fabcore.ItemTypeWarehouse ItemDocsSPNSupport = common.DocsSPNNotSupported ItemDocsURL = "https://learn.microsoft.com/fabric/data-warehouse/data-warehousing" + ItemPreview = true ) diff --git a/internal/services/warehouse/data_warehouse.go b/internal/services/warehouse/data_warehouse.go index 141cd6e5..d1e4bcc4 100644 --- a/internal/services/warehouse/data_warehouse.go +++ b/internal/services/warehouse/data_warehouse.go @@ -78,6 +78,7 @@ func NewDataSourceWarehouse() datasource.DataSource { "Use this data source to fetch a [" + ItemName + "](" + ItemDocsURL + ").\n\n" + ItemDocsSPNSupport, IsDisplayNameUnique: true, + IsPreview: ItemPreview, }, PropertiesAttributes: getDataSourceWarehousePropertiesAttributes(), PropertiesSetter: propertiesSetter, diff --git a/internal/services/warehouse/data_warehouses.go b/internal/services/warehouse/data_warehouses.go index 64069649..1cd8bf7e 100644 --- a/internal/services/warehouse/data_warehouses.go +++ b/internal/services/warehouse/data_warehouses.go @@ -65,6 +65,7 @@ func NewDataSourceWarehouses() datasource.DataSource { MarkdownDescription: "List a Fabric " + ItemsName + ".\n\n" + "Use this data source to list [" + ItemsName + "](" + ItemDocsURL + ").\n\n" + ItemDocsSPNSupport, + IsPreview: ItemPreview, }, PropertiesAttributes: getDataSourceWarehousePropertiesAttributes(), PropertiesSetter: propertiesSetter, diff --git a/internal/services/warehouse/resource_warehouse.go b/internal/services/warehouse/resource_warehouse.go index 0b38c744..e87ed75d 100644 --- a/internal/services/warehouse/resource_warehouse.go +++ b/internal/services/warehouse/resource_warehouse.go @@ -57,6 +57,7 @@ func NewResourceWarehouse() resource.Resource { ItemDocsSPNSupport, DisplayNameMaxLength: 123, DescriptionMaxLength: 256, + IsPreview: ItemPreview, }, PropertiesAttributes: getResourceWarehousePropertiesAttributes(), PropertiesSetter: propertiesSetter, diff --git a/internal/services/workspace/resource_workspace_git.go b/internal/services/workspace/resource_workspace_git.go index 871aeb08..ea1f2e35 100644 --- a/internal/services/workspace/resource_workspace_git.go +++ b/internal/services/workspace/resource_workspace_git.go @@ -24,6 +24,7 @@ import ( "github.com/microsoft/terraform-provider-fabric/internal/common" "github.com/microsoft/terraform-provider-fabric/internal/framework/customtypes" + "github.com/microsoft/terraform-provider-fabric/internal/pkg/fabricitem" "github.com/microsoft/terraform-provider-fabric/internal/pkg/utils" pconfig "github.com/microsoft/terraform-provider-fabric/internal/provider/config" ) @@ -31,25 +32,36 @@ import ( var _ resource.ResourceWithConfigure = (*resourceWorkspaceGit)(nil) type resourceWorkspaceGit struct { - pConfigData *pconfig.ProviderData - client *fabcore.GitClient + pConfigData *pconfig.ProviderData + client *fabcore.GitClient + Name string + TFName string + MarkdownDescription string + IsPreview bool } func NewResourceWorkspaceGit() resource.Resource { - return &resourceWorkspaceGit{} + markdownDescription := "Manage a Fabric " + WorkspaceGitName + ".\n\n" + + "See [" + WorkspaceGitName + "](" + WorkspaceGitDocsURL + ") for more information.\n\n" + + common.DocsSPNNotSupported + + return &resourceWorkspaceGit{ + Name: WorkspaceGitName, + TFName: WorkspaceGitTFName, + MarkdownDescription: fabricitem.GetResourcePreviewNote(markdownDescription, true), + IsPreview: true, + } } func (r *resourceWorkspaceGit) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_" + WorkspaceGitTFName + resp.TypeName = req.ProviderTypeName + "_" + r.TFName } func (r *resourceWorkspaceGit) Schema(ctx context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { possibleInitializationStrategyValues := utils.RemoveSliceByValue(fabcore.PossibleInitializationStrategyValues(), fabcore.InitializationStrategyNone) resp.Schema = schema.Schema{ - MarkdownDescription: "Manage a Fabric " + WorkspaceGitName + ".\n\n" + - "See [" + WorkspaceGitName + "](" + WorkspaceGitDocsURL + ") for more information.\n\n" + - common.DocsSPNNotSupported, + MarkdownDescription: r.MarkdownDescription, Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, @@ -175,6 +187,15 @@ func (r *resourceWorkspaceGit) Configure(_ context.Context, req resource.Configu r.pConfigData = pConfigData r.client = fabcore.NewClientFactoryWithClient(*pConfigData.FabricClient).NewGitClient() + + diags := fabricitem.IsPreviewMode(r.Name, r.IsPreview, r.pConfigData.Preview) + if diags != nil { + resp.Diagnostics.Append(diags...) + + if diags.HasError() { + return + } + } } func (r *resourceWorkspaceGit) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {