From 2e60e0bff6ddaab7d67128e908230b38d9f45156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Cie=C5=9Blak?= Date: Thu, 21 Nov 2024 16:49:00 +0100 Subject: [PATCH] changes after review --- docs/resources/storage_integration.md | 2 +- pkg/resources/storage_integration.go | 3 ++- pkg/sdk/storage_integration_def.go | 9 ++++++--- pkg/sdk/storage_integration_gen_test.go | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/resources/storage_integration.md b/docs/resources/storage_integration.md index 2905735bf2..23e69ec9b6 100644 --- a/docs/resources/storage_integration.md +++ b/docs/resources/storage_integration.md @@ -42,7 +42,7 @@ resource "snowflake_storage_integration" "integration" { - `name` (String) - `storage_allowed_locations` (List of String) Explicitly limits external stages that use the integration to reference one or more storage locations. -- `storage_provider` (String) +- `storage_provider` (String) Specifies the storage provider for the integration. Valid options are: `S3` | `S3GOV` | `S3CHINA` | `GCS` | `AZURE` ### Optional diff --git a/pkg/resources/storage_integration.go b/pkg/resources/storage_integration.go index ad0d9c65e1..85a40729d3 100644 --- a/pkg/resources/storage_integration.go +++ b/pkg/resources/storage_integration.go @@ -57,7 +57,8 @@ var storageIntegrationSchema = map[string]*schema.Schema{ Type: schema.TypeString, Required: true, ForceNew: true, - ValidateDiagFunc: StringInSlice(append(sdk.AsStringList(sdk.AllS3Protocols), "GCS", "AZURE"), true), + ValidateDiagFunc: StringInSlice(sdk.AllStorageProviders, true), + Description: fmt.Sprintf("Specifies the storage provider for the integration. Valid options are: %s", possibleValuesListed(sdk.AllStorageProviders)), }, "storage_aws_external_id": { Type: schema.TypeString, diff --git a/pkg/sdk/storage_integration_def.go b/pkg/sdk/storage_integration_def.go index c5dcc8ad3f..04e24c37da 100644 --- a/pkg/sdk/storage_integration_def.go +++ b/pkg/sdk/storage_integration_def.go @@ -2,8 +2,9 @@ package sdk import ( "fmt" - g "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/poc/generator" "strings" + + g "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk/poc/generator" ) //go:generate go run ./poc/main.go @@ -16,7 +17,10 @@ const ( ChinaS3Protocol S3Protocol = "S3CHINA" ) -var AllS3Protocols = []S3Protocol{RegularS3Protocol, GovS3Protocol, ChinaS3Protocol} +var ( + AllS3Protocols = []S3Protocol{RegularS3Protocol, GovS3Protocol, ChinaS3Protocol} + AllStorageProviders = append(AsStringList(AllS3Protocols), "GCS", "AZURE") +) func ToS3Protocol(s string) (S3Protocol, error) { switch protocol := S3Protocol(strings.ToUpper(s)); protocol { @@ -47,7 +51,6 @@ var StorageIntegrationDef = g.NewInterface( "S3StorageProviderParams", g.NewQueryStruct("S3StorageParams"). PredefinedQueryStructField("Protocol", g.KindOfT[S3Protocol](), g.ParameterOptions().SQL("STORAGE_PROVIDER").SingleQuotes().Required()). - //PredefinedQueryStructField("storageProvider", "string", g.StaticOptions().SQL("STORAGE_PROVIDER = 'S3'")). TextAssignment("STORAGE_AWS_ROLE_ARN", g.ParameterOptions().SingleQuotes().Required()). OptionalTextAssignment("STORAGE_AWS_OBJECT_ACL", g.ParameterOptions().SingleQuotes()), g.KeywordOptions(), diff --git a/pkg/sdk/storage_integration_gen_test.go b/pkg/sdk/storage_integration_gen_test.go index 20f00d98c6..61c74ddac2 100644 --- a/pkg/sdk/storage_integration_gen_test.go +++ b/pkg/sdk/storage_integration_gen_test.go @@ -2,8 +2,9 @@ package sdk import ( "fmt" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestStorageIntegrations_Create(t *testing.T) {