diff --git a/docs/resources/grant_privileges_to_database_role.md b/docs/resources/grant_privileges_to_database_role.md index 00000c23975..0b8c5bbcc9c 100644 --- a/docs/resources/grant_privileges_to_database_role.md +++ b/docs/resources/grant_privileges_to_database_role.md @@ -245,7 +245,7 @@ where: - grant_type - enum - grant_data - enum data -It has varying number of parts, depending on . All the possible types are: +It has varying number of parts, depending on grant_type. All the possible types are: ### OnDatabase `terraform import "||||OnDatabase|"` diff --git a/pkg/resources/grant_privileges_to_database_role.go b/pkg/resources/grant_privileges_to_database_role.go index 44b91bb1619..dcfea1edc9a 100644 --- a/pkg/resources/grant_privileges_to_database_role.go +++ b/pkg/resources/grant_privileges_to_database_role.go @@ -4,14 +4,15 @@ import ( "context" "database/sql" "fmt" + "slices" + "strings" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/go-uuid" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "slices" - "strings" ) // TODO: Imported privileges (after second account will be added) @@ -645,7 +646,7 @@ func ReadGrantPrivilegesToDatabaseRole(ctx context.Context, d *schema.ResourceDa if id.WithGrantOption == grant.GrantOption && id.DatabaseRoleName.Name() == grant.GranteeName.Name() { // Future grants do not have grantedBy, only current grants do. // If grantedby is an empty string, it means terraform could not have created the grant - if (opts.Future == nil || *opts.Future == false) && grant.GrantedBy.Name() == "" { + if (opts.Future == nil || !*opts.Future) && grant.GrantedBy.Name() == "" { continue } // grant_on is for future grants, granted_on is for current grants. diff --git a/pkg/resources/grant_privileges_to_database_role_acceptance_test.go b/pkg/resources/grant_privileges_to_database_role_acceptance_test.go index 4d5dde8d8cd..c2dc2461b20 100644 --- a/pkg/resources/grant_privileges_to_database_role_acceptance_test.go +++ b/pkg/resources/grant_privileges_to_database_role_acceptance_test.go @@ -4,6 +4,9 @@ import ( "context" "database/sql" "fmt" + "regexp" + "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" @@ -11,8 +14,6 @@ import ( "github.com/hashicorp/terraform-plugin-testing/plancheck" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-plugin-testing/tfversion" - "regexp" - "testing" ) func TestAcc_GrantPrivilegesToDatabaseRole_OnDatabase(t *testing.T) { diff --git a/pkg/resources/grant_privileges_to_database_role_identifier.go b/pkg/resources/grant_privileges_to_database_role_identifier.go index cc9ec6284d5..1c4823b840d 100644 --- a/pkg/resources/grant_privileges_to_database_role_identifier.go +++ b/pkg/resources/grant_privileges_to_database_role_identifier.go @@ -2,10 +2,11 @@ package resources import ( "fmt" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers" - "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" "strconv" "strings" + + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" ) type DatabaseRoleGrantKind string diff --git a/pkg/resources/grant_privileges_to_database_role_identifier_test.go b/pkg/resources/grant_privileges_to_database_role_identifier_test.go index 0c6f6fb9085..f9478d812fd 100644 --- a/pkg/resources/grant_privileges_to_database_role_identifier_test.go +++ b/pkg/resources/grant_privileges_to_database_role_identifier_test.go @@ -1,9 +1,10 @@ package resources import ( + "testing" + "github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk" "github.com/stretchr/testify/assert" - "testing" ) func TestParseGrantPrivilegesToDatabaseRoleId(t *testing.T) { diff --git a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_AlwaysApply/test.tf b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_AlwaysApply/test.tf index dda4fa75aa3..1c544f39ce8 100644 --- a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_AlwaysApply/test.tf +++ b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_AlwaysApply/test.tf @@ -1,6 +1,6 @@ resource "snowflake_grant_privileges_to_database_role" "test" { database_role_name = "\"${var.database}\".\"${var.name}\"" - all_privileges = var.all_privileges - on_database = "\"${var.database}\"" - always_apply = var.always_apply + all_privileges = var.all_privileges + on_database = "\"${var.database}\"" + always_apply = var.always_apply } diff --git a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnAllSchemasInDatabase/test.tf b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnAllSchemasInDatabase/test.tf index 03aa12212f9..ebde56ec07b 100644 --- a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnAllSchemasInDatabase/test.tf +++ b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnAllSchemasInDatabase/test.tf @@ -1,7 +1,7 @@ resource "snowflake_grant_privileges_to_database_role" "test" { database_role_name = "\"${var.database}\".\"${var.name}\"" - privileges = var.privileges - with_grant_option = var.with_grant_option + privileges = var.privileges + with_grant_option = var.with_grant_option on_schema { all_schemas_in_database = "\"${var.database}\"" diff --git a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnDatabase/test.tf b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnDatabase/test.tf index 5df1cd9eea7..83113802bea 100644 --- a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnDatabase/test.tf +++ b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnDatabase/test.tf @@ -1,6 +1,6 @@ resource "snowflake_grant_privileges_to_database_role" "test" { database_role_name = "\"${var.database}\".\"${var.name}\"" - privileges = var.privileges - on_database = "\"${var.database}\"" - with_grant_option = var.with_grant_option + privileges = var.privileges + on_database = "\"${var.database}\"" + with_grant_option = var.with_grant_option } diff --git a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnFutureSchemasInDatabase/test.tf b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnFutureSchemasInDatabase/test.tf index 321246bba18..dcecbfd504e 100644 --- a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnFutureSchemasInDatabase/test.tf +++ b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnFutureSchemasInDatabase/test.tf @@ -1,7 +1,7 @@ resource "snowflake_grant_privileges_to_database_role" "test" { database_role_name = "\"${var.database}\".\"${var.name}\"" - privileges = var.privileges - with_grant_option = var.with_grant_option + privileges = var.privileges + with_grant_option = var.with_grant_option on_schema { future_schemas_in_database = "\"${var.database}\"" diff --git a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnSchema/test.tf b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnSchema/test.tf index a1e8f2fd467..ef5613bda3d 100644 --- a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnSchema/test.tf +++ b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnSchema/test.tf @@ -1,7 +1,7 @@ resource "snowflake_grant_privileges_to_database_role" "test" { database_role_name = "\"${var.database}\".\"${var.name}\"" - privileges = var.privileges - with_grant_option = var.with_grant_option + privileges = var.privileges + with_grant_option = var.with_grant_option on_schema { schema_name = "\"${var.database}\".\"${var.schema}\"" diff --git a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnSchemaObject_OnAll_InDatabase/test.tf b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnSchemaObject_OnAll_InDatabase/test.tf index b927be87f29..230a702d236 100644 --- a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnSchemaObject_OnAll_InDatabase/test.tf +++ b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnSchemaObject_OnAll_InDatabase/test.tf @@ -1,12 +1,12 @@ resource "snowflake_grant_privileges_to_database_role" "test" { database_role_name = "\"${var.database}\".\"${var.name}\"" - privileges = var.privileges - with_grant_option = var.with_grant_option + privileges = var.privileges + with_grant_option = var.with_grant_option on_schema_object { all { object_type_plural = "TABLES" - in_database = "\"${var.database}\"" + in_database = "\"${var.database}\"" } } } diff --git a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnSchemaObject_OnFuture_InDatabase/test.tf b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnSchemaObject_OnFuture_InDatabase/test.tf index 33455311274..3463a24a8ff 100644 --- a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnSchemaObject_OnFuture_InDatabase/test.tf +++ b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnSchemaObject_OnFuture_InDatabase/test.tf @@ -1,12 +1,12 @@ resource "snowflake_grant_privileges_to_database_role" "test" { database_role_name = "\"${var.database}\".\"${var.name}\"" - privileges = var.privileges - with_grant_option = var.with_grant_option + privileges = var.privileges + with_grant_option = var.with_grant_option on_schema_object { future { object_type_plural = "TABLES" - in_database = "\"${var.database}\"" + in_database = "\"${var.database}\"" } } } diff --git a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnSchemaObject_OnObject/test.tf b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnSchemaObject_OnObject/test.tf index 19cd9a72bfd..2d480820ae8 100644 --- a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnSchemaObject_OnObject/test.tf +++ b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_OnSchemaObject_OnObject/test.tf @@ -10,10 +10,10 @@ resource "snowflake_table" "test" { } resource "snowflake_grant_privileges_to_database_role" "test" { - depends_on = [snowflake_table.test] + depends_on = [snowflake_table.test] database_role_name = "\"${var.database}\".\"${var.name}\"" - privileges = var.privileges - with_grant_option = var.with_grant_option + privileges = var.privileges + with_grant_option = var.with_grant_option on_schema_object { object_type = "TABLE" diff --git a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_UpdatePrivileges/all_privileges/test.tf b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_UpdatePrivileges/all_privileges/test.tf index 6613c3bcb30..3fc26c3028f 100644 --- a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_UpdatePrivileges/all_privileges/test.tf +++ b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_UpdatePrivileges/all_privileges/test.tf @@ -1,5 +1,5 @@ resource "snowflake_grant_privileges_to_database_role" "test" { database_role_name = "\"${var.database}\".\"${var.name}\"" - all_privileges = var.all_privileges - on_database = "\"${var.database}\"" + all_privileges = var.all_privileges + on_database = "\"${var.database}\"" } diff --git a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_UpdatePrivileges/privileges/test.tf b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_UpdatePrivileges/privileges/test.tf index 22ebfef3aaf..c1ea0cb24f8 100644 --- a/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_UpdatePrivileges/privileges/test.tf +++ b/pkg/resources/testdata/TestAcc_GrantPrivilegesToDatabaseRole_UpdatePrivileges/privileges/test.tf @@ -1,5 +1,5 @@ resource "snowflake_grant_privileges_to_database_role" "test" { database_role_name = "\"${var.database}\".\"${var.name}\"" - privileges = var.privileges - on_database = "\"${var.database}\"" + privileges = var.privileges + on_database = "\"${var.database}\"" }