Skip to content

Commit 8584c2d

Browse files
committed
wip push
Signed-off-by: Laura Brehm <[email protected]>
1 parent 6447bbe commit 8584c2d

File tree

18 files changed

+264
-200
lines changed

18 files changed

+264
-200
lines changed

cli/command/image/push.go

+68-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package image
55

66
import (
7+
"bytes"
78
"context"
89
"encoding/json"
910
"fmt"
@@ -18,8 +19,10 @@ import (
1819
"github.com/docker/cli/cli/streams"
1920
"github.com/docker/docker/api/types/auxprogress"
2021
"github.com/docker/docker/api/types/image"
22+
imagetypes "github.com/docker/docker/api/types/image"
2123
registrytypes "github.com/docker/docker/api/types/registry"
2224
"github.com/docker/docker/pkg/jsonmessage"
25+
"github.com/docker/docker/pkg/stringid"
2326
"github.com/docker/docker/registry"
2427
"github.com/morikuni/aec"
2528
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
@@ -144,28 +147,86 @@ To push the complete multi-platform image, remove the --platform flag.
144147
}
145148

146149
if opts.quiet {
147-
err = jsonmessage.DisplayJSONMessagesToStream(responseBody, streams.NewOut(io.Discard), handleAux(dockerCli))
150+
err = jsonmessage.DisplayJSONMessagesToStream(responseBody, streams.NewOut(io.Discard), handleAux(dockerCli.Out()))
148151
if err == nil {
149152
fmt.Fprintln(dockerCli.Out(), ref.String())
150153
}
151154
return err
152155
}
153-
return jsonmessage.DisplayJSONMessagesToStream(responseBody, dockerCli.Out(), handleAux(dockerCli))
156+
return jsonmessage.DisplayJSONMessagesToStream(responseBody, dockerCli.Out(), handleAux(dockerCli.Out()))
154157
}
155158

156159
var notes []string
157160

158-
func handleAux(dockerCli command.Cli) func(jm jsonmessage.JSONMessage) {
161+
func handleAux(out *streams.Out) func(jm jsonmessage.JSONMessage) {
159162
return func(jm jsonmessage.JSONMessage) {
160163
b := []byte(*jm.Aux)
161164

162165
var stripped auxprogress.ManifestPushedInsteadOfIndex
163166
err := json.Unmarshal(b, &stripped)
164167
if err == nil && stripped.ManifestPushedInsteadOfIndex {
165-
note := fmt.Sprintf("Not all multiplatform-content is present and only the available single-platform image was pushed\n%s -> %s",
166-
aec.RedF.Apply(stripped.OriginalIndex.Digest.String()),
167-
aec.GreenF.Apply(stripped.SelectedManifest.Digest.String()),
168-
)
168+
highlightColor := aec.NewBuilder(aec.GreenF, aec.Bold)
169+
170+
note := fmt.Sprintf("Not all multiplatform-content is present, pushing single-platform image.")
171+
note += "\nNo platform selected, using host platform " + highlightColor.ANSI.Apply(stripped.SelectedManifest.Platform.OS+"/"+stripped.SelectedManifest.Platform.Architecture+"/"+stripped.SelectedManifest.Platform.Variant+"\n\n")
172+
topNameColor := aec.NewBuilder(aec.BlueF, aec.Bold).ANSI
173+
normalColor := aec.NewBuilder(aec.DefaultF).ANSI
174+
untaggedColor := aec.NewBuilder(aec.Faint).ANSI
175+
// Print images
176+
columns := []imgColumn{
177+
{
178+
Title: "Image",
179+
Align: alignLeft,
180+
Width: 10,
181+
},
182+
{
183+
Title: "ID",
184+
Align: alignLeft,
185+
Width: 12,
186+
DetailsValue: func(d *rowDetails) string {
187+
return stringid.TruncateID(d.ID)
188+
},
189+
},
190+
{
191+
Title: "Disk usage",
192+
Align: alignRight,
193+
Width: 10,
194+
DetailsValue: func(d *rowDetails) string {
195+
return d.DiskUsage
196+
},
197+
},
198+
{
199+
Title: "Content size",
200+
Align: alignRight,
201+
Width: 12,
202+
DetailsValue: func(d *rowDetails) string {
203+
return d.ContentSize
204+
},
205+
},
206+
}
207+
208+
imageRows, spacing := buildTableRows([]imagetypes.Summary{*stripped.ImageSummary})
209+
for i, child := range imageRows[0].Children {
210+
if child.Platform == stripped.SelectedManifest.Platform.OS+"/"+stripped.SelectedManifest.Platform.Architecture+"/"+stripped.SelectedManifest.Platform.Variant {
211+
imageRows[0].Children[i].Highlight = true
212+
}
213+
}
214+
215+
_, width := out.GetTtySize()
216+
columns = formatColumnsForOutput(int(width), columns, imageRows)
217+
218+
table := imageTreeTable{
219+
columns: columns,
220+
headerColor: topNameColor,
221+
indexNameColor: topNameColor,
222+
untaggedColor: untaggedColor,
223+
normalColor: normalColor,
224+
spacing: spacing,
225+
}
226+
227+
treeB := bytes.Buffer{}
228+
table.printTable(&treeB, imageRows)
229+
note += treeB.String()
169230
notes = append(notes, note)
170231
}
171232

vendor/github.com/docker/docker/api/swagger.yaml

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/docker/api/types/auxprogress/push.go

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/docker/api/types/system/info.go

+7-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/docker/api/types/types.go

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/docker/client/build_prune.go

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/docker/client/client.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/docker/client/container_create.go

+45-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/docker/client/container_prune.go

+5-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/docker/docker/client/container_resize.go

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)