diff --git a/pkg/datasources/alerts.go b/pkg/datasources/alerts.go index ac0d6435287..f06c3c6ae3b 100644 --- a/pkg/datasources/alerts.go +++ b/pkg/datasources/alerts.go @@ -5,6 +5,7 @@ import ( "log" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -79,7 +80,7 @@ var alertsSchema = map[string]*schema.Schema{ // Alerts Snowflake Roles resource. func Alerts() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.Alerts, ReadAlerts), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.AlertsDatasource), TrackingReadWrapper(datasources.Alerts, ReadAlerts)), Schema: alertsSchema, } } diff --git a/pkg/datasources/common.go b/pkg/datasources/common.go index 2bf8bb87d61..d5a2937c59e 100644 --- a/pkg/datasources/common.go +++ b/pkg/datasources/common.go @@ -213,7 +213,14 @@ func handleExtendedIn(d *schema.ResourceData, setField **sdk.ExtendedIn) error { return nil } -func PreviewFeatureReadWrapper(featureRaw string, readFunc schema.ReadContextFunc) schema.ReadContextFunc { //nolint +func TrackingReadWrapper(datasourceName datasources.Datasource, readImplementation schema.ReadContextFunc) schema.ReadContextFunc { + return func(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + ctx = tracking.NewContext(ctx, tracking.NewVersionedDatasourceMetadata(datasourceName)) + return readImplementation(ctx, d, meta) + } +} + +func PreviewFeatureReadWrapper(featureRaw string, readFunc schema.ReadContextFunc) schema.ReadContextFunc { return func(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { enabled := meta.(*provider.Context).EnabledFeatures feature, err := previewfeatures.StringToFeature(featureRaw) @@ -226,10 +233,3 @@ func PreviewFeatureReadWrapper(featureRaw string, readFunc schema.ReadContextFun return readFunc(ctx, d, meta) } } - -func TrackingReadWrapper(datasourceName datasources.Datasource, readImplementation schema.ReadContextFunc) schema.ReadContextFunc { - return func(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { - ctx = tracking.NewContext(ctx, tracking.NewVersionedDatasourceMetadata(datasourceName)) - return readImplementation(ctx, d, meta) - } -} diff --git a/pkg/datasources/cortex_search_services.go b/pkg/datasources/cortex_search_services.go index b657d9f156a..7fad174a717 100644 --- a/pkg/datasources/cortex_search_services.go +++ b/pkg/datasources/cortex_search_services.go @@ -5,6 +5,7 @@ import ( "log" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -111,7 +112,7 @@ var cortexSearchServicesSchema = map[string]*schema.Schema{ // CortexSearchServices Snowflake Cortex search services resource. func CortexSearchServices() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.CortexSearchServices, ReadCortexSearchServices), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.CortexSearchServicesDatasource), TrackingReadWrapper(datasources.CortexSearchServices, ReadCortexSearchServices)), Schema: cortexSearchServicesSchema, } } diff --git a/pkg/datasources/current_role.go b/pkg/datasources/current_role.go index e078773590c..57d458c38ef 100644 --- a/pkg/datasources/current_role.go +++ b/pkg/datasources/current_role.go @@ -5,6 +5,7 @@ import ( "log" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers" @@ -22,7 +23,7 @@ var currentRoleSchema = map[string]*schema.Schema{ func CurrentRole() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.CurrentRole, ReadCurrentRole), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.CurrentRoleDatasource), TrackingReadWrapper(datasources.CurrentRole, ReadCurrentRole)), Schema: currentRoleSchema, } } diff --git a/pkg/datasources/database_role.go b/pkg/datasources/database_role.go index dc33ac89fa7..66f72c6dc24 100644 --- a/pkg/datasources/database_role.go +++ b/pkg/datasources/database_role.go @@ -5,6 +5,7 @@ import ( "log" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -39,7 +40,7 @@ var databaseRoleSchema = map[string]*schema.Schema{ // DatabaseRole Snowflake Database Role resource. func DatabaseRole() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.DatabaseRole, ReadDatabaseRole), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.DatabaseDatasource), TrackingReadWrapper(datasources.DatabaseRole, ReadDatabaseRole)), Schema: databaseRoleSchema, } } diff --git a/pkg/datasources/database_roles.go b/pkg/datasources/database_roles.go index 570b75fd60b..d22474aa1c0 100644 --- a/pkg/datasources/database_roles.go +++ b/pkg/datasources/database_roles.go @@ -4,6 +4,7 @@ import ( "context" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources" @@ -66,7 +67,7 @@ var databaseRolesSchema = map[string]*schema.Schema{ func DatabaseRoles() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.DatabaseRoles, ReadDatabaseRoles), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.DatabaseRoleDatasource), TrackingReadWrapper(datasources.DatabaseRoles, ReadDatabaseRoles)), Schema: databaseRolesSchema, Description: "Datasource used to get details of filtered database roles. Filtering is aligned with the current possibilities for [SHOW DATABASE ROLES](https://docs.snowflake.com/en/sql-reference/sql/show-database-roles) query (`like` and `limit` are supported). The results of SHOW is encapsulated in show_output collection.", } diff --git a/pkg/datasources/dynamic_tables.go b/pkg/datasources/dynamic_tables.go index 8b5468ef001..8d235c2c8d5 100644 --- a/pkg/datasources/dynamic_tables.go +++ b/pkg/datasources/dynamic_tables.go @@ -5,6 +5,7 @@ import ( "log" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -197,7 +198,7 @@ var dynamicTablesSchema = map[string]*schema.Schema{ // DynamicTables Snowflake Dynamic Tables resource. func DynamicTables() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.DynamicTables, ReadDynamicTables), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.DynamicTablesDatasource), TrackingReadWrapper(datasources.DynamicTables, ReadDynamicTables)), Schema: dynamicTablesSchema, } } diff --git a/pkg/datasources/external_functions.go b/pkg/datasources/external_functions.go index 9a85bd08c36..db45c1a82d9 100644 --- a/pkg/datasources/external_functions.go +++ b/pkg/datasources/external_functions.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -61,7 +62,7 @@ var externalFunctionsSchema = map[string]*schema.Schema{ func ExternalFunctions() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.ExternalFunctions, ReadContextExternalFunctions), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.ExternalFunctionsDatasource), TrackingReadWrapper(datasources.ExternalFunctions, ReadContextExternalFunctions)), Schema: externalFunctionsSchema, } } diff --git a/pkg/datasources/external_tables.go b/pkg/datasources/external_tables.go index 7c8c40ff522..45bb94651d3 100644 --- a/pkg/datasources/external_tables.go +++ b/pkg/datasources/external_tables.go @@ -5,6 +5,7 @@ import ( "log" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -57,7 +58,7 @@ var externalTablesSchema = map[string]*schema.Schema{ func ExternalTables() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.ExternalTables, ReadExternalTables), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.ExternalTablesDatasource), TrackingReadWrapper(datasources.ExternalTables, ReadExternalTables)), Schema: externalTablesSchema, } } diff --git a/pkg/datasources/failover_groups.go b/pkg/datasources/failover_groups.go index 85c50fd2c01..8d4cd0a9056 100644 --- a/pkg/datasources/failover_groups.go +++ b/pkg/datasources/failover_groups.go @@ -4,6 +4,7 @@ import ( "context" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -120,7 +121,7 @@ var failoverGroupsSchema = map[string]*schema.Schema{ // FailoverGroups Snowflake FailoverGroups resource. func FailoverGroups() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.FailoverGroups, ReadFailoverGroups), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.FailoverGroupsDatasource), TrackingReadWrapper(datasources.FailoverGroups, ReadFailoverGroups)), Schema: failoverGroupsSchema, } } diff --git a/pkg/datasources/file_formats.go b/pkg/datasources/file_formats.go index 465ea03c4a9..3864bda9ee5 100644 --- a/pkg/datasources/file_formats.go +++ b/pkg/datasources/file_formats.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -59,7 +60,7 @@ var fileFormatsSchema = map[string]*schema.Schema{ func FileFormats() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.FileFormats, ReadFileFormats), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.FileFormatsDatasource), TrackingReadWrapper(datasources.FileFormats, ReadFileFormats)), Schema: fileFormatsSchema, } } diff --git a/pkg/datasources/materialized_views.go b/pkg/datasources/materialized_views.go index 18f3b796e74..9724e9a5604 100644 --- a/pkg/datasources/materialized_views.go +++ b/pkg/datasources/materialized_views.go @@ -5,6 +5,7 @@ import ( "log" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -55,7 +56,7 @@ var materializedViewsSchema = map[string]*schema.Schema{ func MaterializedViews() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.MaterializedViews, ReadMaterializedViews), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.MaterializedViewsDatasource), TrackingReadWrapper(datasources.MaterializedViews, ReadMaterializedViews)), Schema: materializedViewsSchema, } } diff --git a/pkg/datasources/parameters.go b/pkg/datasources/parameters.go index 8c88eb12223..d01738ab87a 100644 --- a/pkg/datasources/parameters.go +++ b/pkg/datasources/parameters.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -82,7 +83,7 @@ var parametersSchema = map[string]*schema.Schema{ func Parameters() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.Parameters, ReadParameters), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.ParametersDatasource), TrackingReadWrapper(datasources.Parameters, ReadParameters)), Schema: parametersSchema, } } diff --git a/pkg/datasources/pipes.go b/pkg/datasources/pipes.go index 9cca5a20b2f..8ac99aeee82 100644 --- a/pkg/datasources/pipes.go +++ b/pkg/datasources/pipes.go @@ -6,6 +6,7 @@ import ( "log" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -60,7 +61,7 @@ var pipesSchema = map[string]*schema.Schema{ func Pipes() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.Pipes, ReadPipes), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.PipesDatasource), TrackingReadWrapper(datasources.Pipes, ReadPipes)), Schema: pipesSchema, } } diff --git a/pkg/datasources/sequences.go b/pkg/datasources/sequences.go index e9c6b7b53e7..e0d9b989e29 100644 --- a/pkg/datasources/sequences.go +++ b/pkg/datasources/sequences.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -54,7 +55,7 @@ var sequencesSchema = map[string]*schema.Schema{ func Sequences() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.Sequences, ReadSequences), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.SequencesDatasource), TrackingReadWrapper(datasources.Sequences, ReadSequences)), Schema: sequencesSchema, } } diff --git a/pkg/datasources/shares.go b/pkg/datasources/shares.go index 721debb9ede..7096b144007 100644 --- a/pkg/datasources/shares.go +++ b/pkg/datasources/shares.go @@ -4,6 +4,7 @@ import ( "context" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -58,7 +59,7 @@ var sharesSchema = map[string]*schema.Schema{ // Shares Snowflake Shares resource. func Shares() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.Shares, ReadShares), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.SharesDatasource), TrackingReadWrapper(datasources.Shares, ReadShares)), Schema: sharesSchema, } } diff --git a/pkg/datasources/stages.go b/pkg/datasources/stages.go index 695e7857762..bfbaa0997a4 100644 --- a/pkg/datasources/stages.go +++ b/pkg/datasources/stages.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -60,7 +61,7 @@ var stagesSchema = map[string]*schema.Schema{ func Stages() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.Stages, ReadStages), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.StagesDatasource), TrackingReadWrapper(datasources.Stages, ReadStages)), Schema: stagesSchema, } } diff --git a/pkg/datasources/storage_integrations.go b/pkg/datasources/storage_integrations.go index 2e17b297013..e35348c16a4 100644 --- a/pkg/datasources/storage_integrations.go +++ b/pkg/datasources/storage_integrations.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -45,7 +46,7 @@ var storageIntegrationsSchema = map[string]*schema.Schema{ func StorageIntegrations() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.StorageIntegrations, ReadStorageIntegrations), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.StorageIntegrationsDatasource), TrackingReadWrapper(datasources.StorageIntegrations, ReadStorageIntegrations)), Schema: storageIntegrationsSchema, } } diff --git a/pkg/datasources/system_generate_scim_access_token.go b/pkg/datasources/system_generate_scim_access_token.go index f40eb00306d..9c008fd4229 100644 --- a/pkg/datasources/system_generate_scim_access_token.go +++ b/pkg/datasources/system_generate_scim_access_token.go @@ -7,6 +7,7 @@ import ( "log" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" @@ -32,7 +33,7 @@ var systemGenerateSCIMAccesstokenSchema = map[string]*schema.Schema{ func SystemGenerateSCIMAccessToken() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.SystemGenerateScimAccessToken, ReadSystemGenerateSCIMAccessToken), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.SystemGenerateSCIMAccessTokenDatasource), TrackingReadWrapper(datasources.SystemGenerateScimAccessToken, ReadSystemGenerateSCIMAccessToken)), Schema: systemGenerateSCIMAccesstokenSchema, } } diff --git a/pkg/datasources/system_get_aws_sns_iam_policy.go b/pkg/datasources/system_get_aws_sns_iam_policy.go index a772d370add..721d18195ed 100644 --- a/pkg/datasources/system_get_aws_sns_iam_policy.go +++ b/pkg/datasources/system_get_aws_sns_iam_policy.go @@ -7,6 +7,7 @@ import ( "log" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -30,7 +31,7 @@ var systemGetAWSSNSIAMPolicySchema = map[string]*schema.Schema{ func SystemGetAWSSNSIAMPolicy() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.SystemGetAwsSnsIamPolicy, ReadSystemGetAWSSNSIAMPolicy), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.SystemGetAWSSNSIAMPolicyDatasource), TrackingReadWrapper(datasources.SystemGetAwsSnsIamPolicy, ReadSystemGetAWSSNSIAMPolicy)), Schema: systemGetAWSSNSIAMPolicySchema, } } diff --git a/pkg/datasources/system_get_privatelink_config.go b/pkg/datasources/system_get_privatelink_config.go index ae13316ad77..654fbe674e2 100644 --- a/pkg/datasources/system_get_privatelink_config.go +++ b/pkg/datasources/system_get_privatelink_config.go @@ -7,6 +7,7 @@ import ( "log" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -73,7 +74,7 @@ var systemGetPrivateLinkConfigSchema = map[string]*schema.Schema{ func SystemGetPrivateLinkConfig() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.SystemGetPrivateLinkConfig, ReadSystemGetPrivateLinkConfig), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.SystemGetPrivateLinkConfigDatasource), TrackingReadWrapper(datasources.SystemGetPrivateLinkConfig, ReadSystemGetPrivateLinkConfig)), Schema: systemGetPrivateLinkConfigSchema, } } diff --git a/pkg/datasources/system_get_snowflake_platform_info.go b/pkg/datasources/system_get_snowflake_platform_info.go index e9f54ac4ce7..f449be022cb 100644 --- a/pkg/datasources/system_get_snowflake_platform_info.go +++ b/pkg/datasources/system_get_snowflake_platform_info.go @@ -8,6 +8,7 @@ import ( "log" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/datasources" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" @@ -33,7 +34,7 @@ var systemGetSnowflakePlatformInfoSchema = map[string]*schema.Schema{ func SystemGetSnowflakePlatformInfo() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.SystemGetSnowflakePlatformInfo, ReadSystemGetSnowflakePlatformInfo), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.SystemGetSnowflakePlatformInfoDatasource), TrackingReadWrapper(datasources.SystemGetSnowflakePlatformInfo, ReadSystemGetSnowflakePlatformInfo)), Schema: systemGetSnowflakePlatformInfoSchema, } } diff --git a/pkg/provider/previewfeatures/preview_features.go b/pkg/provider/previewfeatures/preview_features.go index c59dd462e1c..328cebaf867 100644 --- a/pkg/provider/previewfeatures/preview_features.go +++ b/pkg/provider/previewfeatures/preview_features.go @@ -47,7 +47,7 @@ const ( SharesDatasource feature = "snowflake_shares_datasource" ParametersDatasource feature = "snowflake_parameters_datasource" StageResource feature = "snowflake_stage_resource" - StageDatasource feature = "snowflake_stages_datasource" + StagesDatasource feature = "snowflake_stages_datasource" StorageIntegrationResource feature = "snowflake_storage_integration_resource" StorageIntegrationsDatasource feature = "snowflake_storage_integrations_datasource" SystemGenerateSCIMAccessTokenDatasource feature = "snowflake_system_generate_scim_access_token_datasource" @@ -56,6 +56,7 @@ const ( SystemGetSnowflakePlatformInfoDatasource feature = "snowflake_system_get_snowflake_platform_info_datasource" TableColumnMaskingPolicyApplicationResource feature = "snowflake_table_column_masking_policy_application_resource" TableConstraintResource feature = "snowflake_table_constraint_resource" + UserAuthenticationPolicyAttachmentResource feature = "snowflake_user_authentication_policy_attachment_resource" UserPublicKeysResource feature = "snowflake_user_public_keys_resource" UserPasswordPolicyAttachmentResource feature = "snowflake_user_password_policy_attachment_resource" ) @@ -99,7 +100,7 @@ var allPreviewFeatures = []feature{ SharesDatasource, ParametersDatasource, StageResource, - StageDatasource, + StagesDatasource, StorageIntegrationResource, StorageIntegrationsDatasource, SystemGenerateSCIMAccessTokenDatasource, @@ -108,6 +109,7 @@ var allPreviewFeatures = []feature{ SystemGetSnowflakePlatformInfoDatasource, TableColumnMaskingPolicyApplicationResource, TableConstraintResource, + UserAuthenticationPolicyAttachmentResource, UserPublicKeysResource, UserPasswordPolicyAttachmentResource, } @@ -131,7 +133,7 @@ func EnsurePreviewFeatureEnabled(feat feature, enabledFeatures []string) error { func StringToFeature(featRaw string) (feature, error) { feat := feature(strings.ToLower(featRaw)) if !slices.Contains(allPreviewFeatures, feat) { - return "", fmt.Errorf("%[1]s is currently a preview feature, and must be enabled by adding %[1]s to `preview_features_enabled` in Terraform configuration.", feat) + return "", fmt.Errorf("invalid feature: %s", featRaw) } return feat, nil } diff --git a/pkg/provider/previewfeatures/preview_features_test.go b/pkg/provider/previewfeatures/preview_features_test.go index 08a5d05daef..c5c334b674e 100644 --- a/pkg/provider/previewfeatures/preview_features_test.go +++ b/pkg/provider/previewfeatures/preview_features_test.go @@ -55,7 +55,7 @@ func Test_StringToFeature(t *testing.T) { {input: "snowflake_shares_datasource", want: SharesDatasource}, {input: "snowflake_parameters_datasource", want: ParametersDatasource}, {input: "snowflake_stage_resource", want: StageResource}, - {input: "snowflake_stages_datasource", want: StageDatasource}, + {input: "snowflake_stages_datasource", want: StagesDatasource}, {input: "snowflake_storage_integration_resource", want: StorageIntegrationResource}, {input: "snowflake_storage_integrations_datasource", want: StorageIntegrationsDatasource}, {input: "snowflake_system_generate_scim_access_token_datasource", want: SystemGenerateSCIMAccessTokenDatasource}, @@ -84,7 +84,7 @@ func Test_StringToFeature(t *testing.T) { for _, tc := range invalid { t.Run(tc.input, func(t *testing.T) { _, err := StringToFeature(tc.input) - require.Error(t, err) + require.ErrorContains(t, err, "invalid feature") }) } } diff --git a/pkg/provider/previewfeatures/wrappers.go b/pkg/provider/previewfeatures/wrappers.go deleted file mode 100644 index 6420ae3a700..00000000000 --- a/pkg/provider/previewfeatures/wrappers.go +++ /dev/null @@ -1,57 +0,0 @@ -package previewfeatures - -import ( - "context" - - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func ensureResourceIsEnabled(featureRaw string, meta any) error { - enabled := meta.(*provider.Context).EnabledFeatures - feature, err := StringToFeature(featureRaw) - if err != nil { - return err - } - if err := EnsurePreviewFeatureEnabled(feature, enabled); err != nil { - return err - } - return nil -} - -func PreviewFeatureReadContextWrapper(featureRaw string, readFunc schema.ReadContextFunc) schema.ReadContextFunc { - return func(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { - if err := ensureResourceIsEnabled(featureRaw, meta); err != nil { - return diag.FromErr(err) - } - return readFunc(ctx, d, meta) - } -} - -func PreviewFeatureCreateContextWrapper(featureRaw string, createFunc schema.CreateContextFunc) schema.CreateContextFunc { //nolint - return func(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { - if err := ensureResourceIsEnabled(featureRaw, meta); err != nil { - return diag.FromErr(err) - } - return createFunc(ctx, d, meta) - } -} - -func PreviewFeatureUpdateContextWrapper(featureRaw string, updateFunc schema.UpdateContextFunc) schema.UpdateContextFunc { //nolint - return func(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { - if err := ensureResourceIsEnabled(featureRaw, meta); err != nil { - return diag.FromErr(err) - } - return updateFunc(ctx, d, meta) - } -} - -func PreviewFeatureDeleteContextWrapper(featureRaw string, deleteFunc schema.DeleteContextFunc) schema.DeleteContextFunc { //nolint - return func(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { - if err := ensureResourceIsEnabled(featureRaw, meta); err != nil { - return diag.FromErr(err) - } - return deleteFunc(ctx, d, meta) - } -} diff --git a/pkg/resources/account_password_policy_attachment.go b/pkg/resources/account_password_policy_attachment.go index 03375b0c75b..12e47afea49 100644 --- a/pkg/resources/account_password_policy_attachment.go +++ b/pkg/resources/account_password_policy_attachment.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -29,9 +30,9 @@ func AccountPasswordPolicyAttachment() *schema.Resource { return &schema.Resource{ Description: "Specifies the password policy to use for the current account. To set the password policy of a different account, use a provider alias.", - CreateContext: TrackingCreateWrapper(resources.AccountPasswordPolicyAttachment, CreateAccountPasswordPolicyAttachment), - ReadContext: TrackingReadWrapper(resources.AccountPasswordPolicyAttachment, ReadAccountPasswordPolicyAttachment), - DeleteContext: TrackingDeleteWrapper(resources.AccountPasswordPolicyAttachment, DeleteAccountPasswordPolicyAttachment), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.AccountPasswordPolicyAttachmentResource), TrackingCreateWrapper(resources.AccountPasswordPolicyAttachment, CreateAccountPasswordPolicyAttachment)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.AccountPasswordPolicyAttachmentResource), TrackingReadWrapper(resources.AccountPasswordPolicyAttachment, ReadAccountPasswordPolicyAttachment)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.AccountPasswordPolicyAttachmentResource), TrackingDeleteWrapper(resources.AccountPasswordPolicyAttachment, DeleteAccountPasswordPolicyAttachment)), Schema: accountPasswordPolicyAttachmentSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/alert.go b/pkg/resources/alert.go index b250d7f26f4..6d7dc22bd14 100644 --- a/pkg/resources/alert.go +++ b/pkg/resources/alert.go @@ -113,10 +113,10 @@ var alertSchema = map[string]*schema.Schema{ // Alert returns a pointer to the resource representing an alert. func Alert() *schema.Resource { return &schema.Resource{ - CreateContext: previewfeatures.PreviewFeatureCreateContextWrapper(string(previewfeatures.AlertResource), TrackingCreateWrapper(resources.Alert, CreateAlert)), - ReadContext: previewfeatures.PreviewFeatureReadContextWrapper(string(previewfeatures.AlertResource), TrackingReadWrapper(resources.Alert, ReadAlert)), - UpdateContext: previewfeatures.PreviewFeatureUpdateContextWrapper(string(previewfeatures.AlertResource), TrackingUpdateWrapper(resources.Alert, UpdateAlert)), - DeleteContext: previewfeatures.PreviewFeatureDeleteContextWrapper(string(previewfeatures.AlertResource), TrackingDeleteWrapper(resources.Alert, DeleteAlert)), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.AlertResource), TrackingCreateWrapper(resources.Alert, CreateAlert)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.AlertResource), TrackingReadWrapper(resources.Alert, ReadAlert)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.AlertResource), TrackingUpdateWrapper(resources.Alert, UpdateAlert)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.AlertResource), TrackingDeleteWrapper(resources.Alert, DeleteAlert)), Schema: alertSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/api_integration.go b/pkg/resources/api_integration.go index fee0a6312cf..9ec63b7632d 100644 --- a/pkg/resources/api_integration.go +++ b/pkg/resources/api_integration.go @@ -6,6 +6,7 @@ import ( "log" "strings" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -124,10 +125,10 @@ var apiIntegrationSchema = map[string]*schema.Schema{ // APIIntegration returns a pointer to the resource representing an api integration. func APIIntegration() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.ApiIntegration, CreateAPIIntegration), - ReadContext: TrackingReadWrapper(resources.ApiIntegration, ReadAPIIntegration), - UpdateContext: TrackingUpdateWrapper(resources.ApiIntegration, UpdateAPIIntegration), - DeleteContext: TrackingDeleteWrapper(resources.ApiIntegration, DeleteAPIIntegration), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.ApiIntegrationResource), TrackingCreateWrapper(resources.ApiIntegration, CreateAPIIntegration)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.ApiIntegrationResource), TrackingReadWrapper(resources.ApiIntegration, ReadAPIIntegration)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.ApiIntegrationResource), TrackingUpdateWrapper(resources.ApiIntegration, UpdateAPIIntegration)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.ApiIntegrationResource), TrackingDeleteWrapper(resources.ApiIntegration, DeleteAPIIntegration)), Schema: apiIntegrationSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/common.go b/pkg/resources/common.go index 643524f9d98..94c13e84706 100644 --- a/pkg/resources/common.go +++ b/pkg/resources/common.go @@ -5,7 +5,9 @@ import ( "regexp" "strings" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/tracking" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -147,3 +149,51 @@ func TrackingCustomDiffWrapper(resourceName resources.Resource, customdiffImplem return customdiffImplementation(ctx, diff, meta) } } + +func ensureResourceIsEnabled(featureRaw string, meta any) error { + enabled := meta.(*provider.Context).EnabledFeatures + feature, err := previewfeatures.StringToFeature(featureRaw) + if err != nil { + return err + } + if err := previewfeatures.EnsurePreviewFeatureEnabled(feature, enabled); err != nil { + return err + } + return nil +} + +func PreviewFeatureReadContextWrapper(featureRaw string, readFunc schema.ReadContextFunc) schema.ReadContextFunc { + return func(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + if err := ensureResourceIsEnabled(featureRaw, meta); err != nil { + return diag.FromErr(err) + } + return readFunc(ctx, d, meta) + } +} + +func PreviewFeatureCreateContextWrapper(featureRaw string, createFunc schema.CreateContextFunc) schema.CreateContextFunc { //nolint + return func(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + if err := ensureResourceIsEnabled(featureRaw, meta); err != nil { + return diag.FromErr(err) + } + return createFunc(ctx, d, meta) + } +} + +func PreviewFeatureUpdateContextWrapper(featureRaw string, updateFunc schema.UpdateContextFunc) schema.UpdateContextFunc { //nolint + return func(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + if err := ensureResourceIsEnabled(featureRaw, meta); err != nil { + return diag.FromErr(err) + } + return updateFunc(ctx, d, meta) + } +} + +func PreviewFeatureDeleteContextWrapper(featureRaw string, deleteFunc schema.DeleteContextFunc) schema.DeleteContextFunc { //nolint + return func(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + if err := ensureResourceIsEnabled(featureRaw, meta); err != nil { + return diag.FromErr(err) + } + return deleteFunc(ctx, d, meta) + } +} diff --git a/pkg/resources/cortex_search_service.go b/pkg/resources/cortex_search_service.go index 250bbb68e98..09ccb423283 100644 --- a/pkg/resources/cortex_search_service.go +++ b/pkg/resources/cortex_search_service.go @@ -83,10 +83,10 @@ var cortexSearchServiceSchema = map[string]*schema.Schema{ // CortexSearchService returns a pointer to the resource representing a Cortex search service. func CortexSearchService() *schema.Resource { return &schema.Resource{ - CreateContext: previewfeatures.PreviewFeatureCreateContextWrapper(string(previewfeatures.CortexSearchServiceResource), TrackingCreateWrapper(resources.CortexSearchService, CreateCortexSearchService)), - ReadContext: previewfeatures.PreviewFeatureReadContextWrapper(string(previewfeatures.CortexSearchServiceResource), TrackingReadWrapper(resources.CortexSearchService, ReadCortexSearchService)), - UpdateContext: previewfeatures.PreviewFeatureUpdateContextWrapper(string(previewfeatures.CortexSearchServiceResource), TrackingUpdateWrapper(resources.CortexSearchService, UpdateCortexSearchService)), - DeleteContext: previewfeatures.PreviewFeatureDeleteContextWrapper(string(previewfeatures.CortexSearchServiceResource), TrackingDeleteWrapper(resources.CortexSearchService, DeleteCortexSearchService)), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.CortexSearchServiceResource), TrackingCreateWrapper(resources.CortexSearchService, CreateCortexSearchService)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.CortexSearchServiceResource), TrackingReadWrapper(resources.CortexSearchService, ReadCortexSearchService)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.CortexSearchServiceResource), TrackingUpdateWrapper(resources.CortexSearchService, UpdateCortexSearchService)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.CortexSearchServiceResource), TrackingDeleteWrapper(resources.CortexSearchService, DeleteCortexSearchService)), Schema: cortexSearchServiceSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/dynamic_table.go b/pkg/resources/dynamic_table.go index 72446d5b91d..409939b62dd 100644 --- a/pkg/resources/dynamic_table.go +++ b/pkg/resources/dynamic_table.go @@ -7,6 +7,7 @@ import ( "strings" "time" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -166,10 +167,10 @@ var dynamicTableSchema = map[string]*schema.Schema{ // DynamicTable returns a pointer to the resource representing a dynamic table. func DynamicTable() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.DynamicTable, CreateDynamicTable), - ReadContext: TrackingReadWrapper(resources.DynamicTable, ReadDynamicTable), - UpdateContext: TrackingUpdateWrapper(resources.DynamicTable, UpdateDynamicTable), - DeleteContext: TrackingDeleteWrapper(resources.DynamicTable, DeleteDynamicTable), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.DynamicTableResource), TrackingCreateWrapper(resources.DynamicTable, CreateDynamicTable)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.DynamicTableResource), TrackingReadWrapper(resources.DynamicTable, ReadDynamicTable)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.DynamicTableResource), TrackingUpdateWrapper(resources.DynamicTable, UpdateDynamicTable)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.DynamicTableResource), TrackingDeleteWrapper(resources.DynamicTable, DeleteDynamicTable)), Schema: dynamicTableSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/email_notification_integration.go b/pkg/resources/email_notification_integration.go index bd0a38c64e1..b5a794a5c0f 100644 --- a/pkg/resources/email_notification_integration.go +++ b/pkg/resources/email_notification_integration.go @@ -6,6 +6,7 @@ import ( "log" "strings" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -45,10 +46,10 @@ var emailNotificationIntegrationSchema = map[string]*schema.Schema{ // EmailNotificationIntegration returns a pointer to the resource representing a notification integration. func EmailNotificationIntegration() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.EmailNotificationIntegration, CreateEmailNotificationIntegration), - ReadContext: TrackingReadWrapper(resources.EmailNotificationIntegration, ReadEmailNotificationIntegration), - UpdateContext: TrackingUpdateWrapper(resources.EmailNotificationIntegration, UpdateEmailNotificationIntegration), - DeleteContext: TrackingDeleteWrapper(resources.EmailNotificationIntegration, DeleteEmailNotificationIntegration), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.EmailNotificationIntegrationResource), TrackingCreateWrapper(resources.EmailNotificationIntegration, CreateEmailNotificationIntegration)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.EmailNotificationIntegrationResource), TrackingReadWrapper(resources.EmailNotificationIntegration, ReadEmailNotificationIntegration)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.EmailNotificationIntegrationResource), TrackingUpdateWrapper(resources.EmailNotificationIntegration, UpdateEmailNotificationIntegration)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.EmailNotificationIntegrationResource), TrackingDeleteWrapper(resources.EmailNotificationIntegration, DeleteEmailNotificationIntegration)), Schema: emailNotificationIntegrationSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/external_function.go b/pkg/resources/external_function.go index 61b556590aa..77b5c08853f 100644 --- a/pkg/resources/external_function.go +++ b/pkg/resources/external_function.go @@ -188,10 +188,10 @@ func ExternalFunction() *schema.Resource { return &schema.Resource{ SchemaVersion: 2, - CreateContext: previewfeatures.PreviewFeatureCreateContextWrapper(string(previewfeatures.ExternalFunctionResource), TrackingCreateWrapper(resources.ExternalFunction, CreateContextExternalFunction)), - ReadContext: previewfeatures.PreviewFeatureReadContextWrapper(string(previewfeatures.ExternalFunctionResource), TrackingReadWrapper(resources.ExternalFunction, ReadContextExternalFunction)), - UpdateContext: previewfeatures.PreviewFeatureUpdateContextWrapper(string(previewfeatures.ExternalFunctionResource), TrackingUpdateWrapper(resources.ExternalFunction, UpdateContextExternalFunction)), - DeleteContext: previewfeatures.PreviewFeatureDeleteContextWrapper(string(previewfeatures.ExternalFunctionResource), TrackingDeleteWrapper(resources.ExternalFunction, DeleteContextExternalFunction)), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.ExternalFunctionResource), TrackingCreateWrapper(resources.ExternalFunction, CreateContextExternalFunction)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.ExternalFunctionResource), TrackingReadWrapper(resources.ExternalFunction, ReadContextExternalFunction)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.ExternalFunctionResource), TrackingUpdateWrapper(resources.ExternalFunction, UpdateContextExternalFunction)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.ExternalFunctionResource), TrackingDeleteWrapper(resources.ExternalFunction, DeleteContextExternalFunction)), Schema: externalFunctionSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/external_table.go b/pkg/resources/external_table.go index 833b8c4dd88..ac99dcf7a56 100644 --- a/pkg/resources/external_table.go +++ b/pkg/resources/external_table.go @@ -5,6 +5,7 @@ import ( "fmt" "log" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -143,10 +144,10 @@ var externalTableSchema = map[string]*schema.Schema{ func ExternalTable() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.ExternalTable, CreateExternalTable), - ReadContext: TrackingReadWrapper(resources.ExternalTable, ReadExternalTable), - UpdateContext: TrackingUpdateWrapper(resources.ExternalTable, UpdateExternalTable), - DeleteContext: TrackingDeleteWrapper(resources.ExternalTable, DeleteExternalTable), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.ExternalTableResource), TrackingCreateWrapper(resources.ExternalTable, CreateExternalTable)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.ExternalTableResource), TrackingReadWrapper(resources.ExternalTable, ReadExternalTable)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.ExternalTableResource), TrackingUpdateWrapper(resources.ExternalTable, UpdateExternalTable)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.ExternalTableResource), TrackingDeleteWrapper(resources.ExternalTable, DeleteExternalTable)), Schema: externalTableSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/external_volume.go b/pkg/resources/external_volume.go index 5103f7cb033..e12e737cb3c 100644 --- a/pkg/resources/external_volume.go +++ b/pkg/resources/external_volume.go @@ -119,10 +119,10 @@ var externalVolumeSchema = map[string]*schema.Schema{ // ExternalVolume returns a pointer to the resource representing an external volume. func ExternalVolume() *schema.Resource { return &schema.Resource{ - CreateContext: previewfeatures.PreviewFeatureCreateContextWrapper(string(previewfeatures.ExternalVolumeResource), TrackingCreateWrapper(resources.ExternalVolume, CreateContextExternalVolume)), - ReadContext: previewfeatures.PreviewFeatureReadContextWrapper(string(previewfeatures.ExternalVolumeResource), TrackingReadWrapper(resources.ExternalVolume, ReadContextExternalVolume(true))), - UpdateContext: previewfeatures.PreviewFeatureUpdateContextWrapper(string(previewfeatures.ExternalVolumeResource), TrackingUpdateWrapper(resources.ExternalVolume, UpdateContextExternalVolume)), - DeleteContext: previewfeatures.PreviewFeatureDeleteContextWrapper(string(previewfeatures.ExternalVolumeResource), TrackingDeleteWrapper(resources.ExternalVolume, DeleteContextExternalVolume)), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.ExternalVolumeResource), TrackingCreateWrapper(resources.ExternalVolume, CreateContextExternalVolume)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.ExternalVolumeResource), TrackingReadWrapper(resources.ExternalVolume, ReadContextExternalVolume(true))), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.ExternalVolumeResource), TrackingUpdateWrapper(resources.ExternalVolume, UpdateContextExternalVolume)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.ExternalVolumeResource), TrackingDeleteWrapper(resources.ExternalVolume, DeleteContextExternalVolume)), Description: "Resource used to manage external volume objects. For more information, check [external volume documentation](https://docs.snowflake.com/en/sql-reference/commands-data-loading#external-volume).", diff --git a/pkg/resources/failover_group.go b/pkg/resources/failover_group.go index 4a8ab0e3fee..6b77bf8f853 100644 --- a/pkg/resources/failover_group.go +++ b/pkg/resources/failover_group.go @@ -8,6 +8,7 @@ import ( "strconv" "strings" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -141,10 +142,10 @@ var failoverGroupSchema = map[string]*schema.Schema{ // FailoverGroup returns a pointer to the resource representing a failover group. func FailoverGroup() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.FailoverGroup, CreateFailoverGroup), - ReadContext: TrackingReadWrapper(resources.FailoverGroup, ReadFailoverGroup), - UpdateContext: TrackingUpdateWrapper(resources.FailoverGroup, UpdateFailoverGroup), - DeleteContext: TrackingDeleteWrapper(resources.FailoverGroup, DeleteFailoverGroup), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.FailoverGroupResource), TrackingCreateWrapper(resources.FailoverGroup, CreateFailoverGroup)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.FailoverGroupResource), TrackingReadWrapper(resources.FailoverGroup, ReadFailoverGroup)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.FailoverGroupResource), TrackingUpdateWrapper(resources.FailoverGroup, UpdateFailoverGroup)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.FailoverGroupResource), TrackingDeleteWrapper(resources.FailoverGroup, DeleteFailoverGroup)), Schema: failoverGroupSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/file_format.go b/pkg/resources/file_format.go index 8ff7cec53f0..f4ab8992d60 100644 --- a/pkg/resources/file_format.go +++ b/pkg/resources/file_format.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers" @@ -317,10 +318,10 @@ func (ffi *fileFormatID) String() (string, error) { // FileFormat returns a pointer to the resource representing a file format. func FileFormat() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.FileFormat, CreateFileFormat), - ReadContext: TrackingReadWrapper(resources.FileFormat, ReadFileFormat), - UpdateContext: TrackingUpdateWrapper(resources.FileFormat, UpdateFileFormat), - DeleteContext: TrackingDeleteWrapper(resources.FileFormat, DeleteFileFormat), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.FileFormatResource), TrackingCreateWrapper(resources.FileFormat, CreateFileFormat)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.FileFormatResource), TrackingReadWrapper(resources.FileFormat, ReadFileFormat)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.FileFormatResource), TrackingUpdateWrapper(resources.FileFormat, UpdateFileFormat)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.FileFormatResource), TrackingDeleteWrapper(resources.FileFormat, DeleteFileFormat)), CustomizeDiff: TrackingCustomDiffWrapper(resources.FileFormat, customdiff.All( ComputedIfAnyAttributeChanged(fileFormatSchema, FullyQualifiedNameAttributeName, "name"), diff --git a/pkg/resources/managed_account.go b/pkg/resources/managed_account.go index 510d7af633f..3b50a32cca2 100644 --- a/pkg/resources/managed_account.go +++ b/pkg/resources/managed_account.go @@ -6,6 +6,7 @@ import ( "log" "time" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -87,9 +88,9 @@ var managedAccountSchema = map[string]*schema.Schema{ // ManagedAccount returns a pointer to the resource representing a managed account. func ManagedAccount() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.ManagedAccount, CreateManagedAccount), - ReadContext: TrackingReadWrapper(resources.ManagedAccount, ReadManagedAccount), - DeleteContext: TrackingDeleteWrapper(resources.ManagedAccount, DeleteManagedAccount), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.ManagedAccountResource), TrackingCreateWrapper(resources.ManagedAccount, CreateManagedAccount)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.ManagedAccountResource), TrackingReadWrapper(resources.ManagedAccount, ReadManagedAccount)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.ManagedAccountResource), TrackingDeleteWrapper(resources.ManagedAccount, DeleteManagedAccount)), Schema: managedAccountSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/materialized_view.go b/pkg/resources/materialized_view.go index 2dacd668e6d..4cb416b2c4d 100644 --- a/pkg/resources/materialized_view.go +++ b/pkg/resources/materialized_view.go @@ -5,6 +5,7 @@ import ( "fmt" "log" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" @@ -73,10 +74,10 @@ var materializedViewSchema = map[string]*schema.Schema{ // MaterializedView returns a pointer to the resource representing a view. func MaterializedView() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.MaterializedView, CreateMaterializedView), - ReadContext: TrackingReadWrapper(resources.MaterializedView, ReadMaterializedView), - UpdateContext: TrackingUpdateWrapper(resources.MaterializedView, UpdateMaterializedView), - DeleteContext: TrackingDeleteWrapper(resources.MaterializedView, DeleteMaterializedView), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.MaterializedViewResource), TrackingCreateWrapper(resources.MaterializedView, CreateMaterializedView)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.MaterializedViewResource), TrackingReadWrapper(resources.MaterializedView, ReadMaterializedView)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.MaterializedViewResource), TrackingUpdateWrapper(resources.MaterializedView, UpdateMaterializedView)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.MaterializedViewResource), TrackingDeleteWrapper(resources.MaterializedView, DeleteMaterializedView)), CustomizeDiff: TrackingCustomDiffWrapper(resources.MaterializedView, customdiff.All( ComputedIfAnyAttributeChanged(materializedViewSchema, FullyQualifiedNameAttributeName, "name"), diff --git a/pkg/resources/network_policy_attachment.go b/pkg/resources/network_policy_attachment.go index c68ab02f859..ebdee5825a2 100644 --- a/pkg/resources/network_policy_attachment.go +++ b/pkg/resources/network_policy_attachment.go @@ -6,6 +6,7 @@ import ( "log" "strings" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -39,10 +40,10 @@ var networkPolicyAttachmentSchema = map[string]*schema.Schema{ // NetworkPolicyAttachment returns a pointer to the resource representing a network policy attachment. func NetworkPolicyAttachment() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.NetworkPolicyAttachment, CreateNetworkPolicyAttachment), - ReadContext: TrackingReadWrapper(resources.NetworkPolicyAttachment, ReadNetworkPolicyAttachment), - UpdateContext: TrackingUpdateWrapper(resources.NetworkPolicyAttachment, UpdateNetworkPolicyAttachment), - DeleteContext: TrackingDeleteWrapper(resources.NetworkPolicyAttachment, DeleteNetworkPolicyAttachment), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.NetworkPolicyAttachmentResource), TrackingCreateWrapper(resources.NetworkPolicyAttachment, CreateNetworkPolicyAttachment)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.NetworkPolicyAttachmentResource), TrackingReadWrapper(resources.NetworkPolicyAttachment, ReadNetworkPolicyAttachment)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.NetworkPolicyAttachmentResource), TrackingUpdateWrapper(resources.NetworkPolicyAttachment, UpdateNetworkPolicyAttachment)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.NetworkPolicyAttachmentResource), TrackingDeleteWrapper(resources.NetworkPolicyAttachment, DeleteNetworkPolicyAttachment)), Schema: networkPolicyAttachmentSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/network_rule.go b/pkg/resources/network_rule.go index 1326dba7a66..9a8ad9a4cb4 100644 --- a/pkg/resources/network_rule.go +++ b/pkg/resources/network_rule.go @@ -68,10 +68,10 @@ var networkRuleSchema = map[string]*schema.Schema{ // NetworkRule returns a pointer to the resource representing a network rule. func NetworkRule() *schema.Resource { return &schema.Resource{ - CreateContext: previewfeatures.PreviewFeatureCreateContextWrapper(string(previewfeatures.NetworkRuleResource), TrackingCreateWrapper(resources.NetworkRule, CreateContextNetworkRule)), - ReadContext: previewfeatures.PreviewFeatureReadContextWrapper(string(previewfeatures.NetworkRuleResource), TrackingReadWrapper(resources.NetworkRule, ReadContextNetworkRule)), - UpdateContext: previewfeatures.PreviewFeatureUpdateContextWrapper(string(previewfeatures.NetworkRuleResource), TrackingUpdateWrapper(resources.NetworkRule, UpdateContextNetworkRule)), - DeleteContext: previewfeatures.PreviewFeatureDeleteContextWrapper(string(previewfeatures.NetworkRuleResource), TrackingDeleteWrapper(resources.NetworkRule, DeleteContextNetworkRule)), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.NetworkRuleResource), TrackingCreateWrapper(resources.NetworkRule, CreateContextNetworkRule)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.NetworkRuleResource), TrackingReadWrapper(resources.NetworkRule, ReadContextNetworkRule)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.NetworkRuleResource), TrackingUpdateWrapper(resources.NetworkRule, UpdateContextNetworkRule)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.NetworkRuleResource), TrackingDeleteWrapper(resources.NetworkRule, DeleteContextNetworkRule)), Schema: networkRuleSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/notification_integration.go b/pkg/resources/notification_integration.go index 109a46e0ba9..0f72ec5c544 100644 --- a/pkg/resources/notification_integration.go +++ b/pkg/resources/notification_integration.go @@ -6,6 +6,7 @@ import ( "log" "strings" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -154,10 +155,10 @@ var notificationIntegrationSchema = map[string]*schema.Schema{ // NotificationIntegration returns a pointer to the resource representing a notification integration. func NotificationIntegration() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.NotificationIntegration, CreateNotificationIntegration), - ReadContext: TrackingReadWrapper(resources.NotificationIntegration, ReadNotificationIntegration), - UpdateContext: TrackingUpdateWrapper(resources.NotificationIntegration, UpdateNotificationIntegration), - DeleteContext: TrackingDeleteWrapper(resources.NotificationIntegration, DeleteNotificationIntegration), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.NotificationIntegrationResource), TrackingCreateWrapper(resources.NotificationIntegration, CreateNotificationIntegration)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.NotificationIntegrationResource), TrackingReadWrapper(resources.NotificationIntegration, ReadNotificationIntegration)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.NotificationIntegrationResource), TrackingUpdateWrapper(resources.NotificationIntegration, UpdateNotificationIntegration)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.NotificationIntegrationResource), TrackingDeleteWrapper(resources.NotificationIntegration, DeleteNotificationIntegration)), Schema: notificationIntegrationSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/object_parameter.go b/pkg/resources/object_parameter.go index 7d5b01ae08c..dac4dad11d1 100644 --- a/pkg/resources/object_parameter.go +++ b/pkg/resources/object_parameter.go @@ -5,6 +5,7 @@ import ( "fmt" "strings" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -72,10 +73,10 @@ var objectParameterSchema = map[string]*schema.Schema{ func ObjectParameter() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.ObjectParameter, CreateObjectParameter), - ReadContext: TrackingReadWrapper(resources.ObjectParameter, ReadObjectParameter), - UpdateContext: TrackingUpdateWrapper(resources.ObjectParameter, UpdateObjectParameter), - DeleteContext: TrackingDeleteWrapper(resources.ObjectParameter, DeleteObjectParameter), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.ObjectParameterResource), TrackingCreateWrapper(resources.ObjectParameter, CreateObjectParameter)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.ObjectParameterResource), TrackingReadWrapper(resources.ObjectParameter, ReadObjectParameter)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.ObjectParameterResource), TrackingUpdateWrapper(resources.ObjectParameter, UpdateObjectParameter)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.ObjectParameterResource), TrackingDeleteWrapper(resources.ObjectParameter, DeleteObjectParameter)), Schema: objectParameterSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/password_policy.go b/pkg/resources/password_policy.go index da3cf850388..b547d063271 100644 --- a/pkg/resources/password_policy.go +++ b/pkg/resources/password_policy.go @@ -3,6 +3,7 @@ package resources import ( "context" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" @@ -142,10 +143,10 @@ var passwordPolicySchema = map[string]*schema.Schema{ func PasswordPolicy() *schema.Resource { return &schema.Resource{ Description: "A password policy specifies the requirements that must be met to create and reset a password to authenticate to Snowflake.", - CreateContext: TrackingCreateWrapper(resources.PasswordPolicy, CreatePasswordPolicy), - ReadContext: TrackingReadWrapper(resources.PasswordPolicy, ReadPasswordPolicy), - UpdateContext: TrackingUpdateWrapper(resources.PasswordPolicy, UpdatePasswordPolicy), - DeleteContext: TrackingDeleteWrapper(resources.PasswordPolicy, DeletePasswordPolicy), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.PasswordPolicyResource), TrackingCreateWrapper(resources.PasswordPolicy, CreatePasswordPolicy)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.PasswordPolicyResource), TrackingReadWrapper(resources.PasswordPolicy, ReadPasswordPolicy)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.PasswordPolicyResource), TrackingUpdateWrapper(resources.ObjectParameter, UpdateObjectParameter)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.PasswordPolicyResource), TrackingDeleteWrapper(resources.PasswordPolicy, UpdatePasswordPolicy)), CustomizeDiff: TrackingCustomDiffWrapper(resources.PasswordPolicy, customdiff.All( ComputedIfAnyAttributeChanged(passwordPolicySchema, FullyQualifiedNameAttributeName, "name"), diff --git a/pkg/resources/pipe.go b/pkg/resources/pipe.go index c15140621f9..99aa291f46a 100644 --- a/pkg/resources/pipe.go +++ b/pkg/resources/pipe.go @@ -6,6 +6,7 @@ import ( "log" "strings" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -86,10 +87,10 @@ var pipeSchema = map[string]*schema.Schema{ func Pipe() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.Pipe, CreatePipe), - ReadContext: TrackingReadWrapper(resources.Pipe, ReadPipe), - UpdateContext: TrackingUpdateWrapper(resources.Pipe, UpdatePipe), - DeleteContext: TrackingDeleteWrapper(resources.Pipe, DeletePipe), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.PipeResource), TrackingCreateWrapper(resources.Pipe, CreatePipe)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.PipeResource), TrackingReadWrapper(resources.Pipe, ReadPipe)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.PipeResource), TrackingUpdateWrapper(resources.Pipe, UpdatePipe)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.PipeResource), TrackingDeleteWrapper(resources.Pipe, DeletePipe)), Schema: pipeSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/sequence.go b/pkg/resources/sequence.go index 449dc566947..464ccb2ab2a 100644 --- a/pkg/resources/sequence.go +++ b/pkg/resources/sequence.go @@ -3,6 +3,7 @@ package resources import ( "context" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -67,10 +68,10 @@ var sequenceSchema = map[string]*schema.Schema{ func Sequence() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.Sequence, CreateSequence), - ReadContext: TrackingReadWrapper(resources.Sequence, ReadSequence), - DeleteContext: TrackingDeleteWrapper(resources.Sequence, DeleteSequence), - UpdateContext: TrackingUpdateWrapper(resources.Sequence, UpdateSequence), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.SequenceResource), TrackingCreateWrapper(resources.Sequence, CreateSequence)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.SequenceResource), TrackingReadWrapper(resources.Sequence, ReadSequence)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.SequenceResource), TrackingUpdateWrapper(resources.Sequence, DeleteSequence)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.SequenceResource), TrackingDeleteWrapper(resources.Sequence, UpdateSequence)), Schema: sequenceSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/share.go b/pkg/resources/share.go index 334a931f309..385c15b93b3 100644 --- a/pkg/resources/share.go +++ b/pkg/resources/share.go @@ -7,6 +7,7 @@ import ( "strings" "time" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -48,10 +49,10 @@ var shareSchema = map[string]*schema.Schema{ // Share returns a pointer to the resource representing a share. func Share() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.Share, CreateShare), - ReadContext: TrackingReadWrapper(resources.Share, ReadShare), - UpdateContext: TrackingUpdateWrapper(resources.Share, UpdateShare), - DeleteContext: TrackingDeleteWrapper(resources.Share, DeleteShare), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.ShareResource), TrackingCreateWrapper(resources.Share, CreateShare)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.ShareResource), TrackingReadWrapper(resources.Share, ReadShare)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.ShareResource), TrackingUpdateWrapper(resources.Share, UpdateShare)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.ShareResource), TrackingDeleteWrapper(resources.Share, DeleteShare)), Schema: shareSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/stage.go b/pkg/resources/stage.go index efbfeb2df92..e2ac46ed96f 100644 --- a/pkg/resources/stage.go +++ b/pkg/resources/stage.go @@ -103,10 +103,10 @@ var stageSchema = map[string]*schema.Schema{ // TODO (SNOW-1019005): Remove snowflake package that is used in Create and Update operations func Stage() *schema.Resource { return &schema.Resource{ - CreateContext: previewfeatures.PreviewFeatureCreateContextWrapper(string(previewfeatures.StageResource), TrackingCreateWrapper(resources.Stage, CreateStage)), - ReadContext: previewfeatures.PreviewFeatureReadContextWrapper(string(previewfeatures.StageResource), TrackingReadWrapper(resources.Stage, ReadStage)), - UpdateContext: previewfeatures.PreviewFeatureUpdateContextWrapper(string(previewfeatures.StageResource), TrackingUpdateWrapper(resources.Stage, UpdateStage)), - DeleteContext: previewfeatures.PreviewFeatureDeleteContextWrapper(string(previewfeatures.StageResource), TrackingDeleteWrapper(resources.Stage, DeleteStage)), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.StageResource), TrackingCreateWrapper(resources.Stage, CreateStage)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.StageResource), TrackingReadWrapper(resources.Stage, ReadStage)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.StageResource), TrackingUpdateWrapper(resources.Stage, UpdateStage)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.StageResource), TrackingDeleteWrapper(resources.Stage, DeleteStage)), Schema: stageSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/storage_integration.go b/pkg/resources/storage_integration.go index 85a40729d32..3723347bc54 100644 --- a/pkg/resources/storage_integration.go +++ b/pkg/resources/storage_integration.go @@ -8,11 +8,14 @@ import ( "strings" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/schemas" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) @@ -112,10 +115,10 @@ var storageIntegrationSchema = map[string]*schema.Schema{ // StorageIntegration returns a pointer to the resource representing a storage integration. func StorageIntegration() *schema.Resource { return &schema.Resource{ - Create: CreateStorageIntegration, - Read: ReadStorageIntegration, - Update: UpdateStorageIntegration, - Delete: DeleteStorageIntegration, + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.StorageIntegrationResource), TrackingCreateWrapper(resources.StorageIntegration, CreateStorageIntegration)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.StorageIntegrationResource), TrackingReadWrapper(resources.StorageIntegration, ReadStorageIntegration)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.StorageIntegrationResource), TrackingUpdateWrapper(resources.StorageIntegration, UpdateStorageIntegration)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.StorageIntegrationResource), TrackingDeleteWrapper(resources.StorageIntegration, DeleteStorageIntegration)), Schema: storageIntegrationSchema, Importer: &schema.ResourceImporter{ @@ -124,9 +127,8 @@ func StorageIntegration() *schema.Resource { } } -func CreateStorageIntegration(d *schema.ResourceData, meta any) error { +func CreateStorageIntegration(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { client := meta.(*provider.Context).Client - ctx := context.Background() name := sdk.NewAccountObjectIdentifierFromFullyQualifiedName(d.Get("name").(string)) enabled := d.Get("enabled").(bool) @@ -161,12 +163,12 @@ func CreateStorageIntegration(d *schema.ResourceData, meta any) error { case slices.Contains(sdk.AllS3Protocols, sdk.S3Protocol(storageProvider)): s3Protocol, err := sdk.ToS3Protocol(storageProvider) if err != nil { - return err + return diag.FromErr(err) } v, ok := d.GetOk("storage_aws_role_arn") if !ok { - return fmt.Errorf("if you use the S3 storage provider you must specify a storage_aws_role_arn") + return diag.FromErr(fmt.Errorf("if you use the S3 storage provider you must specify a storage_aws_role_arn")) } s3Params := sdk.NewS3StorageParamsRequest(s3Protocol, v.(string)) @@ -177,29 +179,28 @@ func CreateStorageIntegration(d *schema.ResourceData, meta any) error { case storageProvider == "AZURE": v, ok := d.GetOk("azure_tenant_id") if !ok { - return fmt.Errorf("if you use the Azure storage provider you must specify an azure_tenant_id") + return diag.FromErr(fmt.Errorf("if you use the Azure storage provider you must specify an azure_tenant_id")) } req.WithAzureStorageProviderParams(*sdk.NewAzureStorageParamsRequest(sdk.String(v.(string)))) case storageProvider == "GCS": req.WithGCSStorageProviderParams(*sdk.NewGCSStorageParamsRequest()) default: - return fmt.Errorf("unexpected provider %v", storageProvider) + return diag.FromErr(fmt.Errorf("unexpected provider %v", storageProvider)) } if err := client.StorageIntegrations.Create(ctx, req); err != nil { - return fmt.Errorf("error creating storage integration: %w", err) + return diag.FromErr(fmt.Errorf("error creating storage integration: %w", err)) } d.SetId(helpers.EncodeSnowflakeID(name)) - return ReadStorageIntegration(d, meta) + return ReadStorageIntegration(ctx, d, meta) } -func ReadStorageIntegration(d *schema.ResourceData, meta any) error { +func ReadStorageIntegration(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { client := meta.(*provider.Context).Client - ctx := context.Background() id, ok := helpers.DecodeSnowflakeID(d.Id()).(sdk.AccountObjectIdentifier) if !ok { - return fmt.Errorf("storage integration read, error decoding id: %s as sdk.AccountObjectIdentifier, got: %T", d.Id(), id) + return diag.FromErr(fmt.Errorf("storage integration read, error decoding id: %s as sdk.AccountObjectIdentifier, got: %T", d.Id(), id)) } s, err := client.StorageIntegrations.ShowByID(ctx, id) @@ -209,91 +210,90 @@ func ReadStorageIntegration(d *schema.ResourceData, meta any) error { return nil } if err := d.Set(FullyQualifiedNameAttributeName, id.FullyQualifiedName()); err != nil { - return err + return diag.FromErr(err) } if s.Category != "STORAGE" { - return fmt.Errorf("expected %v to be a STORAGE integration, got %v", d.Id(), s.Category) + return diag.FromErr(fmt.Errorf("expected %v to be a STORAGE integration, got %v", d.Id(), s.Category)) } if err := d.Set("name", s.Name); err != nil { - return err + return diag.FromErr(err) } if err := d.Set("type", s.StorageType); err != nil { - return err + return diag.FromErr(err) } if err := d.Set("created_on", s.CreatedOn.String()); err != nil { - return err + return diag.FromErr(err) } if err := d.Set("enabled", s.Enabled); err != nil { - return err + return diag.FromErr(err) } if err := d.Set("comment", s.Comment); err != nil { - return err + return diag.FromErr(err) } storageIntegrationProps, err := client.StorageIntegrations.Describe(ctx, id) if err != nil { - return fmt.Errorf("could not describe storage integration (%s), err = %w", d.Id(), err) + return diag.FromErr(fmt.Errorf("could not describe storage integration (%s), err = %w", d.Id(), err)) } for _, prop := range storageIntegrationProps { switch prop.Name { case "STORAGE_PROVIDER": if err := d.Set("storage_provider", prop.Value); err != nil { - return err + return diag.FromErr(err) } case "STORAGE_ALLOWED_LOCATIONS": if err := d.Set("storage_allowed_locations", strings.Split(prop.Value, ",")); err != nil { - return err + return diag.FromErr(err) } case "STORAGE_BLOCKED_LOCATIONS": if prop.Value != "" { if err := d.Set("storage_blocked_locations", strings.Split(prop.Value, ",")); err != nil { - return err + return diag.FromErr(err) } } case "STORAGE_AWS_IAM_USER_ARN": if err := d.Set("storage_aws_iam_user_arn", prop.Value); err != nil { - return err + return diag.FromErr(err) } case "STORAGE_AWS_OBJECT_ACL": if prop.Value != "" { if err := d.Set("storage_aws_object_acl", prop.Value); err != nil { - return err + return diag.FromErr(err) } } case "STORAGE_AWS_ROLE_ARN": if err := d.Set("storage_aws_role_arn", prop.Value); err != nil { - return err + return diag.FromErr(err) } case "STORAGE_AWS_EXTERNAL_ID": if err := d.Set("storage_aws_external_id", prop.Value); err != nil { - return err + return diag.FromErr(err) } case "STORAGE_GCP_SERVICE_ACCOUNT": if err := d.Set("storage_gcp_service_account", prop.Value); err != nil { - return err + return diag.FromErr(err) } case "AZURE_CONSENT_URL": if err := d.Set("azure_consent_url", prop.Value); err != nil { - return err + return diag.FromErr(err) } case "AZURE_MULTI_TENANT_APP_NAME": if err := d.Set("azure_multi_tenant_app_name", prop.Value); err != nil { - return err + return diag.FromErr(err) } } } - return err + return diag.FromErr(err) } -func UpdateStorageIntegration(d *schema.ResourceData, meta any) error { +func UpdateStorageIntegration(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { client := meta.(*provider.Context).Client - ctx := context.Background() id, ok := helpers.DecodeSnowflakeID(d.Id()).(sdk.AccountObjectIdentifier) if !ok { - return fmt.Errorf("storage integration update, error decoding id: %s as sdk.AccountObjectIdentifier, got: %T", d.Id(), id) + return diag.FromErr(fmt.Errorf("storage integration update, error decoding id: %s as sdk.AccountObjectIdentifier, got: %T", d.Id(), id)) } var runSetStatement bool @@ -327,7 +327,7 @@ func UpdateStorageIntegration(d *schema.ResourceData, meta any) error { if len(v) == 0 { if err := client.StorageIntegrations.Alter(ctx, sdk.NewAlterStorageIntegrationRequest(id). WithUnset(*sdk.NewStorageIntegrationUnsetRequest().WithStorageBlockedLocations(true))); err != nil { - return fmt.Errorf("error unsetting storage_blocked_locations, err = %w", err) + return diag.FromErr(fmt.Errorf("error unsetting storage_blocked_locations, err = %w", err)) } } else { runSetStatement = true @@ -352,7 +352,7 @@ func UpdateStorageIntegration(d *schema.ResourceData, meta any) error { } else { if err := client.StorageIntegrations.Alter(ctx, sdk.NewAlterStorageIntegrationRequest(id). WithUnset(*sdk.NewStorageIntegrationUnsetRequest().WithStorageAwsObjectAcl(true))); err != nil { - return fmt.Errorf("error unsetting storage_aws_object_acl, err = %w", err) + return diag.FromErr(fmt.Errorf("error unsetting storage_aws_object_acl, err = %w", err)) } } } @@ -367,22 +367,21 @@ func UpdateStorageIntegration(d *schema.ResourceData, meta any) error { if runSetStatement { if err := client.StorageIntegrations.Alter(ctx, sdk.NewAlterStorageIntegrationRequest(id).WithSet(*setReq)); err != nil { - return fmt.Errorf("error updating storage integration, err = %w", err) + return diag.FromErr(fmt.Errorf("error updating storage integration, err = %w", err)) } } - return ReadStorageIntegration(d, meta) + return ReadStorageIntegration(ctx, d, meta) } -func DeleteStorageIntegration(d *schema.ResourceData, meta any) error { +func DeleteStorageIntegration(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { client := meta.(*provider.Context).Client - ctx := context.Background() id, ok := helpers.DecodeSnowflakeID(d.Id()).(sdk.AccountObjectIdentifier) if !ok { - return fmt.Errorf("storage integration delete, error decoding id: %s as sdk.AccountObjectIdentifier, got: %T", d.Id(), id) + return diag.FromErr(fmt.Errorf("storage integration delete, error decoding id: %s as sdk.AccountObjectIdentifier, got: %T", d.Id(), id)) } if err := client.StorageIntegrations.Drop(ctx, sdk.NewDropStorageIntegrationRequest(id)); err != nil { - return fmt.Errorf("error dropping storage integration (%s), err = %w", d.Id(), err) + return diag.FromErr(fmt.Errorf("error dropping storage integration (%s), err = %w", d.Id(), err)) } d.SetId("") diff --git a/pkg/resources/table_column_masking_policy_application.go b/pkg/resources/table_column_masking_policy_application.go index e48d4447add..87a15a2ca61 100644 --- a/pkg/resources/table_column_masking_policy_application.go +++ b/pkg/resources/table_column_masking_policy_application.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -37,9 +38,9 @@ var tableColumnMaskingPolicyApplicationSchema = map[string]*schema.Schema{ func TableColumnMaskingPolicyApplication() *schema.Resource { return &schema.Resource{ Description: "Applies a masking policy to a table column.", - CreateContext: TrackingCreateWrapper(resources.TableColumnMaskingPolicyApplication, CreateTableColumnMaskingPolicyApplication), - ReadContext: TrackingReadWrapper(resources.TableColumnMaskingPolicyApplication, ReadTableColumnMaskingPolicyApplication), - DeleteContext: TrackingDeleteWrapper(resources.TableColumnMaskingPolicyApplication, DeleteTableColumnMaskingPolicyApplication), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.TableColumnMaskingPolicyApplicationResource), TrackingCreateWrapper(resources.TableColumnMaskingPolicyApplication, CreateTableColumnMaskingPolicyApplication)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.TableColumnMaskingPolicyApplicationResource), TrackingReadWrapper(resources.TableColumnMaskingPolicyApplication, ReadTableColumnMaskingPolicyApplication)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.TableColumnMaskingPolicyApplicationResource), TrackingDeleteWrapper(resources.TableColumnMaskingPolicyApplication, DeleteTableColumnMaskingPolicyApplication)), Schema: tableColumnMaskingPolicyApplicationSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/table_constraint.go b/pkg/resources/table_constraint.go index 92e2f6a3f71..8969da1201f 100644 --- a/pkg/resources/table_constraint.go +++ b/pkg/resources/table_constraint.go @@ -5,6 +5,7 @@ import ( "fmt" "strings" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -182,10 +183,10 @@ var tableConstraintSchema = map[string]*schema.Schema{ func TableConstraint() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.TableConstraint, CreateTableConstraint), - ReadContext: TrackingReadWrapper(resources.TableConstraint, ReadTableConstraint), - UpdateContext: TrackingUpdateWrapper(resources.TableConstraint, UpdateTableConstraint), - DeleteContext: TrackingDeleteWrapper(resources.TableConstraint, DeleteTableConstraint), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.TableConstraintResource), TrackingCreateWrapper(resources.TableConstraint, CreateTableConstraint)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.TableConstraintResource), TrackingReadWrapper(resources.TableConstraint, ReadTableConstraint)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.TableConstraintResource), TrackingUpdateWrapper(resources.TableConstraint, UpdateTableConstraint)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.TableConstraintResource), TrackingDeleteWrapper(resources.TableConstraint, DeleteTableConstraint)), Schema: tableConstraintSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/user_authentication_policy_attachment.go b/pkg/resources/user_authentication_policy_attachment.go index 7e03ef118b2..78838d96eda 100644 --- a/pkg/resources/user_authentication_policy_attachment.go +++ b/pkg/resources/user_authentication_policy_attachment.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -35,10 +36,11 @@ var userAuthenticationPolicyAttachmentSchema = map[string]*schema.Schema{ func UserAuthenticationPolicyAttachment() *schema.Resource { return &schema.Resource{ Description: "Specifies the authentication policy to use for a certain user.", - CreateContext: TrackingCreateWrapper(resources.UserAuthenticationPolicyAttachment, CreateUserAuthenticationPolicyAttachment), - ReadContext: TrackingReadWrapper(resources.UserAuthenticationPolicyAttachment, ReadUserAuthenticationPolicyAttachment), - DeleteContext: TrackingDeleteWrapper(resources.UserAuthenticationPolicyAttachment, DeleteUserAuthenticationPolicyAttachment), - Schema: userAuthenticationPolicyAttachmentSchema, + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.UserAuthenticationPolicyAttachmentResource), TrackingCreateWrapper(resources.UserAuthenticationPolicyAttachment, CreateUserAuthenticationPolicyAttachment)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.UserAuthenticationPolicyAttachmentResource), TrackingReadWrapper(resources.UserAuthenticationPolicyAttachment, ReadUserAuthenticationPolicyAttachment)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.UserAuthenticationPolicyAttachmentResource), TrackingDeleteWrapper(resources.UserAuthenticationPolicyAttachment, DeleteUserAuthenticationPolicyAttachment)), + + Schema: userAuthenticationPolicyAttachmentSchema, Importer: &schema.ResourceImporter{ StateContext: schema.ImportStatePassthroughContext, }, diff --git a/pkg/resources/user_password_policy_attachment.go b/pkg/resources/user_password_policy_attachment.go index 84cdd42a1fd..dce350afca8 100644 --- a/pkg/resources/user_password_policy_attachment.go +++ b/pkg/resources/user_password_policy_attachment.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -35,10 +36,11 @@ var userPasswordPolicyAttachmentSchema = map[string]*schema.Schema{ func UserPasswordPolicyAttachment() *schema.Resource { return &schema.Resource{ Description: "Specifies the password policy to use for a certain user.", - CreateContext: TrackingCreateWrapper(resources.UserPasswordPolicyAttachment, CreateUserPasswordPolicyAttachment), - ReadContext: TrackingReadWrapper(resources.UserPasswordPolicyAttachment, ReadUserPasswordPolicyAttachment), - DeleteContext: TrackingDeleteWrapper(resources.UserPasswordPolicyAttachment, DeleteUserPasswordPolicyAttachment), - Schema: userPasswordPolicyAttachmentSchema, + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.UserPasswordPolicyAttachmentResource), TrackingCreateWrapper(resources.UserPasswordPolicyAttachment, CreateUserPasswordPolicyAttachment)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.UserPasswordPolicyAttachmentResource), TrackingReadWrapper(resources.UserPasswordPolicyAttachment, ReadUserPasswordPolicyAttachment)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.UserPasswordPolicyAttachmentResource), TrackingDeleteWrapper(resources.UserPasswordPolicyAttachment, DeleteUserPasswordPolicyAttachment)), + + Schema: userPasswordPolicyAttachmentSchema, Importer: &schema.ResourceImporter{ StateContext: schema.ImportStatePassthroughContext, }, diff --git a/pkg/resources/user_public_keys.go b/pkg/resources/user_public_keys.go index c46b0990c76..1afefd5706c 100644 --- a/pkg/resources/user_public_keys.go +++ b/pkg/resources/user_public_keys.go @@ -8,6 +8,7 @@ import ( "log" "strings" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -54,10 +55,10 @@ var userPublicKeysSchema = map[string]*schema.Schema{ func UserPublicKeys() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.UserPublicKeys, CreateUserPublicKeys), - ReadContext: TrackingReadWrapper(resources.UserPublicKeys, ReadUserPublicKeys), - UpdateContext: TrackingUpdateWrapper(resources.UserPublicKeys, UpdateUserPublicKeys), - DeleteContext: TrackingDeleteWrapper(resources.UserPublicKeys, DeleteUserPublicKeys), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.UserPublicKeysResource), TrackingCreateWrapper(resources.UserPublicKeys, CreateUserPublicKeys)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.UserPublicKeysResource), TrackingReadWrapper(resources.UserPublicKeys, ReadUserPublicKeys)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.UserPublicKeysResource), TrackingUpdateWrapper(resources.UserPublicKeys, UpdateUserPublicKeys)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.UserPublicKeysResource), TrackingDeleteWrapper(resources.UserPublicKeys, DeleteUserPublicKeys)), Schema: userPublicKeysSchema, Importer: &schema.ResourceImporter{