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)
| 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. |
| 51 | func 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. |
| 73 | func ParseFilterConfig(configMap map[string]any) SafeOutputFilterConfig { |
no test coverage detected