From 0124b6b9c98dea7e7a7ab4693e88c2b855afd4d5 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Wed, 29 Jul 2020 20:27:19 -0700 Subject: [PATCH] build: avoid warning if default load disabled Signed-off-by: Tonis Tiigi --- build/build.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/build/build.go b/build/build.go index 532bb0c1..fb7d4c34 100644 --- a/build/build.go +++ b/build/build.go @@ -343,13 +343,11 @@ func toSolveOpt(d driver.Driver, multiDriver bool, opt Options, dl dockerLoadCal IsDefaultMobyDriver() }) - noDefaultLoad, _ := strconv.ParseBool(os.Getenv("BUILDX_NO_DEFAULT_LOAD")) - switch len(opt.Exports) { case 1: // valid case 0: - if isDefaultMobyDriver && !noDefaultLoad { + if isDefaultMobyDriver && !noDefaultLoad() { // backwards compat for docker driver only: // this ensures the build results in a docker image. opt.Exports = []client.ExportEntry{{Type: "image", Attrs: map[string]string{}}} @@ -502,7 +500,7 @@ func Build(ctx context.Context, drivers []DriverInfo, opt map[string]Options, do } } - if noMobyDriver != nil { + if noMobyDriver != nil && !noDefaultLoad() { for _, opt := range opt { if len(opt.Exports) == 0 { logrus.Warnf("No output specified for %s driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load", noMobyDriver.Factory().Name()) @@ -855,6 +853,15 @@ func newDockerLoader(ctx context.Context, d DockerAPI, name string, mw *progress }, nil } +func noDefaultLoad() bool { + v := os.Getenv("BUILDX_NO_DEFAULT_LOAD") + b, err := strconv.ParseBool(v) + if err != nil { + logrus.Warnf("invalid non-bool value for BUILDX_NO_DEFAULT_LOAD: %s", v) + } + return b +} + type waitingWriter struct { *io.PipeWriter f func()