Skip to content

Commit 44337d2

Browse files
cmrigneyndeloof
authored andcommitted
Enhance JSON progress events with more fields.
Signed-off-by: Cody Rigney <cody.rigney@docker.com>
1 parent bc73350 commit 44337d2

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

pkg/progress/json.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@ type jsonWriter struct {
3030
}
3131

3232
type jsonMessage struct {
33-
DryRun bool `json:"dry-run,omitempty"`
34-
Tail bool `json:"tail,omitempty"`
35-
ID string `json:"id,omitempty"`
36-
Text string `json:"text,omitempty"`
37-
Status string `json:"status,omitempty"`
33+
DryRun bool `json:"dry-run,omitempty"`
34+
Tail bool `json:"tail,omitempty"`
35+
ID string `json:"id,omitempty"`
36+
ParentID string `json:"parent_id,omitempty"`
37+
Text string `json:"text,omitempty"`
38+
Status string `json:"status,omitempty"`
39+
Current int64 `json:"current,omitempty"`
40+
Total int64 `json:"total,omitempty"`
41+
Percent int `json:"percent,omitempty"`
3842
}
3943

4044
func (p *jsonWriter) Start(ctx context.Context) error {
@@ -48,11 +52,15 @@ func (p *jsonWriter) Start(ctx context.Context) error {
4852

4953
func (p *jsonWriter) Event(e Event) {
5054
var message = &jsonMessage{
51-
DryRun: p.dryRun,
52-
Tail: false,
53-
ID: e.ID,
54-
Text: e.Text,
55-
Status: e.StatusText,
55+
DryRun: p.dryRun,
56+
Tail: false,
57+
ID: e.ID,
58+
Text: e.Text,
59+
Status: e.StatusText,
60+
ParentID: e.ParentID,
61+
Current: e.Current,
62+
Total: e.Total,
63+
Percent: e.Percent,
5664
}
5765
marshal, err := json.Marshal(message)
5866
if err == nil {

0 commit comments

Comments
 (0)