build: rework build package to use only a single Build call

Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
Justin Chadwell
2023-04-19 11:54:02 +01:00
parent c6a78d216c
commit 1571c137bc
16 changed files with 1206 additions and 1014 deletions

View File

@@ -29,6 +29,7 @@ type Printer struct {
warnings []client.VertexWarning
logMu sync.Mutex
logSourceMap map[digest.Digest]interface{}
paused *bool
}
func (p *Printer) Wait() error {
@@ -45,6 +46,10 @@ func (p *Printer) Warnings() []client.VertexWarning {
return p.warnings
}
func (p *Printer) Pause(v bool) {
*p.paused = v
}
func (p *Printer) ValidateLogSource(dgst digest.Digest, v interface{}) bool {
p.logMu.Lock()
defer p.logMu.Unlock()
@@ -74,10 +79,12 @@ func NewPrinter(ctx context.Context, w io.Writer, out console.File, mode string,
statusCh := make(chan *client.SolveStatus)
doneCh := make(chan struct{})
paused := false
pw := &Printer{
status: statusCh,
done: doneCh,
logSourceMap: map[digest.Digest]interface{}{},
paused: &paused,
}
if v := os.Getenv("BUILDKIT_PROGRESS"); v != "" && mode == PrinterModeAuto {
@@ -101,7 +108,7 @@ func NewPrinter(ctx context.Context, w io.Writer, out console.File, mode string,
go func() {
resumeLogs := logutil.Pause(logrus.StandardLogger())
// not using shared context to not disrupt display but let is finish reporting errors
pw.warnings, pw.err = progressui.DisplaySolveStatus(ctx, c, w, statusCh, solveStatusOpt...)
pw.warnings, pw.err = progressui.DisplaySolveStatus(ctx, c, w, statusCh, pw.paused, solveStatusOpt...)
resumeLogs()
close(doneCh)
}()