-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
progressui: adds a json output that shows raw events for the solver s…
…tatus This adds an additional display output for the progress indicator to support a json output. It refactors the progressui package a bit to add a new method that takes in a `SolveStatusDisplay`. This `SolveStatusDisplay` can be created by the user using `NewDisplay` with the various modes as input parameters. The json output will print the status updates and log messages for the vertexes that have had updates. Each JSON blob has the same format and it matches closely with the raw underlying status updates. The display will still attempt to regulate the number of messages that come through and will batch various events together if events are sent too quickly according to the default parameters for rate limiting set in the progressui package. At the moment, there is no public API for creating your own `SolveStatusDisplay` and each of the display implementations borrow heavily from each other. In the future, it is possible this API could be expanded. If you need to create a custom progress bar that requires more than what this package offers, I'd probably recommend just copying the package and acting on the `SolveStatus` channel directly. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
- Loading branch information
1 parent
a26a22b
commit 35d9a5a
Showing
6 changed files
with
484 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package progressui | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/moby/buildkit/solver/pb" | ||
digest "github.com/opencontainers/go-digest" | ||
) | ||
|
||
// SolveStatus holds the latest status update for a vertex by its digest. | ||
type SolveStatus struct { | ||
Digest digest.Digest `json:"digest"` | ||
Vertex Vertex `json:"vertex,omitempty"` | ||
Statuses []VertexStatus `json:"statuses,omitempty"` | ||
Warnings []VertexWarning `json:"warnings,omitempty"` | ||
Logs []VertexLog `json:"logs,omitempty"` | ||
} | ||
|
||
// Vertex contains information about the vertex itself. | ||
// Information will only be included if it has changed since the last time | ||
// that the information was sent or if it is the first time this vertex has | ||
// been output. | ||
type Vertex struct { | ||
Name string `json:"name,omitempty"` | ||
Started *time.Time `json:"started,omitempty"` | ||
Completed *time.Time `json:"completed,omitempty"` | ||
Cached bool `json:"cached,omitempty"` | ||
Canceled bool `json:"canceled,omitempty"` | ||
Error string `json:"error,omitempty"` | ||
} | ||
|
||
// VertexStatus holds the status information for a continuous action performed by this vertex. | ||
// As an example, downloading a file would result in a VertexStatus being created and updated. | ||
// | ||
// For non-progress messages, VertexLog is used instead. | ||
type VertexStatus struct { | ||
ID string `json:"id"` | ||
Name string `json:"name,omitempty"` | ||
Total int64 `json:"total,omitempty"` | ||
Current int64 `json:"current"` | ||
Timestamp time.Time `json:"ts"` | ||
Started *time.Time `json:"start,omitempty"` | ||
Completed *time.Time `json:"completed,omitempty"` | ||
} | ||
|
||
// VertexWarning holds a warning issued for a particular vertex in the solve graph. | ||
type VertexWarning struct { | ||
Level int `json:"level"` | ||
Short []byte `json:"short"` | ||
Detail [][]byte `json:"detail"` | ||
URL string `json:"url,omitempty"` | ||
SourceInfo *pb.SourceInfo `json:"sourceInfo,omitempty"` | ||
Range []*pb.Range `json:"range,omitempty"` | ||
} | ||
|
||
// VertexLog holds log messages produced by the build. For user output that gets updated | ||
// over time, VertexStatus is used instead. | ||
type VertexLog struct { | ||
Message []byte `json:"msg"` | ||
Partial bool `json:"partial,omitempty"` | ||
} |
Oops, something went wrong.