Skip to content

Commit

Permalink
passing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jcieslak committed Jan 17, 2024
1 parent 2a87d36 commit 3155c2f
Show file tree
Hide file tree
Showing 18 changed files with 221 additions and 168 deletions.
3 changes: 3 additions & 0 deletions pkg/resources/grant_privileges_to_account_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ func ImportGrantPrivilegesToAccountRole() func(ctx context.Context, d *schema.Re
if err := d.Set("privileges", id.Privileges); err != nil {
return nil, err
}
if err := d.Set("on_account", false); err != nil {
return nil, err
}

switch id.Kind {
case OnAccountAccountRoleGrantKind:
Expand Down
254 changes: 153 additions & 101 deletions pkg/resources/grant_privileges_to_account_role_acceptance_test.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
resource "snowflake_grant_privileges_to_database_role" "test" {
database_role_name = "${var.database}.${var.name}"
resource "snowflake_grant_privileges_to_account_role" "test" {
role_name = var.name
all_privileges = var.all_privileges
on_database = var.database
always_apply = var.always_apply
on_account_object {
object_type = "DATABASE"
object_name = var.database
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "snowflake_grant_privileges_to_role" "test" {
privileges = ["CREATE SCHEMA"]
role_name = "\"${var.name}\""
on_account_object {
object_type = "DATABASE"
object_name = var.database
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
variable "name" {
type = string
}

variable "database" {
type = string
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource "snowflake_grant_privileges_to_database_role" "test" {
database_role_name = "\"${var.database}\".\"${var.name}\""
resource "snowflake_grant_privileges_to_account_role" "test" {
role_name = var.name
privileges = var.privileges
with_grant_option = var.with_grant_option

on_schema {
all_schemas_in_database = "\"${var.database}\""
all_schemas_in_database = var.database
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
resource "snowflake_grant_privileges_to_database_role" "test" {
database_role_name = "\"${var.database}\".\"${var.name}\""
resource "snowflake_grant_privileges_to_account_role" "test" {
role_name = var.name
privileges = var.privileges
with_grant_option = var.with_grant_option

on_schema {
future_schemas_in_database = "\"${var.database}\""
future_schemas_in_database = var.database
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "snowflake_grant_privileges_to_database_role" "test" {
database_role_name = "\"${var.database}\".\"${var.name}\""
resource "snowflake_grant_privileges_to_account_role" "test" {
role_name = var.name
privileges = var.privileges
with_grant_option = var.with_grant_option

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
resource "snowflake_grant_privileges_to_database_role" "test" {
database_role_name = "\"${var.database}\".\"${var.name}\""
resource "snowflake_grant_privileges_to_account_role" "test" {
role_name = var.name
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
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
resource "snowflake_grant_privileges_to_database_role" "test" {
database_role_name = "\"${var.database}\".\"${var.name}\""
resource "snowflake_grant_privileges_to_account_role" "test" {
role_name = var.name
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
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ resource "snowflake_table" "test" {
}
}

resource "snowflake_grant_privileges_to_database_role" "test" {
resource "snowflake_grant_privileges_to_account_role" "test" {
depends_on = [snowflake_table.test]
database_role_name = "\"${var.database}\".\"${var.name}\""
role_name = var.name
privileges = var.privileges
with_grant_option = var.with_grant_option

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "snowflake_grant_privileges_to_database_role" "test" {
database_role_name = "some_database.role_name"
resource "snowflake_grant_privileges_to_account_role" "test" {
role_name = "role_name"
privileges = ["USAGE"]

on_schema {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
resource "snowflake_grant_privileges_to_database_role" "test" {
database_role_name = "\"${var.database}\".\"${var.name}\""
resource "snowflake_grant_privileges_to_account_role" "test" {
role_name = var.name
all_privileges = var.all_privileges
on_database = "\"${var.database}\""
on_account_object {
object_type = "DATABASE"
object_name = var.database
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
resource "snowflake_grant_privileges_to_database_role" "test" {
database_role_name = "\"${var.database}\".\"${var.name}\""
resource "snowflake_grant_privileges_to_account_role" "test" {
role_name = var.name
privileges = var.privileges
on_database = "\"${var.database}\""
on_account_object {
object_type = "DATABASE"
object_name = var.database
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
resource "snowflake_grant_privileges_to_database_role" "test" {
database_role_name = "\"${var.database}\".\"${var.name}\""
resource "snowflake_grant_privileges_to_account_role" "test" {
role_name = var.name
all_privileges = var.all_privileges
on_database = "\"${var.database}\""
on_account_object {
object_type = "DATABASE"
object_name = var.database
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ resource "snowflake_schema" "test" {
name = var.schema_name
}

resource "snowflake_grant_privileges_to_database_role" "test" {
resource "snowflake_grant_privileges_to_account_role" "test" {
depends_on = [snowflake_schema.test]
database_role_name = "\"${var.database}\".\"${var.name}\""
role_name = var.name
privileges = var.privileges
on_schema {
schema_name = "${var.database}.${var.schema_name}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
resource "snowflake_grant_privileges_to_database_role" "test" {
database_role_name = "\"${var.database}\".\"${var.name}\""
resource "snowflake_grant_privileges_to_account_role" "test" {
role_name = var.name
privileges = var.privileges
on_database = "\"${var.database}\""
on_account_object {
object_type = "DATABASE"
object_name = var.database
}
}

0 comments on commit 3155c2f

Please sign in to comment.