Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
nkvuong committed Jun 7, 2024
1 parent 46d7b6f commit 0759a41
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions catalog/permissions/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ var Mappings = SecurableMapping{
"volume": catalog.SecurableType("volume"),
}

// Unity Catalog accepts privileges with spaces, but will automatically convert them to underscores
func NormalizePrivilege(privilege string) string {
return strings.ToUpper(strings.Replace(privilege, " ", "_", -1))
}
Expand Down
2 changes: 1 addition & 1 deletion catalog/resource_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ func ResourceGrant() common.Resource {
s := common.StructToSchema(permissions.UnityCatalogPrivilegeAssignment{},
func(m map[string]*schema.Schema) map[string]*schema.Schema {
common.CustomizeSchemaPath(m, "principal").SetForceNew().SetCustomSuppressDiff(common.EqualFoldDiffSuppress)
common.MustSchemaPath(m, "principal").DiffSuppressFunc = common.EqualFoldDiffSuppress

// set custom hash function for privileges
common.MustSchemaPath(m, "privileges").Set = func(i any) int {
privilege := i.(string)
return schema.HashString(permissions.NormalizePrivilege(privilege))
Expand Down
1 change: 1 addition & 0 deletions catalog/resource_grants.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func parseId(d *schema.ResourceData) (string, string, error) {
func ResourceGrants() common.Resource {
s := common.StructToSchema(PermissionsList{},
func(s map[string]*schema.Schema) map[string]*schema.Schema {
// set custom hash function for principal and privileges
common.MustSchemaPath(s, "grant", "privileges").Set = func(i any) int {
privilege := i.(string)
return schema.HashString(permissions.NormalizePrivilege(privilege))
Expand Down

0 comments on commit 0759a41

Please sign in to comment.