Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 6d698be

Browse files
Merge pull request #779 from ulyssessouza/refactor-build
Bump buildx and fix file finalizer breaking the stdout fix
2 parents 3064a5d + 864442b commit 6d698be

File tree

692 files changed

+137249
-56462
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

692 files changed

+137249
-56462
lines changed

Gopkg.lock

Lines changed: 155 additions & 138 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
required = ["github.com/wadey/gocovmerge"]
2323

24-
[[constraint]]
24+
[[override]]
2525
name = "github.com/docker/buildx"
26-
version = "=v0.3.1"
26+
revision = "709ef36b4f10a9389fd9a806657c48a969909d85"
2727

2828
[[override]]
2929
name = "github.com/moby/buildkit"
@@ -46,7 +46,7 @@ required = ["github.com/wadey/gocovmerge"]
4646

4747
[[override]]
4848
name = "github.com/containerd/containerd"
49-
version = "v1.3.0"
49+
revision = "97712c8ad73dd302d5d226e0384b2d86e5de2989"
5050

5151
[[override]]
5252
name = "github.com/docker/cli"

internal/commands/build/build.go

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ import (
1313
"strings"
1414
"sync"
1515

16-
"github.com/deislabs/cnab-go/bundle"
17-
cnab "github.com/deislabs/cnab-go/driver"
1816
"github.com/docker/app/internal"
1917
"github.com/docker/app/internal/packager"
2018
"github.com/docker/app/types"
19+
20+
"github.com/containerd/console"
21+
"github.com/deislabs/cnab-go/bundle"
22+
cnab "github.com/deislabs/cnab-go/driver"
2123
"github.com/docker/buildx/build"
2224
"github.com/docker/buildx/driver"
2325
_ "github.com/docker/buildx/driver/docker" // required to get default driver registered, see driver/docker/factory.go:14
@@ -86,28 +88,43 @@ func Cmd(dockerCli command.Cli) *cobra.Command {
8688
return cmd
8789
}
8890

89-
// FIXME: DO NOT SET THIS VARIABLE DIRECTLY! Use `getOutputFile`
90-
// This global var prevents the file to be garbage collected and by that invalidated
91-
// A an alternative fix for this would be writing the output to a bytes buffer and flushing to stdout.
92-
// The impossibility here is that os.File is not an interface that a buffer can implement.
93-
// Maybe `progress.NewPrinter` should implement an "os.File-like" interface just for its needs.
94-
// See https://github.com/golang/go/issues/14106
95-
var _outputFile *os.File
91+
type File struct {
92+
f *streams.Out
93+
}
9694

97-
func getOutputFile(realOut *streams.Out, quiet bool) (*os.File, error) {
98-
if _outputFile != nil {
99-
return _outputFile, nil
100-
}
95+
func NewFile(f *streams.Out) console.File {
96+
return File{f: f}
97+
}
98+
99+
func (f File) Fd() uintptr {
100+
return f.f.FD()
101+
}
102+
103+
func (f File) Name() string {
104+
return os.Stdout.Name()
105+
}
106+
107+
func (f File) Read(p []byte) (n int, err error) {
108+
return 0, nil
109+
}
110+
111+
func (f File) Write(p []byte) (n int, err error) {
112+
return f.f.Write(p)
113+
}
114+
115+
func (f File) Close() error {
116+
return nil
117+
}
118+
119+
func getOutputFile(realOut *streams.Out, quiet bool) (console.File, error) {
101120
if quiet {
102-
var err error
103-
_outputFile, err = os.Create(os.DevNull)
121+
nullFile, err := os.Create(os.DevNull)
104122
if err != nil {
105123
return nil, err
106124
}
107-
return _outputFile, nil
125+
return nullFile, nil
108126
}
109-
_outputFile = os.NewFile(realOut.FD(), os.Stdout.Name())
110-
return _outputFile, nil
127+
return NewFile(realOut), nil
111128
}
112129

113130
func runBuild(dockerCli command.Cli, contextPath string, opt buildOptions) error {
@@ -212,7 +229,7 @@ func buildImageUsingBuildx(app *types.App, contextPath string, opt buildOptions,
212229
ctx, cancel := context.WithCancel(appcontext.Context())
213230
defer cancel()
214231
const drivername = "buildx_buildkit_default"
215-
d, err := driver.GetDriver(ctx, drivername, nil, dockerCli.Client(), nil, "", nil)
232+
d, err := driver.GetDriver(ctx, drivername, nil, dockerCli.Client(), nil, nil, "", nil, "")
216233
if err != nil {
217234
return nil, err
218235
}

vendor/cloud.google.com/go/AUTHORS

Lines changed: 0 additions & 15 deletions
This file was deleted.

vendor/cloud.google.com/go/CONTRIBUTORS

Lines changed: 0 additions & 40 deletions
This file was deleted.

vendor/cloud.google.com/go/compute/metadata/metadata.go

Lines changed: 18 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/Masterminds/semver/LICENSE.txt

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)