Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat!: introduction of preview mode #185

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changes/unreleased/breaking-20250107-233638.yaml
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 3 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/data-sources/data_pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/data-sources/domain.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions docs/data-sources/domain_workspace_assignments.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/data-sources/ml_experiment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/data-sources/ml_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/data-sources/warehouse.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions docs/resources/data_pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
11 changes: 7 additions & 4 deletions docs/resources/domain.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions docs/resources/domain_role_assignments.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions docs/resources/domain_workspace_assignments.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/resources/ml_experiment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/resources/ml_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 generated by tfplugindocs -->
## Schema

Expand Down
3 changes: 3 additions & 0 deletions docs/resources/warehouse.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/resources/workspace_git.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion internal/common/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
6 changes: 5 additions & 1 deletion internal/pkg/fabricitem/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
17 changes: 17 additions & 0 deletions internal/pkg/fabricitem/data_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type DataSourceFabricItem struct {
TFName string
MarkdownDescription string
IsDisplayNameUnique bool
IsPreview bool
}

func NewDataSourceFabricItem(config DataSourceFabricItem) datasource.DataSource {
Expand Down Expand Up @@ -82,6 +83,22 @@ func (d *DataSourceFabricItem) Configure(_ context.Context, req datasource.Confi

d.pConfigData = pConfigData
d.client = fabcore.NewClientFactoryWithClient(*pConfigData.FabricClient).NewItemsClient()

if d.IsPreview && !d.pConfigData.Preview {
resp.Diagnostics.AddError(
common.ErrorPreviewModeHeader,
fmt.Sprintf(common.ErrorPreviewModeDetails, d.Name),
)

return
}

if d.IsPreview && d.pConfigData.Preview {
resp.Diagnostics.AddWarning(
common.WarningPreviewModeHeader,
fmt.Sprintf(common.WarningPreviewModeDetails, d.Name),
)
}
}

func (d *DataSourceFabricItem) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
Expand Down
17 changes: 17 additions & 0 deletions internal/pkg/fabricitem/data_item_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type DataSourceFabricItemDefinition struct {
FormatTypeDefault string
FormatTypes []string
DefinitionPathKeys []string
IsPreview bool
}

func NewDataSourceFabricItemDefinition(config DataSourceFabricItemDefinition) datasource.DataSource {
Expand Down Expand Up @@ -86,6 +87,22 @@ func (d *DataSourceFabricItemDefinition) Configure(_ context.Context, req dataso

d.pConfigData = pConfigData
d.client = fabcore.NewClientFactoryWithClient(*pConfigData.FabricClient).NewItemsClient()

if d.IsPreview && !d.pConfigData.Preview {
resp.Diagnostics.AddError(
common.ErrorPreviewModeHeader,
fmt.Sprintf(common.ErrorPreviewModeDetails, d.Name),
)

return
}

if d.IsPreview && d.pConfigData.Preview {
resp.Diagnostics.AddWarning(
common.WarningPreviewModeHeader,
fmt.Sprintf(common.WarningPreviewModeDetails, d.Name),
)
}
}

func (d *DataSourceFabricItemDefinition) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
Expand Down
Loading
Loading