ToYAMLMap converts a TriggerIR to a map structure suitable for YAML generation
()
| 104 | |
| 105 | // ToYAMLMap converts a TriggerIR to a map structure suitable for YAML generation |
| 106 | func (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" |
| 138 | func parseSlashCommandTrigger(input string) (*TriggerIR, error) { |
no outgoing calls