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

Function parseRolesValue

pkg/workflow/role_checks.go:136–158  ·  view source on GitHub ↗

parseRolesValue parses a roles value from frontmatter (supports string, []any, []string)

(rolesValue any, fieldName string)

Source from the content-addressed store, hash-verified

134
135// parseRolesValue parses a roles value from frontmatter (supports string, []any, []string)
136func parseRolesValue(rolesValue any, fieldName string) []string {
137 switch v := rolesValue.(type) {
138 case string:
139 if v == "all" {
140 // Special case: "all" means no restrictions
141 roleLog.Printf("Roles in '%s' set to 'all' - no permission restrictions", fieldName)
142 return []string{"all"}
143 }
144 // Single permission level as string
145 roleLog.Printf("Extracted single role from '%s': %s", fieldName, v)
146 return []string{v}
147 case []any:
148 // Array of permission levels
149 permissions := parseStringSliceAny(v, roleLog)
150 roleLog.Printf("Extracted %d roles from '%s' array: %v", len(permissions), fieldName, permissions)
151 return permissions
152 case []string:
153 // Already a string slice
154 roleLog.Printf("Extracted %d roles from '%s': %v", len(v), fieldName, v)
155 return v
156 }
157 return nil
158}
159
160// extractBots extracts the 'bots' field from frontmatter to determine allowed bot identifiers
161func (c *Compiler) extractBots(frontmatter map[string]any) []string {

Callers 1

extractRolesMethod · 0.85

Calls 2

parseStringSliceAnyFunction · 0.85
PrintfMethod · 0.45

Tested by

no test coverage detected