From 6c8c9190d4e8f0707883b9cc735f905ac9f68f23 Mon Sep 17 00:00:00 2001 From: Jakub Michalak Date: Mon, 9 Dec 2024 16:52:42 +0100 Subject: [PATCH 1/6] init --- .../snowflake_account_parameter/import.sh | 2 +- pkg/resources/account_parameter.go | 30 ++++++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/examples/resources/snowflake_account_parameter/import.sh b/examples/resources/snowflake_account_parameter/import.sh index c1dd2640d1..c5a0051fd8 100644 --- a/examples/resources/snowflake_account_parameter/import.sh +++ b/examples/resources/snowflake_account_parameter/import.sh @@ -1 +1 @@ -terraform import snowflake_account_parameter.p +terraform import snowflake_account_parameter.p '' diff --git a/pkg/resources/account_parameter.go b/pkg/resources/account_parameter.go index 95cea28579..9b313421e6 100644 --- a/pkg/resources/account_parameter.go +++ b/pkg/resources/account_parameter.go @@ -2,6 +2,7 @@ package resources import ( "context" + "errors" "fmt" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" @@ -15,9 +16,10 @@ import ( var accountParameterSchema = map[string]*schema.Schema{ "key": { - Type: schema.TypeString, - Required: true, - ForceNew: true, + Type: schema.TypeString, + Required: true, + ForceNew: true, + // TODO(after Janek's PR): validate the parameter name Description: "Name of account parameter. Valid values are those in [account parameters](https://docs.snowflake.com/en/sql-reference/parameters.html#account-parameters).", }, "value": { @@ -42,7 +44,7 @@ func AccountParameter() *schema.Resource { } // CreateAccountParameter implements schema.CreateFunc. -func CreateAccountParameter(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { +func CreateAccountParameter(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { client := meta.(*provider.Context).Client key := d.Get("key").(string) value := d.Get("value").(string) @@ -56,31 +58,30 @@ func CreateAccountParameter(ctx context.Context, d *schema.ResourceData, meta in } // ReadAccountParameter implements schema.ReadFunc. -func ReadAccountParameter(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { +func ReadAccountParameter(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { client := meta.(*provider.Context).Client parameterName := d.Id() parameter, err := client.Parameters.ShowAccountParameter(ctx, sdk.AccountParameter(parameterName)) if err != nil { return diag.FromErr(fmt.Errorf("error reading account parameter err = %w", err)) } - err = d.Set("value", parameter.Value) - if err != nil { - return diag.FromErr(fmt.Errorf("error setting account parameter err = %w", err)) - } - err = d.Set("key", parameter.Key) - if err != nil { - return diag.FromErr(fmt.Errorf("error setting account parameter err = %w", err)) + errs := errors.Join( + d.Set("value", parameter.Value), + d.Set("key", parameter.Key), + ) + if errs != nil { + return diag.FromErr(errs) } return nil } // UpdateAccountParameter implements schema.UpdateFunc. -func UpdateAccountParameter(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { +func UpdateAccountParameter(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { return CreateAccountParameter(ctx, d, meta) } // DeleteAccountParameter implements schema.DeleteFunc. -func DeleteAccountParameter(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { +func DeleteAccountParameter(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { client := meta.(*provider.Context).Client key := d.Get("key").(string) parameter := sdk.AccountParameter(key) @@ -89,6 +90,7 @@ func DeleteAccountParameter(ctx context.Context, d *schema.ResourceData, meta in return diag.FromErr(err) } defaultValue := defaultParameter.Default + // TODO: use unset err = client.Parameters.SetAccountParameter(ctx, parameter, defaultValue) if err != nil { return diag.FromErr(fmt.Errorf("error resetting account parameter err = %w", err)) From 31d43e0e601422d4db04ad2debb4594a4e128c3f Mon Sep 17 00:00:00 2001 From: Jakub Michalak Date: Tue, 10 Dec 2024 15:46:18 +0100 Subject: [PATCH 2/6] Rework --- MIGRATION_GUIDE.md | 8 + .../resourceassert/gen/resource_schema_def.go | 4 + pkg/resources/account_parameter.go | 44 ++-- .../account_parameter_acceptance_test.go | 3 - pkg/sdk/parameters.go | 221 +++++++++++++++++- pkg/sdk/parameters_impl.go | 8 +- pkg/sdk/parameters_test.go | 116 +++++++++ templates/resources/account_parameter.md.tmpl | 37 +++ 8 files changed, 413 insertions(+), 28 deletions(-) create mode 100644 templates/resources/account_parameter.md.tmpl diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index dbfef7d7f6..c1f70ee820 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -9,6 +9,14 @@ across different versions. ## v0.99.0 ➞ v0.100.0 +### snowflake_account_parameter resource changes + +#### *(behavior change)* resource deletion +During resource deleting, provider now uses `UNSET` instead of `SET` with the default value. + +#### *(behavior change)* changes in `key` field +The value of `key` field is now case-insensitive and is validated. The list of supported values is available in the resource documentation. + ### snowflake_tag_association resource changes #### *(behavior change)* new id format In order to provide more functionality for tagging objects, we have changed the resource id from `"TAG_DATABASE"."TAG_SCHEMA"."TAG_NAME"` to `"TAG_DATABASE"."TAG_SCHEMA"."TAG_NAME"|TAG_VALUE|OBJECT_TYPE`. This allows to group tags associations per tag ID, tag value and object type in one resource. diff --git a/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go b/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go index 2c48ff623c..905f8be0b1 100644 --- a/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/gen/resource_schema_def.go @@ -121,4 +121,8 @@ var allResourceSchemaDefs = []ResourceSchemaDef{ name: "Account", schema: resources.Account().Schema, }, + { + name: "AccountParameter", + schema: resources.AccountParameter().Schema, + }, } diff --git a/pkg/resources/account_parameter.go b/pkg/resources/account_parameter.go index 9b313421e6..f8a782b1f2 100644 --- a/pkg/resources/account_parameter.go +++ b/pkg/resources/account_parameter.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -16,16 +17,17 @@ import ( var accountParameterSchema = map[string]*schema.Schema{ "key": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - // TODO(after Janek's PR): validate the parameter name - Description: "Name of account parameter. Valid values are those in [account parameters](https://docs.snowflake.com/en/sql-reference/parameters.html#account-parameters).", + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateDiagFunc: sdkValidation(sdk.ToAccountParameter), + DiffSuppressFunc: NormalizeAndCompare(sdk.ToAccountParameter), + Description: fmt.Sprintf("Name of account parameter. Valid values are (case-insensitive): %s.", possibleValuesListed(sdk.AsStringList(sdk.AllAccountParameters))), }, "value": { Type: schema.TypeString, Required: true, - Description: "Value of account parameter, as a string. Constraints are the same as those for the parameters in Snowflake documentation.", + Description: "Value of account parameter, as a string. Constraints are the same as those for the parameters in Snowflake documentation. The parameter values are validated in Snowflake.", }, } @@ -36,6 +38,8 @@ func AccountParameter() *schema.Resource { UpdateContext: TrackingUpdateWrapper(resources.AccountParameter, UpdateAccountParameter), DeleteContext: TrackingDeleteWrapper(resources.AccountParameter, DeleteAccountParameter), + Description: "Resource used to manage current account parameters. For more information, check [parameters documentation](https://docs.snowflake.com/en/sql-reference/parameters).", + Schema: accountParameterSchema, Importer: &schema.ResourceImporter{ StateContext: schema.ImportStatePassthroughContext, @@ -48,22 +52,29 @@ func CreateAccountParameter(ctx context.Context, d *schema.ResourceData, meta an client := meta.(*provider.Context).Client key := d.Get("key").(string) value := d.Get("value").(string) - parameter := sdk.AccountParameter(key) - err := client.Parameters.SetAccountParameter(ctx, parameter, value) + parameter, err := sdk.ToAccountParameter(key) + if err != nil { + return diag.FromErr(err) + } + err = client.Parameters.SetAccountParameter(ctx, parameter, value) if err != nil { return diag.FromErr(err) } - d.SetId(key) + d.SetId(helpers.EncodeResourceIdentifier(string(parameter))) return ReadAccountParameter(ctx, d, meta) } // ReadAccountParameter implements schema.ReadFunc. func ReadAccountParameter(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { client := meta.(*provider.Context).Client - parameterName := d.Id() + parameterNameRaw := d.Id() + parameterName, err := sdk.ToAccountParameter(parameterNameRaw) + if err != nil { + return diag.FromErr(err) + } parameter, err := client.Parameters.ShowAccountParameter(ctx, sdk.AccountParameter(parameterName)) if err != nil { - return diag.FromErr(fmt.Errorf("error reading account parameter err = %w", err)) + return diag.FromErr(fmt.Errorf("reading account parameter: %w", err)) } errs := errors.Join( d.Set("value", parameter.Value), @@ -85,15 +96,10 @@ func DeleteAccountParameter(ctx context.Context, d *schema.ResourceData, meta an client := meta.(*provider.Context).Client key := d.Get("key").(string) parameter := sdk.AccountParameter(key) - defaultParameter, err := client.Parameters.ShowAccountParameter(ctx, sdk.AccountParameter(key)) - if err != nil { - return diag.FromErr(err) - } - defaultValue := defaultParameter.Default - // TODO: use unset - err = client.Parameters.SetAccountParameter(ctx, parameter, defaultValue) + + err := client.Parameters.UnsetAccountParameter(ctx, parameter) if err != nil { - return diag.FromErr(fmt.Errorf("error resetting account parameter err = %w", err)) + return diag.FromErr(fmt.Errorf("unsetting account parameter: %w", err)) } d.SetId("") diff --git a/pkg/resources/account_parameter_acceptance_test.go b/pkg/resources/account_parameter_acceptance_test.go index 8b269e8983..7af59dc238 100644 --- a/pkg/resources/account_parameter_acceptance_test.go +++ b/pkg/resources/account_parameter_acceptance_test.go @@ -80,9 +80,7 @@ func TestAcc_AccountParameter_REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION(t * }) } -// TODO [SNOW-1528546]: unskip func TestAcc_AccountParameter_Issue2573(t *testing.T) { - t.Skipf("The cleanup for parameter is currently incorrect and this test messes with other ones. Skipping until SNOW-1528546 is resolved.") resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories, PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -109,7 +107,6 @@ func TestAcc_AccountParameter_Issue2573(t *testing.T) { } func TestAcc_AccountParameter_Issue3025(t *testing.T) { - t.Skipf("The cleanup for parameter is currently incorrect and this test messes with other ones. Skipping until SNOW-1528546 is resolved.") resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories, PreCheck: func() { acc.TestAccPreCheck(t) }, diff --git a/pkg/sdk/parameters.go b/pkg/sdk/parameters.go index b651b673f3..13576c4b72 100644 --- a/pkg/sdk/parameters.go +++ b/pkg/sdk/parameters.go @@ -5,6 +5,7 @@ import ( "database/sql" "errors" "fmt" + "slices" "strconv" "strings" ) @@ -22,6 +23,7 @@ var _ Parameters = (*parameters)(nil) type Parameters interface { SetAccountParameter(ctx context.Context, parameter AccountParameter, value string) error + UnsetAccountParameter(ctx context.Context, parameter AccountParameter) error SetSessionParameterOnAccount(ctx context.Context, parameter SessionParameter, value string) error SetSessionParameterOnUser(ctx context.Context, userID AccountObjectIdentifier, parameter SessionParameter, value string) error SetObjectParameterOnAccount(ctx context.Context, parameter ObjectParameter, value string) error @@ -174,6 +176,63 @@ func (parameters *parameters) SetAccountParameter(ctx context.Context, parameter return nil } +func (parameters *parameters) UnsetAccountParameter(ctx context.Context, parameter AccountParameter) error { + opts := AlterAccountOptions{ + Unset: &AccountUnset{ + Parameters: &AccountLevelParametersUnset{ + AccountParameters: &AccountParametersUnset{}, + }, + }, + } + switch parameter { + case AccountParameterAllowClientMFACaching: + opts.Unset.Parameters.AccountParameters.AllowClientMFACaching = Pointer(true) + case AccountParameterAllowIDToken: + opts.Unset.Parameters.AccountParameters.AllowIDToken = Pointer(true) + case AccountParameterClientEncryptionKeySize: + opts.Unset.Parameters.AccountParameters.ClientEncryptionKeySize = Pointer(true) + case AccountParameterEnableIdentifierFirstLogin: + opts.Unset.Parameters.AccountParameters.EnableIdentifierFirstLogin = Pointer(true) + case AccountParameterEnableInternalStagesPrivatelink: + opts.Unset.Parameters.AccountParameters.EnableInternalStagesPrivatelink = Pointer(true) + case AccountParameterEnableTriSecretAndRekeyOptOutForImageRepository: + opts.Unset.Parameters.AccountParameters.EnableTriSecretAndRekeyOptOutForImageRepository = Pointer(true) + case AccountParameterEnableTriSecretAndRekeyOptOutForSpcsBlockStorage: + opts.Unset.Parameters.AccountParameters.EnableTriSecretAndRekeyOptOutForSpcsBlockStorage = Pointer(true) + case AccountParameterEnableUnredactedQuerySyntaxError: + opts.Unset.Parameters.AccountParameters.EnableUnredactedQuerySyntaxError = Pointer(true) + case AccountParameterEventTable: + opts.Unset.Parameters.AccountParameters.EventTable = Pointer(true) + case AccountParameterExternalOAuthAddPrivilegedRolesToBlockedList: + opts.Unset.Parameters.AccountParameters.ExternalOAuthAddPrivilegedRolesToBlockedList = Pointer(true) + case AccountParameterInitialReplicationSizeLimitInTB: + opts.Unset.Parameters.AccountParameters.InitialReplicationSizeLimitInTB = Pointer(true) + case AccountParameterMinDataRetentionTimeInDays: + opts.Unset.Parameters.AccountParameters.MinDataRetentionTimeInDays = Pointer(true) + case AccountParameterNetworkPolicy: + opts.Unset.Parameters.AccountParameters.NetworkPolicy = Pointer(true) + case AccountParameterOAuthAddPrivilegedRolesToBlockedList: + opts.Unset.Parameters.AccountParameters.OAuthAddPrivilegedRolesToBlockedList = Pointer(true) + case AccountParameterPeriodicDataRekeying: + opts.Unset.Parameters.AccountParameters.PeriodicDataRekeying = Pointer(true) + case AccountParameterPreventLoadFromInlineURL: + opts.Unset.Parameters.AccountParameters.PreventLoadFromInlineURL = Pointer(true) + case AccountParameterPreventUnloadToInlineURL: + opts.Unset.Parameters.AccountParameters.PreventUnloadToInlineURL = Pointer(true) + case AccountParameterPreventUnloadToInternalStages: + opts.Unset.Parameters.AccountParameters.PreventUnloadToInternalStages = Pointer(true) + case AccountParameterRequireStorageIntegrationForStageCreation: + opts.Unset.Parameters.AccountParameters.RequireStorageIntegrationForStageCreation = Pointer(true) + case AccountParameterRequireStorageIntegrationForStageOperation: + opts.Unset.Parameters.AccountParameters.RequireStorageIntegrationForStageOperation = Pointer(true) + case AccountParameterSSOLoginPage: + opts.Unset.Parameters.AccountParameters.SSOLoginPage = Pointer(true) + default: + return parameters.UnsetSessionParameterOnAccount(ctx, SessionParameter(parameter)) + } + return parameters.client.Accounts.Alter(ctx, &opts) +} + func (parameters *parameters) SetSessionParameterOnAccount(ctx context.Context, parameter SessionParameter, value string) error { sp := &SessionParameters{} err := sp.setParam(parameter, value) @@ -192,6 +251,24 @@ func (parameters *parameters) SetSessionParameterOnAccount(ctx context.Context, } } +func (parameters *parameters) UnsetSessionParameterOnAccount(ctx context.Context, parameter SessionParameter) error { + sp := &SessionParametersUnset{} + err := sp.setParam(parameter) + if err == nil { + opts := AlterAccountOptions{Unset: &AccountUnset{Parameters: &AccountLevelParametersUnset{SessionParameters: sp}}} + err = parameters.client.Accounts.Alter(ctx, &opts) + if err != nil { + return err + } + return nil + } else { + if strings.Contains(err.Error(), "session parameter is not supported") { + return parameters.UnsetObjectParameterOnAccount(ctx, ObjectParameter(parameter)) + } + return err + } +} + func (parameters *parameters) SetSessionParameterOnUser(ctx context.Context, userId AccountObjectIdentifier, parameter SessionParameter, value string) error { sp := &SessionParameters{} err := sp.setParam(parameter, value) @@ -297,6 +374,49 @@ func (parameters *parameters) SetObjectParameterOnAccount(ctx context.Context, p return nil } +func (parameters *parameters) UnsetObjectParameterOnAccount(ctx context.Context, parameter ObjectParameter) error { + opts := AlterAccountOptions{Unset: &AccountUnset{Parameters: &AccountLevelParametersUnset{ObjectParameters: &ObjectParametersUnset{}}}} + switch parameter { + case ObjectParameterCatalog: + opts.Unset.Parameters.ObjectParameters.Catalog = Pointer(true) + case ObjectParameterDataRetentionTimeInDays: + opts.Unset.Parameters.ObjectParameters.DataRetentionTimeInDays = Pointer(true) + case ObjectParameterDefaultDDLCollation: + opts.Unset.Parameters.ObjectParameters.DefaultDDLCollation = Pointer(true) + case ObjectParameterLogLevel: + opts.Unset.Parameters.ObjectParameters.LogLevel = Pointer(true) + case ObjectParameterMaxConcurrencyLevel: + opts.Unset.Parameters.ObjectParameters.MaxConcurrencyLevel = Pointer(true) + case ObjectParameterMaxDataExtensionTimeInDays: + opts.Unset.Parameters.ObjectParameters.MaxDataExtensionTimeInDays = Pointer(true) + case ObjectParameterPipeExecutionPaused: + opts.Unset.Parameters.ObjectParameters.PipeExecutionPaused = Pointer(true) + case ObjectParameterPreventUnloadToInternalStages: + opts.Unset.Parameters.ObjectParameters.PreventUnloadToInternalStages = Pointer(true) + case ObjectParameterStatementQueuedTimeoutInSeconds: + opts.Unset.Parameters.ObjectParameters.StatementQueuedTimeoutInSeconds = Pointer(true) + case ObjectParameterStatementTimeoutInSeconds: + opts.Unset.Parameters.ObjectParameters.StatementTimeoutInSeconds = Pointer(true) + case ObjectParameterNetworkPolicy: + opts.Unset.Parameters.ObjectParameters.NetworkPolicy = Pointer(true) + case ObjectParameterShareRestrictions: + opts.Unset.Parameters.ObjectParameters.ShareRestrictions = Pointer(true) + case ObjectParameterSuspendTaskAfterNumFailures: + opts.Unset.Parameters.ObjectParameters.SuspendTaskAfterNumFailures = Pointer(true) + case ObjectParameterTraceLevel: + opts.Unset.Parameters.ObjectParameters.TraceLevel = Pointer(true) + case ObjectParameterUserTaskManagedInitialWarehouseSize: + opts.Unset.Parameters.ObjectParameters.UserTaskManagedInitialWarehouseSize = Pointer(true) + case ObjectParameterUserTaskTimeoutMs: + opts.Unset.Parameters.ObjectParameters.UserTaskTimeoutMs = Pointer(true) + case ObjectParameterEnableUnredactedQuerySyntaxError: + opts.Unset.Parameters.ObjectParameters.EnableUnredactedQuerySyntaxError = Pointer(true) + default: + return fmt.Errorf("invalid object parameter: %v", string(parameter)) + } + return parameters.client.Accounts.Alter(ctx, &opts) +} + type setParameterOnObject struct { alter bool `ddl:"static" sql:"ALTER"` objectType ObjectType `ddl:"keyword"` @@ -344,6 +464,7 @@ type AccountParameter string // https://docs.snowflake.com/en/sql-reference/parameters#parameter-hierarchy-and-types // Account Parameters include Session Parameters, Object Parameters and User Parameters const ( + // TODO(next pr): add remaining parameters // Account Parameters AccountParameterAllowClientMFACaching AccountParameter = "ALLOW_CLIENT_MFA_CACHING" AccountParameterAllowIDToken AccountParameter = "ALLOW_ID_TOKEN" // #nosec G101 @@ -375,10 +496,10 @@ const ( AccountParameterClientMetadataUseSessionDatabase AccountParameter = "CLIENT_METADATA_USE_SESSION_DATABASE" AccountParameterClientResultColumnCaseInsensitive AccountParameter = "CLIENT_RESULT_COLUMN_CASE_INSENSITIVE" AccountParameterDateInputFormat AccountParameter = "DATE_INPUT_FORMAT" - AccountParameterGeographyOutputFormat AccountParameter = "GEOGRAPHY_OUTPUT_FORMAT" AccountParameterDateOutputFormat AccountParameter = "DATE_OUTPUT_FORMAT" AccountParameterErrorOnNondeterministicMerge AccountParameter = "ERROR_ON_NONDETERMINISTIC_MERGE" AccountParameterErrorOnNondeterministicUpdate AccountParameter = "ERROR_ON_NONDETERMINISTIC_UPDATE" + AccountParameterGeographyOutputFormat AccountParameter = "GEOGRAPHY_OUTPUT_FORMAT" AccountParameterJSONIndent AccountParameter = "JSON_INDENT" AccountParameterLockTimeout AccountParameter = "LOCK_TIMEOUT" AccountParameterMultiStatementCount AccountParameter = "MULTI_STATEMENT_COUNT" @@ -433,6 +554,97 @@ const ( AccountParameterEnableUnredactedQuerySyntaxError AccountParameter = "ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR" ) +var AllAccountParameters = []AccountParameter{ + AccountParameterAllowClientMFACaching, + AccountParameterAllowIDToken, + AccountParameterClientEncryptionKeySize, + AccountParameterEnableIdentifierFirstLogin, + AccountParameterEnableInternalStagesPrivatelink, + AccountParameterEnableTriSecretAndRekeyOptOutForImageRepository, + AccountParameterEnableTriSecretAndRekeyOptOutForSpcsBlockStorage, + AccountParameterEventTable, + AccountParameterExternalOAuthAddPrivilegedRolesToBlockedList, + AccountParameterInitialReplicationSizeLimitInTB, + AccountParameterMinDataRetentionTimeInDays, + AccountParameterNetworkPolicy, + AccountParameterOAuthAddPrivilegedRolesToBlockedList, + AccountParameterPeriodicDataRekeying, + AccountParameterPreventLoadFromInlineURL, + AccountParameterPreventUnloadToInlineURL, + AccountParameterPreventUnloadToInternalStages, + AccountParameterRequireStorageIntegrationForStageCreation, + AccountParameterRequireStorageIntegrationForStageOperation, + AccountParameterSSOLoginPage, + AccountParameterAbortDetachedQuery, + AccountParameterAutocommit, + AccountParameterBinaryInputFormat, + AccountParameterBinaryOutputFormat, + AccountParameterClientMetadataRequestUseConnectionCtx, + AccountParameterClientMetadataUseSessionDatabase, + AccountParameterClientResultColumnCaseInsensitive, + AccountParameterDateInputFormat, + AccountParameterDateOutputFormat, + AccountParameterErrorOnNondeterministicMerge, + AccountParameterErrorOnNondeterministicUpdate, + AccountParameterGeographyOutputFormat, + AccountParameterJSONIndent, + AccountParameterLockTimeout, + AccountParameterMultiStatementCount, + AccountParameterQueryTag, + AccountParameterQuotedIdentifiersIgnoreCase, + AccountParameterRowsPerResultset, + AccountParameterS3StageVpceDnsName, + AccountParameterSimulatedDataSharingConsumer, + AccountParameterStatementTimeoutInSeconds, + AccountParameterStrictJSONOutput, + AccountParameterTimeInputFormat, + AccountParameterTimeOutputFormat, + AccountParameterTimestampDayIsAlways24h, + AccountParameterTimestampInputFormat, + AccountParameterTimestampLtzOutputFormat, + AccountParameterTimestampNtzOutputFormat, + AccountParameterTimestampOutputFormat, + AccountParameterTimestampTypeMapping, + AccountParameterTimestampTzOutputFormat, + AccountParameterTimezone, + AccountParameterTransactionAbortOnError, + AccountParameterTransactionDefaultIsolationLevel, + AccountParameterTwoDigitCenturyStart, + AccountParameterUnsupportedDdlAction, + AccountParameterUseCachedResult, + AccountParameterWeekOfYearPolicy, + AccountParameterWeekStart, + AccountParameterCatalog, + AccountParameterDataRetentionTimeInDays, + AccountParameterDefaultDDLCollation, + AccountParameterExternalVolume, + AccountParameterLogLevel, + AccountParameterMaxConcurrencyLevel, + AccountParameterMaxDataExtensionTimeInDays, + AccountParameterPipeExecutionPaused, + AccountParameterReplaceInvalidCharacters, + AccountParameterStatementQueuedTimeoutInSeconds, + AccountParameterStorageSerializationPolicy, + AccountParameterShareRestrictions, + AccountParameterSuspendTaskAfterNumFailures, + AccountParameterTraceLevel, + AccountParameterUserTaskManagedInitialWarehouseSize, + AccountParameterUserTaskTimeoutMs, + AccountParameterTaskAutoRetryAttempts, + AccountParameterUserTaskMinimumTriggerIntervalInSeconds, + AccountParameterMetricLevel, + AccountParameterEnableConsoleOutput, + AccountParameterEnableUnredactedQuerySyntaxError, +} + +func ToAccountParameter(s string) (AccountParameter, error) { + s = strings.ToUpper(s) + if !slices.Contains(AllAccountParameters, AccountParameter(s)) { + return "", fmt.Errorf("invalid account parameter: %s", s) + } + return AccountParameter(s), nil +} + type SessionParameter string const ( @@ -898,11 +1110,14 @@ type AccountParametersUnset struct { EnableTriSecretAndRekeyOptOutForImageRepository *bool `ddl:"keyword" sql:"ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_IMAGE_REPOSITORY"` EnableTriSecretAndRekeyOptOutForSpcsBlockStorage *bool `ddl:"keyword" sql:"ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_SPCS_BLOCK_STORAGE"` EventTable *bool `ddl:"keyword" sql:"EVENT_TABLE"` + EnableUnredactedQuerySyntaxError *bool `ddl:"keyword" sql:"ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR"` ExternalOAuthAddPrivilegedRolesToBlockedList *bool `ddl:"keyword" sql:"EXTERNAL_OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST"` InitialReplicationSizeLimitInTB *bool `ddl:"keyword" sql:"INITIAL_REPLICATION_SIZE_LIMIT_IN_TB"` MinDataRetentionTimeInDays *bool `ddl:"keyword" sql:"MIN_DATA_RETENTION_TIME_IN_DAYS"` NetworkPolicy *bool `ddl:"keyword" sql:"NETWORK_POLICY"` + OAuthAddPrivilegedRolesToBlockedList *bool `ddl:"keyword" sql:"OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST"` PeriodicDataRekeying *bool `ddl:"keyword" sql:"PERIODIC_DATA_REKEYING"` + PreventLoadFromInlineURL *bool `ddl:"keyword" sql:"PREVENT_LOAD_FROM_INLINE_URL"` PreventUnloadToInlineURL *bool `ddl:"keyword" sql:"PREVENT_UNLOAD_TO_INLINE_URL"` PreventUnloadToInternalStages *bool `ddl:"keyword" sql:"PREVENT_UNLOAD_TO_INTERNAL_STAGES"` RequireStorageIntegrationForStageCreation *bool `ddl:"keyword" sql:"REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION"` @@ -1243,6 +1458,7 @@ func (v *SessionParametersUnset) validate() error { // ObjectParameters is based on https://docs.snowflake.com/en/sql-reference/parameters#object-parameters. type ObjectParameters struct { + Catalog *string `ddl:"parameter" sql:"CATALOG"` DataRetentionTimeInDays *int `ddl:"parameter" sql:"DATA_RETENTION_TIME_IN_DAYS"` DefaultDDLCollation *string `ddl:"parameter,single_quotes" sql:"DEFAULT_DDL_COLLATION"` EnableUnredactedQuerySyntaxError *bool `ddl:"parameter" sql:"ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR"` @@ -1259,7 +1475,6 @@ type ObjectParameters struct { TraceLevel *TraceLevel `ddl:"parameter" sql:"TRACE_LEVEL"` UserTaskManagedInitialWarehouseSize *WarehouseSize `ddl:"parameter" sql:"USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE"` UserTaskTimeoutMs *int `ddl:"parameter" sql:"USER_TASK_TIMEOUT_MS"` - Catalog *string `ddl:"parameter" sql:"CATALOG"` } func (v *ObjectParameters) validate() error { @@ -1303,8 +1518,10 @@ func (v *ObjectParameters) validate() error { } type ObjectParametersUnset struct { + Catalog *bool `ddl:"keyword" sql:"CATALOG"` DataRetentionTimeInDays *bool `ddl:"keyword" sql:"DATA_RETENTION_TIME_IN_DAYS"` DefaultDDLCollation *bool `ddl:"keyword" sql:"DEFAULT_DDL_COLLATION"` + EnableUnredactedQuerySyntaxError *bool `ddl:"keyword" sql:"ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR"` LogLevel *bool `ddl:"keyword" sql:"LOG_LEVEL"` MaxConcurrencyLevel *bool `ddl:"keyword" sql:"MAX_CONCURRENCY_LEVEL"` MaxDataExtensionTimeInDays *bool `ddl:"keyword" sql:"MAX_DATA_EXTENSION_TIME_IN_DAYS"` diff --git a/pkg/sdk/parameters_impl.go b/pkg/sdk/parameters_impl.go index 098e9e1d03..d01af6d161 100644 --- a/pkg/sdk/parameters_impl.go +++ b/pkg/sdk/parameters_impl.go @@ -187,14 +187,14 @@ func (sessionParametersUnset *SessionParametersUnset) setParam(parameter Session unsetField = &sessionParametersUnset.ClientMemoryLimit case SessionParameterClientMetadataRequestUseConnectionCtx: unsetField = &sessionParametersUnset.ClientMetadataRequestUseConnectionCtx + case SessionParameterClientMetadataUseSessionDatabase: + unsetField = &sessionParametersUnset.ClientMetadataUseSessionDatabase + case SessionParameterClientResultColumnCaseInsensitive: + unsetField = &sessionParametersUnset.ClientResultColumnCaseInsensitive case SessionParameterClientPrefetchThreads: unsetField = &sessionParametersUnset.ClientPrefetchThreads case SessionParameterClientResultChunkSize: unsetField = &sessionParametersUnset.ClientResultChunkSize - case SessionParameterClientResultColumnCaseInsensitive: - unsetField = &sessionParametersUnset.ClientResultColumnCaseInsensitive - case SessionParameterClientMetadataUseSessionDatabase: - unsetField = &sessionParametersUnset.ClientMetadataUseSessionDatabase case SessionParameterClientSessionKeepAlive: unsetField = &sessionParametersUnset.ClientSessionKeepAlive case SessionParameterClientSessionKeepAliveHeartbeatFrequency: diff --git a/pkg/sdk/parameters_test.go b/pkg/sdk/parameters_test.go index f7f1a88233..a288f9eee5 100644 --- a/pkg/sdk/parameters_test.go +++ b/pkg/sdk/parameters_test.go @@ -2,6 +2,8 @@ package sdk import ( "testing" + + "github.com/stretchr/testify/require" ) // TODO: add more tests @@ -51,3 +53,117 @@ func TestUnSetObjectParameterNetworkPolicyOnUser(t *testing.T) { assertOptsValidAndSQLEquals(t, opts, `ALTER USER "TEST_USER" UNSET NETWORK_POLICY`) }) } + +func TestToAccountParameter(t *testing.T) { + type test struct { + input string + want AccountParameter + } + + valid := []test{ + // Case insensitive. + {input: "allow_client_mfa_caching", want: AccountParameterAllowClientMFACaching}, + + // Supported Values. + {input: "ALLOW_CLIENT_MFA_CACHING", want: AccountParameterAllowClientMFACaching}, + {input: "ALLOW_ID_TOKEN", want: AccountParameterAllowIDToken}, + {input: "CLIENT_ENCRYPTION_KEY_SIZE", want: AccountParameterClientEncryptionKeySize}, + {input: "ENABLE_IDENTIFIER_FIRST_LOGIN", want: AccountParameterEnableIdentifierFirstLogin}, + {input: "ENABLE_INTERNAL_STAGES_PRIVATELINK", want: AccountParameterEnableInternalStagesPrivatelink}, + {input: "ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_IMAGE_REPOSITORY", want: AccountParameterEnableTriSecretAndRekeyOptOutForImageRepository}, + {input: "ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_SPCS_BLOCK_STORAGE", want: AccountParameterEnableTriSecretAndRekeyOptOutForSpcsBlockStorage}, + {input: "EVENT_TABLE", want: AccountParameterEventTable}, + {input: "EXTERNAL_OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST", want: AccountParameterExternalOAuthAddPrivilegedRolesToBlockedList}, + {input: "INITIAL_REPLICATION_SIZE_LIMIT_IN_TB", want: AccountParameterInitialReplicationSizeLimitInTB}, + {input: "MIN_DATA_RETENTION_TIME_IN_DAYS", want: AccountParameterMinDataRetentionTimeInDays}, + {input: "NETWORK_POLICY", want: AccountParameterNetworkPolicy}, + {input: "OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST", want: AccountParameterOAuthAddPrivilegedRolesToBlockedList}, + {input: "PERIODIC_DATA_REKEYING", want: AccountParameterPeriodicDataRekeying}, + {input: "PREVENT_LOAD_FROM_INLINE_URL", want: AccountParameterPreventLoadFromInlineURL}, + {input: "PREVENT_UNLOAD_TO_INLINE_URL", want: AccountParameterPreventUnloadToInlineURL}, + {input: "PREVENT_UNLOAD_TO_INTERNAL_STAGES", want: AccountParameterPreventUnloadToInternalStages}, + {input: "REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION", want: AccountParameterRequireStorageIntegrationForStageCreation}, + {input: "REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_OPERATION", want: AccountParameterRequireStorageIntegrationForStageOperation}, + {input: "SSO_LOGIN_PAGE", want: AccountParameterSSOLoginPage}, + {input: "ABORT_DETACHED_QUERY", want: AccountParameterAbortDetachedQuery}, + {input: "AUTOCOMMIT", want: AccountParameterAutocommit}, + {input: "BINARY_INPUT_FORMAT", want: AccountParameterBinaryInputFormat}, + {input: "BINARY_OUTPUT_FORMAT", want: AccountParameterBinaryOutputFormat}, + {input: "CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX", want: AccountParameterClientMetadataRequestUseConnectionCtx}, + {input: "CLIENT_METADATA_USE_SESSION_DATABASE", want: AccountParameterClientMetadataUseSessionDatabase}, + {input: "CLIENT_RESULT_COLUMN_CASE_INSENSITIVE", want: AccountParameterClientResultColumnCaseInsensitive}, + {input: "DATE_INPUT_FORMAT", want: AccountParameterDateInputFormat}, + {input: "DATE_OUTPUT_FORMAT", want: AccountParameterDateOutputFormat}, + {input: "ERROR_ON_NONDETERMINISTIC_MERGE", want: AccountParameterErrorOnNondeterministicMerge}, + {input: "ERROR_ON_NONDETERMINISTIC_UPDATE", want: AccountParameterErrorOnNondeterministicUpdate}, + {input: "GEOGRAPHY_OUTPUT_FORMAT", want: AccountParameterGeographyOutputFormat}, + {input: "JSON_INDENT", want: AccountParameterJSONIndent}, + {input: "LOCK_TIMEOUT", want: AccountParameterLockTimeout}, + {input: "MULTI_STATEMENT_COUNT", want: AccountParameterMultiStatementCount}, + {input: "QUERY_TAG", want: AccountParameterQueryTag}, + {input: "QUOTED_IDENTIFIERS_IGNORE_CASE", want: AccountParameterQuotedIdentifiersIgnoreCase}, + {input: "ROWS_PER_RESULTSET", want: AccountParameterRowsPerResultset}, + {input: "S3_STAGE_VPCE_DNS_NAME", want: AccountParameterS3StageVpceDnsName}, + {input: "SIMULATED_DATA_SHARING_CONSUMER", want: AccountParameterSimulatedDataSharingConsumer}, + {input: "STATEMENT_TIMEOUT_IN_SECONDS", want: AccountParameterStatementTimeoutInSeconds}, + {input: "STRICT_JSON_OUTPUT", want: AccountParameterStrictJSONOutput}, + {input: "TIME_INPUT_FORMAT", want: AccountParameterTimeInputFormat}, + {input: "TIME_OUTPUT_FORMAT", want: AccountParameterTimeOutputFormat}, + {input: "TIMESTAMP_DAY_IS_ALWAYS_24H", want: AccountParameterTimestampDayIsAlways24h}, + {input: "TIMESTAMP_INPUT_FORMAT", want: AccountParameterTimestampInputFormat}, + {input: "TIMESTAMP_LTZ_OUTPUT_FORMAT", want: AccountParameterTimestampLtzOutputFormat}, + {input: "TIMESTAMP_NTZ_OUTPUT_FORMAT", want: AccountParameterTimestampNtzOutputFormat}, + {input: "TIMESTAMP_OUTPUT_FORMAT", want: AccountParameterTimestampOutputFormat}, + {input: "TIMESTAMP_TYPE_MAPPING", want: AccountParameterTimestampTypeMapping}, + {input: "TIMESTAMP_TZ_OUTPUT_FORMAT", want: AccountParameterTimestampTzOutputFormat}, + {input: "TIMEZONE", want: AccountParameterTimezone}, + {input: "TRANSACTION_ABORT_ON_ERROR", want: AccountParameterTransactionAbortOnError}, + {input: "TRANSACTION_DEFAULT_ISOLATION_LEVEL", want: AccountParameterTransactionDefaultIsolationLevel}, + {input: "TWO_DIGIT_CENTURY_START", want: AccountParameterTwoDigitCenturyStart}, + {input: "UNSUPPORTED_DDL_ACTION", want: AccountParameterUnsupportedDdlAction}, + {input: "USE_CACHED_RESULT", want: AccountParameterUseCachedResult}, + {input: "WEEK_OF_YEAR_POLICY", want: AccountParameterWeekOfYearPolicy}, + {input: "WEEK_START", want: AccountParameterWeekStart}, + {input: "CATALOG", want: AccountParameterCatalog}, + {input: "DATA_RETENTION_TIME_IN_DAYS", want: AccountParameterDataRetentionTimeInDays}, + {input: "DEFAULT_DDL_COLLATION", want: AccountParameterDefaultDDLCollation}, + {input: "EXTERNAL_VOLUME", want: AccountParameterExternalVolume}, + {input: "LOG_LEVEL", want: AccountParameterLogLevel}, + {input: "MAX_CONCURRENCY_LEVEL", want: AccountParameterMaxConcurrencyLevel}, + {input: "MAX_DATA_EXTENSION_TIME_IN_DAYS", want: AccountParameterMaxDataExtensionTimeInDays}, + {input: "PIPE_EXECUTION_PAUSED", want: AccountParameterPipeExecutionPaused}, + {input: "REPLACE_INVALID_CHARACTERS", want: AccountParameterReplaceInvalidCharacters}, + {input: "STATEMENT_QUEUED_TIMEOUT_IN_SECONDS", want: AccountParameterStatementQueuedTimeoutInSeconds}, + {input: "STORAGE_SERIALIZATION_POLICY", want: AccountParameterStorageSerializationPolicy}, + {input: "SHARE_RESTRICTIONS", want: AccountParameterShareRestrictions}, + {input: "SUSPEND_TASK_AFTER_NUM_FAILURES", want: AccountParameterSuspendTaskAfterNumFailures}, + {input: "TRACE_LEVEL", want: AccountParameterTraceLevel}, + {input: "USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE", want: AccountParameterUserTaskManagedInitialWarehouseSize}, + {input: "USER_TASK_TIMEOUT_MS", want: AccountParameterUserTaskTimeoutMs}, + {input: "TASK_AUTO_RETRY_ATTEMPTS", want: AccountParameterTaskAutoRetryAttempts}, + {input: "USER_TASK_MINIMUM_TRIGGER_INTERVAL_IN_SECONDS", want: AccountParameterUserTaskMinimumTriggerIntervalInSeconds}, + {input: "METRIC_LEVEL", want: AccountParameterMetricLevel}, + {input: "ENABLE_CONSOLE_OUTPUT", want: AccountParameterEnableConsoleOutput}, + {input: "ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR", want: AccountParameterEnableUnredactedQuerySyntaxError}, + } + + invalid := []test{ + {input: ""}, + {input: "foo"}, + } + + for _, tc := range valid { + t.Run(tc.input, func(t *testing.T) { + got, err := ToAccountParameter(tc.input) + require.NoError(t, err) + require.Equal(t, tc.want, got) + }) + } + + for _, tc := range invalid { + t.Run(tc.input, func(t *testing.T) { + _, err := ToAccountParameter(tc.input) + require.Error(t, err) + }) + } +} diff --git a/templates/resources/account_parameter.md.tmpl b/templates/resources/account_parameter.md.tmpl new file mode 100644 index 0000000000..15c1ee96c9 --- /dev/null +++ b/templates/resources/account_parameter.md.tmpl @@ -0,0 +1,37 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ if gt (len (split .Description "")) 1 -}} +{{ index (split .Description "") 1 | plainmarkdown | trimspace | prefixlines " " }} +{{- else -}} +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +{{- end }} +--- + +!> **V1 release candidate** This resource was reworked and is a release candidate for the V1. We do not expect significant changes in it before the V1. We will welcome any feedback and adjust the resource if needed. Any errors reported will be resolved with a higher priority. We encourage checking this resource out before the V1 release. Please follow the [migration guide](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/MIGRATION_GUIDE.md#v0990--v01000) to use it. + +-> **Note** This resource does not support all account parameters. The supported ones are listed below. This feature gap will be addressed in future releases. + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +{{ if .HasExample -}} +## Example Usage + +{{ tffile (printf "examples/resources/%s/resource.tf" .Name)}} +-> **Note** Instead of using fully_qualified_name, you can reference objects managed outside Terraform by constructing a correct ID, consult [identifiers guide](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/guides/identifiers#new-computed-fully-qualified-name-field-in-resources). + + +{{- end }} + +{{ .SchemaMarkdown | trimspace }} +{{- if .HasImport }} + +## Import + +Import is supported using the following syntax: + +{{ codefile "shell" (printf "examples/resources/%s/import.sh" .Name)}} +{{- end }} From 9406e0e51b39db0370a37c585bef2c20b5534698 Mon Sep 17 00:00:00 2001 From: Jakub Michalak Date: Tue, 10 Dec 2024 16:12:57 +0100 Subject: [PATCH 3/6] generate builders --- docs/resources/account_parameter.md | 15 ++-- .../account_parameter_resource_gen.go | 57 +++++++++++++++ .../model/account_parameter_model_gen.go | 70 +++++++++++++++++++ pkg/resources/account_parameter.go | 2 +- .../account_parameter_acceptance_test.go | 57 +++++++++------ pkg/sdk/parameters.go | 1 + 6 files changed, 173 insertions(+), 29 deletions(-) create mode 100644 pkg/acceptance/bettertestspoc/assert/resourceassert/account_parameter_resource_gen.go create mode 100644 pkg/acceptance/bettertestspoc/config/model/account_parameter_model_gen.go diff --git a/docs/resources/account_parameter.md b/docs/resources/account_parameter.md index 4607f52742..fb84bdc32f 100644 --- a/docs/resources/account_parameter.md +++ b/docs/resources/account_parameter.md @@ -2,12 +2,16 @@ page_title: "snowflake_account_parameter Resource - terraform-provider-snowflake" subcategory: "" description: |- - + Resource used to manage current account parameters. For more information, check parameters documentation https://docs.snowflake.com/en/sql-reference/parameters. --- -# snowflake_account_parameter (Resource) +!> **V1 release candidate** This resource was reworked and is a release candidate for the V1. We do not expect significant changes in it before the V1. We will welcome any feedback and adjust the resource if needed. Any errors reported will be resolved with a higher priority. We encourage checking this resource out before the V1 release. Please follow the [migration guide](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/MIGRATION_GUIDE.md#v0990--v01000) to use it. + +-> **Note** This resource does not support all account parameters. The supported ones are listed below. This feature gap will be addressed in future releases. +# snowflake_account_parameter (Resource) +Resource used to manage current account parameters. For more information, check [parameters documentation](https://docs.snowflake.com/en/sql-reference/parameters). ## Example Usage @@ -22,7 +26,6 @@ resource "snowflake_account_parameter" "p2" { value = "256" } ``` - -> **Note** Instead of using fully_qualified_name, you can reference objects managed outside Terraform by constructing a correct ID, consult [identifiers guide](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/guides/identifiers#new-computed-fully-qualified-name-field-in-resources). @@ -31,8 +34,8 @@ resource "snowflake_account_parameter" "p2" { ### Required -- `key` (String) Name of account parameter. Valid values are those in [account parameters](https://docs.snowflake.com/en/sql-reference/parameters.html#account-parameters). -- `value` (String) Value of account parameter, as a string. Constraints are the same as those for the parameters in Snowflake documentation. +- `key` (String) Name of account parameter. Valid values are (case-insensitive): `ALLOW_CLIENT_MFA_CACHING` | `ALLOW_ID_TOKEN` | `CLIENT_ENCRYPTION_KEY_SIZE` | `ENABLE_IDENTIFIER_FIRST_LOGIN` | `ENABLE_INTERNAL_STAGES_PRIVATELINK` | `ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_IMAGE_REPOSITORY` | `ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_SPCS_BLOCK_STORAGE` | `EVENT_TABLE` | `EXTERNAL_OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST` | `INITIAL_REPLICATION_SIZE_LIMIT_IN_TB` | `MIN_DATA_RETENTION_TIME_IN_DAYS` | `NETWORK_POLICY` | `OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST` | `PERIODIC_DATA_REKEYING` | `PREVENT_LOAD_FROM_INLINE_URL` | `PREVENT_UNLOAD_TO_INLINE_URL` | `PREVENT_UNLOAD_TO_INTERNAL_STAGES` | `REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION` | `REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_OPERATION` | `SSO_LOGIN_PAGE` | `ABORT_DETACHED_QUERY` | `AUTOCOMMIT` | `BINARY_INPUT_FORMAT` | `BINARY_OUTPUT_FORMAT` | `CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX` | `CLIENT_METADATA_USE_SESSION_DATABASE` | `CLIENT_RESULT_COLUMN_CASE_INSENSITIVE` | `DATE_INPUT_FORMAT` | `DATE_OUTPUT_FORMAT` | `ERROR_ON_NONDETERMINISTIC_MERGE` | `ERROR_ON_NONDETERMINISTIC_UPDATE` | `GEOGRAPHY_OUTPUT_FORMAT` | `JSON_INDENT` | `LOCK_TIMEOUT` | `MULTI_STATEMENT_COUNT` | `QUERY_TAG` | `QUOTED_IDENTIFIERS_IGNORE_CASE` | `ROWS_PER_RESULTSET` | `S3_STAGE_VPCE_DNS_NAME` | `SIMULATED_DATA_SHARING_CONSUMER` | `STATEMENT_TIMEOUT_IN_SECONDS` | `STRICT_JSON_OUTPUT` | `TIME_INPUT_FORMAT` | `TIME_OUTPUT_FORMAT` | `TIMESTAMP_DAY_IS_ALWAYS_24H` | `TIMESTAMP_INPUT_FORMAT` | `TIMESTAMP_LTZ_OUTPUT_FORMAT` | `TIMESTAMP_NTZ_OUTPUT_FORMAT` | `TIMESTAMP_OUTPUT_FORMAT` | `TIMESTAMP_TYPE_MAPPING` | `TIMESTAMP_TZ_OUTPUT_FORMAT` | `TIMEZONE` | `TRANSACTION_ABORT_ON_ERROR` | `TRANSACTION_DEFAULT_ISOLATION_LEVEL` | `TWO_DIGIT_CENTURY_START` | `UNSUPPORTED_DDL_ACTION` | `USE_CACHED_RESULT` | `WEEK_OF_YEAR_POLICY` | `WEEK_START` | `CATALOG` | `DATA_RETENTION_TIME_IN_DAYS` | `DEFAULT_DDL_COLLATION` | `EXTERNAL_VOLUME` | `LOG_LEVEL` | `MAX_CONCURRENCY_LEVEL` | `MAX_DATA_EXTENSION_TIME_IN_DAYS` | `PIPE_EXECUTION_PAUSED` | `REPLACE_INVALID_CHARACTERS` | `STATEMENT_QUEUED_TIMEOUT_IN_SECONDS` | `STORAGE_SERIALIZATION_POLICY` | `SHARE_RESTRICTIONS` | `SUSPEND_TASK_AFTER_NUM_FAILURES` | `TRACE_LEVEL` | `USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE` | `USER_TASK_TIMEOUT_MS` | `TASK_AUTO_RETRY_ATTEMPTS` | `USER_TASK_MINIMUM_TRIGGER_INTERVAL_IN_SECONDS` | `METRIC_LEVEL` | `ENABLE_CONSOLE_OUTPUT` | `ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR`. +- `value` (String) Value of account parameter, as a string. Constraints are the same as those for the parameters in Snowflake documentation. The parameter values are validated in Snowflake. ### Read-Only @@ -43,5 +46,5 @@ resource "snowflake_account_parameter" "p2" { Import is supported using the following syntax: ```shell -terraform import snowflake_account_parameter.p +terraform import snowflake_account_parameter.p '' ``` diff --git a/pkg/acceptance/bettertestspoc/assert/resourceassert/account_parameter_resource_gen.go b/pkg/acceptance/bettertestspoc/assert/resourceassert/account_parameter_resource_gen.go new file mode 100644 index 0000000000..a021e54a07 --- /dev/null +++ b/pkg/acceptance/bettertestspoc/assert/resourceassert/account_parameter_resource_gen.go @@ -0,0 +1,57 @@ +// Code generated by assertions generator; DO NOT EDIT. + +package resourceassert + +import ( + "testing" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" +) + +type AccountParameterResourceAssert struct { + *assert.ResourceAssert +} + +func AccountParameterResource(t *testing.T, name string) *AccountParameterResourceAssert { + t.Helper() + + return &AccountParameterResourceAssert{ + ResourceAssert: assert.NewResourceAssert(name, "resource"), + } +} + +func ImportedAccountParameterResource(t *testing.T, id string) *AccountParameterResourceAssert { + t.Helper() + + return &AccountParameterResourceAssert{ + ResourceAssert: assert.NewImportedResourceAssert(id, "imported resource"), + } +} + +/////////////////////////////////// +// Attribute value string checks // +/////////////////////////////////// + +func (a *AccountParameterResourceAssert) HasKeyString(expected string) *AccountParameterResourceAssert { + a.AddAssertion(assert.ValueSet("key", expected)) + return a +} + +func (a *AccountParameterResourceAssert) HasValueString(expected string) *AccountParameterResourceAssert { + a.AddAssertion(assert.ValueSet("value", expected)) + return a +} + +//////////////////////////// +// Attribute empty checks // +//////////////////////////// + +func (a *AccountParameterResourceAssert) HasNoKey() *AccountParameterResourceAssert { + a.AddAssertion(assert.ValueNotSet("key")) + return a +} + +func (a *AccountParameterResourceAssert) HasNoValue() *AccountParameterResourceAssert { + a.AddAssertion(assert.ValueNotSet("value")) + return a +} diff --git a/pkg/acceptance/bettertestspoc/config/model/account_parameter_model_gen.go b/pkg/acceptance/bettertestspoc/config/model/account_parameter_model_gen.go new file mode 100644 index 0000000000..9fc1cff42a --- /dev/null +++ b/pkg/acceptance/bettertestspoc/config/model/account_parameter_model_gen.go @@ -0,0 +1,70 @@ +// Code generated by config model builder generator; DO NOT EDIT. + +package model + +import ( + tfconfig "github.com/hashicorp/terraform-plugin-testing/config" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources" +) + +type AccountParameterModel struct { + Key tfconfig.Variable `json:"key,omitempty"` + Value tfconfig.Variable `json:"value,omitempty"` + + *config.ResourceModelMeta +} + +///////////////////////////////////////////////// +// Basic builders (resource name and required) // +///////////////////////////////////////////////// + +func AccountParameter( + resourceName string, + key string, + value string, +) *AccountParameterModel { + a := &AccountParameterModel{ResourceModelMeta: config.Meta(resourceName, resources.AccountParameter)} + a.WithKey(key) + a.WithValue(value) + return a +} + +func AccountParameterWithDefaultMeta( + key string, + value string, +) *AccountParameterModel { + a := &AccountParameterModel{ResourceModelMeta: config.DefaultMeta(resources.AccountParameter)} + a.WithKey(key) + a.WithValue(value) + return a +} + +///////////////////////////////// +// below all the proper values // +///////////////////////////////// + +func (a *AccountParameterModel) WithKey(key string) *AccountParameterModel { + a.Key = tfconfig.StringVariable(key) + return a +} + +func (a *AccountParameterModel) WithValue(value string) *AccountParameterModel { + a.Value = tfconfig.StringVariable(value) + return a +} + +////////////////////////////////////////// +// below it's possible to set any value // +////////////////////////////////////////// + +func (a *AccountParameterModel) WithKeyValue(value tfconfig.Variable) *AccountParameterModel { + a.Key = value + return a +} + +func (a *AccountParameterModel) WithValueValue(value tfconfig.Variable) *AccountParameterModel { + a.Value = value + return a +} diff --git a/pkg/resources/account_parameter.go b/pkg/resources/account_parameter.go index f8a782b1f2..2f8021c080 100644 --- a/pkg/resources/account_parameter.go +++ b/pkg/resources/account_parameter.go @@ -72,7 +72,7 @@ func ReadAccountParameter(ctx context.Context, d *schema.ResourceData, meta any) if err != nil { return diag.FromErr(err) } - parameter, err := client.Parameters.ShowAccountParameter(ctx, sdk.AccountParameter(parameterName)) + parameter, err := client.Parameters.ShowAccountParameter(ctx, parameterName) if err != nil { return diag.FromErr(fmt.Errorf("reading account parameter: %w", err)) } diff --git a/pkg/resources/account_parameter_acceptance_test.go b/pkg/resources/account_parameter_acceptance_test.go index 7af59dc238..1e61229df7 100644 --- a/pkg/resources/account_parameter_acceptance_test.go +++ b/pkg/resources/account_parameter_acceptance_test.go @@ -5,12 +5,18 @@ import ( "testing" acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/assert/resourceassert" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance/bettertestspoc/config/model" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/tfversion" ) func TestAcc_AccountParameter(t *testing.T) { + model := model.AccountParameter("test", "ALLOW_ID_TOKEN", "true") resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories, PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -20,10 +26,10 @@ func TestAcc_AccountParameter(t *testing.T) { CheckDestroy: nil, Steps: []resource.TestStep{ { - Config: accountParameterBasic("ALLOW_ID_TOKEN", "true"), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_account_parameter.p", "key", "ALLOW_ID_TOKEN"), - resource.TestCheckResourceAttr("snowflake_account_parameter.p", "value", "true"), + Config: config.FromModel(t, model), + Check: assert.AssertThat(t, resourceassert.AccountParameterResource(t, model.ResourceReference()). + HasKeyString(string(sdk.AccountParameterAllowIDToken)). + HasValueString("true"), ), }, }, @@ -41,6 +47,7 @@ resource "snowflake_account_parameter" "p" { } func TestAcc_AccountParameter_PREVENT_LOAD_FROM_INLINE_URL(t *testing.T) { + model := model.AccountParameter("test", string(sdk.AccountParameterPreventLoadFromInlineURL), "true") resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories, PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -50,10 +57,10 @@ func TestAcc_AccountParameter_PREVENT_LOAD_FROM_INLINE_URL(t *testing.T) { CheckDestroy: nil, Steps: []resource.TestStep{ { - Config: accountParameterBasic("PREVENT_LOAD_FROM_INLINE_URL", "true"), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_account_parameter.p", "key", "PREVENT_LOAD_FROM_INLINE_URL"), - resource.TestCheckResourceAttr("snowflake_account_parameter.p", "value", "true"), + Config: config.FromModel(t, model), + Check: assert.AssertThat(t, resourceassert.AccountParameterResource(t, model.ResourceReference()). + HasKeyString(string(sdk.AccountParameterPreventLoadFromInlineURL)). + HasValueString("true"), ), }, }, @@ -61,6 +68,7 @@ func TestAcc_AccountParameter_PREVENT_LOAD_FROM_INLINE_URL(t *testing.T) { } func TestAcc_AccountParameter_REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION(t *testing.T) { + model := model.AccountParameter("test", string(sdk.AccountParameterRequireStorageIntegrationForStageCreation), "true") resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories, PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -70,10 +78,10 @@ func TestAcc_AccountParameter_REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION(t * CheckDestroy: nil, Steps: []resource.TestStep{ { - Config: accountParameterBasic("REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION", "true"), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_account_parameter.p", "key", "REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION"), - resource.TestCheckResourceAttr("snowflake_account_parameter.p", "value", "true"), + Config: config.FromModel(t, model), + Check: assert.AssertThat(t, resourceassert.AccountParameterResource(t, model.ResourceReference()). + HasKeyString(string(sdk.AccountParameterRequireStorageIntegrationForStageCreation)). + HasValueString("true"), ), }, }, @@ -81,6 +89,7 @@ func TestAcc_AccountParameter_REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION(t * } func TestAcc_AccountParameter_Issue2573(t *testing.T) { + model := model.AccountParameter("test", string(sdk.AccountParameterTimezone), "Etc/UTC") resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories, PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -90,14 +99,14 @@ func TestAcc_AccountParameter_Issue2573(t *testing.T) { CheckDestroy: nil, Steps: []resource.TestStep{ { - Config: accountParameterBasic("TIMEZONE", "Etc/UTC"), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_account_parameter.p", "key", "TIMEZONE"), - resource.TestCheckResourceAttr("snowflake_account_parameter.p", "value", "Etc/UTC"), + Config: config.FromModel(t, model), + Check: assert.AssertThat(t, resourceassert.AccountParameterResource(t, model.ResourceReference()). + HasKeyString(string(sdk.AccountParameterTimezone)). + HasValueString("Etc/UTC"), ), }, { - ResourceName: "snowflake_account_parameter.p", + ResourceName: "snowflake_account_parameter.test", ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{}, @@ -107,6 +116,7 @@ func TestAcc_AccountParameter_Issue2573(t *testing.T) { } func TestAcc_AccountParameter_Issue3025(t *testing.T) { + model := model.AccountParameter("test", string(sdk.AccountParameterOAuthAddPrivilegedRolesToBlockedList), "true") resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories, PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -116,14 +126,14 @@ func TestAcc_AccountParameter_Issue3025(t *testing.T) { CheckDestroy: nil, Steps: []resource.TestStep{ { - Config: accountParameterBasic("OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST", "true"), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr("snowflake_account_parameter.p", "key", "OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST"), - resource.TestCheckResourceAttr("snowflake_account_parameter.p", "value", "true"), + Config: config.FromModel(t, model), + Check: assert.AssertThat(t, resourceassert.AccountParameterResource(t, model.ResourceReference()). + HasKeyString(string(sdk.AccountParameterOAuthAddPrivilegedRolesToBlockedList)). + HasValueString("true"), ), }, { - ResourceName: "snowflake_account_parameter.p", + ResourceName: "snowflake_account_parameter.test", ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{}, @@ -131,3 +141,6 @@ func TestAcc_AccountParameter_Issue3025(t *testing.T) { }, }) } + +// TODO(next pr): add more acc tests +// TODO(next pr): check unsetting in CheckDestroy diff --git a/pkg/sdk/parameters.go b/pkg/sdk/parameters.go index 13576c4b72..ea1ddf66e7 100644 --- a/pkg/sdk/parameters.go +++ b/pkg/sdk/parameters.go @@ -176,6 +176,7 @@ func (parameters *parameters) SetAccountParameter(ctx context.Context, parameter return nil } +// TODO(next pr): add integration tests func (parameters *parameters) UnsetAccountParameter(ctx context.Context, parameter AccountParameter) error { opts := AlterAccountOptions{ Unset: &AccountUnset{ From 1a598a968b2b6a2a0196c0def81a48cea3d7ae44 Mon Sep 17 00:00:00 2001 From: Jakub Michalak Date: Wed, 11 Dec 2024 10:36:28 +0100 Subject: [PATCH 4/6] improve docs --- docs/resources/account_parameter.md | 4 ++-- pkg/resources/account_parameter.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/resources/account_parameter.md b/docs/resources/account_parameter.md index fb84bdc32f..ef37fc8cff 100644 --- a/docs/resources/account_parameter.md +++ b/docs/resources/account_parameter.md @@ -2,7 +2,7 @@ page_title: "snowflake_account_parameter Resource - terraform-provider-snowflake" subcategory: "" description: |- - Resource used to manage current account parameters. For more information, check parameters documentation https://docs.snowflake.com/en/sql-reference/parameters. + Resource used to manage current account parameters. For more information, check parameters documentation https://docs.snowflake.com/en/sql-reference/parameters. To manage the whole account resource, see account ./account resource. --- !> **V1 release candidate** This resource was reworked and is a release candidate for the V1. We do not expect significant changes in it before the V1. We will welcome any feedback and adjust the resource if needed. Any errors reported will be resolved with a higher priority. We encourage checking this resource out before the V1 release. Please follow the [migration guide](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/MIGRATION_GUIDE.md#v0990--v01000) to use it. @@ -11,7 +11,7 @@ description: |- # snowflake_account_parameter (Resource) -Resource used to manage current account parameters. For more information, check [parameters documentation](https://docs.snowflake.com/en/sql-reference/parameters). +Resource used to manage current account parameters. For more information, check [parameters documentation](https://docs.snowflake.com/en/sql-reference/parameters). To manage the whole account resource, see [account](./account) resource. ## Example Usage diff --git a/pkg/resources/account_parameter.go b/pkg/resources/account_parameter.go index 2f8021c080..94894f7415 100644 --- a/pkg/resources/account_parameter.go +++ b/pkg/resources/account_parameter.go @@ -38,7 +38,7 @@ func AccountParameter() *schema.Resource { UpdateContext: TrackingUpdateWrapper(resources.AccountParameter, UpdateAccountParameter), DeleteContext: TrackingDeleteWrapper(resources.AccountParameter, DeleteAccountParameter), - Description: "Resource used to manage current account parameters. For more information, check [parameters documentation](https://docs.snowflake.com/en/sql-reference/parameters).", + Description: "Resource used to manage current account parameters. For more information, check [parameters documentation](https://docs.snowflake.com/en/sql-reference/parameters). To manage the whole account resource, see [account](./account) resource.", Schema: accountParameterSchema, Importer: &schema.ResourceImporter{ From bbf622eb2f31dabec3faa9e5da0eb86d19f77940 Mon Sep 17 00:00:00 2001 From: Jakub Michalak Date: Thu, 12 Dec 2024 12:39:44 +0100 Subject: [PATCH 5/6] Add missing params --- docs/resources/account_parameter.md | 6 +- pkg/resources/account_parameter.go | 2 +- .../account_parameter_acceptance_test.go | 2 +- pkg/sdk/parameters.go | 109 +++++++++++------- 4 files changed, 74 insertions(+), 45 deletions(-) diff --git a/docs/resources/account_parameter.md b/docs/resources/account_parameter.md index ef37fc8cff..07b49e485f 100644 --- a/docs/resources/account_parameter.md +++ b/docs/resources/account_parameter.md @@ -2,7 +2,7 @@ page_title: "snowflake_account_parameter Resource - terraform-provider-snowflake" subcategory: "" description: |- - Resource used to manage current account parameters. For more information, check parameters documentation https://docs.snowflake.com/en/sql-reference/parameters. To manage the whole account resource, see account ./account resource. + Resource used to manage current account parameters. For more information, check parameters documentation https://docs.snowflake.com/en/sql-reference/parameters. --- !> **V1 release candidate** This resource was reworked and is a release candidate for the V1. We do not expect significant changes in it before the V1. We will welcome any feedback and adjust the resource if needed. Any errors reported will be resolved with a higher priority. We encourage checking this resource out before the V1 release. Please follow the [migration guide](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/MIGRATION_GUIDE.md#v0990--v01000) to use it. @@ -11,7 +11,7 @@ description: |- # snowflake_account_parameter (Resource) -Resource used to manage current account parameters. For more information, check [parameters documentation](https://docs.snowflake.com/en/sql-reference/parameters). To manage the whole account resource, see [account](./account) resource. +Resource used to manage current account parameters. For more information, check [parameters documentation](https://docs.snowflake.com/en/sql-reference/parameters). ## Example Usage @@ -34,7 +34,7 @@ resource "snowflake_account_parameter" "p2" { ### Required -- `key` (String) Name of account parameter. Valid values are (case-insensitive): `ALLOW_CLIENT_MFA_CACHING` | `ALLOW_ID_TOKEN` | `CLIENT_ENCRYPTION_KEY_SIZE` | `ENABLE_IDENTIFIER_FIRST_LOGIN` | `ENABLE_INTERNAL_STAGES_PRIVATELINK` | `ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_IMAGE_REPOSITORY` | `ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_SPCS_BLOCK_STORAGE` | `EVENT_TABLE` | `EXTERNAL_OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST` | `INITIAL_REPLICATION_SIZE_LIMIT_IN_TB` | `MIN_DATA_RETENTION_TIME_IN_DAYS` | `NETWORK_POLICY` | `OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST` | `PERIODIC_DATA_REKEYING` | `PREVENT_LOAD_FROM_INLINE_URL` | `PREVENT_UNLOAD_TO_INLINE_URL` | `PREVENT_UNLOAD_TO_INTERNAL_STAGES` | `REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION` | `REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_OPERATION` | `SSO_LOGIN_PAGE` | `ABORT_DETACHED_QUERY` | `AUTOCOMMIT` | `BINARY_INPUT_FORMAT` | `BINARY_OUTPUT_FORMAT` | `CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX` | `CLIENT_METADATA_USE_SESSION_DATABASE` | `CLIENT_RESULT_COLUMN_CASE_INSENSITIVE` | `DATE_INPUT_FORMAT` | `DATE_OUTPUT_FORMAT` | `ERROR_ON_NONDETERMINISTIC_MERGE` | `ERROR_ON_NONDETERMINISTIC_UPDATE` | `GEOGRAPHY_OUTPUT_FORMAT` | `JSON_INDENT` | `LOCK_TIMEOUT` | `MULTI_STATEMENT_COUNT` | `QUERY_TAG` | `QUOTED_IDENTIFIERS_IGNORE_CASE` | `ROWS_PER_RESULTSET` | `S3_STAGE_VPCE_DNS_NAME` | `SIMULATED_DATA_SHARING_CONSUMER` | `STATEMENT_TIMEOUT_IN_SECONDS` | `STRICT_JSON_OUTPUT` | `TIME_INPUT_FORMAT` | `TIME_OUTPUT_FORMAT` | `TIMESTAMP_DAY_IS_ALWAYS_24H` | `TIMESTAMP_INPUT_FORMAT` | `TIMESTAMP_LTZ_OUTPUT_FORMAT` | `TIMESTAMP_NTZ_OUTPUT_FORMAT` | `TIMESTAMP_OUTPUT_FORMAT` | `TIMESTAMP_TYPE_MAPPING` | `TIMESTAMP_TZ_OUTPUT_FORMAT` | `TIMEZONE` | `TRANSACTION_ABORT_ON_ERROR` | `TRANSACTION_DEFAULT_ISOLATION_LEVEL` | `TWO_DIGIT_CENTURY_START` | `UNSUPPORTED_DDL_ACTION` | `USE_CACHED_RESULT` | `WEEK_OF_YEAR_POLICY` | `WEEK_START` | `CATALOG` | `DATA_RETENTION_TIME_IN_DAYS` | `DEFAULT_DDL_COLLATION` | `EXTERNAL_VOLUME` | `LOG_LEVEL` | `MAX_CONCURRENCY_LEVEL` | `MAX_DATA_EXTENSION_TIME_IN_DAYS` | `PIPE_EXECUTION_PAUSED` | `REPLACE_INVALID_CHARACTERS` | `STATEMENT_QUEUED_TIMEOUT_IN_SECONDS` | `STORAGE_SERIALIZATION_POLICY` | `SHARE_RESTRICTIONS` | `SUSPEND_TASK_AFTER_NUM_FAILURES` | `TRACE_LEVEL` | `USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE` | `USER_TASK_TIMEOUT_MS` | `TASK_AUTO_RETRY_ATTEMPTS` | `USER_TASK_MINIMUM_TRIGGER_INTERVAL_IN_SECONDS` | `METRIC_LEVEL` | `ENABLE_CONSOLE_OUTPUT` | `ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR`. +- `key` (String) Name of account parameter. Valid values are (case-insensitive): `ALLOW_CLIENT_MFA_CACHING` | `ALLOW_ID_TOKEN` | `CLIENT_ENCRYPTION_KEY_SIZE` | `ENABLE_IDENTIFIER_FIRST_LOGIN` | `ENABLE_INTERNAL_STAGES_PRIVATELINK` | `ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_IMAGE_REPOSITORY` | `ENABLE_TRI_SECRET_AND_REKEY_OPT_OUT_FOR_SPCS_BLOCK_STORAGE` | `EVENT_TABLE` | `EXTERNAL_OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST` | `INITIAL_REPLICATION_SIZE_LIMIT_IN_TB` | `MIN_DATA_RETENTION_TIME_IN_DAYS` | `NETWORK_POLICY` | `OAUTH_ADD_PRIVILEGED_ROLES_TO_BLOCKED_LIST` | `PERIODIC_DATA_REKEYING` | `PREVENT_LOAD_FROM_INLINE_URL` | `PREVENT_UNLOAD_TO_INLINE_URL` | `PREVENT_UNLOAD_TO_INTERNAL_STAGES` | `REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION` | `REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_OPERATION` | `SSO_LOGIN_PAGE` | `ABORT_DETACHED_QUERY` | `AUTOCOMMIT` | `BINARY_INPUT_FORMAT` | `BINARY_OUTPUT_FORMAT` | `CLIENT_MEMORY_LIMIT` | `CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX` | `CLIENT_METADATA_USE_SESSION_DATABASE` | `CLIENT_PREFETCH_THREADS` | `CLIENT_RESULT_CHUNK_SIZE` | `CLIENT_SESSION_KEEP_ALIVE` | `CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY` | `CLIENT_TIMESTAMP_TYPE_MAPPING` | `ENABLE_UNLOAD_PHYSICAL_TYPE_OPTIMIZATION` | `CLIENT_RESULT_COLUMN_CASE_INSENSITIVE` | `DATE_INPUT_FORMAT` | `DATE_OUTPUT_FORMAT` | `ERROR_ON_NONDETERMINISTIC_MERGE` | `ERROR_ON_NONDETERMINISTIC_UPDATE` | `GEOGRAPHY_OUTPUT_FORMAT` | `GEOMETRY_OUTPUT_FORMAT` | `JDBC_TREAT_DECIMAL_AS_INT` | `JDBC_TREAT_TIMESTAMP_NTZ_AS_UTC` | `JDBC_USE_SESSION_TIMEZONE` | `JSON_INDENT` | `LOCK_TIMEOUT` | `MULTI_STATEMENT_COUNT` | `NOORDER_SEQUENCE_AS_DEFAULT` | `ODBC_TREAT_DECIMAL_AS_INT` | `QUERY_TAG` | `QUOTED_IDENTIFIERS_IGNORE_CASE` | `ROWS_PER_RESULTSET` | `S3_STAGE_VPCE_DNS_NAME` | `SEARCH_PATH` | `SIMULATED_DATA_SHARING_CONSUMER` | `STATEMENT_TIMEOUT_IN_SECONDS` | `STRICT_JSON_OUTPUT` | `TIME_INPUT_FORMAT` | `TIME_OUTPUT_FORMAT` | `TIMESTAMP_DAY_IS_ALWAYS_24H` | `TIMESTAMP_INPUT_FORMAT` | `TIMESTAMP_LTZ_OUTPUT_FORMAT` | `TIMESTAMP_NTZ_OUTPUT_FORMAT` | `TIMESTAMP_OUTPUT_FORMAT` | `TIMESTAMP_TYPE_MAPPING` | `TIMESTAMP_TZ_OUTPUT_FORMAT` | `TIMEZONE` | `TRANSACTION_ABORT_ON_ERROR` | `TRANSACTION_DEFAULT_ISOLATION_LEVEL` | `TWO_DIGIT_CENTURY_START` | `UNSUPPORTED_DDL_ACTION` | `USE_CACHED_RESULT` | `WEEK_OF_YEAR_POLICY` | `WEEK_START` | `CATALOG` | `DATA_RETENTION_TIME_IN_DAYS` | `DEFAULT_DDL_COLLATION` | `EXTERNAL_VOLUME` | `LOG_LEVEL` | `MAX_CONCURRENCY_LEVEL` | `MAX_DATA_EXTENSION_TIME_IN_DAYS` | `PIPE_EXECUTION_PAUSED` | `PREVENT_UNLOAD_TO_INTERNAL_STAGES` | `REPLACE_INVALID_CHARACTERS` | `STATEMENT_QUEUED_TIMEOUT_IN_SECONDS` | `STORAGE_SERIALIZATION_POLICY` | `SHARE_RESTRICTIONS` | `SUSPEND_TASK_AFTER_NUM_FAILURES` | `TRACE_LEVEL` | `USER_TASK_MANAGED_INITIAL_WAREHOUSE_SIZE` | `USER_TASK_TIMEOUT_MS` | `TASK_AUTO_RETRY_ATTEMPTS` | `USER_TASK_MINIMUM_TRIGGER_INTERVAL_IN_SECONDS` | `METRIC_LEVEL` | `ENABLE_CONSOLE_OUTPUT` | `ENABLE_UNREDACTED_QUERY_SYNTAX_ERROR`. - `value` (String) Value of account parameter, as a string. Constraints are the same as those for the parameters in Snowflake documentation. The parameter values are validated in Snowflake. ### Read-Only diff --git a/pkg/resources/account_parameter.go b/pkg/resources/account_parameter.go index 94894f7415..2f8021c080 100644 --- a/pkg/resources/account_parameter.go +++ b/pkg/resources/account_parameter.go @@ -38,7 +38,7 @@ func AccountParameter() *schema.Resource { UpdateContext: TrackingUpdateWrapper(resources.AccountParameter, UpdateAccountParameter), DeleteContext: TrackingDeleteWrapper(resources.AccountParameter, DeleteAccountParameter), - Description: "Resource used to manage current account parameters. For more information, check [parameters documentation](https://docs.snowflake.com/en/sql-reference/parameters). To manage the whole account resource, see [account](./account) resource.", + Description: "Resource used to manage current account parameters. For more information, check [parameters documentation](https://docs.snowflake.com/en/sql-reference/parameters).", Schema: accountParameterSchema, Importer: &schema.ResourceImporter{ diff --git a/pkg/resources/account_parameter_acceptance_test.go b/pkg/resources/account_parameter_acceptance_test.go index 1e61229df7..f9c9a8ab55 100644 --- a/pkg/resources/account_parameter_acceptance_test.go +++ b/pkg/resources/account_parameter_acceptance_test.go @@ -142,5 +142,5 @@ func TestAcc_AccountParameter_Issue3025(t *testing.T) { }) } -// TODO(next pr): add more acc tests +// TODO(next pr): add more acc tests for the remaining parameters // TODO(next pr): check unsetting in CheckDestroy diff --git a/pkg/sdk/parameters.go b/pkg/sdk/parameters.go index d8d1c7227f..377d46a5fd 100644 --- a/pkg/sdk/parameters.go +++ b/pkg/sdk/parameters.go @@ -465,7 +465,7 @@ type AccountParameter string // https://docs.snowflake.com/en/sql-reference/parameters#parameter-hierarchy-and-types // Account Parameters include Session Parameters, Object Parameters and User Parameters const ( - // TODO(next pr): add remaining parameters + // TODO(next pr): add remaining parameters; also in parameters_impl.go // Account Parameters AccountParameterAllowClientMFACaching AccountParameter = "ALLOW_CLIENT_MFA_CACHING" AccountParameterAllowIDToken AccountParameter = "ALLOW_ID_TOKEN" // #nosec G101 @@ -489,45 +489,59 @@ const ( AccountParameterSSOLoginPage AccountParameter = "SSO_LOGIN_PAGE" // Session Parameters (inherited) - AccountParameterAbortDetachedQuery AccountParameter = "ABORT_DETACHED_QUERY" - AccountParameterAutocommit AccountParameter = "AUTOCOMMIT" - AccountParameterBinaryInputFormat AccountParameter = "BINARY_INPUT_FORMAT" - AccountParameterBinaryOutputFormat AccountParameter = "BINARY_OUTPUT_FORMAT" - AccountParameterClientMetadataRequestUseConnectionCtx AccountParameter = "CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX" - AccountParameterClientMetadataUseSessionDatabase AccountParameter = "CLIENT_METADATA_USE_SESSION_DATABASE" - AccountParameterClientResultColumnCaseInsensitive AccountParameter = "CLIENT_RESULT_COLUMN_CASE_INSENSITIVE" - AccountParameterDateInputFormat AccountParameter = "DATE_INPUT_FORMAT" - AccountParameterDateOutputFormat AccountParameter = "DATE_OUTPUT_FORMAT" - AccountParameterErrorOnNondeterministicMerge AccountParameter = "ERROR_ON_NONDETERMINISTIC_MERGE" - AccountParameterErrorOnNondeterministicUpdate AccountParameter = "ERROR_ON_NONDETERMINISTIC_UPDATE" - AccountParameterGeographyOutputFormat AccountParameter = "GEOGRAPHY_OUTPUT_FORMAT" - AccountParameterJSONIndent AccountParameter = "JSON_INDENT" - AccountParameterLockTimeout AccountParameter = "LOCK_TIMEOUT" - AccountParameterMultiStatementCount AccountParameter = "MULTI_STATEMENT_COUNT" - AccountParameterQueryTag AccountParameter = "QUERY_TAG" - AccountParameterQuotedIdentifiersIgnoreCase AccountParameter = "QUOTED_IDENTIFIERS_IGNORE_CASE" - AccountParameterRowsPerResultset AccountParameter = "ROWS_PER_RESULTSET" - AccountParameterS3StageVpceDnsName AccountParameter = "S3_STAGE_VPCE_DNS_NAME" - AccountParameterSimulatedDataSharingConsumer AccountParameter = "SIMULATED_DATA_SHARING_CONSUMER" - AccountParameterStatementTimeoutInSeconds AccountParameter = "STATEMENT_TIMEOUT_IN_SECONDS" - AccountParameterStrictJSONOutput AccountParameter = "STRICT_JSON_OUTPUT" - AccountParameterTimeInputFormat AccountParameter = "TIME_INPUT_FORMAT" - AccountParameterTimeOutputFormat AccountParameter = "TIME_OUTPUT_FORMAT" - AccountParameterTimestampDayIsAlways24h AccountParameter = "TIMESTAMP_DAY_IS_ALWAYS_24H" - AccountParameterTimestampInputFormat AccountParameter = "TIMESTAMP_INPUT_FORMAT" - AccountParameterTimestampLtzOutputFormat AccountParameter = "TIMESTAMP_LTZ_OUTPUT_FORMAT" - AccountParameterTimestampNtzOutputFormat AccountParameter = "TIMESTAMP_NTZ_OUTPUT_FORMAT" - AccountParameterTimestampOutputFormat AccountParameter = "TIMESTAMP_OUTPUT_FORMAT" - AccountParameterTimestampTypeMapping AccountParameter = "TIMESTAMP_TYPE_MAPPING" - AccountParameterTimestampTzOutputFormat AccountParameter = "TIMESTAMP_TZ_OUTPUT_FORMAT" - AccountParameterTimezone AccountParameter = "TIMEZONE" - AccountParameterTransactionAbortOnError AccountParameter = "TRANSACTION_ABORT_ON_ERROR" - AccountParameterTransactionDefaultIsolationLevel AccountParameter = "TRANSACTION_DEFAULT_ISOLATION_LEVEL" - AccountParameterTwoDigitCenturyStart AccountParameter = "TWO_DIGIT_CENTURY_START" - AccountParameterUnsupportedDdlAction AccountParameter = "UNSUPPORTED_DDL_ACTION" - AccountParameterUseCachedResult AccountParameter = "USE_CACHED_RESULT" - AccountParameterWeekOfYearPolicy AccountParameter = "WEEK_OF_YEAR_POLICY" - AccountParameterWeekStart AccountParameter = "WEEK_START" + AccountParameterAbortDetachedQuery AccountParameter = "ABORT_DETACHED_QUERY" + AccountParameterAutocommit AccountParameter = "AUTOCOMMIT" + AccountParameterBinaryInputFormat AccountParameter = "BINARY_INPUT_FORMAT" + AccountParameterBinaryOutputFormat AccountParameter = "BINARY_OUTPUT_FORMAT" + AccountParameterClientMemoryLimit AccountParameter = "CLIENT_MEMORY_LIMIT" + AccountParameterClientMetadataRequestUseConnectionCtx AccountParameter = "CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX" + AccountParameterClientMetadataUseSessionDatabase AccountParameter = "CLIENT_METADATA_USE_SESSION_DATABASE" + AccountParameterClientPrefetchThreads AccountParameter = "CLIENT_PREFETCH_THREADS" + AccountParameterClientResultChunkSize AccountParameter = "CLIENT_RESULT_CHUNK_SIZE" + AccountParameterClientResultColumnCaseInsensitive AccountParameter = "CLIENT_RESULT_COLUMN_CASE_INSENSITIVE" + AccountParameterClientSessionKeepAlive AccountParameter = "CLIENT_SESSION_KEEP_ALIVE" + AccountParameterClientSessionKeepAliveHeartbeatFrequency AccountParameter = "CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY" + AccountParameterClientTimestampTypeMapping AccountParameter = "CLIENT_TIMESTAMP_TYPE_MAPPING" + AccountParameterDateInputFormat AccountParameter = "DATE_INPUT_FORMAT" + AccountParameterDateOutputFormat AccountParameter = "DATE_OUTPUT_FORMAT" + AccountParameterEnableUnloadPhysicalTypeOptimization AccountParameter = "ENABLE_UNLOAD_PHYSICAL_TYPE_OPTIMIZATION" + AccountParameterErrorOnNondeterministicMerge AccountParameter = "ERROR_ON_NONDETERMINISTIC_MERGE" + AccountParameterErrorOnNondeterministicUpdate AccountParameter = "ERROR_ON_NONDETERMINISTIC_UPDATE" + AccountParameterGeographyOutputFormat AccountParameter = "GEOGRAPHY_OUTPUT_FORMAT" + AccountParameterGeometryOutputFormat AccountParameter = "GEOMETRY_OUTPUT_FORMAT" + AccountParameterJdbcTreatDecimalAsInt AccountParameter = "JDBC_TREAT_DECIMAL_AS_INT" + AccountParameterJdbcTreatTimestampNtzAsUtc AccountParameter = "JDBC_TREAT_TIMESTAMP_NTZ_AS_UTC" + AccountParameterJdbcUseSessionTimezone AccountParameter = "JDBC_USE_SESSION_TIMEZONE" + AccountParameterJSONIndent AccountParameter = "JSON_INDENT" + AccountParameterLockTimeout AccountParameter = "LOCK_TIMEOUT" + AccountParameterMultiStatementCount AccountParameter = "MULTI_STATEMENT_COUNT" + AccountParameterNoorderSequenceAsDefault AccountParameter = "NOORDER_SEQUENCE_AS_DEFAULT" + AccountParameterOdbcTreatDecimalAsInt AccountParameter = "ODBC_TREAT_DECIMAL_AS_INT" + AccountParameterQueryTag AccountParameter = "QUERY_TAG" + AccountParameterQuotedIdentifiersIgnoreCase AccountParameter = "QUOTED_IDENTIFIERS_IGNORE_CASE" + AccountParameterRowsPerResultset AccountParameter = "ROWS_PER_RESULTSET" + AccountParameterS3StageVpceDnsName AccountParameter = "S3_STAGE_VPCE_DNS_NAME" + AccountParameterSearchPath AccountParameter = "SEARCH_PATH" + AccountParameterSimulatedDataSharingConsumer AccountParameter = "SIMULATED_DATA_SHARING_CONSUMER" + AccountParameterStatementTimeoutInSeconds AccountParameter = "STATEMENT_TIMEOUT_IN_SECONDS" + AccountParameterStrictJSONOutput AccountParameter = "STRICT_JSON_OUTPUT" + AccountParameterTimeInputFormat AccountParameter = "TIME_INPUT_FORMAT" + AccountParameterTimeOutputFormat AccountParameter = "TIME_OUTPUT_FORMAT" + AccountParameterTimestampDayIsAlways24h AccountParameter = "TIMESTAMP_DAY_IS_ALWAYS_24H" + AccountParameterTimestampInputFormat AccountParameter = "TIMESTAMP_INPUT_FORMAT" + AccountParameterTimestampLtzOutputFormat AccountParameter = "TIMESTAMP_LTZ_OUTPUT_FORMAT" + AccountParameterTimestampNtzOutputFormat AccountParameter = "TIMESTAMP_NTZ_OUTPUT_FORMAT" + AccountParameterTimestampOutputFormat AccountParameter = "TIMESTAMP_OUTPUT_FORMAT" + AccountParameterTimestampTypeMapping AccountParameter = "TIMESTAMP_TYPE_MAPPING" + AccountParameterTimestampTzOutputFormat AccountParameter = "TIMESTAMP_TZ_OUTPUT_FORMAT" + AccountParameterTimezone AccountParameter = "TIMEZONE" + AccountParameterTransactionAbortOnError AccountParameter = "TRANSACTION_ABORT_ON_ERROR" + AccountParameterTransactionDefaultIsolationLevel AccountParameter = "TRANSACTION_DEFAULT_ISOLATION_LEVEL" + AccountParameterTwoDigitCenturyStart AccountParameter = "TWO_DIGIT_CENTURY_START" + AccountParameterUnsupportedDdlAction AccountParameter = "UNSUPPORTED_DDL_ACTION" + AccountParameterUseCachedResult AccountParameter = "USE_CACHED_RESULT" + AccountParameterWeekOfYearPolicy AccountParameter = "WEEK_OF_YEAR_POLICY" + AccountParameterWeekStart AccountParameter = "WEEK_START" // Object Parameters (inherited) AccountParameterCatalog AccountParameter = "CATALOG" @@ -580,21 +594,35 @@ var AllAccountParameters = []AccountParameter{ AccountParameterAutocommit, AccountParameterBinaryInputFormat, AccountParameterBinaryOutputFormat, + AccountParameterClientMemoryLimit, AccountParameterClientMetadataRequestUseConnectionCtx, AccountParameterClientMetadataUseSessionDatabase, + AccountParameterClientPrefetchThreads, + AccountParameterClientResultChunkSize, + AccountParameterClientSessionKeepAlive, + AccountParameterClientSessionKeepAliveHeartbeatFrequency, + AccountParameterClientTimestampTypeMapping, + AccountParameterEnableUnloadPhysicalTypeOptimization, AccountParameterClientResultColumnCaseInsensitive, AccountParameterDateInputFormat, AccountParameterDateOutputFormat, AccountParameterErrorOnNondeterministicMerge, AccountParameterErrorOnNondeterministicUpdate, AccountParameterGeographyOutputFormat, + AccountParameterGeometryOutputFormat, + AccountParameterJdbcTreatDecimalAsInt, + AccountParameterJdbcTreatTimestampNtzAsUtc, + AccountParameterJdbcUseSessionTimezone, AccountParameterJSONIndent, AccountParameterLockTimeout, AccountParameterMultiStatementCount, + AccountParameterNoorderSequenceAsDefault, + AccountParameterOdbcTreatDecimalAsInt, AccountParameterQueryTag, AccountParameterQuotedIdentifiersIgnoreCase, AccountParameterRowsPerResultset, AccountParameterS3StageVpceDnsName, + AccountParameterSearchPath, AccountParameterSimulatedDataSharingConsumer, AccountParameterStatementTimeoutInSeconds, AccountParameterStrictJSONOutput, @@ -623,6 +651,7 @@ var AllAccountParameters = []AccountParameter{ AccountParameterMaxConcurrencyLevel, AccountParameterMaxDataExtensionTimeInDays, AccountParameterPipeExecutionPaused, + AccountParameterPreventUnloadToInternalStages, AccountParameterReplaceInvalidCharacters, AccountParameterStatementQueuedTimeoutInSeconds, AccountParameterStorageSerializationPolicy, From 4b8f8e6c9570149bc96d075319be2c928f978c30 Mon Sep 17 00:00:00 2001 From: Jakub Michalak Date: Thu, 12 Dec 2024 13:23:01 +0100 Subject: [PATCH 6/6] add check destroy and fix tests --- .../database_parameters_snowflake_gen.go | 2 +- .../gen/object_parameters_def.go | 14 +++++------ .../task_parameters_snowflake_gen.go | 6 ++--- .../user_parameters_snowflake_gen.go | 6 ++--- pkg/acceptance/check_destroy.go | 16 +++++++++++++ .../account_parameter_acceptance_test.go | 24 +++++-------------- 6 files changed, 36 insertions(+), 32 deletions(-) diff --git a/pkg/acceptance/bettertestspoc/assert/objectparametersassert/database_parameters_snowflake_gen.go b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/database_parameters_snowflake_gen.go index 6c33814187..8937660447 100644 --- a/pkg/acceptance/bettertestspoc/assert/objectparametersassert/database_parameters_snowflake_gen.go +++ b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/database_parameters_snowflake_gen.go @@ -81,7 +81,7 @@ func (d *DatabaseParametersAssert) HasAllDefaults() *DatabaseParametersAssert { HasDefaultParameterValueOnLevel(sdk.DatabaseParameterUserTaskManagedInitialWarehouseSize, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.DatabaseParameterUserTaskTimeoutMs, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.DatabaseParameterUserTaskMinimumTriggerIntervalInSeconds, sdk.ParameterTypeSnowflakeDefault). - HasDefaultParameterValueOnLevel(sdk.DatabaseParameterQuotedIdentifiersIgnoreCase, sdk.ParameterTypeAccount). + HasDefaultParameterValueOnLevel(sdk.DatabaseParameterQuotedIdentifiersIgnoreCase, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.DatabaseParameterEnableConsoleOutput, sdk.ParameterTypeSnowflakeDefault) } diff --git a/pkg/acceptance/bettertestspoc/assert/objectparametersassert/gen/object_parameters_def.go b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/gen/object_parameters_def.go index fd716a8993..9f9c3c6733 100644 --- a/pkg/acceptance/bettertestspoc/assert/objectparametersassert/gen/object_parameters_def.go +++ b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/gen/object_parameters_def.go @@ -36,7 +36,7 @@ var allObjectsParameters = []SnowflakeObjectParameters{ {ParameterName: string(sdk.UserParameterNetworkPolicy), ParameterType: "string", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.UserParameterPreventUnloadToInternalStages), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.UserParameterAbortDetachedQuery), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, - {ParameterName: string(sdk.UserParameterAutocommit), ParameterType: "bool", DefaultValue: "true", DefaultLevel: "sdk.ParameterTypeAccount"}, + {ParameterName: string(sdk.UserParameterAutocommit), ParameterType: "bool", DefaultValue: "true", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.UserParameterBinaryInputFormat), ParameterType: "sdk.BinaryInputFormat", DefaultValue: "sdk.BinaryInputFormatHex", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.UserParameterBinaryOutputFormat), ParameterType: "sdk.BinaryOutputFormat", DefaultValue: "sdk.BinaryOutputFormatHex", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.UserParameterClientMemoryLimit), ParameterType: "int", DefaultValue: "1536", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, @@ -64,7 +64,7 @@ var allObjectsParameters = []SnowflakeObjectParameters{ {ParameterName: string(sdk.UserParameterNoorderSequenceAsDefault), ParameterType: "bool", DefaultValue: "true", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.UserParameterOdbcTreatDecimalAsInt), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.UserParameterQueryTag), ParameterType: "string", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, - {ParameterName: string(sdk.UserParameterQuotedIdentifiersIgnoreCase), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeAccount"}, + {ParameterName: string(sdk.UserParameterQuotedIdentifiersIgnoreCase), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.UserParameterRowsPerResultset), ParameterType: "int", DefaultValue: "0", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.UserParameterS3StageVpceDnsName), ParameterType: "string", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.UserParameterSearchPath), ParameterType: "string", DefaultValue: "$current, $public", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, @@ -83,7 +83,7 @@ var allObjectsParameters = []SnowflakeObjectParameters{ {ParameterName: string(sdk.UserParameterTimeInputFormat), ParameterType: "string", DefaultValue: "AUTO", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.UserParameterTimeOutputFormat), ParameterType: "string", DefaultValue: "HH24:MI:SS", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.UserParameterTraceLevel), ParameterType: "sdk.TraceLevel", DefaultValue: "sdk.TraceLevelOff", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, - {ParameterName: string(sdk.UserParameterTransactionAbortOnError), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeAccount"}, + {ParameterName: string(sdk.UserParameterTransactionAbortOnError), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.UserParameterTransactionDefaultIsolationLevel), ParameterType: "sdk.TransactionDefaultIsolationLevel", DefaultValue: "sdk.TransactionDefaultIsolationLevelReadCommitted", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.UserParameterTwoDigitCenturyStart), ParameterType: "int", DefaultValue: "1970", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, // TODO [SNOW-1501905]: quick workaround for now: lowercase for ignore in snowflake by default but uppercase for FAIL @@ -124,7 +124,7 @@ var allObjectsParameters = []SnowflakeObjectParameters{ {ParameterName: string(sdk.DatabaseParameterUserTaskManagedInitialWarehouseSize), ParameterType: "sdk.WarehouseSize", DefaultValue: "sdk.WarehouseSizeMedium", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.DatabaseParameterUserTaskTimeoutMs), ParameterType: "int", DefaultValue: "3600000", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.DatabaseParameterUserTaskMinimumTriggerIntervalInSeconds), ParameterType: "int", DefaultValue: "30", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, - {ParameterName: string(sdk.DatabaseParameterQuotedIdentifiersIgnoreCase), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeAccount"}, + {ParameterName: string(sdk.DatabaseParameterQuotedIdentifiersIgnoreCase), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.DatabaseParameterEnableConsoleOutput), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, }, }, @@ -139,7 +139,7 @@ var allObjectsParameters = []SnowflakeObjectParameters{ {ParameterName: string(sdk.TaskParameterUserTaskMinimumTriggerIntervalInSeconds), ParameterType: "int", DefaultValue: "30", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.TaskParameterUserTaskTimeoutMs), ParameterType: "int", DefaultValue: "3600000", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.TaskParameterAbortDetachedQuery), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, - {ParameterName: string(sdk.TaskParameterAutocommit), ParameterType: "bool", DefaultValue: "true", DefaultLevel: "sdk.ParameterTypeAccount"}, + {ParameterName: string(sdk.TaskParameterAutocommit), ParameterType: "bool", DefaultValue: "true", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.TaskParameterBinaryInputFormat), ParameterType: "sdk.BinaryInputFormat", DefaultValue: "sdk.BinaryInputFormatHex", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.TaskParameterBinaryOutputFormat), ParameterType: "sdk.BinaryOutputFormat", DefaultValue: "sdk.BinaryOutputFormatHex", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.TaskParameterClientMemoryLimit), ParameterType: "int", DefaultValue: "1536", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, @@ -166,7 +166,7 @@ var allObjectsParameters = []SnowflakeObjectParameters{ {ParameterName: string(sdk.TaskParameterNoorderSequenceAsDefault), ParameterType: "bool", DefaultValue: "true", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.TaskParameterOdbcTreatDecimalAsInt), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.TaskParameterQueryTag), ParameterType: "string", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, - {ParameterName: string(sdk.TaskParameterQuotedIdentifiersIgnoreCase), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeAccount"}, + {ParameterName: string(sdk.TaskParameterQuotedIdentifiersIgnoreCase), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.TaskParameterRowsPerResultset), ParameterType: "int", DefaultValue: "0", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.TaskParameterS3StageVpceDnsName), ParameterType: "string", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.TaskParameterSearchPath), ParameterType: "string", DefaultValue: "$current, $public", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, @@ -184,7 +184,7 @@ var allObjectsParameters = []SnowflakeObjectParameters{ {ParameterName: string(sdk.TaskParameterTimeInputFormat), ParameterType: "string", DefaultValue: "AUTO", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.TaskParameterTimeOutputFormat), ParameterType: "string", DefaultValue: "HH24:MI:SS", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.TaskParameterTraceLevel), ParameterType: "sdk.TraceLevel", DefaultValue: "sdk.TraceLevelOff", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, - {ParameterName: string(sdk.TaskParameterTransactionAbortOnError), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeAccount"}, + {ParameterName: string(sdk.TaskParameterTransactionAbortOnError), ParameterType: "bool", DefaultValue: "false", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.TaskParameterTransactionDefaultIsolationLevel), ParameterType: "sdk.TransactionDefaultIsolationLevel", DefaultValue: "sdk.TransactionDefaultIsolationLevelReadCommitted", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, {ParameterName: string(sdk.TaskParameterTwoDigitCenturyStart), ParameterType: "int", DefaultValue: "1970", DefaultLevel: "sdk.ParameterTypeSnowflakeDefault"}, // TODO [SNOW-1501905]: quick workaround for now: lowercase for ignore in snowflake by default but uppercase for FAIL diff --git a/pkg/acceptance/bettertestspoc/assert/objectparametersassert/task_parameters_snowflake_gen.go b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/task_parameters_snowflake_gen.go index b5c571149d..85ef79ebd6 100644 --- a/pkg/acceptance/bettertestspoc/assert/objectparametersassert/task_parameters_snowflake_gen.go +++ b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/task_parameters_snowflake_gen.go @@ -74,7 +74,7 @@ func (t *TaskParametersAssert) HasAllDefaults() *TaskParametersAssert { HasDefaultParameterValueOnLevel(sdk.TaskParameterUserTaskMinimumTriggerIntervalInSeconds, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.TaskParameterUserTaskTimeoutMs, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.TaskParameterAbortDetachedQuery, sdk.ParameterTypeSnowflakeDefault). - HasDefaultParameterValueOnLevel(sdk.TaskParameterAutocommit, sdk.ParameterTypeAccount). + HasDefaultParameterValueOnLevel(sdk.TaskParameterAutocommit, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.TaskParameterBinaryInputFormat, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.TaskParameterBinaryOutputFormat, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.TaskParameterClientMemoryLimit, sdk.ParameterTypeSnowflakeDefault). @@ -101,7 +101,7 @@ func (t *TaskParametersAssert) HasAllDefaults() *TaskParametersAssert { HasDefaultParameterValueOnLevel(sdk.TaskParameterNoorderSequenceAsDefault, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.TaskParameterOdbcTreatDecimalAsInt, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.TaskParameterQueryTag, sdk.ParameterTypeSnowflakeDefault). - HasDefaultParameterValueOnLevel(sdk.TaskParameterQuotedIdentifiersIgnoreCase, sdk.ParameterTypeAccount). + HasDefaultParameterValueOnLevel(sdk.TaskParameterQuotedIdentifiersIgnoreCase, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.TaskParameterRowsPerResultset, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.TaskParameterS3StageVpceDnsName, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.TaskParameterSearchPath, sdk.ParameterTypeSnowflakeDefault). @@ -119,7 +119,7 @@ func (t *TaskParametersAssert) HasAllDefaults() *TaskParametersAssert { HasDefaultParameterValueOnLevel(sdk.TaskParameterTimeInputFormat, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.TaskParameterTimeOutputFormat, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.TaskParameterTraceLevel, sdk.ParameterTypeSnowflakeDefault). - HasDefaultParameterValueOnLevel(sdk.TaskParameterTransactionAbortOnError, sdk.ParameterTypeAccount). + HasDefaultParameterValueOnLevel(sdk.TaskParameterTransactionAbortOnError, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.TaskParameterTransactionDefaultIsolationLevel, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.TaskParameterTwoDigitCenturyStart, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.TaskParameterUnsupportedDdlAction, sdk.ParameterTypeSnowflakeDefault). diff --git a/pkg/acceptance/bettertestspoc/assert/objectparametersassert/user_parameters_snowflake_gen.go b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/user_parameters_snowflake_gen.go index 4f860eb38d..433fc0fa70 100644 --- a/pkg/acceptance/bettertestspoc/assert/objectparametersassert/user_parameters_snowflake_gen.go +++ b/pkg/acceptance/bettertestspoc/assert/objectparametersassert/user_parameters_snowflake_gen.go @@ -72,7 +72,7 @@ func (u *UserParametersAssert) HasAllDefaults() *UserParametersAssert { HasDefaultParameterValueOnLevel(sdk.UserParameterNetworkPolicy, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.UserParameterPreventUnloadToInternalStages, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.UserParameterAbortDetachedQuery, sdk.ParameterTypeSnowflakeDefault). - HasDefaultParameterValueOnLevel(sdk.UserParameterAutocommit, sdk.ParameterTypeAccount). + HasDefaultParameterValueOnLevel(sdk.UserParameterAutocommit, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.UserParameterBinaryInputFormat, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.UserParameterBinaryOutputFormat, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.UserParameterClientMemoryLimit, sdk.ParameterTypeSnowflakeDefault). @@ -100,7 +100,7 @@ func (u *UserParametersAssert) HasAllDefaults() *UserParametersAssert { HasDefaultParameterValueOnLevel(sdk.UserParameterNoorderSequenceAsDefault, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.UserParameterOdbcTreatDecimalAsInt, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.UserParameterQueryTag, sdk.ParameterTypeSnowflakeDefault). - HasDefaultParameterValueOnLevel(sdk.UserParameterQuotedIdentifiersIgnoreCase, sdk.ParameterTypeAccount). + HasDefaultParameterValueOnLevel(sdk.UserParameterQuotedIdentifiersIgnoreCase, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.UserParameterRowsPerResultset, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.UserParameterS3StageVpceDnsName, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.UserParameterSearchPath, sdk.ParameterTypeSnowflakeDefault). @@ -119,7 +119,7 @@ func (u *UserParametersAssert) HasAllDefaults() *UserParametersAssert { HasDefaultParameterValueOnLevel(sdk.UserParameterTimeInputFormat, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.UserParameterTimeOutputFormat, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.UserParameterTraceLevel, sdk.ParameterTypeSnowflakeDefault). - HasDefaultParameterValueOnLevel(sdk.UserParameterTransactionAbortOnError, sdk.ParameterTypeAccount). + HasDefaultParameterValueOnLevel(sdk.UserParameterTransactionAbortOnError, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.UserParameterTransactionDefaultIsolationLevel, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.UserParameterTwoDigitCenturyStart, sdk.ParameterTypeSnowflakeDefault). HasDefaultParameterValueOnLevel(sdk.UserParameterUnsupportedDdlAction, sdk.ParameterTypeSnowflakeDefault). diff --git a/pkg/acceptance/check_destroy.go b/pkg/acceptance/check_destroy.go index 5959720df0..6d056a613b 100644 --- a/pkg/acceptance/check_destroy.go +++ b/pkg/acceptance/check_destroy.go @@ -630,3 +630,19 @@ func TestAccCheckGrantApplicationRoleDestroy(s *terraform.State) error { } return nil } + +func CheckAccountParameterUnset(t *testing.T, paramName sdk.AccountParameter) func(*terraform.State) error { + t.Helper() + return func(s *terraform.State) error { + for _, rs := range s.RootModule().Resources { + if rs.Type != "snowflake_account_parameter" { + continue + } + parameter := TestClient().Parameter.ShowAccountParameter(t, paramName) + if parameter.Level != sdk.ParameterTypeSnowflakeDefault { + return fmt.Errorf("expected parameter level empty, got %v", parameter.Level) + } + } + return nil + } +} diff --git a/pkg/resources/account_parameter_acceptance_test.go b/pkg/resources/account_parameter_acceptance_test.go index f9c9a8ab55..ab20439532 100644 --- a/pkg/resources/account_parameter_acceptance_test.go +++ b/pkg/resources/account_parameter_acceptance_test.go @@ -1,7 +1,6 @@ package resources_test import ( - "fmt" "testing" acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" @@ -16,14 +15,14 @@ import ( ) func TestAcc_AccountParameter(t *testing.T) { - model := model.AccountParameter("test", "ALLOW_ID_TOKEN", "true") + model := model.AccountParameter("test", string(sdk.AccountParameterAllowIDToken), "true") resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: acc.TestAccProtoV6ProviderFactories, PreCheck: func() { acc.TestAccPreCheck(t) }, TerraformVersionChecks: []tfversion.TerraformVersionCheck{ tfversion.RequireAbove(tfversion.Version1_5_0), }, - CheckDestroy: nil, + CheckDestroy: acc.CheckAccountParameterUnset(t, sdk.AccountParameterAllowIDToken), Steps: []resource.TestStep{ { Config: config.FromModel(t, model), @@ -36,16 +35,6 @@ func TestAcc_AccountParameter(t *testing.T) { }) } -func accountParameterBasic(key, value string) string { - s := ` -resource "snowflake_account_parameter" "p" { - key = "%s" - value = "%s" -} -` - return fmt.Sprintf(s, key, value) -} - func TestAcc_AccountParameter_PREVENT_LOAD_FROM_INLINE_URL(t *testing.T) { model := model.AccountParameter("test", string(sdk.AccountParameterPreventLoadFromInlineURL), "true") resource.Test(t, resource.TestCase{ @@ -54,7 +43,7 @@ func TestAcc_AccountParameter_PREVENT_LOAD_FROM_INLINE_URL(t *testing.T) { TerraformVersionChecks: []tfversion.TerraformVersionCheck{ tfversion.RequireAbove(tfversion.Version1_5_0), }, - CheckDestroy: nil, + CheckDestroy: acc.CheckAccountParameterUnset(t, sdk.AccountParameterPreventLoadFromInlineURL), Steps: []resource.TestStep{ { Config: config.FromModel(t, model), @@ -75,7 +64,7 @@ func TestAcc_AccountParameter_REQUIRE_STORAGE_INTEGRATION_FOR_STAGE_CREATION(t * TerraformVersionChecks: []tfversion.TerraformVersionCheck{ tfversion.RequireAbove(tfversion.Version1_5_0), }, - CheckDestroy: nil, + CheckDestroy: acc.CheckAccountParameterUnset(t, sdk.AccountParameterRequireStorageIntegrationForStageCreation), Steps: []resource.TestStep{ { Config: config.FromModel(t, model), @@ -96,7 +85,7 @@ func TestAcc_AccountParameter_Issue2573(t *testing.T) { TerraformVersionChecks: []tfversion.TerraformVersionCheck{ tfversion.RequireAbove(tfversion.Version1_5_0), }, - CheckDestroy: nil, + CheckDestroy: acc.CheckAccountParameterUnset(t, sdk.AccountParameterTimezone), Steps: []resource.TestStep{ { Config: config.FromModel(t, model), @@ -123,7 +112,7 @@ func TestAcc_AccountParameter_Issue3025(t *testing.T) { TerraformVersionChecks: []tfversion.TerraformVersionCheck{ tfversion.RequireAbove(tfversion.Version1_5_0), }, - CheckDestroy: nil, + CheckDestroy: acc.CheckAccountParameterUnset(t, sdk.AccountParameterOAuthAddPrivilegedRolesToBlockedList), Steps: []resource.TestStep{ { Config: config.FromModel(t, model), @@ -143,4 +132,3 @@ func TestAcc_AccountParameter_Issue3025(t *testing.T) { } // TODO(next pr): add more acc tests for the remaining parameters -// TODO(next pr): check unsetting in CheckDestroy