Skip to content

Commit 302af46

Browse files
committed
direct: grants: inline trivial helpers
Keep the grants fix focused by inlining tiny one-use helpers instead of carrying extra wrappers. This reduces review noise without changing the revoke behavior.
1 parent b6ce059 commit 302af46

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

bundle/direct/dresources/grants.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func PrepareGrantsInputConfig(inputConfig any, node string) (*structvar.StructVa
5050

5151
// Backend sorts privileges, so we sort here as well.
5252
for i := range *grantsPtr {
53-
sortPriviliges((*grantsPtr)[i].Privileges)
53+
slices.Sort((*grantsPtr)[i].Privileges)
5454
}
5555

5656
return &structvar.StructVar{
@@ -113,7 +113,7 @@ func (r *ResourceGrants) DoCreate(ctx context.Context, state *GrantsState) (stri
113113
return "", nil, err
114114
}
115115

116-
return makeGrantsID(state.SecurableType, state.FullName), nil, nil
116+
return state.SecurableType + "/" + state.FullName, nil, nil
117117
}
118118

119119
func (r *ResourceGrants) DoUpdate(ctx context.Context, _ string, state *GrantsState, changes Changes) (*GrantsState, error) {
@@ -265,10 +265,6 @@ func (r *ResourceGrants) listGrants(ctx context.Context, securableType, fullName
265265
return assignments, nil
266266
}
267267

268-
func sortPriviliges(privileges []catalog.Privilege) {
269-
slices.Sort(privileges)
270-
}
271-
272268
func extractGrantResourceType(node string) (string, error) {
273269
rest, ok := strings.CutPrefix(node, "resources.")
274270
if !ok {
@@ -291,7 +287,3 @@ func parseGrantsID(id string) (string, string, error) {
291287
}
292288
return parts[0], parts[1], nil
293289
}
294-
295-
func makeGrantsID(securableType, fullName string) string {
296-
return securableType + "/" + fullName
297-
}

0 commit comments

Comments
 (0)