From 7c302ac755f8a739803bf294dc6c7fb510e7fb6f Mon Sep 17 00:00:00 2001 From: Jakub Michalak Date: Thu, 12 Dec 2024 18:07:43 +0100 Subject: [PATCH] Mark preview remaining features --- pkg/datasources/functions.go | 3 +- pkg/datasources/procedures.go | 3 +- pkg/datasources/tables.go | 3 +- .../previewfeatures/preview_features.go | 108 ++++++++++-------- ...ccount_authentication_policy_attachment.go | 7 +- pkg/resources/authentication_policy.go | 9 +- pkg/resources/table.go | 9 +- .../LIST_OF_PREVIEW_FEATURES_FOR_V1.md | 2 + 8 files changed, 80 insertions(+), 64 deletions(-) diff --git a/pkg/datasources/functions.go b/pkg/datasources/functions.go index 8dc158b406..fcf325c9c9 100644 --- a/pkg/datasources/functions.go +++ b/pkg/datasources/functions.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" @@ -66,7 +67,7 @@ var functionsSchema = map[string]*schema.Schema{ func Functions() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.Functions, ReadContextFunctions), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.FunctionsDatasource), TrackingReadWrapper(datasources.Functions, ReadContextFunctions)), Schema: functionsSchema, } } diff --git a/pkg/datasources/procedures.go b/pkg/datasources/procedures.go index c0dd714ff1..5cb4f7dc6c 100644 --- a/pkg/datasources/procedures.go +++ b/pkg/datasources/procedures.go @@ -7,6 +7,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" @@ -67,7 +68,7 @@ var proceduresSchema = map[string]*schema.Schema{ func Procedures() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.Procedures, ReadContextProcedures), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.ProceduresDatasource), TrackingReadWrapper(datasources.Procedures, ReadContextProcedures)), Schema: proceduresSchema, } } diff --git a/pkg/datasources/tables.go b/pkg/datasources/tables.go index fac59da574..c814a1fcb3 100644 --- a/pkg/datasources/tables.go +++ b/pkg/datasources/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" @@ -55,7 +56,7 @@ var tablesSchema = map[string]*schema.Schema{ func Tables() *schema.Resource { return &schema.Resource{ - ReadContext: TrackingReadWrapper(datasources.Tables, ReadTables), + ReadContext: PreviewFeatureReadWrapper(string(previewfeatures.TablesDatasource), TrackingReadWrapper(datasources.Tables, ReadTables)), Schema: tablesSchema, } } diff --git a/pkg/provider/previewfeatures/preview_features.go b/pkg/provider/previewfeatures/preview_features.go index 328cebaf86..67905d4ae0 100644 --- a/pkg/provider/previewfeatures/preview_features.go +++ b/pkg/provider/previewfeatures/preview_features.go @@ -9,64 +9,72 @@ import ( type feature string const ( - CurrentAccountDatasource feature = "snowflake_current_account_datasource" - AccountPasswordPolicyAttachmentResource feature = "snowflake_account_password_policy_attachment_resource" - AlertResource feature = "snowflake_alert_resource" - AlertsDatasource feature = "snowflake_alerts_datasource" - ApiIntegrationResource feature = "snowflake_api_integration_resource" - CortexSearchServiceResource feature = "snowflake_cortex_search_service_resource" - CortexSearchServicesDatasource feature = "snowflake_cortex_search_services_datasource" - DatabaseDatasource feature = "snowflake_database_datasource" - DatabaseRoleDatasource feature = "snowflake_database_role_datasource" - DynamicTableResource feature = "snowflake_dynamic_table_resource" - DynamicTablesDatasource feature = "snowflake_dynamic_tables_datasource" - ExternalFunctionResource feature = "snowflake_external_function_resource" - ExternalFunctionsDatasource feature = "snowflake_external_functions_datasource" - ExternalTableResource feature = "snowflake_external_table_resource" - ExternalTablesDatasource feature = "snowflake_external_tables_datasource" - ExternalVolumeResource feature = "snowflake_external_volume_resource" - FailoverGroupResource feature = "snowflake_failover_group_resource" - FailoverGroupsDatasource feature = "snowflake_failover_groups_datasource" - FileFormatResource feature = "snowflake_file_format_resource" - FileFormatsDatasource feature = "snowflake_file_formats_datasource" - ManagedAccountResource feature = "snowflake_managed_account_resource" - MaterializedViewResource feature = "snowflake_materialized_view_resource" - MaterializedViewsDatasource feature = "snowflake_materialized_views_datasource" - NetworkPolicyAttachmentResource feature = "snowflake_network_policy_attachment_resource" - NetworkRuleResource feature = "snowflake_network_rule_resource" - EmailNotificationIntegrationResource feature = "snowflake_email_notification_integration_resource" - NotificationIntegrationResource feature = "snowflake_notification_integration_resource" - ObjectParameterResource feature = "snowflake_object_parameter_resource" - PasswordPolicyResource feature = "snowflake_password_policy_resource" - PipeResource feature = "snowflake_pipe_resource" - PipesDatasource feature = "snowflake_pipes_datasource" - CurrentRoleDatasource feature = "snowflake_current_role_datasource" - SequenceResource feature = "snowflake_sequence_resource" - SequencesDatasource feature = "snowflake_sequences_datasource" - ShareResource feature = "snowflake_share_resource" - SharesDatasource feature = "snowflake_shares_datasource" - ParametersDatasource feature = "snowflake_parameters_datasource" - StageResource feature = "snowflake_stage_resource" - 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" - SystemGetAWSSNSIAMPolicyDatasource feature = "snowflake_system_get_aws_sns_iam_policy_datasource" - SystemGetPrivateLinkConfigDatasource feature = "snowflake_system_get_privatelink_config_datasource" - 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" + CurrentAccountDatasource feature = "snowflake_current_account_datasource" + AccountAuthenticationPolicyAttachmentResource feature = "snowflake_account_authentication_policy_attachment_resource" + AccountPasswordPolicyAttachmentResource feature = "snowflake_account_password_policy_attachment_resource" + AlertResource feature = "snowflake_alert_resource" + AlertsDatasource feature = "snowflake_alerts_datasource" + ApiIntegrationResource feature = "snowflake_api_integration_resource" + AuthenticationPolicyResource feature = "snowflake_authentication_policy_resource" + CortexSearchServiceResource feature = "snowflake_cortex_search_service_resource" + CortexSearchServicesDatasource feature = "snowflake_cortex_search_services_datasource" + DatabaseDatasource feature = "snowflake_database_datasource" + DatabaseRoleDatasource feature = "snowflake_database_role_datasource" + DynamicTableResource feature = "snowflake_dynamic_table_resource" + DynamicTablesDatasource feature = "snowflake_dynamic_tables_datasource" + ExternalFunctionResource feature = "snowflake_external_function_resource" + ExternalFunctionsDatasource feature = "snowflake_external_functions_datasource" + ExternalTableResource feature = "snowflake_external_table_resource" + ExternalTablesDatasource feature = "snowflake_external_tables_datasource" + ExternalVolumeResource feature = "snowflake_external_volume_resource" + FailoverGroupResource feature = "snowflake_failover_group_resource" + FailoverGroupsDatasource feature = "snowflake_failover_groups_datasource" + FileFormatResource feature = "snowflake_file_format_resource" + FileFormatsDatasource feature = "snowflake_file_formats_datasource" + FunctionsDatasource feature = "snowflake_functions_datasource" + ManagedAccountResource feature = "snowflake_managed_account_resource" + MaterializedViewResource feature = "snowflake_materialized_view_resource" + MaterializedViewsDatasource feature = "snowflake_materialized_views_datasource" + NetworkPolicyAttachmentResource feature = "snowflake_network_policy_attachment_resource" + NetworkRuleResource feature = "snowflake_network_rule_resource" + EmailNotificationIntegrationResource feature = "snowflake_email_notification_integration_resource" + NotificationIntegrationResource feature = "snowflake_notification_integration_resource" + ObjectParameterResource feature = "snowflake_object_parameter_resource" + PasswordPolicyResource feature = "snowflake_password_policy_resource" + PipeResource feature = "snowflake_pipe_resource" + PipesDatasource feature = "snowflake_pipes_datasource" + ProceduresDatasource feature = "snowflake_procedures_datasource" + CurrentRoleDatasource feature = "snowflake_current_role_datasource" + SequenceResource feature = "snowflake_sequence_resource" + SequencesDatasource feature = "snowflake_sequences_datasource" + ShareResource feature = "snowflake_share_resource" + SharesDatasource feature = "snowflake_shares_datasource" + ParametersDatasource feature = "snowflake_parameters_datasource" + StageResource feature = "snowflake_stage_resource" + 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" + SystemGetAWSSNSIAMPolicyDatasource feature = "snowflake_system_get_aws_sns_iam_policy_datasource" + SystemGetPrivateLinkConfigDatasource feature = "snowflake_system_get_privatelink_config_datasource" + SystemGetSnowflakePlatformInfoDatasource feature = "snowflake_system_get_snowflake_platform_info_datasource" + TableResource feature = "snowflake_table_resource" + TablesDatasource feature = "snowflake_tables_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" ) var allPreviewFeatures = []feature{ CurrentAccountDatasource, + AccountAuthenticationPolicyAttachmentResource, AccountPasswordPolicyAttachmentResource, AlertResource, AlertsDatasource, ApiIntegrationResource, + AuthenticationPolicyResource, CortexSearchServiceResource, CortexSearchServicesDatasource, DatabaseDatasource, diff --git a/pkg/resources/account_authentication_policy_attachment.go b/pkg/resources/account_authentication_policy_attachment.go index bb61f3d215..a71a02be00 100644 --- a/pkg/resources/account_authentication_policy_attachment.go +++ b/pkg/resources/account_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" @@ -29,9 +30,9 @@ func AccountAuthenticationPolicyAttachment() *schema.Resource { return &schema.Resource{ Description: "Specifies the authentication policy to use for the current account. To set the authentication policy of a different account, use a provider alias.", - CreateContext: TrackingCreateWrapper(resources.AccountAuthenticationPolicyAttachment, CreateAccountAuthenticationPolicyAttachment), - ReadContext: TrackingReadWrapper(resources.AccountAuthenticationPolicyAttachment, ReadAccountAuthenticationPolicyAttachment), - DeleteContext: TrackingDeleteWrapper(resources.AccountAuthenticationPolicyAttachment, DeleteAccountAuthenticationPolicyAttachment), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.AccountAuthenticationPolicyAttachmentResource), TrackingCreateWrapper(resources.AccountAuthenticationPolicyAttachment, CreateAccountAuthenticationPolicyAttachment)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.AccountAuthenticationPolicyAttachmentResource), TrackingReadWrapper(resources.AccountAuthenticationPolicyAttachment, ReadAccountAuthenticationPolicyAttachment)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.AccountAuthenticationPolicyAttachmentResource), TrackingDeleteWrapper(resources.AccountAuthenticationPolicyAttachment, DeleteAccountAuthenticationPolicyAttachment)), Schema: accountAuthenticationPolicyAttachmentSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/authentication_policy.go b/pkg/resources/authentication_policy.go index 851cbe67d9..0ea6648178 100644 --- a/pkg/resources/authentication_policy.go +++ b/pkg/resources/authentication_policy.go @@ -6,6 +6,7 @@ import ( "fmt" "reflect" + "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" @@ -110,10 +111,10 @@ var authenticationPolicySchema = map[string]*schema.Schema{ // AuthenticationPolicy returns a pointer to the resource representing an authentication policy. func AuthenticationPolicy() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.AuthenticationPolicy, CreateContextAuthenticationPolicy), - ReadContext: TrackingReadWrapper(resources.AuthenticationPolicy, ReadContextAuthenticationPolicy), - UpdateContext: TrackingUpdateWrapper(resources.AuthenticationPolicy, UpdateContextAuthenticationPolicy), - DeleteContext: TrackingDeleteWrapper(resources.AuthenticationPolicy, DeleteContextAuthenticationPolicy), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.AuthenticationPolicyResource), TrackingCreateWrapper(resources.AuthenticationPolicy, CreateContextAuthenticationPolicy)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.AuthenticationPolicyResource), TrackingReadWrapper(resources.AuthenticationPolicy, ReadContextAuthenticationPolicy)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.AuthenticationPolicyResource), TrackingUpdateWrapper(resources.AuthenticationPolicy, UpdateContextAuthenticationPolicy)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.AuthenticationPolicyResource), TrackingDeleteWrapper(resources.AuthenticationPolicy, DeleteContextAuthenticationPolicy)), Description: "Resource used to manage authentication policy objects. For more information, check [authentication policy documentation](https://docs.snowflake.com/en/sql-reference/sql/create-authentication-policy).", Schema: authenticationPolicySchema, diff --git a/pkg/resources/table.go b/pkg/resources/table.go index f0d4d77ea4..3eb8bbe823 100644 --- a/pkg/resources/table.go +++ b/pkg/resources/table.go @@ -9,6 +9,7 @@ import ( "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers" "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/sdk" @@ -208,10 +209,10 @@ var tableSchema = map[string]*schema.Schema{ func Table() *schema.Resource { return &schema.Resource{ - CreateContext: TrackingCreateWrapper(resources.Table, CreateTable), - ReadContext: TrackingReadWrapper(resources.Table, ReadTable), - UpdateContext: TrackingUpdateWrapper(resources.Table, UpdateTable), - DeleteContext: TrackingDeleteWrapper(resources.Table, DeleteTable), + CreateContext: PreviewFeatureCreateContextWrapper(string(previewfeatures.TableResource), TrackingCreateWrapper(resources.Table, CreateTable)), + ReadContext: PreviewFeatureReadContextWrapper(string(previewfeatures.TableResource), TrackingReadWrapper(resources.Table, ReadTable)), + UpdateContext: PreviewFeatureUpdateContextWrapper(string(previewfeatures.TableResource), TrackingUpdateWrapper(resources.Table, UpdateTable)), + DeleteContext: PreviewFeatureDeleteContextWrapper(string(previewfeatures.TableResource), TrackingDeleteWrapper(resources.Table, DeleteTable)), CustomizeDiff: TrackingCustomDiffWrapper(resources.Table, customdiff.All( ComputedIfAnyAttributeChanged(tableSchema, FullyQualifiedNameAttributeName, "name"), diff --git a/v1-preparations/LIST_OF_PREVIEW_FEATURES_FOR_V1.md b/v1-preparations/LIST_OF_PREVIEW_FEATURES_FOR_V1.md index 4dc1917b01..2a58d9a9c7 100644 --- a/v1-preparations/LIST_OF_PREVIEW_FEATURES_FOR_V1.md +++ b/v1-preparations/LIST_OF_PREVIEW_FEATURES_FOR_V1.md @@ -2,8 +2,10 @@ * [snowflake_current_account](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/0.97.0/docs/data-sources/current_account) (datasource) * [snowflake_account_password_policy_attachment](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/0.97.0/docs/resources/account_password_policy_attachment) +* [snowflake_account_authentication_policy_attachment](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/0.97.0/docs/resources/account_authentication_policy_attachment) * [snowflake_alert](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/0.97.0/docs/resources/alert) * [snowflake_alerts](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/0.97.0/docs/data-sources/alerts) (datasource) +* [snowflake_authentication_policy](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/0.97.0/docs/resources/authentication_policy) * [snowflake_api_integration](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/0.97.0/docs/resources/api_integration) * [snowflake_cortex_search_service](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/0.97.0/docs/resources/cortex_search_service) * [snowflake_cortex_search_services](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/0.97.0/docs/data-sources/cortex_search_services) (datasource)