coerceStringOrArrayField converts configData[key] from a string to []string{value} so YAML unmarshaling into []string fields succeeds for single-value shorthand. When key is missing, nil, or already a non-string type, this function is a no-op. The debugLog parameter is optional; pass nil to suppres
(configData map[string]any, key string, debugLog *logger.Logger)
| 26 | // When key is missing, nil, or already a non-string type, this function is a no-op. |
| 27 | // The debugLog parameter is optional; pass nil to suppress debug output. |
| 28 | func coerceStringOrArrayField(configData map[string]any, key string, debugLog *logger.Logger) { |
| 29 | if configData == nil { |
| 30 | return |
| 31 | } |
| 32 | |
| 33 | if value, exists := configData[key]; exists { |
| 34 | if stringValue, ok := value.(string); ok { |
| 35 | configData[key] = []string{stringValue} |
| 36 | if debugLog != nil { |
| 37 | debugLog.Printf("Converted single %s string to array before unmarshaling", key) |
| 38 | } else { |
| 39 | parseHelpersLog.Printf("Coerced %s scalar to single-element array (no caller log provided)", key) |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | // coerceStringOrArrayFields applies coerceStringOrArrayField to multiple keys. |
| 46 | func coerceStringOrArrayFields(configData map[string]any, keys []string, debugLog *logger.Logger) { |
no test coverage detected