From 17a15a60c5c6ad46abce622fb96a49d503894094 Mon Sep 17 00:00:00 2001 From: Artur Sawicki Date: Fri, 8 Dec 2023 14:02:15 +0100 Subject: [PATCH 1/2] Propose additional debug logging --- README.md | 6 +++ pkg/internal/logging/debug_helpers.go | 18 +++++++ pkg/resources/grant_privileges_to_role.go | 58 ++++++++++++++++++++++- pkg/sdk/grants_impl.go | 15 +++++- 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 pkg/internal/logging/debug_helpers.go diff --git a/README.md b/README.md index bae8da7a9f..51ad78ee7d 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,12 @@ Some links that might help you: - **If you are an enterprise customer**, reach out to your account team. This helps us prioritize issues. - The [issues section](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues) might already have an issue addressing your question. +## Additional debug logs for `snowflake_grant_privileges_to_role` resource +Set environment variable `SF_TF_ADDITIONAL_DEBUG_LOGGING` to a non-empty value. Additional logs will be visible with `sf-tf-additional-debug` prefix, e.g.: +```text +2023/12/08 12:58:22.497078 sf-tf-additional-debug [DEBUG] Creating new client from db +``` + ## Contributing Cf. [Contributing](./CONTRIBUTING.md). diff --git a/pkg/internal/logging/debug_helpers.go b/pkg/internal/logging/debug_helpers.go new file mode 100644 index 0000000000..8ed6257421 --- /dev/null +++ b/pkg/internal/logging/debug_helpers.go @@ -0,0 +1,18 @@ +package logging + +import ( + "io" + "log" + "os" +) + +func init() { + additionalDebugLoggingEnabled = os.Getenv("SF_TF_ADDITIONAL_DEBUG_LOGGING") != "" + DebugLogger = log.New(os.Stderr, "sf-tf-additional-debug ", log.LstdFlags|log.Lmsgprefix|log.LUTC|log.Lmicroseconds) + if !additionalDebugLoggingEnabled { + DebugLogger.SetOutput(io.Discard) + } +} + +var additionalDebugLoggingEnabled bool +var DebugLogger *log.Logger diff --git a/pkg/resources/grant_privileges_to_role.go b/pkg/resources/grant_privileges_to_role.go index c185219dea..cb21954c10 100644 --- a/pkg/resources/grant_privileges_to_role.go +++ b/pkg/resources/grant_privileges_to_role.go @@ -4,6 +4,7 @@ import ( "context" "database/sql" "fmt" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/logging" "log" "strings" @@ -442,12 +443,15 @@ func (v GrantPrivilegesToAccountRoleID) String() string { } func CreateGrantPrivilegesToRole(d *schema.ResourceData, meta interface{}) error { + logging.DebugLogger.Printf("[DEBUG] Entering create grant privileges to role") db := meta.(*sql.DB) + logging.DebugLogger.Printf("[DEBUG] Creating new client from db") client := sdk.NewClientFromDB(db) ctx := context.Background() resourceID := &GrantPrivilegesToAccountRoleID{} var privileges []string if p, ok := d.GetOk("privileges"); ok { + logging.DebugLogger.Printf("[DEBUG] Building privileges list based on config") privileges = expandStringList(p.(*schema.Set).List()) resourceID.Privileges = privileges } @@ -465,17 +469,22 @@ func CreateGrantPrivilegesToRole(d *schema.ResourceData, meta interface{}) error roleName := d.Get("role_name").(string) resourceID.RoleName = roleName roleID := sdk.NewAccountObjectIdentifier(roleName) + logging.DebugLogger.Printf("[DEBUG] About to grant privileges to account role") err = client.Grants.GrantPrivilegesToAccountRole(ctx, privilegesToGrant, on, roleID, &opts) + logging.DebugLogger.Printf("[DEBUG] After granting privileges to account role: err = %v", err) if err != nil { return fmt.Errorf("error granting privileges to account role: %w", err) } + logging.DebugLogger.Printf("[DEBUG] Setting ID to %s", resourceID.String()) d.SetId(resourceID.String()) return ReadGrantPrivilegesToRole(d, meta) } func ReadGrantPrivilegesToRole(d *schema.ResourceData, meta interface{}) error { + logging.DebugLogger.Printf("[DEBUG] Entering read grant privileges to role") db := meta.(*sql.DB) + logging.DebugLogger.Printf("[DEBUG] Creating new client from db") client := sdk.NewClientFromDB(db) ctx := context.Background() resourceID := NewGrantPrivilegesToAccountRoleID(d.Id()) @@ -488,6 +497,7 @@ func ReadGrantPrivilegesToRole(d *schema.ResourceData, meta interface{}) error { var opts sdk.ShowGrantOptions var grantOn sdk.ObjectType if resourceID.OnAccount { + logging.DebugLogger.Printf("[DEBUG] Preparing to read privileges: on account") grantOn = sdk.ObjectTypeAccount opts = sdk.ShowGrantOptions{ On: &sdk.ShowGrantsOn{ @@ -497,6 +507,7 @@ func ReadGrantPrivilegesToRole(d *schema.ResourceData, meta interface{}) error { } if resourceID.OnAccountObject { + logging.DebugLogger.Printf("[DEBUG] Preparing to read privileges: on account object") objectType := sdk.ObjectType(resourceID.ObjectType) grantOn = objectType opts = sdk.ShowGrantOptions{ @@ -510,6 +521,7 @@ func ReadGrantPrivilegesToRole(d *schema.ResourceData, meta interface{}) error { } if resourceID.OnSchema { + logging.DebugLogger.Printf("[DEBUG] Preparing to read privileges: on schema") grantOn = sdk.ObjectTypeSchema if resourceID.SchemaName != "" { opts = sdk.ShowGrantOptions{ @@ -536,6 +548,7 @@ func ReadGrantPrivilegesToRole(d *schema.ResourceData, meta interface{}) error { } if resourceID.OnSchemaObject { + logging.DebugLogger.Printf("[DEBUG] Preparing to read privileges: on schema object") if resourceID.ObjectName != "" { objectType := sdk.ObjectType(resourceID.ObjectType) grantOn = objectType @@ -582,7 +595,9 @@ func ReadGrantPrivilegesToRole(d *schema.ResourceData, meta interface{}) error { } func UpdateGrantPrivilegesToRole(d *schema.ResourceData, meta interface{}) error { + logging.DebugLogger.Printf("[DEBUG] Entering update grant privileges to role") db := meta.(*sql.DB) + logging.DebugLogger.Printf("[DEBUG] Creating new client from db") client := sdk.NewClientFromDB(db) ctx := context.Background() @@ -590,7 +605,9 @@ func UpdateGrantPrivilegesToRole(d *schema.ResourceData, meta interface{}) error roleName := d.Get("role_name").(string) roleID := sdk.NewAccountObjectIdentifier(roleName) + logging.DebugLogger.Printf("[DEBUG] Checking if privileges have changed") if d.HasChange("privileges") { + logging.DebugLogger.Printf("[DEBUG] Privileges have changed") old, new := d.GetChange("privileges") oldPrivileges := expandStringList(old.(*schema.Set).List()) newPrivileges := expandStringList(new.(*schema.Set).List()) @@ -611,11 +628,14 @@ func UpdateGrantPrivilegesToRole(d *schema.ResourceData, meta interface{}) error // first add new privileges if len(addPrivileges) > 0 { + logging.DebugLogger.Printf("[DEBUG] Adding new privileges") privilegesToGrant, on, err := configureAccountRoleGrantPrivilegeOptions(d, addPrivileges, false, &GrantPrivilegesToAccountRoleID{}) if err != nil { return fmt.Errorf("error configuring account role grant privilege options: %w", err) } + logging.DebugLogger.Printf("[DEBUG] About to grant privileges to account role") err = client.Grants.GrantPrivilegesToAccountRole(ctx, privilegesToGrant, on, roleID, nil) + logging.DebugLogger.Printf("[DEBUG] After granting privileges to account role: err = %v", err) if err != nil { return fmt.Errorf("error granting privileges to account role: %w", err) } @@ -623,15 +643,19 @@ func UpdateGrantPrivilegesToRole(d *schema.ResourceData, meta interface{}) error // then remove old privileges if len(removePrivileges) > 0 { + logging.DebugLogger.Printf("[DEBUG] Removing old privileges") privilegesToRevoke, on, err := configureAccountRoleGrantPrivilegeOptions(d, removePrivileges, false, &GrantPrivilegesToAccountRoleID{}) if err != nil { return fmt.Errorf("error configuring account role grant privilege options: %w", err) } + logging.DebugLogger.Printf("[DEBUG] About to revoke privileges from account role") err = client.Grants.RevokePrivilegesFromAccountRole(ctx, privilegesToRevoke, on, roleID, nil) + logging.DebugLogger.Printf("[DEBUG] After revoking privileges from account role: err = %v", err) if err != nil { return fmt.Errorf("error revoking privileges from account role: %w", err) } } + logging.DebugLogger.Printf("[DEBUG] Setting new values") resourceID := NewGrantPrivilegesToAccountRoleID(d.Id()) resourceID.Privileges = newPrivileges d.SetId(resourceID.String()) @@ -640,7 +664,9 @@ func UpdateGrantPrivilegesToRole(d *schema.ResourceData, meta interface{}) error } func DeleteGrantPrivilegesToRole(d *schema.ResourceData, meta interface{}) error { + logging.DebugLogger.Printf("[DEBUG] Entering delete grant privileges to role") db := meta.(*sql.DB) + logging.DebugLogger.Printf("[DEBUG] Creating new client from db") client := sdk.NewClientFromDB(db) ctx := context.Background() @@ -656,19 +682,23 @@ func DeleteGrantPrivilegesToRole(d *schema.ResourceData, meta interface{}) error if err != nil { return fmt.Errorf("error configuring account role grant privilege options: %w", err) } - + logging.DebugLogger.Printf("[DEBUG] About to revoke privileges from account role") err = client.Grants.RevokePrivilegesFromAccountRole(ctx, privilegesToRevoke, on, roleID, nil) + logging.DebugLogger.Printf("[DEBUG] After revoking privileges from account role: err = %v", err) if err != nil { return fmt.Errorf("error revoking privileges from account role: %w", err) } + logging.DebugLogger.Printf("[DEBUG] Cleaning resource id") d.SetId("") return nil } func configureAccountRoleGrantPrivilegeOptions(d *schema.ResourceData, privileges []string, allPrivileges bool, resourceID *GrantPrivilegesToAccountRoleID) (*sdk.AccountRoleGrantPrivileges, *sdk.AccountRoleGrantOn, error) { + logging.DebugLogger.Printf("[DEBUG] Configuring account role grant privileges options") var privilegesToGrant *sdk.AccountRoleGrantPrivileges on := sdk.AccountRoleGrantOn{} if v, ok := d.GetOk("on_account"); ok && v.(bool) { + logging.DebugLogger.Printf("[DEBUG] Configuring account role grant privileges options: on account") on.Account = sdk.Bool(true) resourceID.OnAccount = true privilegesToGrant = setAccountRolePrivilegeOptions(privileges, allPrivileges, true, false, false, false) @@ -676,6 +706,7 @@ func configureAccountRoleGrantPrivilegeOptions(d *schema.ResourceData, privilege } if v, ok := d.GetOk("on_account_object"); ok && len(v.([]interface{})) > 0 { + logging.DebugLogger.Printf("[DEBUG] Configuring account role grant privileges options: on account object") on.AccountObject = &sdk.GrantOnAccountObject{} resourceID.OnAccountObject = true onAccountObject := v.([]interface{})[0].(map[string]interface{}) @@ -707,14 +738,17 @@ func configureAccountRoleGrantPrivilegeOptions(d *schema.ResourceData, privilege } if v, ok := d.GetOk("on_schema"); ok && len(v.([]interface{})) > 0 { + logging.DebugLogger.Printf("[DEBUG] Configuring account role grant privileges options: on schema") onSchema := v.([]interface{})[0].(map[string]interface{}) on.Schema = &sdk.GrantOnSchema{} resourceID.OnSchema = true if v, ok := onSchema["schema_name"]; ok && len(v.(string)) > 0 { + logging.DebugLogger.Printf("[DEBUG] Configuring account role grant privileges options: setting schema name") resourceID.SchemaName = v.(string) on.Schema.Schema = sdk.Pointer(sdk.NewDatabaseObjectIdentifierFromFullyQualifiedName(v.(string))) } if v, ok := onSchema["all_schemas_in_database"]; ok && len(v.(string)) > 0 { + logging.DebugLogger.Printf("[DEBUG] Configuring account role grant privileges options: setting all schemas in database") resourceID.All = true resourceID.InDatabase = true resourceID.DatabaseName = v.(string) @@ -722,6 +756,7 @@ func configureAccountRoleGrantPrivilegeOptions(d *schema.ResourceData, privilege } if v, ok := onSchema["future_schemas_in_database"]; ok && len(v.(string)) > 0 { + logging.DebugLogger.Printf("[DEBUG] Configuring account role grant privileges options: setting future schemas in database") resourceID.Future = true resourceID.InDatabase = true resourceID.DatabaseName = v.(string) @@ -732,20 +767,24 @@ func configureAccountRoleGrantPrivilegeOptions(d *schema.ResourceData, privilege } if v, ok := d.GetOk("on_schema_object"); ok && len(v.([]interface{})) > 0 { + logging.DebugLogger.Printf("[DEBUG] Configuring account role grant privileges options: on schema object") onSchemaObject := v.([]interface{})[0].(map[string]interface{}) on.SchemaObject = &sdk.GrantOnSchemaObject{} resourceID.OnSchemaObject = true if v, ok := onSchemaObject["object_type"]; ok && len(v.(string)) > 0 { + logging.DebugLogger.Printf("[DEBUG] Configuring account role grant privileges options: setting schema object type") resourceID.ObjectType = v.(string) on.SchemaObject.SchemaObject = &sdk.Object{ ObjectType: sdk.ObjectType(v.(string)), } } if v, ok := onSchemaObject["object_name"]; ok && len(v.(string)) > 0 { + logging.DebugLogger.Printf("[DEBUG] Configuring account role grant privileges options: setting schema object name") resourceID.ObjectName = v.(string) on.SchemaObject.SchemaObject.Name = sdk.Pointer(sdk.NewSchemaObjectIdentifierFromFullyQualifiedName(v.(string))) } if v, ok := onSchemaObject["all"]; ok && len(v.([]interface{})) > 0 { + logging.DebugLogger.Printf("[DEBUG] Configuring account role grant privileges options: setting all") all := v.([]interface{})[0].(map[string]interface{}) on.SchemaObject.All = &sdk.GrantOnSchemaObjectIn{} resourceID.All = true @@ -753,11 +792,13 @@ func configureAccountRoleGrantPrivilegeOptions(d *schema.ResourceData, privilege resourceID.ObjectTypePlural = pluralObjectType on.SchemaObject.All.PluralObjectType = sdk.PluralObjectType(pluralObjectType) if v, ok := all["in_database"]; ok && len(v.(string)) > 0 { + logging.DebugLogger.Printf("[DEBUG] Configuring account role grant privileges options: setting all in database") resourceID.InDatabase = true resourceID.DatabaseName = v.(string) on.SchemaObject.All.InDatabase = sdk.Pointer(sdk.NewAccountObjectIdentifierFromFullyQualifiedName(v.(string))) } if v, ok := all["in_schema"]; ok && len(v.(string)) > 0 { + logging.DebugLogger.Printf("[DEBUG] Configuring account role grant privileges options: setting all in schema") resourceID.InSchema = true resourceID.SchemaName = v.(string) on.SchemaObject.All.InSchema = sdk.Pointer(sdk.NewDatabaseObjectIdentifierFromFullyQualifiedName(v.(string))) @@ -765,6 +806,7 @@ func configureAccountRoleGrantPrivilegeOptions(d *schema.ResourceData, privilege } if v, ok := onSchemaObject["future"]; ok && len(v.([]interface{})) > 0 { + logging.DebugLogger.Printf("[DEBUG] Configuring account role grant privileges options: setting future") future := v.([]interface{})[0].(map[string]interface{}) resourceID.Future = true on.SchemaObject.Future = &sdk.GrantOnSchemaObjectIn{} @@ -772,11 +814,13 @@ func configureAccountRoleGrantPrivilegeOptions(d *schema.ResourceData, privilege resourceID.ObjectTypePlural = pluralObjectType on.SchemaObject.Future.PluralObjectType = sdk.PluralObjectType(pluralObjectType) if v, ok := future["in_database"]; ok && len(v.(string)) > 0 { + logging.DebugLogger.Printf("[DEBUG] Configuring account role grant privileges options: setting future in database") resourceID.InDatabase = true resourceID.DatabaseName = v.(string) on.SchemaObject.Future.InDatabase = sdk.Pointer(sdk.NewAccountObjectIdentifierFromFullyQualifiedName(v.(string))) } if v, ok := future["in_schema"]; ok && len(v.(string)) > 0 { + logging.DebugLogger.Printf("[DEBUG] Configuring account role grant privileges options: setting future in schema") resourceID.InSchema = true resourceID.SchemaName = v.(string) on.SchemaObject.Future.InSchema = sdk.Pointer(sdk.NewDatabaseObjectIdentifierFromFullyQualifiedName(v.(string))) @@ -786,16 +830,19 @@ func configureAccountRoleGrantPrivilegeOptions(d *schema.ResourceData, privilege privilegesToGrant = setAccountRolePrivilegeOptions(privileges, allPrivileges, false, false, false, true) return privilegesToGrant, &on, nil } + logging.DebugLogger.Printf("[DEBUG] Configuring account role grant privileges options: invalid") return nil, nil, fmt.Errorf("invalid grant options") } func setAccountRolePrivilegeOptions(privileges []string, allPrivileges bool, onAccount bool, onAccountObject bool, onSchema bool, onSchemaObject bool) *sdk.AccountRoleGrantPrivileges { privilegesToGrant := &sdk.AccountRoleGrantPrivileges{} if allPrivileges { + logging.DebugLogger.Printf("[DEBUG] Setting all privileges on privileges to grant") privilegesToGrant.AllPrivileges = sdk.Bool(true) return privilegesToGrant } if onAccount { + logging.DebugLogger.Printf("[DEBUG] Setting global privileges on privileges to grant") privilegesToGrant.GlobalPrivileges = []sdk.GlobalPrivilege{} for _, privilege := range privileges { privilegesToGrant.GlobalPrivileges = append(privilegesToGrant.GlobalPrivileges, sdk.GlobalPrivilege(privilege)) @@ -803,6 +850,7 @@ func setAccountRolePrivilegeOptions(privileges []string, allPrivileges bool, onA return privilegesToGrant } if onAccountObject { + logging.DebugLogger.Printf("[DEBUG] Setting account object privileges on privileges to grant") privilegesToGrant.AccountObjectPrivileges = []sdk.AccountObjectPrivilege{} for _, privilege := range privileges { privilegesToGrant.AccountObjectPrivileges = append(privilegesToGrant.AccountObjectPrivileges, sdk.AccountObjectPrivilege(privilege)) @@ -810,6 +858,7 @@ func setAccountRolePrivilegeOptions(privileges []string, allPrivileges bool, onA return privilegesToGrant } if onSchema { + logging.DebugLogger.Printf("[DEBUG] Setting schema privileges on privileges to grant") privilegesToGrant.SchemaPrivileges = []sdk.SchemaPrivilege{} for _, privilege := range privileges { privilegesToGrant.SchemaPrivileges = append(privilegesToGrant.SchemaPrivileges, sdk.SchemaPrivilege(privilege)) @@ -817,17 +866,21 @@ func setAccountRolePrivilegeOptions(privileges []string, allPrivileges bool, onA return privilegesToGrant } if onSchemaObject { + logging.DebugLogger.Printf("[DEBUG] Setting schema object privileges on privileges to grant") privilegesToGrant.SchemaObjectPrivileges = []sdk.SchemaObjectPrivilege{} for _, privilege := range privileges { privilegesToGrant.SchemaObjectPrivileges = append(privilegesToGrant.SchemaObjectPrivileges, sdk.SchemaObjectPrivilege(privilege)) } return privilegesToGrant } + logging.DebugLogger.Printf("[DEBUG] Not setting any privileges on privileges to grant") return nil } func readAccountRoleGrantPrivileges(ctx context.Context, client *sdk.Client, grantedOn sdk.ObjectType, id GrantPrivilegesToAccountRoleID, opts *sdk.ShowGrantOptions, d *schema.ResourceData) error { + logging.DebugLogger.Printf("[DEBUG] About to show grants") grants, err := client.Grants.Show(ctx, opts) + logging.DebugLogger.Printf("[DEBUG] After showing grants: err = %v", err) if err != nil { return fmt.Errorf("error retrieving grants for account role: %w", err) } @@ -836,6 +889,7 @@ func readAccountRoleGrantPrivileges(ctx context.Context, client *sdk.Client, gra privileges := []string{} roleName := d.Get("role_name").(string) + logging.DebugLogger.Printf("[DEBUG] Filtering grants to be set on account: count = %d", len(grants)) for _, grant := range grants { // Only consider privileges that are already present in the ID so we // don't delete privileges managed by other resources. @@ -854,7 +908,9 @@ func readAccountRoleGrantPrivileges(ctx context.Context, client *sdk.Client, gra } } } + logging.DebugLogger.Printf("[DEBUG] Setting privileges on account") if err := d.Set("privileges", privileges); err != nil { + logging.DebugLogger.Printf("[DEBUG] Error setting privileges for account role: err = %v", err) return fmt.Errorf("error setting privileges for account role: %w", err) } return nil diff --git a/pkg/sdk/grants_impl.go b/pkg/sdk/grants_impl.go index e2a078556e..31f978dd64 100644 --- a/pkg/sdk/grants_impl.go +++ b/pkg/sdk/grants_impl.go @@ -1,6 +1,10 @@ package sdk -import "context" +import ( + "context" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/logging" +) var _ Grants = (*grants)(nil) @@ -9,22 +13,26 @@ type grants struct { } func (v *grants) GrantPrivilegesToAccountRole(ctx context.Context, privileges *AccountRoleGrantPrivileges, on *AccountRoleGrantOn, role AccountObjectIdentifier, opts *GrantPrivilegesToAccountRoleOptions) error { + logging.DebugLogger.Printf("[DEBUG] Grant privileges to account role") if opts == nil { opts = &GrantPrivilegesToAccountRoleOptions{} } opts.privileges = privileges opts.on = on opts.accountRole = role + logging.DebugLogger.Printf("[DEBUG] Grant privileges to account role: opts %+v", opts) return validateAndExec(v.client, ctx, opts) } func (v *grants) RevokePrivilegesFromAccountRole(ctx context.Context, privileges *AccountRoleGrantPrivileges, on *AccountRoleGrantOn, role AccountObjectIdentifier, opts *RevokePrivilegesFromAccountRoleOptions) error { + logging.DebugLogger.Printf("[DEBUG] Revoke privileges from account role") if opts == nil { opts = &RevokePrivilegesFromAccountRoleOptions{} } opts.privileges = privileges opts.on = on opts.accountRole = role + logging.DebugLogger.Printf("[DEBUG] Revoke privileges from account role: opts %+v", opts) return validateAndExec(v.client, ctx, opts) } @@ -76,14 +84,19 @@ func (v *grants) GrantOwnership(ctx context.Context, on OwnershipGrantOn, to Own } func (v *grants) Show(ctx context.Context, opts *ShowGrantOptions) ([]Grant, error) { + logging.DebugLogger.Printf("[DEBUG] Show grants") if opts == nil { opts = &ShowGrantOptions{} } + logging.DebugLogger.Printf("[DEBUG] Show grants: opts %+v", opts) dbRows, err := validateAndQuery[grantRow](v.client, ctx, opts) + logging.DebugLogger.Printf("[DEBUG] Show grants: query finished err = %v", err) if err != nil { return nil, err } + logging.DebugLogger.Printf("[DEBUG] Show grants: converting rows") resultList := convertRows[grantRow, Grant](dbRows) + logging.DebugLogger.Printf("[DEBUG] Show grants: rows converted") return resultList, nil } From 60b79aaa1c2ccf9111be1691de0ea4249ab52e81 Mon Sep 17 00:00:00 2001 From: Artur Sawicki Date: Fri, 8 Dec 2023 14:15:58 +0100 Subject: [PATCH 2/2] Fix fmt complains --- pkg/internal/logging/debug_helpers.go | 6 ++++-- pkg/resources/grant_privileges_to_role.go | 2 +- pkg/resources/schema_acceptance_test.go | 6 +++--- pkg/resources/testdata/TestAcc_Schema/test.tf | 4 ++-- pkg/resources/testdata/TestAcc_Schema_Rename/test.tf | 4 ++-- .../1/test.tf | 2 +- .../2/test.tf | 4 ++-- pkg/sdk/tables_dto.go | 2 +- pkg/sdk/tables_dto_generated.go | 12 ++++++------ 9 files changed, 22 insertions(+), 20 deletions(-) diff --git a/pkg/internal/logging/debug_helpers.go b/pkg/internal/logging/debug_helpers.go index 8ed6257421..c8f6e50708 100644 --- a/pkg/internal/logging/debug_helpers.go +++ b/pkg/internal/logging/debug_helpers.go @@ -14,5 +14,7 @@ func init() { } } -var additionalDebugLoggingEnabled bool -var DebugLogger *log.Logger +var ( + additionalDebugLoggingEnabled bool + DebugLogger *log.Logger +) diff --git a/pkg/resources/grant_privileges_to_role.go b/pkg/resources/grant_privileges_to_role.go index cb21954c10..e8a08d4d1c 100644 --- a/pkg/resources/grant_privileges_to_role.go +++ b/pkg/resources/grant_privileges_to_role.go @@ -4,11 +4,11 @@ import ( "context" "database/sql" "fmt" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/logging" "log" "strings" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/logging" "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" diff --git a/pkg/resources/schema_acceptance_test.go b/pkg/resources/schema_acceptance_test.go index 435561c958..456771435b 100644 --- a/pkg/resources/schema_acceptance_test.go +++ b/pkg/resources/schema_acceptance_test.go @@ -4,15 +4,15 @@ import ( "context" "database/sql" "fmt" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" - "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-testing/terraform" "strings" "testing" acc "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/acceptance" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" "github.com/hashicorp/terraform-plugin-testing/config" + "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-plugin-testing/tfversion" ) diff --git a/pkg/resources/testdata/TestAcc_Schema/test.tf b/pkg/resources/testdata/TestAcc_Schema/test.tf index 5f8ca0abfc..ce85eca50c 100644 --- a/pkg/resources/testdata/TestAcc_Schema/test.tf +++ b/pkg/resources/testdata/TestAcc_Schema/test.tf @@ -1,5 +1,5 @@ resource "snowflake_schema" "test" { - name = var.name + name = var.name database = var.database - comment = var.comment + comment = var.comment } \ No newline at end of file diff --git a/pkg/resources/testdata/TestAcc_Schema_Rename/test.tf b/pkg/resources/testdata/TestAcc_Schema_Rename/test.tf index 5f8ca0abfc..ce85eca50c 100644 --- a/pkg/resources/testdata/TestAcc_Schema_Rename/test.tf +++ b/pkg/resources/testdata/TestAcc_Schema_Rename/test.tf @@ -1,5 +1,5 @@ resource "snowflake_schema" "test" { - name = var.name + name = var.name database = var.database - comment = var.comment + comment = var.comment } \ No newline at end of file diff --git a/pkg/resources/testdata/TestAcc_Schema_TwoSchemasWithTheSameNameOnDifferentDatabases/1/test.tf b/pkg/resources/testdata/TestAcc_Schema_TwoSchemasWithTheSameNameOnDifferentDatabases/1/test.tf index 991e3b38d5..4325ee4234 100644 --- a/pkg/resources/testdata/TestAcc_Schema_TwoSchemasWithTheSameNameOnDifferentDatabases/1/test.tf +++ b/pkg/resources/testdata/TestAcc_Schema_TwoSchemasWithTheSameNameOnDifferentDatabases/1/test.tf @@ -1,4 +1,4 @@ resource "snowflake_schema" "test" { - name = var.name + name = var.name database = var.database } \ No newline at end of file diff --git a/pkg/resources/testdata/TestAcc_Schema_TwoSchemasWithTheSameNameOnDifferentDatabases/2/test.tf b/pkg/resources/testdata/TestAcc_Schema_TwoSchemasWithTheSameNameOnDifferentDatabases/2/test.tf index bc1af37dd8..0b1a598ccf 100644 --- a/pkg/resources/testdata/TestAcc_Schema_TwoSchemasWithTheSameNameOnDifferentDatabases/2/test.tf +++ b/pkg/resources/testdata/TestAcc_Schema_TwoSchemasWithTheSameNameOnDifferentDatabases/2/test.tf @@ -1,5 +1,5 @@ resource "snowflake_schema" "test" { - name = var.name + name = var.name database = var.database } @@ -8,6 +8,6 @@ resource "snowflake_database" "test" { } resource "snowflake_schema" "test_2" { - name = var.name + name = var.name database = snowflake_database.test.name } diff --git a/pkg/sdk/tables_dto.go b/pkg/sdk/tables_dto.go index c490558deb..49fb03da58 100644 --- a/pkg/sdk/tables_dto.go +++ b/pkg/sdk/tables_dto.go @@ -508,7 +508,7 @@ type TableExternalTableColumnRenameActionRequest struct { } type TableExternalTableColumnDropActionRequest struct { - Columns []string //required + Columns []string // required IfExists *bool } diff --git a/pkg/sdk/tables_dto_generated.go b/pkg/sdk/tables_dto_generated.go index ed88b35cb3..3573a85be8 100644 --- a/pkg/sdk/tables_dto_generated.go +++ b/pkg/sdk/tables_dto_generated.go @@ -673,20 +673,20 @@ func (s *DropTableRequest) WithRestrict(restrict *bool) *DropTableRequest { } func NewTableAddRowAccessPolicyRequest( - RowAccessPolicy SchemaObjectIdentifier, - On []string, + rowAccessPolicy SchemaObjectIdentifier, + on []string, ) *TableAddRowAccessPolicyRequest { s := TableAddRowAccessPolicyRequest{} - s.RowAccessPolicy = RowAccessPolicy - s.On = On + s.RowAccessPolicy = rowAccessPolicy + s.On = on return &s } func NewTableDropRowAccessPolicyRequest( - RowAccessPolicy SchemaObjectIdentifier, + rowAccessPolicy SchemaObjectIdentifier, ) *TableDropRowAccessPolicyRequest { s := TableDropRowAccessPolicyRequest{} - s.RowAccessPolicy = RowAccessPolicy + s.RowAccessPolicy = rowAccessPolicy return &s }