mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
pkg/jsonmessage: stop printing deprecated progressDetail, errorDetail
The API still returns it for backward-compatibility (but probably shouldn't), but we should no longer print it. This removes the use of these fields for printing, but keeps them for streamformatter to use. - ErrorMessage was deprecated in3043c26419- ProgressMessage was deprecated in597e0e69b4Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -122,26 +122,15 @@ func (p *JSONProgress) width() int {
|
||||
// the created time, where it from, status, ID of the
|
||||
// message. It's used for docker events.
|
||||
type JSONMessage struct {
|
||||
Stream string `json:"stream,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Progress *JSONProgress `json:"progressDetail,omitempty"`
|
||||
|
||||
// ProgressMessage is a pre-formatted presentation of [Progress].
|
||||
//
|
||||
// Deprecated: this field is deprecated since docker v0.7.1 / API v1.8. Use the information in [Progress] instead. This field will be omitted in a future release.
|
||||
ProgressMessage string `json:"progress,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
From string `json:"from,omitempty"`
|
||||
Time int64 `json:"time,omitempty"`
|
||||
TimeNano int64 `json:"timeNano,omitempty"`
|
||||
Error *jsonstream.Error `json:"errorDetail,omitempty"`
|
||||
|
||||
// ErrorMessage contains errors encountered during the operation.
|
||||
//
|
||||
// Deprecated: this field is deprecated since docker v0.6.0 / API v1.4. Use [Error.Message] instead. This field will be omitted in a future release.
|
||||
ErrorMessage string `json:"error,omitempty"` // deprecated
|
||||
// Aux contains out-of-band data, such as digests for push signing and image id after building.
|
||||
Aux *json.RawMessage `json:"aux,omitempty"`
|
||||
Stream string `json:"stream,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Progress *JSONProgress `json:"progressDetail,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
From string `json:"from,omitempty"`
|
||||
Time int64 `json:"time,omitempty"`
|
||||
TimeNano int64 `json:"timeNano,omitempty"`
|
||||
Error *jsonstream.Error `json:"errorDetail,omitempty"`
|
||||
Aux *json.RawMessage `json:"aux,omitempty"` // Aux contains out-of-band data, such as digests for push signing and image id after building.
|
||||
}
|
||||
|
||||
// We can probably use [aec.EmptyBuilder] for managing the output, but
|
||||
@@ -201,8 +190,6 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error {
|
||||
}
|
||||
if jm.Progress != nil && isTerminal {
|
||||
_, _ = fmt.Fprintf(out, "%s %s%s", jm.Status, jm.Progress.String(), endl)
|
||||
} else if jm.ProgressMessage != "" { // deprecated
|
||||
_, _ = fmt.Fprintf(out, "%s %s%s", jm.Status, jm.ProgressMessage, endl)
|
||||
} else if jm.Stream != "" {
|
||||
_, _ = fmt.Fprintf(out, "%s%s", jm.Stream, endl)
|
||||
} else {
|
||||
@@ -253,7 +240,7 @@ func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr,
|
||||
if jm.Progress != nil {
|
||||
jm.Progress.terminalFd = terminalFd
|
||||
}
|
||||
if jm.ID != "" && (jm.Progress != nil || jm.ProgressMessage != "") {
|
||||
if jm.ID != "" && jm.Progress != nil {
|
||||
line, ok := ids[jm.ID]
|
||||
if !ok {
|
||||
// NOTE: This approach of using len(id) to
|
||||
|
||||
@@ -162,14 +162,6 @@ func TestJSONMessageDisplay(t *testing.T) {
|
||||
"stream",
|
||||
"stream",
|
||||
},
|
||||
// With progress message
|
||||
{
|
||||
Status: "status",
|
||||
ProgressMessage: "progressMessage",
|
||||
}: {
|
||||
"status progressMessage",
|
||||
"status progressMessage",
|
||||
},
|
||||
// With progress, stream empty
|
||||
{
|
||||
Status: "status",
|
||||
@@ -248,11 +240,6 @@ func TestDisplayJSONMessagesStream(t *testing.T) {
|
||||
"ID: status\n",
|
||||
"ID: status\n",
|
||||
},
|
||||
// With progress
|
||||
`{ "id": "ID", "status": "status", "progress": "ProgressMessage" }`: {
|
||||
"ID: status ProgressMessage",
|
||||
fmt.Sprintf("\n%c[%dAID: status ProgressMessage%c[%dB", 27, 1, 27, 1),
|
||||
},
|
||||
// With progressDetail
|
||||
`{ "id": "ID", "status": "status", "progressDetail": { "Current": 1} }`: {
|
||||
"", // progressbar is disabled in non-terminal
|
||||
|
||||
Reference in New Issue
Block a user