MCPcopy
hub / github.com/docker/compose / getImageSummaries

Method getImageSummaries

pkg/compose/images.go:128–164  ·  view source on GitHub ↗
(ctx context.Context, repoTags []string)

Source from the content-addressed store, hash-verified

126}
127
128func (s *composeService) getImageSummaries(ctx context.Context, repoTags []string) (map[string]api.ImageSummary, error) {
129 summary := map[string]api.ImageSummary{}
130 l := sync.Mutex{}
131 eg, ctx := errgroup.WithContext(ctx)
132 for _, repoTag := range repoTags {
133 eg.Go(func() error {
134 inspect, err := s.apiClient().ImageInspect(ctx, repoTag)
135 if err != nil {
136 if errdefs.IsNotFound(err) {
137 return nil
138 }
139 return fmt.Errorf("unable to get image '%s': %w", repoTag, err)
140 }
141 tag := ""
142 repository := ""
143 ref, err := reference.ParseDockerRef(repoTag)
144 if err == nil {
145 // ParseDockerRef will reject a local image ID
146 repository = reference.FamiliarName(ref)
147 if tagged, ok := ref.(reference.Tagged); ok {
148 tag = tagged.Tag()
149 }
150 }
151 l.Lock()
152 summary[repoTag] = api.ImageSummary{
153 ID: inspect.ID,
154 Repository: repository,
155 Tag: tag,
156 Size: inspect.Size,
157 LastTagTime: inspect.Metadata.LastTagTime,
158 }
159 l.Unlock()
160 return nil
161 })
162 }
163 return summary, eg.Wait()
164}

Callers 1

getLocalImagesDigestsMethod · 0.95

Calls 4

apiClientMethod · 0.95
WaitMethod · 0.65
ImageInspectMethod · 0.45
LockMethod · 0.45

Tested by

no test coverage detected