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

Function normalizeAndDedupeImages

pkg/compose/image_pruner.go:222–242  ·  view source on GitHub ↗

normalizeAndDedupeImages returns the unique set of images after normalization.

(images []string)

Source from the content-addressed store, hash-verified

220
221// normalizeAndDedupeImages returns the unique set of images after normalization.
222func normalizeAndDedupeImages(images []string) []string {
223 seen := make(map[string]struct{}, len(images))
224 for _, img := range images {
225 // since some references come from user input (service.image) and some
226 // come from the engine API, we standardize them, opting for the
227 // familiar name format since they'll also be displayed in the CLI
228 ref, err := reference.ParseNormalizedNamed(img)
229 if err == nil {
230 ref = reference.TagNameOnly(ref)
231 img = reference.FamiliarString(ref)
232 }
233 seen[img] = struct{}{}
234 }
235 ret := make([]string, 0, len(seen))
236 for v := range seen {
237 ret = append(ret, v)
238 }
239 // ensure a deterministic return result - the actual ordering is not useful
240 sort.Strings(ret)
241 return ret
242}

Callers 1

ImagesToPruneMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected