Skip to content

Commit 872736a

Browse files
Merge pull request #286 from depot/load-logs
Report `--load` progress to UI
2 parents 0c8ce5f + de5508d commit 872736a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pkg/buildx/commands/bake.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/depot/cli/pkg/compose"
1717
"github.com/depot/cli/pkg/helpers"
1818
"github.com/depot/cli/pkg/load"
19+
"github.com/depot/cli/pkg/progresshelper"
1920
"github.com/depot/cli/pkg/registry"
2021
"github.com/depot/cli/pkg/sbom"
2122
buildx "github.com/docker/buildx/build"
@@ -187,7 +188,8 @@ func RunBake(dockerCli command.Cli, in BakeOptions, validator BakeValidator) (er
187188
var err error
188189
// Only load images from requested targets to avoid pulling unnecessary images.
189190
if slices.Contains(requestedTargets, resp[i].Name) {
190-
err = load.DepotFastLoad(ctx2, dockerCli.Client(), depotResponses, pullOpts, printer)
191+
reportingPrinter := progresshelper.NewReportingWriter(printer, in.buildID, in.token)
192+
err = load.DepotFastLoad(ctx2, dockerCli.Client(), depotResponses, pullOpts, reportingPrinter)
191193
}
192194
load.DeleteExportLeases(ctx2, depotResponses)
193195
return err

pkg/buildx/commands/build.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/depot/cli/pkg/debuglog"
2828
"github.com/depot/cli/pkg/helpers"
2929
"github.com/depot/cli/pkg/load"
30+
"github.com/depot/cli/pkg/progresshelper"
3031
"github.com/depot/cli/pkg/registry"
3132
"github.com/depot/cli/pkg/sbom"
3233
"github.com/distribution/reference"
@@ -320,7 +321,8 @@ func buildTargets(ctx context.Context, dockerCli command.Cli, nodes []builder.No
320321
}
321322

322323
// NOTE: the err is returned at the end of this function after the final prints.
323-
err = load.DepotFastLoad(ctx, dockerCli.Client(), resp, pullOpts, printer)
324+
reportingPrinter := progresshelper.NewReportingWriter(printer, depotOpts.buildID, depotOpts.token)
325+
err = load.DepotFastLoad(ctx, dockerCli.Client(), resp, pullOpts, reportingPrinter)
324326
if err != nil && !errors.Is(err, context.Canceled) {
325327
// For now, we will fallback by rebuilding with load.
326328
if exportLoad {
@@ -334,7 +336,7 @@ func buildTargets(ctx context.Context, dockerCli command.Cli, nodes []builder.No
334336
}
335337

336338
if retryable {
337-
progress.Write(printer, "[load] fast load failed; retrying", func() error { return err })
339+
progress.Write(reportingPrinter, "[load] fast load failed; retrying", func() error { return err })
338340
opts = load.WithDockerLoad(fallbackOpts)
339341
_, err = depotbuildxbuild.DepotBuildWithResultHandler(ctx, buildxNodes, opts, dockerClient, dockerConfigDir, printer, nil, nil, allowNoOutput, depotOpts.build)
340342
}

0 commit comments

Comments
 (0)