From c7e463d17d664cf2efa7a8f1910ba5e1ccd7a432 Mon Sep 17 00:00:00 2001 From: Jakub Michalak Date: Thu, 9 Jan 2025 16:15:05 +0100 Subject: [PATCH] Fix tests and docs --- MIGRATION_GUIDE.md | 2 -- docs/index.md | 6 ++++-- docs/resources/schema.md | 2 +- docs/resources/tag.md | 4 ++-- pkg/resources/schema.go | 2 +- pkg/resources/tag.go | 2 +- pkg/sdk/tasks_gen_test.go | 11 ++++++----- templates/index.md.tmpl | 6 ++++-- 8 files changed, 19 insertions(+), 16 deletions(-) diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index 6272acfd36..def4f262c7 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -674,7 +674,6 @@ If you use TOML configuration file, adjust it from ```toml [default] account = "ORGANIZATION-ACCOUNT" -} ``` to @@ -682,7 +681,6 @@ to [default] organizationname = "ORGANIZATION" accountname = "ACCOUNT" -} ``` If you use environmental variables, adjust them from diff --git a/docs/index.md b/docs/index.md index bc11401f91..9bb4ff292c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -150,7 +150,9 @@ To export the variables into your provider: ```shell export SNOWFLAKE_USER="..." -export SNOWFLAKE_PRIVATE_KEY="~/.ssh/snowflake_key" +export SNOWFLAKE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----..." +# Alternatively, source from a file. +export SNOWFLAKE_PRIVATE_KEY=$(cat ~/.ssh/snowflake_key.p8) ``` ### Keypair Authentication Passphrase @@ -172,7 +174,7 @@ To export the variables into your provider: ```shell export SNOWFLAKE_USER="..." -export SNOWFLAKE_PRIVATE_KEY="~/.ssh/snowflake_key.p8" +export SNOWFLAKE_PRIVATE_KEY=$(cat ~/.ssh/snowflake_key.p8) export SNOWFLAKE_PRIVATE_KEY_PASSPHRASE="..." ``` diff --git a/docs/resources/schema.md b/docs/resources/schema.md index 2e6ded33f2..85936c2dd9 100644 --- a/docs/resources/schema.md +++ b/docs/resources/schema.md @@ -88,7 +88,7 @@ resource "snowflake_schema" "schema" { ### Read-Only -- `describe_output` (List of Object) Outputs the result of `DESCRIBE SCHEMA` for the given object. In order to handle this output, one must grant sufficient privileges, e.g. [grant_ownership](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/grant_ownership) on all objects in the schema. (see [below for nested schema](#nestedatt--describe_output)) +- `describe_output` (List of Object) Outputs the result of `DESCRIBE SCHEMA` for the given object. In order to handle this output, one must grant sufficient privileges, e.g. [grant_ownership](./grant_ownership) on all objects in the schema. (see [below for nested schema](#nestedatt--describe_output)) - `fully_qualified_name` (String) Fully qualified name of the resource. For more information, see [object name resolution](https://docs.snowflake.com/en/sql-reference/name-resolution). - `id` (String) The ID of this resource. - `parameters` (List of Object) Outputs the result of `SHOW PARAMETERS IN SCHEMA` for the given object. (see [below for nested schema](#nestedatt--parameters)) diff --git a/docs/resources/tag.md b/docs/resources/tag.md index a3ea0d486a..54a33de702 100644 --- a/docs/resources/tag.md +++ b/docs/resources/tag.md @@ -2,14 +2,14 @@ page_title: "snowflake_tag Resource - terraform-provider-snowflake" subcategory: "" description: |- - Resource used to manage tags. For more information, check tag documentation https://docs.snowflake.com/en/sql-reference/sql/create-tag. For asssigning tags to Snowflake objects, see tag_association resource https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/tag_association. + Resource used to manage tags. For more information, check tag documentation https://docs.snowflake.com/en/sql-reference/sql/create-tag. For asssigning tags to Snowflake objects, see tag_association resource ./tag_association. --- ~> **Required warehouse** For this resource, the provider now uses [tag references](https://docs.snowflake.com/en/sql-reference/functions/tag_references) to get information about masking policies attached to tags. This function requires a warehouse in the connection. Please, make sure you have either set a `DEFAULT_WAREHOUSE` for the user, or specified a warehouse in the provider configuration. # snowflake_tag (Resource) -Resource used to manage tags. For more information, check [tag documentation](https://docs.snowflake.com/en/sql-reference/sql/create-tag). For asssigning tags to Snowflake objects, see [tag_association resource](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/tag_association). +Resource used to manage tags. For more information, check [tag documentation](https://docs.snowflake.com/en/sql-reference/sql/create-tag). For asssigning tags to Snowflake objects, see [tag_association resource](./tag_association). ## Example Usage diff --git a/pkg/resources/schema.go b/pkg/resources/schema.go index 32fd784e5d..c08d8f796f 100644 --- a/pkg/resources/schema.go +++ b/pkg/resources/schema.go @@ -72,7 +72,7 @@ var schemaSchema = map[string]*schema.Schema{ DescribeOutputAttributeName: { Type: schema.TypeList, Computed: true, - Description: "Outputs the result of `DESCRIBE SCHEMA` for the given object. In order to handle this output, one must grant sufficient privileges, e.g. [grant_ownership](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/grant_ownership) on all objects in the schema.", + Description: "Outputs the result of `DESCRIBE SCHEMA` for the given object. In order to handle this output, one must grant sufficient privileges, e.g. [grant_ownership](./grant_ownership) on all objects in the schema.", Elem: &schema.Resource{ Schema: schemas.SchemaDescribeSchema, }, diff --git a/pkg/resources/tag.go b/pkg/resources/tag.go index 7695fd318b..db58e030bb 100644 --- a/pkg/resources/tag.go +++ b/pkg/resources/tag.go @@ -114,7 +114,7 @@ func Tag() *schema.Resource { ReadContext: TrackingReadWrapper(resources.Tag, ReadContextTag), UpdateContext: TrackingUpdateWrapper(resources.Tag, UpdateContextTag), DeleteContext: TrackingDeleteWrapper(resources.Tag, DeleteContextTag), - Description: "Resource used to manage tags. For more information, check [tag documentation](https://docs.snowflake.com/en/sql-reference/sql/create-tag). For asssigning tags to Snowflake objects, see [tag_association resource](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/tag_association).", + Description: "Resource used to manage tags. For more information, check [tag documentation](https://docs.snowflake.com/en/sql-reference/sql/create-tag). For asssigning tags to Snowflake objects, see [tag_association resource](./tag_association).", CustomizeDiff: TrackingCustomDiffWrapper(resources.Tag, customdiff.All( ComputedIfAnyAttributeChanged(tagSchema, ShowOutputAttributeName, "name", "comment", "allowed_values"), diff --git a/pkg/sdk/tasks_gen_test.go b/pkg/sdk/tasks_gen_test.go index 6df6a9067a..29882d301f 100644 --- a/pkg/sdk/tasks_gen_test.go +++ b/pkg/sdk/tasks_gen_test.go @@ -263,11 +263,12 @@ func TestTasks_Alter(t *testing.T) { t.Run("validation: opts.Set.SessionParameters.SessionParameters should be valid", func(t *testing.T) { opts := defaultOpts() - opts.Set = &TaskSet{} - opts.Set.SessionParameters = &SessionParameters{ - JsonIndent: Int(25), + opts.Set = &TaskSet{ + SessionParameters: &SessionParameters{ + JsonIndent: Int(-1), + }, } - assertOptsInvalidJoinedErrors(t, opts, errIntBetween("SessionParameters", "JSONIndent", 0, 16)) + assertOptsInvalidJoinedErrors(t, opts, errIntValue("SessionParameters", "JsonIndent", IntErrGreaterOrEqual, 0)) }) t.Run("validation: at least one of the fields [opts.Unset.Warehouse opts.Unset.Schedule opts.Unset.Config opts.Unset.AllowOverlappingExecution opts.Unset.UserTaskTimeoutMs opts.Unset.SuspendTaskAfterNumFailures opts.Unset.ErrorIntegration opts.Unset.Comment opts.Unset.SessionParametersUnset] should be set", func(t *testing.T) { @@ -280,7 +281,7 @@ func TestTasks_Alter(t *testing.T) { opts := defaultOpts() opts.Unset = &TaskUnset{} opts.Unset.SessionParametersUnset = &SessionParametersUnset{} - assertOptsInvalidJoinedErrors(t, opts, errAtLeastOneOf("SessionParametersUnset", "AbortDetachedQuery", "Autocommit", "BinaryInputFormat", "BinaryOutputFormat", "ClientMemoryLimit", "ClientMetadataRequestUseConnectionCtx", "ClientPrefetchThreads", "ClientResultChunkSize", "ClientResultColumnCaseInsensitive", "ClientMetadataUseSessionDatabase", "ClientSessionKeepAlive", "ClientSessionKeepAliveHeartbeatFrequency", "ClientTimestampTypeMapping", "DateInputFormat", "DateOutputFormat", "EnableUnloadPhysicalTypeOptimization", "ErrorOnNondeterministicMerge", "ErrorOnNondeterministicUpdate", "GeographyOutputFormat", "GeometryOutputFormat", "JdbcTreatDecimalAsInt", "JdbcTreatTimestampNtzAsUtc", "JdbcUseSessionTimezone", "JSONIndent", "LockTimeout", "LogLevel", "MultiStatementCount", "NoorderSequenceAsDefault", "OdbcTreatDecimalAsInt", "QueryTag", "QuotedIdentifiersIgnoreCase", "RowsPerResultset", "S3StageVpceDnsName", "SearchPath", "SimulatedDataSharingConsumer", "StatementQueuedTimeoutInSeconds", "StatementTimeoutInSeconds", "StrictJSONOutput", "TimestampDayIsAlways24h", "TimestampInputFormat", "TimestampLTZOutputFormat", "TimestampNTZOutputFormat", "TimestampOutputFormat", "TimestampTypeMapping", "TimestampTZOutputFormat", "Timezone", "TimeInputFormat", "TimeOutputFormat", "TraceLevel", "TransactionAbortOnError", "TransactionDefaultIsolationLevel", "TwoDigitCenturyStart", "UnsupportedDDLAction", "UseCachedResult", "WeekOfYearPolicy", "WeekStart")) + assertOptsInvalidJoinedErrors(t, opts, errAtLeastOneOf("SessionParametersUnset", "AbortDetachedQuery", "ActivePythonProfiler", "Autocommit", "BinaryInputFormat", "BinaryOutputFormat", "ClientEnableLogInfoStatementParameters", "ClientMemoryLimit", "ClientMetadataRequestUseConnectionCtx", "ClientPrefetchThreads", "ClientResultChunkSize", "ClientResultColumnCaseInsensitive", "ClientMetadataUseSessionDatabase", "ClientSessionKeepAlive", "ClientSessionKeepAliveHeartbeatFrequency", "ClientTimestampTypeMapping", "CsvTimestampFormat", "DateInputFormat", "DateOutputFormat", "EnableUnloadPhysicalTypeOptimization", "ErrorOnNondeterministicMerge", "ErrorOnNondeterministicUpdate", "GeographyOutputFormat", "GeometryOutputFormat", "HybridTableLockTimeout", "JdbcTreatDecimalAsInt", "JdbcTreatTimestampNtzAsUtc", "JdbcUseSessionTimezone", "JsonIndent", "JsTreatIntegerAsBigInt", "LockTimeout", "LogLevel", "MultiStatementCount", "NoorderSequenceAsDefault", "OdbcTreatDecimalAsInt", "PythonProfilerModules", "PythonProfilerTargetStage", "QueryTag", "QuotedIdentifiersIgnoreCase", "RowsPerResultset", "S3StageVpceDnsName", "SearchPath", "SimulatedDataSharingConsumer", "StatementQueuedTimeoutInSeconds", "StatementTimeoutInSeconds", "StrictJsonOutput", "TimestampDayIsAlways24h", "TimestampInputFormat", "TimestampLTZOutputFormat", "TimestampNTZOutputFormat", "TimestampOutputFormat", "TimestampTypeMapping", "TimestampTZOutputFormat", "Timezone", "TimeInputFormat", "TimeOutputFormat", "TraceLevel", "TransactionAbortOnError", "TransactionDefaultIsolationLevel", "TwoDigitCenturyStart", "UnsupportedDDLAction", "UseCachedResult", "WeekOfYearPolicy", "WeekStart")) }) t.Run("alter resume", func(t *testing.T) { diff --git a/templates/index.md.tmpl b/templates/index.md.tmpl index 67bbd531c3..b2d507fb61 100644 --- a/templates/index.md.tmpl +++ b/templates/index.md.tmpl @@ -55,7 +55,9 @@ To export the variables into your provider: ```shell export SNOWFLAKE_USER="..." -export SNOWFLAKE_PRIVATE_KEY="~/.ssh/snowflake_key" +export SNOWFLAKE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----..." +# Alternatively, source from a file. +export SNOWFLAKE_PRIVATE_KEY=$(cat ~/.ssh/snowflake_key.p8) ``` ### Keypair Authentication Passphrase @@ -77,7 +79,7 @@ To export the variables into your provider: ```shell export SNOWFLAKE_USER="..." -export SNOWFLAKE_PRIVATE_KEY="~/.ssh/snowflake_key.p8" +export SNOWFLAKE_PRIVATE_KEY=$(cat ~/.ssh/snowflake_key.p8) export SNOWFLAKE_PRIVATE_KEY_PASSPHRASE="..." ```