Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed Grants Resource Update With Futures #1289

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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