Skip to content

Commit

Permalink
Merge pull request #338 from tonistiigi/load-no-warn
Browse files Browse the repository at this point in the history
build: avoid warning if default load disabled
  • Loading branch information
tonistiigi authored Aug 22, 2020
2 parents 9ac5b07 + 0124b6b commit fb7b670
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,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{}}}
Expand Down Expand Up @@ -499,7 +497,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())
Expand Down Expand Up @@ -852,6 +850,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()
Expand Down

0 comments on commit fb7b670

Please sign in to comment.