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

Function displayTransformer

cmd/compose/bridge.go:109–141  ·  view source on GitHub ↗
(dockerCli command.Cli, transformers []image.Summary, options lsOptions)

Source from the content-addressed store, hash-verified

107}
108
109func displayTransformer(dockerCli command.Cli, transformers []image.Summary, options lsOptions) error {
110 if options.Quiet {
111 for _, t := range transformers {
112 if len(t.RepoTags) > 0 {
113 _, _ = fmt.Fprintln(dockerCli.Out(), t.RepoTags[0])
114 } else {
115 _, _ = fmt.Fprintln(dockerCli.Out(), t.ID)
116 }
117 }
118 return nil
119 }
120 return formatter.Print(transformers, options.Format, dockerCli.Out(),
121 func(w io.Writer) {
122 for _, img := range transformers {
123 id := stringid.TruncateID(img.ID)
124 size := units.HumanSizeWithPrecision(float64(img.Size), 3)
125 repo, tag := "<none>", "<none>"
126 if len(img.RepoTags) > 0 {
127 ref, err := reference.ParseDockerRef(img.RepoTags[0])
128 if err == nil {
129 // ParseDockerRef will reject a local image ID
130 repo = reference.FamiliarName(ref)
131 if tagged, ok := ref.(reference.Tagged); ok {
132 tag = tagged.Tag()
133 }
134 }
135 }
136
137 _, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", id, repo, tag, size)
138 }
139 },
140 "IMAGE ID", "REPO", "TAGS", "SIZE")
141}
142
143func createTransformerCommand(dockerCli command.Cli) *cobra.Command {
144 var opts bridge.CreateTransformerOptions

Callers 1

listTransformersCommandFunction · 0.85

Calls 2

PrintFunction · 0.92
OutMethod · 0.45

Tested by

no test coverage detected