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: Added Missing Account Privileges #635

Merged
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export BASE_BINARY_NAME=terraform-provider-snowflake_v$(VERSION)
export GO111MODULE=on
export TF_ACC_TERRAFORM_VERSION=0.13.0
export SKIP_EXTERNAL_TABLE_TESTS=true
export SKIP_SCIM_INTEGRATION_TESTS=true

go_test ?= -
ifeq (, $(shell which gotest))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package datasources_test

import (
"fmt"
"os"
"strings"
"testing"

Expand All @@ -10,6 +11,10 @@ import (
)

func TestAcc_SystemGenerateSCIMAccessToken(t *testing.T) {
if _, ok := os.LookupEnv("SKIP_SCIM_INTEGRATION_TESTS"); ok {
t.Skip("Skipping TestAccScimIntegration")
}

scimIntName := strings.ToUpper(acctest.RandStringFromCharSet(10, acctest.CharSetAlpha))
resource.ParallelTest(t, resource.TestCase{
Providers: providers(),
Expand Down
19 changes: 13 additions & 6 deletions pkg/resources/account_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,25 @@ import (
)

var validAccountPrivileges = NewPrivilegeSet(
privilegeApplyMaskingPolicy,
privilegeApplyRowAccessPolicy,
privilegeApplyTag,
privilegeAttachPolicy,
privilegeCreateAccount,
privilegeCreateDatabase,
privilegeCreateDataExchangeListing,
privilegeCreateIntegration,
privilegeCreateNetworkPolicy,
privilegeCreateRole,
privilegeCreateShare,
privilegeCreateUser,
privilegeCreateWarehouse,
privilegeCreateDatabase,
privilegeCreateIntegration,
privilegeExecuteTask,
privilegeImportShare,
privilegeManageGrants,
privilegeMonitorUsage,
privilegeMonitorExecution,
privilegeExecuteTask,
privilegeApplyMaskingPolicy,
privilegeCreateShare,
privilegeImportShare,
privilegeOverrideShareRestrictions,
)

var accountGrantSchema = map[string]*schema.Schema{
Expand Down
1 change: 1 addition & 0 deletions pkg/resources/external_table_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

var validExternalTablePrivileges = NewPrivilegeSet(
privilegeOwnership,
privilegeReferences,
privilegeSelect,
)

Expand Down
81 changes: 44 additions & 37 deletions pkg/resources/privileges.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,50 @@ func (p Privilege) String() string {
}

const (
privilegeSelect Privilege = "SELECT"
privilegeInsert Privilege = "INSERT"
privilegeUpdate Privilege = "UPDATE"
privilegeDelete Privilege = "DELETE"
privilegeTruncate Privilege = "TRUNCATE"
privilegeReferences Privilege = "REFERENCES"
privilegeRebuild Privilege = "REBUILD"
privilegeCreateSchema Privilege = "CREATE SCHEMA"
privilegeImportedPrivileges Privilege = "IMPORTED PRIVILEGES"
privilegeModify Privilege = "MODIFY"
privilegeOperate Privilege = "OPERATE"
privilegeMonitor Privilege = "MONITOR"
privilegeOwnership Privilege = "OWNERSHIP"
privilegeRead Privilege = "READ"
privilegeReferenceUsage Privilege = "REFERENCE_USAGE"
privilegeUsage Privilege = "USAGE"
privilegeWrite Privilege = "WRITE"
privilegeCreateTable Privilege = "CREATE TABLE"
privilegeCreateView Privilege = "CREATE VIEW"
privilegeCreateFileFormat Privilege = "CREATE FILE FORMAT"
privilegeCreateStage Privilege = "CREATE STAGE"
privilegeCreatePipe Privilege = "CREATE PIPE"
privilegeCreateStream Privilege = "CREATE STREAM"
privilegeCreateTask Privilege = "CREATE TASK"
privilegeCreateSequence Privilege = "CREATE SEQUENCE"
privilegeCreateFunction Privilege = "CREATE FUNCTION"
privilegeCreateProcedure Privilege = "CREATE PROCEDURE"
privilegeCreateExternalTable Privilege = "CREATE EXTERNAL TABLE"
privilegeCreateMaterializedView Privilege = "CREATE MATERIALIZED VIEW"
privilegeCreateRowAccessPolicy Privilege = "CREATE ROW ACCESS POLICY"
privilegeCreateTemporaryTable Privilege = "CREATE TEMPORARY TABLE"
privilegeCreateMaskingPolicy Privilege = "CREATE MASKING POLICY"
privilegeCreateShare Privilege = "CREATE SHARE"
privilegeImportShare Privilege = "IMPORT SHARE"
privilegeAddSearchOptimization Privilege = "ADD SEARCH OPTIMIZATION"
privilegeApplyMaskingPolicy Privilege = "APPLY MASKING POLICY"
privilegeApply Privilege = "APPLY"
privilegeSelect Privilege = "SELECT"
privilegeInsert Privilege = "INSERT"
privilegeUpdate Privilege = "UPDATE"
privilegeDelete Privilege = "DELETE"
privilegeTruncate Privilege = "TRUNCATE"
privilegeReferences Privilege = "REFERENCES"
privilegeRebuild Privilege = "REBUILD"
privilegeCreateSchema Privilege = "CREATE SCHEMA"
privilegeImportedPrivileges Privilege = "IMPORTED PRIVILEGES"
privilegeModify Privilege = "MODIFY"
privilegeOperate Privilege = "OPERATE"
privilegeMonitor Privilege = "MONITOR"
privilegeOwnership Privilege = "OWNERSHIP"
privilegeRead Privilege = "READ"
privilegeReferenceUsage Privilege = "REFERENCE_USAGE"
privilegeUsage Privilege = "USAGE"
privilegeWrite Privilege = "WRITE"
privilegeCreateTable Privilege = "CREATE TABLE"
privilegeCreateView Privilege = "CREATE VIEW"
privilegeCreateFileFormat Privilege = "CREATE FILE FORMAT"
privilegeCreateStage Privilege = "CREATE STAGE"
privilegeCreatePipe Privilege = "CREATE PIPE"
privilegeCreateStream Privilege = "CREATE STREAM"
privilegeCreateTask Privilege = "CREATE TASK"
privilegeCreateSequence Privilege = "CREATE SEQUENCE"
privilegeCreateFunction Privilege = "CREATE FUNCTION"
privilegeCreateProcedure Privilege = "CREATE PROCEDURE"
privilegeCreateExternalTable Privilege = "CREATE EXTERNAL TABLE"
privilegeCreateMaterializedView Privilege = "CREATE MATERIALIZED VIEW"
privilegeCreateRowAccessPolicy Privilege = "CREATE ROW ACCESS POLICY"
privilegeCreateTemporaryTable Privilege = "CREATE TEMPORARY TABLE"
privilegeCreateMaskingPolicy Privilege = "CREATE MASKING POLICY"
privilegeCreateNetworkPolicy Privilege = "CREATE NETWORK POLICY"
privilegeCreateDataExchangeListing Privilege = "CREATE DATA EXCHANGE LISTING"
privilegeCreateAccount Privilege = "CREATE ACCOUNT"
privilegeCreateShare Privilege = "CREATE SHARE"
privilegeImportShare Privilege = "IMPORT SHARE"
privilegeOverrideShareRestrictions Privilege = "OVERRIDE SHARE RESTRICTIONS"
privilegeAddSearchOptimization Privilege = "ADD SEARCH OPTIMIZATION"
privilegeApplyMaskingPolicy Privilege = "APPLY MASKING POLICY"
privilegeApplyRowAccessPolicy Privilege = "APPLY ROW ACCESS POLICY"
privilegeApplyTag Privilege = "APPLY TAG"
privilegeApply Privilege = "APPLY"
privilegeAttachPolicy Privilege = "ATTACH POLICY"

privilegeCreateRole Privilege = "CREATE ROLE"
privilegeCreateUser Privilege = "CREATE USER"
Expand Down
3 changes: 2 additions & 1 deletion pkg/resources/view_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (
)

var validViewPrivileges = NewPrivilegeSet(
privilegeSelect,
privilegeOwnership,
privilegeReferences,
privilegeSelect,
)

var viewGrantSchema = map[string]*schema.Schema{
Expand Down