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

Add redshift_grant resource #22

Merged
merged 2 commits into from
Sep 6, 2021
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
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