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

Function parseTypedOrMap

cli/context/store/metadatastore.go:45–61  ·  view source on GitHub ↗
(payload []byte, getter TypeGetter)

Source from the content-addressed store, hash-verified

43}
44
45func parseTypedOrMap(payload []byte, getter TypeGetter) (any, error) {
46 if len(payload) == 0 || string(payload) == "null" {
47 return nil, nil
48 }
49 if getter == nil {
50 var res map[string]any
51 if err := json.Unmarshal(payload, &res); err != nil {
52 return nil, err
53 }
54 return res, nil
55 }
56 typed := getter()
57 if err := json.Unmarshal(payload, typed); err != nil {
58 return nil, err
59 }
60 return reflect.ValueOf(typed).Elem().Interface(), nil
61}
62
63func (s *metadataStore) get(name string) (Metadata, error) {
64 m, err := s.getByID(contextdirOf(name))

Callers 1

getByIDMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…