normalizeArguments coerces the arguments value into []map[string]any so it serializes as a stable YAML sequence of maps. Accepts []map[string]any or []any (e.g. JSON-decoded) whose elements are map[string]any. Anything it cannot interpret as a map is skipped.
(v any)
| 107 | // []any (e.g. JSON-decoded) whose elements are map[string]any. Anything it |
| 108 | // cannot interpret as a map is skipped. |
| 109 | func normalizeArguments(v any) []map[string]any { |
| 110 | switch xs := v.(type) { |
| 111 | case []map[string]any: |
| 112 | if len(xs) == 0 { |
| 113 | return nil |
| 114 | } |
| 115 | return xs |
| 116 | case []any: |
| 117 | out := make([]map[string]any, 0, len(xs)) |
| 118 | for _, el := range xs { |
| 119 | if m := toStringMap(el); m != nil { |
| 120 | out = append(out, m) |
| 121 | } |
| 122 | } |
| 123 | if len(out) == 0 { |
| 124 | return nil |
| 125 | } |
| 126 | return out |
| 127 | default: |
| 128 | return nil |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | func toStringMap(v any) map[string]any { |
| 133 | if m, ok := v.(map[string]any); ok { |