(mappingOrList any, sep string, allowNil bool)
| 854 | } |
| 855 | |
| 856 | func transformMappingOrList(mappingOrList any, sep string, allowNil bool) any { |
| 857 | switch values := mappingOrList.(type) { |
| 858 | case map[string]any: |
| 859 | return toMapStringString(values, allowNil) |
| 860 | case []any: |
| 861 | result := make(map[string]any) |
| 862 | for _, v := range values { |
| 863 | key, val, hasValue := strings.Cut(v.(string), sep) |
| 864 | switch { |
| 865 | case !hasValue && allowNil: |
| 866 | result[key] = nil |
| 867 | case !hasValue && !allowNil: |
| 868 | result[key] = "" |
| 869 | default: |
| 870 | result[key] = val |
| 871 | } |
| 872 | } |
| 873 | return result |
| 874 | } |
| 875 | panic(fmt.Errorf("expected a map or a list, got %T: %#v", mappingOrList, mappingOrList)) |
| 876 | } |
| 877 | |
| 878 | var transformShellCommand TransformerFunc = func(value any) (any, error) { |
| 879 | if str, ok := value.(string); ok { |
no test coverage detected
searching dependent graphs…