Skip to content

Commit

Permalink
Enhance JSON progress events with more fields.
Browse files Browse the repository at this point in the history
Signed-off-by: Cody Rigney <[email protected]>
  • Loading branch information
cmrigney authored and ndeloof committed Jul 23, 2024
1 parent bc73350 commit 44337d2
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions pkg/progress/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ type jsonWriter struct {
}

type jsonMessage struct {
DryRun bool `json:"dry-run,omitempty"`
Tail bool `json:"tail,omitempty"`
ID string `json:"id,omitempty"`
Text string `json:"text,omitempty"`
Status string `json:"status,omitempty"`
DryRun bool `json:"dry-run,omitempty"`
Tail bool `json:"tail,omitempty"`
ID string `json:"id,omitempty"`
ParentID string `json:"parent_id,omitempty"`
Text string `json:"text,omitempty"`
Status string `json:"status,omitempty"`
Current int64 `json:"current,omitempty"`
Total int64 `json:"total,omitempty"`
Percent int `json:"percent,omitempty"`
}

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

func (p *jsonWriter) Event(e Event) {
var message = &jsonMessage{
DryRun: p.dryRun,
Tail: false,
ID: e.ID,
Text: e.Text,
Status: e.StatusText,
DryRun: p.dryRun,
Tail: false,
ID: e.ID,
Text: e.Text,
Status: e.StatusText,
ParentID: e.ParentID,
Current: e.Current,
Total: e.Total,
Percent: e.Percent,
}
marshal, err := json.Marshal(message)
if err == nil {
Expand Down

0 comments on commit 44337d2

Please sign in to comment.