Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use suppressQuoting to fix stage file_format permadiff #2885

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/resources/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func suppressIdentifierQuoting(_, oldValue, newValue string, _ *schema.ResourceD
}

// TODO [SNOW-1325214]: address during stage resource rework
func suppressCopyOptionsQuoting(_, oldValue, newValue string, _ *schema.ResourceData) bool {
func suppressQuoting(_, oldValue, newValue string, _ *schema.ResourceData) bool {
if oldValue == "" || newValue == "" {
return false
} else {
Expand Down
9 changes: 5 additions & 4 deletions pkg/resources/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ var stageSchema = map[string]*schema.Schema{
Description: "Specifies the name of the storage integration used to delegate authentication responsibility for external cloud storage to a Snowflake identity and access management (IAM) entity.",
},
"file_format": {
Type: schema.TypeString,
Optional: true,
Description: "Specifies the file format for the stage.",
Type: schema.TypeString,
Optional: true,
Description: "Specifies the file format for the stage.",
DiffSuppressFunc: suppressQuoting,
},
"copy_options": {
Type: schema.TypeString,
Optional: true,
Description: "Specifies the copy options for the stage.",
DiffSuppressFunc: suppressCopyOptionsQuoting,
DiffSuppressFunc: suppressQuoting,
},
"encryption": {
Type: schema.TypeString,
Expand Down
20 changes: 20 additions & 0 deletions pkg/resources/stage_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func TestAcc_Stage_CreateAndAlter(t *testing.T) {
changedStorageIntegration := ids.PrecreatedS3StorageIntegration
changedEncryption := "TYPE = 'AWS_SSE_S3'"
changedFileFormat := "TYPE = JSON NULL_IF = []"
changedFileFormatWithQuotes := "FIELD_DELIMITER = '|' PARSE_HEADER = true"
changedComment := random.Comment()
copyOptionsWithoutQuotes := "ON_ERROR = CONTINUE"

Expand Down Expand Up @@ -129,6 +130,25 @@ func TestAcc_Stage_CreateAndAlter(t *testing.T) {
PostApplyPreRefresh: []plancheck.PlanCheck{plancheck.ExpectEmptyPlan()},
},
},
{
ConfigDirectory: config.TestNameDirectory(),
ConfigVariables: configVariables(changedUrl, changedStorageIntegration.Name(), credentials, changedEncryption, changedFileFormatWithQuotes, changedComment, copyOptionsWithoutQuotes),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "database", databaseName),
resource.TestCheckResourceAttr(resourceName, "schema", schemaName),
resource.TestCheckResourceAttr(resourceName, "name", name),
resource.TestCheckResourceAttr(resourceName, "storage_integration", changedStorageIntegration.Name()),
resource.TestCheckResourceAttr(resourceName, "credentials", credentials),
resource.TestCheckResourceAttr(resourceName, "encryption", changedEncryption),
resource.TestCheckResourceAttr(resourceName, "file_format", changedFileFormatWithQuotes),
resource.TestCheckResourceAttr(resourceName, "copy_options", copyOptionsWithoutQuotes),
resource.TestCheckResourceAttr(resourceName, "url", changedUrl),
resource.TestCheckResourceAttr(resourceName, "comment", changedComment),
),
ConfigPlanChecks: resource.ConfigPlanChecks{
PostApplyPreRefresh: []plancheck.PlanCheck{plancheck.ExpectEmptyPlan()},
},
},
{
ConfigDirectory: config.TestNameDirectory(),
ConfigVariables: configVariables(changedUrl, changedStorageIntegration.Name(), credentials, changedEncryption, changedFileFormat, changedComment, copyOptionsWithoutQuotes),
Expand Down
Loading