Skip to content

Commit

Permalink
fix: Fixed Grants Resource Update With Futures (#1289)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisIsidora authored Oct 20, 2022
1 parent b6fc9ea commit 132373c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
9 changes: 7 additions & 2 deletions pkg/resources/sequence_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,14 @@ func UpdateSequenceGrant(d *schema.ResourceData, meta interface{}) error {
dbName := grantID.ResourceName
schemaName := grantID.SchemaName
sequenceName := grantID.ObjectName
futureSequences := (sequenceName == "")

// create the builder
builder := snowflake.SequenceGrant(dbName, schemaName, sequenceName)
var builder snowflake.GrantBuilder
if futureSequences {
builder = snowflake.FutureSequenceGrant(dbName, schemaName)
} else {
builder = snowflake.SequenceGrant(dbName, schemaName, sequenceName)
}

// first revoke
err = deleteGenericGrantRolesAndShares(
Expand Down
9 changes: 7 additions & 2 deletions pkg/resources/stage_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,14 @@ func UpdateStageGrant(d *schema.ResourceData, meta interface{}) error {
dbName := grantID.ResourceName
schemaName := grantID.SchemaName
stageName := grantID.ObjectName
futureStages := (stageName == "")

// create the builder
builder := snowflake.StageGrant(dbName, schemaName, stageName)
var builder snowflake.GrantBuilder
if futureStages {
builder = snowflake.FutureStageGrant(dbName, schemaName)
} else {
builder = snowflake.StageGrant(dbName, schemaName, stageName)
}

// first revoke
err = deleteGenericGrantRolesAndShares(
Expand Down
10 changes: 8 additions & 2 deletions pkg/resources/stream_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,14 @@ func UpdateStreamGrant(d *schema.ResourceData, meta interface{}) error {
schemaName := grantID.SchemaName
streamName := grantID.ObjectName

// create the builder
builder := snowflake.StreamGrant(dbName, schemaName, streamName)
futureStreams := (streamName == "")

var builder snowflake.GrantBuilder
if futureStreams {
builder = snowflake.FutureStreamGrant(dbName, schemaName)
} else {
builder = snowflake.StreamGrant(dbName, schemaName, streamName)
}

// first revoke
err = deleteGenericGrantRolesAndShares(
Expand Down
9 changes: 7 additions & 2 deletions pkg/resources/task_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,14 @@ func UpdateTaskGrant(d *schema.ResourceData, meta interface{}) error {
dbName := grantID.ResourceName
schemaName := grantID.SchemaName
taskName := grantID.ObjectName
futureTasks := (taskName == "")

// create the builder
builder := snowflake.TaskGrant(dbName, schemaName, taskName)
var builder snowflake.GrantBuilder
if futureTasks {
builder = snowflake.FutureTaskGrant(dbName, schemaName)
} else {
builder = snowflake.TaskGrant(dbName, schemaName, taskName)
}

// first revoke
err = deleteGenericGrantRolesAndShares(
Expand Down

0 comments on commit 132373c

Please sign in to comment.