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

Function ParseTargetConfig

pkg/workflow/safe_outputs_parser.go:51–70  ·  view source on GitHub ↗

ParseTargetConfig parses target and target-repo fields from a config map. Returns the parsed SafeOutputTargetConfig and a boolean indicating if there was a validation error. target-repo accepts "*" (wildcard) to indicate that any repository can be targeted.

(configMap map[string]any)

Source from the content-addressed store, hash-verified

49// Returns the parsed SafeOutputTargetConfig and a boolean indicating if there was a validation error.
50// target-repo accepts "*" (wildcard) to indicate that any repository can be targeted.
51func ParseTargetConfig(configMap map[string]any) (SafeOutputTargetConfig, bool) {
52 safeOutputParserLog.Print("Parsing target config from map")
53 config := SafeOutputTargetConfig{}
54
55 // Parse target
56 if target, exists := configMap["target"]; exists {
57 if targetStr, ok := target.(string); ok {
58 config.Target = targetStr
59 safeOutputParserLog.Printf("Target set to: %s", targetStr)
60 }
61 }
62
63 // Parse target-repo; wildcard "*" is allowed and means "any repository"
64 config.TargetRepoSlug = extractStringFromMap(configMap, "target-repo", safeOutputParserLog)
65
66 // Parse allowed-repos
67 config.AllowedRepos = ParseStringArrayFromConfig(configMap, "allowed-repos", safeOutputParserLog)
68
69 return config, false
70}
71
72// ParseFilterConfig parses required-labels and required-title-prefix fields from a config map.
73func ParseFilterConfig(configMap map[string]any) SafeOutputFilterConfig {

Calls 4

extractStringFromMapFunction · 0.85
PrintMethod · 0.80
PrintfMethod · 0.45

Tested by

no test coverage detected