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

Method parseHideCommentConfig

pkg/workflow/hide_comment.go:19–59  ·  view source on GitHub ↗

parseHideCommentConfig handles hide-comment configuration

(outputMap map[string]any)

Source from the content-addressed store, hash-verified

17
18// parseHideCommentConfig handles hide-comment configuration
19func (c *Compiler) parseHideCommentConfig(outputMap map[string]any) *HideCommentConfig {
20 hideCommentLog.Print("Parsing hide-comment configuration")
21 if configData, exists := outputMap["hide-comment"]; exists {
22 hideCommentConfig := &HideCommentConfig{}
23
24 if configMap, ok := configData.(map[string]any); ok {
25 hideCommentLog.Print("Found hide-comment config map")
26
27 // Parse target config (target-repo) with validation
28 targetConfig, isInvalid := ParseTargetConfig(configMap)
29 if isInvalid {
30 return nil // Invalid configuration (e.g., wildcard target-repo), return nil to cause validation error
31 }
32 hideCommentConfig.SafeOutputTargetConfig = targetConfig
33
34 // Parse allowed-reasons
35 if allowedReasons, exists := configMap["allowed-reasons"]; exists {
36 if reasonsArray, ok := allowedReasons.([]any); ok {
37 for _, reason := range reasonsArray {
38 if reasonStr, ok := reason.(string); ok {
39 hideCommentConfig.AllowedReasons = append(hideCommentConfig.AllowedReasons, reasonStr)
40 }
41 }
42 }
43 }
44
45 // Parse common base fields with default max of 5
46 c.parseBaseSafeOutputConfig(configMap, &hideCommentConfig.BaseSafeOutputConfig, 5)
47
48 hideCommentLog.Printf("Parsed hide-comment config: max=%d, target_repo=%s",
49 hideCommentConfig.Max, hideCommentConfig.TargetRepoSlug)
50 } else {
51 // If configData is nil or not a map, still set the default max
52 hideCommentConfig.Max = defaultIntStr(5)
53 }
54
55 return hideCommentConfig
56 }
57
58 return nil
59}

Callers 1

Calls 5

ParseTargetConfigFunction · 0.85
defaultIntStrFunction · 0.85
PrintMethod · 0.80
PrintfMethod · 0.45

Tested by

no test coverage detected