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

Function ParseStringArrayFromConfig

pkg/workflow/config_helpers.go:50–67  ·  view source on GitHub ↗

ParseStringArrayFromConfig is a generic helper that extracts and validates a string array from a map Returns a slice of strings, or nil if not present or invalid If log is provided, it will log the extracted values for debugging

(m map[string]any, key string, debugLog *logger.Logger)

Source from the content-addressed store, hash-verified

48// Returns a slice of strings, or nil if not present or invalid
49// If log is provided, it will log the extracted values for debugging
50func ParseStringArrayFromConfig(m map[string]any, key string, debugLog *logger.Logger) []string {
51 if value, exists := m[key]; exists {
52 if debugLog != nil {
53 debugLog.Printf("Parsing %s from config", key)
54 }
55 if strings := parseStringSliceAny(value, debugLog); strings != nil {
56 // Return the slice even if empty (to distinguish from not provided)
57 if len(strings) == 0 && debugLog != nil {
58 debugLog.Printf("No valid %s strings found, returning empty array", key)
59 }
60 if debugLog != nil {
61 debugLog.Printf("Parsed %d %s from config", len(strings), key)
62 }
63 return strings
64 }
65 }
66 return nil
67}
68
69// ParseStringArrayOrExprFromConfig is like ParseStringArrayFromConfig but also accepts a
70// GitHub Actions expression string as a valid value. When the raw value is an expression

Calls 2

parseStringSliceAnyFunction · 0.85
PrintfMethod · 0.45