MCPcopy Create free account
hub / github.com/github/gh-aw / ToPermissions

Method ToPermissions

pkg/workflow/permissions_parser.go:296–346  ·  view source on GitHub ↗

ToPermissions converts a PermissionsParser to a Permissions object

()

Source from the content-addressed store, hash-verified

294
295// ToPermissions converts a PermissionsParser to a Permissions object
296func (p *PermissionsParser) ToPermissions() *Permissions {
297 if p == nil {
298 return NewPermissions()
299 }
300
301 // Handle shorthand permissions
302 if p.isShorthand {
303 switch p.shorthandValue {
304 case "read-all":
305 return NewPermissionsReadAll()
306 case "write-all":
307 return NewPermissionsWriteAll()
308 case "none":
309 return NewPermissionsNone()
310 default:
311 return NewPermissions()
312 }
313 }
314
315 // Handle all: read case
316 if p.hasAll && p.allLevel == "read" {
317 perms := NewPermissionsAllRead()
318
319 // Apply explicit overrides from parsedPerms
320 for key, value := range p.parsedPerms {
321 if key == "all" {
322 continue // Skip the "all" key itself
323 }
324 scope := convertStringToPermissionScope(key)
325 if scope != "" {
326 perms.Set(scope, PermissionLevel(value))
327 }
328 }
329
330 return perms
331 }
332
333 // Handle explicit permissions map
334 permsMap := make(map[PermissionScope]PermissionLevel)
335 for key, value := range p.parsedPerms {
336 if key == "all" {
337 continue // Skip the "all" key
338 }
339 scope := convertStringToPermissionScope(key)
340 if scope != "" {
341 permsMap[scope] = PermissionLevel(value)
342 }
343 }
344
345 return NewPermissionsFromMap(permsMap)
346}

Calls 9

NewPermissionsFunction · 0.85
NewPermissionsReadAllFunction · 0.85
NewPermissionsWriteAllFunction · 0.85
NewPermissionsNoneFunction · 0.85
NewPermissionsAllReadFunction · 0.85
PermissionLevelTypeAlias · 0.85
NewPermissionsFromMapFunction · 0.85
SetMethod · 0.45