Skip to content

Commit

Permalink
silent buildkit output by default
Browse files Browse the repository at this point in the history
  • Loading branch information
oclaussen committed Feb 7, 2019
1 parent 6ccfe07 commit 1381557
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
22 changes: 12 additions & 10 deletions pkg/image/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ func (image *Image) Build() (string, error) {
return image.session.Run(context.TODO(), image.client.DialSession)
})

eg.Go(func() error {
cons, err := console.ConsoleFromFile(os.Stdout)
if err != nil {
return err
}
return progressui.DisplaySolveStatus(context.TODO(), "", cons, os.Stdout, displayCh)
})
if image.config.PrintOutput {
eg.Go(func() error {
cons, err := console.ConsoleFromFile(os.Stdout)
if err != nil {
return err
}
return progressui.DisplaySolveStatus(context.TODO(), "", cons, os.Stdout, displayCh)
})
}

eg.Go(func() error {
defer func() {
Expand Down Expand Up @@ -105,10 +107,10 @@ func (image *Image) runBuild(contextData *contextData, displayCh chan *client.So
}
defer response.Body.Close()

return handleBuildResult(response.Body, displayCh)
return handleBuildResult(response.Body, displayCh, image.config.PrintOutput)
}

func handleBuildResult(response io.Reader, displayCh chan *client.SolveStatus) (string, error) {
func handleBuildResult(response io.Reader, displayCh chan *client.SolveStatus, printOutput bool) (string, error) {
var imageID string
decoder := json.NewDecoder(response)
for {
Expand All @@ -131,7 +133,7 @@ func handleBuildResult(response io.Reader, displayCh chan *client.SolveStatus) (
continue
}
imageID = result.ID
} else if msg.ID == "moby.buildkit.trace" {
} else if printOutput && msg.ID == "moby.buildkit.trace" {
var resp controlapi.StatusResponse
var dt []byte
if err := json.Unmarshal(*msg.Aux, &dt); err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type ImageConfig struct {
NoCache bool
ForceRebuild bool
ForcePull bool
PrintOutput bool
}

// Client represents a docker client that can do everything this package
Expand Down

0 comments on commit 1381557

Please sign in to comment.