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

Method parseNoOpConfig

pkg/workflow/noop.go:16–70  ·  view source on GitHub ↗

parseNoOpConfig handles noop configuration

(outputMap map[string]any)

Source from the content-addressed store, hash-verified

14
15// parseNoOpConfig handles noop configuration
16func (c *Compiler) parseNoOpConfig(outputMap map[string]any) *NoOpConfig {
17 if configData, exists := outputMap["noop"]; exists {
18 noopLog.Print("Parsing noop configuration from safe-outputs")
19
20 // Handle the case where configData is false (explicitly disabled)
21 if configBool, ok := configData.(bool); ok && !configBool {
22 noopLog.Print("Noop explicitly disabled")
23 return nil
24 }
25
26 noopConfig := &NoOpConfig{}
27
28 // Handle the case where configData is nil (noop: with no value)
29 if configData == nil {
30 // Set default max for noop messages
31 noopConfig.Max = defaultIntStr(1)
32 // Set default report-as-issue to true
33 trueVal := "true"
34 noopConfig.ReportAsIssue = &trueVal
35 noopLog.Print("Noop enabled with default max=1, report-as-issue=true")
36 return noopConfig
37 }
38
39 if configMap, ok := configData.(map[string]any); ok {
40 // Pre-process report-as-issue as a templatable bool
41 if err := preprocessBoolFieldAsString(configMap, "report-as-issue", noopLog); err != nil {
42 noopLog.Printf("Invalid report-as-issue value: %v", err)
43 return nil
44 }
45
46 // Parse common base fields with default max of 1
47 c.parseBaseSafeOutputConfig(configMap, &noopConfig.BaseSafeOutputConfig, 1)
48
49 // Parse report-as-issue field with default of true
50 if reportAsIssue, ok := configMap["report-as-issue"].(string); ok {
51 noopConfig.ReportAsIssue = &reportAsIssue
52 noopLog.Printf("report-as-issue explicitly set to: %s", reportAsIssue)
53 } else {
54 // Default to true
55 trueVal := "true"
56 noopConfig.ReportAsIssue = &trueVal
57 noopLog.Print("report-as-issue not specified, defaulting to true")
58 }
59
60 if noopConfig.Max != nil {
61 noopLog.Printf("Parsed noop configuration: max=%s, report-as-issue=%s", *noopConfig.Max, *noopConfig.ReportAsIssue)
62 }
63 }
64
65 return noopConfig
66 }
67
68 noopLog.Print("No noop configuration found")
69 return nil
70}

Callers 2

TestParseNoOpConfigFunction · 0.95

Calls 5

defaultIntStrFunction · 0.85
PrintMethod · 0.80
PrintfMethod · 0.45

Tested by 1

TestParseNoOpConfigFunction · 0.76