Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

progressui: adds a json output that shows raw events for the solver status #4113

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 32 additions & 31 deletions client/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,50 @@ import (
)

type Vertex struct {
Digest digest.Digest
Inputs []digest.Digest
Name string
Started *time.Time
Completed *time.Time
Cached bool
Error string
ProgressGroup *pb.ProgressGroup
Digest digest.Digest `json:"digest,omitempty"`
Inputs []digest.Digest `json:"inputs,omitempty"`
Name string `json:"name,omitempty"`
Started *time.Time `json:"started,omitempty"`
Completed *time.Time `json:"completed,omitempty"`
Cached bool `json:"cached,omitempty"`
Error string `json:"error,omitempty"`
ProgressGroup *pb.ProgressGroup `json:"progressGroup,omitempty"`
}

type VertexStatus struct {
ID string
Vertex digest.Digest
Name string
Total int64
Current int64
Timestamp time.Time
Started *time.Time
Completed *time.Time
ID string `json:"id"`
Vertex digest.Digest `json:"vertex,omitempty"`
Name string `json:"name,omitempty"`
Total int64 `json:"total,omitempty"`
Current int64 `json:"current"`
Timestamp time.Time `json:"timestamp,omitempty"`
Started *time.Time `json:"started,omitempty"`
Completed *time.Time `json:"completed,omitempty"`
}

type VertexLog struct {
Vertex digest.Digest
Stream int
Data []byte
Timestamp time.Time
Vertex digest.Digest `json:"vertex,omitempty"`
Stream int `json:"stream,omitempty"`
Data []byte `json:"data"`
Timestamp time.Time `json:"timestamp"`
}

type VertexWarning struct {
Vertex digest.Digest
Level int
Short []byte
Detail [][]byte
URL string
SourceInfo *pb.SourceInfo
Range []*pb.Range
Vertex digest.Digest `json:"vertex,omitempty"`
Level int `json:"level,omitempty"`
Short []byte `json:"short,omitempty"`
Detail [][]byte `json:"detail,omitempty"`
URL string `json:"url,omitempty"`

SourceInfo *pb.SourceInfo `json:"sourceInfo,omitempty"`
Range []*pb.Range `json:"range,omitempty"`
}

type SolveStatus struct {
Vertexes []*Vertex
Statuses []*VertexStatus
Logs []*VertexLog
Warnings []*VertexWarning
Vertexes []*Vertex `json:"vertexes,omitempty"`
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I should change this at the same time now that it will be publicly exposed, but the proper plural of vertex is vertices. That would involve a change to the field name though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I didn't realize this was a regional thing.

Statuses []*VertexStatus `json:"statuses,omitempty"`
Logs []*VertexLog `json:"logs,omitempty"`
Warnings []*VertexWarning `json:"warnings,omitempty"`
}

type SolveResponse struct {
Expand Down
2 changes: 1 addition & 1 deletion cmd/buildctl/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var buildCommand = cli.Command{
},
cli.StringFlag{
Name: "progress",
Usage: "Set type of progress (auto, plain, tty). Use plain to show container output",
Usage: "Set type of progress (auto, plain, tty, rawjson). Use plain to show container output",
Value: "auto",
},
cli.StringFlag{
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/buildctl.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ USAGE:

OPTIONS:
--output value, -o value Define exports for build result, e.g. --output type=image,name=docker.io/username/image,push=true
--progress value Set type of progress (auto, plain, tty). Use plain to show container output (default: "auto")
--progress value Set type of progress (auto, plain, tty, rawjson). Use plain to show container output (default: "auto")
--trace value Path to trace file. Defaults to no tracing.
--local value Allow build access to the local directory
--oci-layout value Allow build access to the local OCI layout
Expand Down
11 changes: 6 additions & 5 deletions examples/build-using-dockerfile/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"path/filepath"
"strings"

"github.com/containerd/console"
"github.com/moby/buildkit/client"
dockerfile "github.com/moby/buildkit/frontend/dockerfile/builder"
"github.com/moby/buildkit/util/appcontext"
Expand Down Expand Up @@ -102,12 +101,14 @@ func action(clicontext *cli.Context) error {
return err
})
eg.Go(func() error {
var c console.Console
if cn, err := console.ConsoleFromFile(os.Stderr); err == nil {
c = cn
d, err := progressui.NewDisplay(os.Stderr, progressui.TtyMode)
if err != nil {
// If an error occurs while attempting to create the tty display,
// fallback to using plain mode on stdout (in contrast to stderr).
d, _ = progressui.NewDisplay(os.Stdout, progressui.PlainMode)
}
// not using shared context to not disrupt display but let is finish reporting errors
_, err = progressui.DisplaySolveStatus(context.TODO(), c, os.Stdout, ch)
_, err = d.UpdateFrom(context.TODO(), ch)
return err
})
eg.Go(func() error {
Expand Down
Loading