Skip to content

Commit

Permalink
chore: 0.84 release (#2374)
Browse files Browse the repository at this point in the history
fix sweepers. currently `SHOW DATABASES` also returns applications, so
`DROP DATABASE XXX` will fail on it. Once we get Applications added to
SDK then we can do `DROP APPLICATION XXX` instead
  • Loading branch information
sfc-gh-swinkler authored Jan 19, 2024
1 parent a648ca7 commit 18638fe
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
4 changes: 2 additions & 2 deletions pkg/resources/resource_monitor_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestAcc_ResourceMonitorChangeStartEndTimestamp(t *testing.T) {
func resourceMonitorConfigUpdatedTimestamp(accName string) string {
return fmt.Sprintf(`
resource "snowflake_warehouse" "warehouse" {
name = "test"
name = "test%v"
comment = "foo"
warehouse_size = "XSMALL"
}
Expand All @@ -119,7 +119,7 @@ resource "snowflake_resource_monitor" "test" {
end_timestamp = "2056-01-01 12:00"
}
`, accName)
`, accName, accName)
}

// fix 2 added empy notifiy user
Expand Down
10 changes: 4 additions & 6 deletions pkg/resources/table_constraint.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"log"
"strings"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/snowflake"
snowflakeValidation "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/validation"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand All @@ -33,11 +32,10 @@ var tableConstraintSchema = map[string]*schema.Schema{
},
},
"table_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "Idenfifier for table to create constraint on. Must be of the form Note: format must follow: \"<db_name>\".\"<schema_name>\".\"<table_name>\" or \"<db_name>.<schema_name>.<table_name>\" or \"<db_name>|<schema_name>.<table_name>\" (snowflake_table.my_table.id)",
ValidateDiagFunc: IsValidIdentifier[sdk.SchemaObjectIdentifier](),
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "Idenfifier for table to create constraint on. Must be of the form Note: format must follow: \"<db_name>\".\"<schema_name>\".\"<table_name>\" or \"<db_name>.<schema_name>.<table_name>\" or \"<db_name>|<schema_name>.<table_name>\" (snowflake_table.my_table.id)",
},
"columns": {
Type: schema.TypeList,
Expand Down
10 changes: 4 additions & 6 deletions pkg/resources/tag_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/snowflake"
snowflakeValidation "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/validation"
)
Expand Down Expand Up @@ -65,11 +64,10 @@ var tagAssociationSchema = map[string]*schema.Schema{
ForceNew: true,
},
"tag_id": {
Type: schema.TypeString,
Required: true,
Description: "Specifies the identifier for the tag. Note: format must follow: \"databaseName\".\"schemaName\".\"tagName\" or \"databaseName.schemaName.tagName\" or \"databaseName|schemaName.tagName\" (snowflake_tag.tag.id)",
ValidateDiagFunc: IsValidIdentifier[sdk.SchemaObjectIdentifier](),
ForceNew: true,
Type: schema.TypeString,
Required: true,
Description: "Specifies the identifier for the tag. Note: format must follow: \"databaseName\".\"schemaName\".\"tagName\" or \"databaseName.schemaName.tagName\" or \"databaseName|schemaName.tagName\" (snowflake_tag.tag.id)",
ForceNew: true,
},
"tag_value": {
Type: schema.TypeString,
Expand Down
9 changes: 4 additions & 5 deletions pkg/resources/tag_masking_policy_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ const (

var mpAttachmentPolicySchema = map[string]*schema.Schema{
"tag_id": {
Type: schema.TypeString,
Required: true,
Description: "Specifies the identifier for the tag. Note: format must follow: \"databaseName\".\"schemaName\".\"tagName\" or \"databaseName.schemaName.tagName\" or \"databaseName|schemaName.tagName\" (snowflake_tag.tag.id)",
ValidateDiagFunc: IsValidIdentifier[sdk.SchemaObjectIdentifier](),
ForceNew: true,
Type: schema.TypeString,
Required: true,
Description: "Specifies the identifier for the tag. Note: format must follow: \"databaseName\".\"schemaName\".\"tagName\" or \"databaseName.schemaName.tagName\" or \"databaseName|schemaName.tagName\" (snowflake_tag.tag.id)",
ForceNew: true,
},
"masking_policy_id": {
Type: schema.TypeString,
Expand Down
6 changes: 5 additions & 1 deletion pkg/sdk/sweepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ func getDatabaseSweeper(client *Client, prefix string) func() error {
if (prefix == "" || strings.HasPrefix(db.Name, prefix)) && db.Name != "SNOWFLAKE" && db.Name != "terraform_test_database" {
log.Printf("[DEBUG] Dropping database %s", db.Name)
if err := client.Databases.Drop(ctx, db.ID(), nil); err != nil {
return err
if strings.Contains(err.Error(), "Object found is of type 'APPLICATION', not specified type 'DATABASE'") {
log.Printf("[DEBUG] Skipping database %s", db.Name)
} else {
return err
}
}
} else {
log.Printf("[DEBUG] Skipping database %s", db.Name)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sdk/testint/application_packages_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func TestInt_ApplicationPackagesVersionAndReleaseDirective(t *testing.T) {
createApplicationPackageHandle := func(t *testing.T) *sdk.ApplicationPackage {
t.Helper()

id := sdk.NewAccountObjectIdentifier("snowflake_package_test")
id := sdk.RandomAccountObjectIdentifier()
request := sdk.NewCreateApplicationPackageRequest(id).WithDistribution(sdk.DistributionPointer(sdk.DistributionInternal))
err := client.ApplicationPackages.Create(ctx, request)
require.NoError(t, err)
Expand Down

0 comments on commit 18638fe

Please sign in to comment.