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

Method list

cli/context/store/metadatastore.go:106–129  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

104}
105
106func (s *metadataStore) list() ([]Metadata, error) {
107 ctxDirs, err := listRecursivelyMetadataDirs(s.root)
108 if err != nil {
109 if errors.Is(err, os.ErrNotExist) {
110 return nil, nil
111 }
112 return nil, err
113 }
114 res := make([]Metadata, 0, len(ctxDirs))
115 for _, dir := range ctxDirs {
116 c, err := s.getByID(contextdir(dir))
117 if err != nil {
118 if errors.Is(err, os.ErrNotExist) {
119 continue
120 }
121 return nil, fmt.Errorf("failed to read metadata: %w", err)
122 }
123 res = append(res, c)
124 }
125 sort.Slice(res, func(i, j int) bool {
126 return sortorder.NaturalLess(res[i].Name, res[j].Name)
127 })
128 return res, nil
129}
130
131func isContextDir(path string) bool {
132 s, err := os.Stat(filepath.Join(path, metaFile))

Callers 3

TestMetadataListFunction · 0.95
TestEmptyConfigFunction · 0.95
ListMethod · 0.80

Calls 3

getByIDMethod · 0.95
contextdirTypeAlias · 0.85

Tested by 2

TestMetadataListFunction · 0.76
TestEmptyConfigFunction · 0.76