MCPcopy Create free account
hub / github.com/docker/cli / transformMappingOrList

Function transformMappingOrList

cli/compose/loader/loader.go:856–876  ·  view source on GitHub ↗
(mappingOrList any, sep string, allowNil bool)

Source from the content-addressed store, hash-verified

854}
855
856func 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
878var transformShellCommand TransformerFunc = func(value any) (any, error) {
879 if str, ok := value.(string); ok {

Callers 1

Calls 1

toMapStringStringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…