Skip to content

Commit

Permalink
Merge pull request #22 from brainly/feature/resource_grants
Browse files Browse the repository at this point in the history
Add `redshift_grant` resource
  • Loading branch information
winglot authored Sep 6, 2021
2 parents 58f3b6a + 643389a commit 23455bc
Show file tree
Hide file tree
Showing 4 changed files with 582 additions and 1 deletion.
23 changes: 22 additions & 1 deletion redshift/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,16 @@ func validatePrivileges(privileges []string, objectType string) bool {
default:
return false
}
case "DATABASE":
switch strings.ToUpper(p) {
case "CREATE", "TEMPORARY":
continue
default:
return false
}
default:
return false
}

}

return true
Expand All @@ -182,3 +190,16 @@ func appendIfTrue(condition bool, item string, list *[]string) {
*list = append(*list, item)
}
}

func setToPgIdentList(identifiers *schema.Set, prefix string) string {
quoted := make([]string, identifiers.Len())
for i, identifier := range identifiers.List() {
if prefix == "" {
quoted[i] = pq.QuoteIdentifier(identifier.(string))
} else {
quoted[i] = fmt.Sprintf("%s.%s", pq.QuoteIdentifier(prefix), pq.QuoteIdentifier(identifier.(string)))
}
}

return strings.Join(quoted, ",")
}
1 change: 1 addition & 0 deletions redshift/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func Provider() *schema.Provider {
"redshift_schema": redshiftSchema(),
"redshift_privilege": redshiftPrivilege(),
"redshift_default_privileges": redshiftDefaultPrivileges(),
"redshift_grant": redshiftGrant(),
"redshift_database": redshiftDatabase(),
"redshift_datashare": redshiftDatashare(),
"redshift_datashare_privilege": redshiftDatasharePrivilege(),
Expand Down
Loading

0 comments on commit 23455bc

Please sign in to comment.