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

Method ToYAMLMap

pkg/workflow/trigger_parser.go:106–135  ·  view source on GitHub ↗

ToYAMLMap converts a TriggerIR to a map structure suitable for YAML generation

()

Source from the content-addressed store, hash-verified

104
105// ToYAMLMap converts a TriggerIR to a map structure suitable for YAML generation
106func (ir *TriggerIR) ToYAMLMap() map[string]any {
107 result := make(map[string]any)
108
109 // Add the main event
110 if ir.Event != "" {
111 eventConfig := make(map[string]any)
112
113 // Add types if specified
114 if len(ir.Types) > 0 {
115 eventConfig["types"] = ir.Types
116 }
117
118 // Add filters
119 maps.Copy(eventConfig, ir.Filters)
120
121 // If event config has content, add it; otherwise omit the event entirely for simple triggers
122 if len(eventConfig) > 0 {
123 result[ir.Event] = eventConfig
124 } else {
125 // For events with no configuration, use an empty map instead of nil
126 // This ensures proper YAML generation without "null" values
127 result[ir.Event] = map[string]any{}
128 }
129 }
130
131 // Add additional events
132 maps.Copy(result, ir.AdditionalEvents)
133
134 return result
135}
136
137// parseSlashCommandTrigger parses slash command triggers like "/test"
138func parseSlashCommandTrigger(input string) (*TriggerIR, error) {

Callers 3

FuzzTriggerIRToYAMLMapFunction · 0.95
TestTriggerIRToYAMLMapFunction · 0.80

Calls

no outgoing calls

Tested by 2

FuzzTriggerIRToYAMLMapFunction · 0.76
TestTriggerIRToYAMLMapFunction · 0.64