parseHideCommentConfig handles hide-comment configuration
(outputMap map[string]any)
| 17 | |
| 18 | // parseHideCommentConfig handles hide-comment configuration |
| 19 | func (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 | } |
no test coverage detected