Skip to content

Commit

Permalink
bake: display read definition files in build output
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Oct 14, 2023
1 parent 01245e7 commit 30543f5
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 19 deletions.
108 changes: 102 additions & 6 deletions bake/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ import (
"sort"
"strconv"
"strings"
"time"

composecli "github.com/compose-spec/compose-go/cli"
"github.com/docker/buildx/bake/hclparser"
"github.com/docker/buildx/build"
controllerapi "github.com/docker/buildx/controller/pb"
"github.com/docker/buildx/util/buildflags"
"github.com/docker/buildx/util/platformutil"
"github.com/docker/buildx/util/progress"
"github.com/docker/cli/cli/config"
hcl "github.com/hashicorp/hcl/v2"
"github.com/moby/buildkit/client"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/session/auth/authprovider"
"github.com/pkg/errors"
Expand Down Expand Up @@ -54,28 +57,34 @@ func defaultFilenames() []string {
return names
}

func ReadLocalFiles(names []string, stdin io.Reader) ([]File, error) {
func ReadLocalFiles(names []string, stdin io.Reader, l progress.SubLogger) ([]File, error) {
isDefault := false
if len(names) == 0 {
isDefault = true
names = defaultFilenames()
}
out := make([]File, 0, len(names))

setStatus := func(st *client.VertexStatus) {
if l != nil {
l.SetStatus(st)
}
}

for _, n := range names {
var dt []byte
var err error
if n == "-" {
dt, err = io.ReadAll(stdin)
dt, err = readWithStatus(stdin, setStatus)
if err != nil {
return nil, err
}
} else {
dt, err = os.ReadFile(n)
dt, err = readFileWithStatus(n, isDefault, setStatus)
if dt == nil && err == nil {
continue
}
if err != nil {
if isDefault && errors.Is(err, os.ErrNotExist) {
continue
}
return nil, err
}
}
Expand All @@ -84,6 +93,93 @@ func ReadLocalFiles(names []string, stdin io.Reader) ([]File, error) {
return out, nil
}

func readFileWithStatus(fname string, isDefault bool, setStatus func(st *client.VertexStatus)) (dt []byte, err error) {
st := &client.VertexStatus{
ID: "reading " + fname,
}

defer func() {
now := time.Now()
st.Completed = &now
if dt != nil || err != nil {
setStatus(st)
}
}()

now := time.Now()
st.Started = &now

f, err := os.Open(fname)
if err != nil {
if isDefault && errors.Is(err, os.ErrNotExist) {
return nil, nil
}
setStatus(st)
return nil, err
}
defer f.Close()
setStatus(st)

info, err := f.Stat()
if err != nil {
return nil, err
}
st.Total = info.Size()
setStatus(st)

buf := make([]byte, 1024)
current := int64(0)
for {
n, err := f.Read(buf)
if err == io.EOF {
break
}
if err != nil {
return nil, err
}
dt = append(dt, buf[:n]...)
current += int64(n)
st.Current = current
setStatus(st)
}

return dt, nil
}

func readWithStatus(r io.Reader, setStatus func(st *client.VertexStatus)) (dt []byte, err error) {
st := &client.VertexStatus{
ID: "reading from stdin",
}

defer func() {
now := time.Now()
st.Completed = &now
setStatus(st)
}()

now := time.Now()
st.Started = &now
setStatus(st)

buf := make([]byte, 1024)
current := int64(0)
for {
n, err := r.Read(buf)
if err == io.EOF {
break
}
if err != nil {
return nil, err
}
dt = append(dt, buf[:n]...)
current += int64(n)
st.Current = current
setStatus(st)
}

return dt, nil
}

func ListTargets(files []File) ([]string, error) {
c, err := ParseFiles(files, nil)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion bake/bake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ func TestReadLocalFilesDefault(t *testing.T) {
for _, tf := range tt.filenames {
require.NoError(t, os.WriteFile(tf, []byte(tf), 0644))
}
files, err := ReadLocalFiles(nil, nil)
files, err := ReadLocalFiles(nil, nil, nil)
require.NoError(t, err)
if len(files) == 0 {
require.Equal(t, len(tt.expected), len(files))
Expand Down
33 changes: 25 additions & 8 deletions bake/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"archive/tar"
"bytes"
"context"
"time"

"github.com/docker/buildx/builder"
controllerapi "github.com/docker/buildx/controller/pb"
Expand Down Expand Up @@ -76,11 +77,14 @@ func ReadRemoteFiles(ctx context.Context, nodes []builder.Node, url string, name
return nil, err
}

if filename != "" {
files, err = filesFromURLRef(ctx, c, ref, inp, filename, names)
} else {
files, err = filesFromRef(ctx, ref, names)
}
progress.Wrap("[internal] load remote bake definitions", pw.Write, func(sub progress.SubLogger) error {
if filename != "" {
files, err = filesFromURLRef(ctx, c, ref, inp, filename, names, sub)
} else {
files, err = filesFromRef(ctx, ref, names, sub)
}
return nil
})
return nil, err
}, ch)

Expand Down Expand Up @@ -110,7 +114,7 @@ func isArchive(header []byte) bool {
return err == nil
}

func filesFromURLRef(ctx context.Context, c gwclient.Client, ref gwclient.Reference, inp *Input, filename string, names []string) ([]File, error) {
func filesFromURLRef(ctx context.Context, c gwclient.Client, ref gwclient.Reference, inp *Input, filename string, names []string, l progress.SubLogger) ([]File, error) {
stat, err := ref.StatFile(ctx, gwclient.StatRequest{Path: filename})
if err != nil {
return nil, err
Expand Down Expand Up @@ -148,13 +152,20 @@ func filesFromURLRef(ctx context.Context, c gwclient.Client, ref gwclient.Refere
return nil, err
}

return filesFromRef(ctx, ref, names)
return filesFromRef(ctx, ref, names, l)
}

inp.State = nil
name := inp.URL
inp.URL = ""

now := time.Now()
l.SetStatus(&client.VertexStatus{
ID: "reading " + name,
Started: &now,
Completed: &now,
})

if len(dt) > stat.Size() {
if stat.Size() > 1024*512 {
return nil, errors.Errorf("non-archive definition URL bigger than maximum allowed size")
Expand All @@ -171,7 +182,7 @@ func filesFromURLRef(ctx context.Context, c gwclient.Client, ref gwclient.Refere
return []File{{Name: name, Data: dt}}, nil
}

func filesFromRef(ctx context.Context, ref gwclient.Reference, names []string) ([]File, error) {
func filesFromRef(ctx context.Context, ref gwclient.Reference, names []string, l progress.SubLogger) ([]File, error) {
// TODO: auto-remove parent dir in needed
var files []File

Expand All @@ -189,6 +200,12 @@ func filesFromRef(ctx context.Context, ref gwclient.Reference, names []string) (
}
return nil, err
}
now := time.Now()
l.SetStatus(&client.VertexStatus{
ID: "reading " + name,
Started: &now,
Completed: &now,
})
dt, err := ref.ReadFile(ctx, gwclient.ReadRequest{Filename: name})
if err != nil {
return nil, err
Expand Down
5 changes: 4 additions & 1 deletion commands/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ func runBake(dockerCli command.Cli, targets []string, in bakeOptions, cFlags com
if url != "" {
files, inp, err = bake.ReadRemoteFiles(ctx, nodes, url, in.files, printer)
} else {
files, err = bake.ReadLocalFiles(in.files, dockerCli.In())
progress.Wrap("[internal] load local bake definitions", printer.Write, func(sub progress.SubLogger) error {
files, err = bake.ReadLocalFiles(in.files, dockerCli.In(), sub)
return nil
})
}
if err != nil {
return err
Expand Down
45 changes: 43 additions & 2 deletions tests/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func bakeCmd(sb integration.Sandbox, opts ...cmdOpt) (string, error) {

var bakeTests = []func(t *testing.T, sb integration.Sandbox){
testBakeLocal,
testBakeLocalMulti,
testBakeRemote,
testBakeRemoteCmdContext,
testBakeRemoteCmdContextOverride,
Expand All @@ -44,8 +45,45 @@ target "default" {
)
dirDest := t.TempDir()

out, err := bakeCmd(sb, withDir(dir), withArgs("--set", "*.output=type=local,dest="+dirDest))
cmd := buildxCmd(sb, withDir(dir), withArgs("bake", "--progress=plain", "--set", "*.output=type=local,dest="+dirDest))
out, err := cmd.CombinedOutput()
require.NoError(t, err, out)
require.Contains(t, string(out), `#1 [internal] load local bake definitions`)
require.Contains(t, string(out), `#1 reading docker-bake.hcl`)

require.FileExists(t, filepath.Join(dirDest, "foo"))
}

func testBakeLocalMulti(t *testing.T, sb integration.Sandbox) {
dockerfile := []byte(`
FROM scratch
COPY foo /foo
`)
bakefile := []byte(`
target "default" {
}
`)
composefile := []byte(`
services:
app:
build: {}
`)

dir := tmpdir(
t,
fstest.CreateFile("docker-bake.hcl", bakefile, 0600),
fstest.CreateFile("compoose.yaml", composefile, 0600),
fstest.CreateFile("Dockerfile", dockerfile, 0600),
fstest.CreateFile("foo", []byte("foo"), 0600),
)
dirDest := t.TempDir()

cmd := buildxCmd(sb, withDir(dir), withArgs("bake", "--progress=plain", "--set", "*.output=type=local,dest="+dirDest))
out, err := cmd.CombinedOutput()
require.NoError(t, err, out)
require.Contains(t, string(out), `#1 [internal] load local bake definitions`)
require.Contains(t, string(out), `#1 reading compose.yaml`)

Check failure on line 85 in tests/bake.go

View workflow job for this annotation

GitHub Actions / test (docker, ./tests)

Failed: tests/TestIntegration/TestBakeLocalMulti/worker=docker

=== RUN TestIntegration/TestBakeLocalMulti/worker=docker === PAUSE TestIntegration/TestBakeLocalMulti/worker=docker === CONT TestIntegration/TestBakeLocalMulti/worker=docker bake.go:85: Error Trace: /src/tests/bake.go:85 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:91 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:205 Error: "#0 building with \"integration-38d50wjeviv85oswlfcw07im1\" instance using docker driver\n\n#1 [internal] load local bake definitions\n#1 reading docker-bake.hcl 22B / 22B done\n#1 DONE 0.0s\n\n#2 [internal] load build definition from Dockerfile\n#2 transferring dockerfile: 66B done\n#2 DONE 0.0s\n\n#3 [internal] load .dockerignore\n#3 transferring context: 2B done\n#3 DONE 0.0s\n\n#4 [internal] load build context\n#4 transferring context: 33B done\n#4 DONE 0.0s\n\n#5 [1/1] COPY foo /foo\n#5 DONE 0.0s\n\n#6 exporting to client directory\n#6 copying files 29B done\n#6 DONE 0.0s\n" does not contain "#1 reading compose.yaml" Test: TestIntegration/TestBakeLocalMulti/worker=docker sandbox.go:128: stdout: /usr/bin/dockerd sandbox.go:128: stderr: /usr/bin/dockerd sandbox.go:131: > startCmd 2023-10-14 05:01:14.541308396 +0000 UTC m=+34.575103846 /usr/bin/dockerd --data-root /tmp/integration503360238/di2jcviu1owdd/root --exec-root /tmp/dxr/di2jcviu1owdd --pidfile /tmp/integration503360238/di2jcviu1owdd/docker.pid --containerd-namespace di2jcviu1owdd --containerd-plugins-namespace di2jcviu1owddp --host unix:///tmp/docker-integration/di2jcviu1owdd.sock --config-file /tmp/integration503360238/daemon.json --userland-proxy=false --tls=false --debug sandbox.go:131: time="2023-10-14T05:01:14.576619899Z" level=info msg="Starting up" sandbox.go:131: time="2023-10-14T05:01:14.578847350Z" level=warning msg="could not change group /tmp/docker-integration/di2jcviu1owdd.sock to docker: group docker not found" sandbox.go:131: time="2023-10-14T05:01:14.579034854Z" level=debug msg="Listener created for HTTP on unix (/tmp/docker-integration/di2jcviu1owdd.sock)" sandbox.go:131: time="2023-10-14T05:01:14.579049355Z" level=info msg="containerd not running, starting managed containerd" sandbox.go:131: time="2023-10-14T05:01:14.580069478Z" level=info msg="started new containerd process" address=/tmp/dxr/di2jcviu1owdd/containerd/containerd.sock module=libcontainerd pid=8164 sandbox.go:131: time="2023-10-14T05:01:14.599583422Z" level=info msg="starting containerd" revision=1677a17964311325ed1c31e2c0a3589ce6d5c30d version=v1.7.1 sandbox.go:131: time="2023-10-14T05:01:14.619543376Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.aufs\"..." type=io.containerd.snapshotter.v1 sandbox.go:131: time="2023-10-14T05:01:14.620576500Z" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.aufs\"..." error="aufs is not supported (modprobe aufs failed: exit status 1 \"modprobe: can't change directory to '/lib/modules': No such file or directory\\n\"): skip plugin" type=io.containerd.snapshotter.v1 sandbox.go:131: time="2023-10-14T05:01:14.620638401Z" level=info msg="loading plugin \"io.containerd.content.v1.content\"..." type=io.containerd.content.v1 sandbox.go:131: time="2023-10-14T05:01:14.620776204Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.native\"..." type=io.containerd.snapshotter.v1 sandbox.go:131: time="2023-10-14T05:01:14.620870806Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.overlayfs\"..." type=io.containerd.snapshotter.v1 sandbox.go:131: time="2023-10-14T05:01:14.621146413Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.devmapper\"..." type=io.containerd.snapshotter.v1 sandbox.go:131: time="2023-10-14T05:01:14.621191614Z" level=warning msg="failed to load plugin io.containerd.snapshotter.v1.devmapper" error="devmapper not configured" sandbox.go:131: time="2023-10-14T05:01:14.621214414Z" level=info msg="loading plugin \"io.containerd.snapshotte

Check failure on line 85 in tests/bake.go

View workflow job for this annotation

GitHub Actions / test (docker\+containerd, ./tests)

Failed: tests/TestIntegration/TestBakeLocalMulti/worker=docker+containerd

=== RUN TestIntegration/TestBakeLocalMulti/worker=docker+containerd === PAUSE TestIntegration/TestBakeLocalMulti/worker=docker+containerd === CONT TestIntegration/TestBakeLocalMulti/worker=docker+containerd bake.go:85: Error Trace: /src/tests/bake.go:85 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:91 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:205 Error: "#0 building with \"integration-zhsy4fwtwv3jigd6c0cjfric9\" instance using docker driver\n\n#1 [internal] load local bake definitions\n#1 reading docker-bake.hcl 22B / 22B done\n#1 DONE 0.0s\n\n#2 [internal] load .dockerignore\n#2 transferring context: 2B done\n#2 DONE 0.0s\n\n#3 [internal] load build definition from Dockerfile\n#3 transferring dockerfile: 66B done\n#3 DONE 0.0s\n\n#4 [internal] load build context\n#4 transferring context: 33B done\n#4 DONE 0.0s\n\n#5 [1/1] COPY foo /foo\n#5 DONE 0.0s\n\n#6 exporting to client directory\n#6 copying files 29B done\n#6 DONE 0.0s\n" does not contain "#1 reading compose.yaml" Test: TestIntegration/TestBakeLocalMulti/worker=docker+containerd sandbox.go:128: stdout: /usr/bin/dockerd sandbox.go:128: stderr: /usr/bin/dockerd sandbox.go:131: > startCmd 2023-10-14 05:00:25.979290378 +0000 UTC m=+28.652511583 /usr/bin/dockerd --data-root /tmp/integration3260696299/dy138w4iafykr/root --exec-root /tmp/dxr/dy138w4iafykr --pidfile /tmp/integration3260696299/dy138w4iafykr/docker.pid --containerd-namespace dy138w4iafykr --containerd-plugins-namespace dy138w4iafykrp --host unix:///tmp/docker-integration/dy138w4iafykr.sock --config-file /tmp/integration3260696299/daemon.json --userland-proxy=false --tls=false --debug sandbox.go:131: time="2023-10-14T05:00:26.014577629Z" level=info msg="Starting up" sandbox.go:131: time="2023-10-14T05:00:26.015545753Z" level=warning msg="could not change group /tmp/docker-integration/dy138w4iafykr.sock to docker: group docker not found" sandbox.go:131: time="2023-10-14T05:00:26.015693556Z" level=debug msg="Listener created for HTTP on unix (/tmp/docker-integration/dy138w4iafykr.sock)" sandbox.go:131: time="2023-10-14T05:00:26.015709457Z" level=info msg="containerd not running, starting managed containerd" sandbox.go:131: time="2023-10-14T05:00:26.016301471Z" level=info msg="started new containerd process" address=/tmp/dxr/dy138w4iafykr/containerd/containerd.sock module=libcontainerd pid=7773 sandbox.go:131: time="2023-10-14T05:00:26.032335158Z" level=info msg="starting containerd" revision=1677a17964311325ed1c31e2c0a3589ce6d5c30d version=v1.7.1 sandbox.go:131: time="2023-10-14T05:00:26.049463071Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.aufs\"..." type=io.containerd.snapshotter.v1 sandbox.go:131: time="2023-10-14T05:00:26.050137487Z" level=info msg="skip loading plugin \"io.containerd.snapshotter.v1.aufs\"..." error="aufs is not supported (modprobe aufs failed: exit status 1 \"modprobe: can't change directory to '/lib/modules': No such file or directory\\n\"): skip plugin" type=io.containerd.snapshotter.v1 sandbox.go:131: time="2023-10-14T05:00:26.050162388Z" level=info msg="loading plugin \"io.containerd.content.v1.content\"..." type=io.containerd.content.v1 sandbox.go:131: time="2023-10-14T05:00:26.050245590Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.native\"..." type=io.containerd.snapshotter.v1 sandbox.go:131: time="2023-10-14T05:00:26.050312092Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.overlayfs\"..." type=io.containerd.snapshotter.v1 sandbox.go:131: time="2023-10-14T05:00:26.050475696Z" level=info msg="loading plugin \"io.containerd.snapshotter.v1.devmapper\"..." type=io.containerd.snapshotter.v1 sandbox.go:131: time="2023-10-14T05:00:26.050492796Z" level=warning msg="failed to load plugin io.containerd.snapshotter.v1.devmapper" error="devmapper not configured" sandbox.go:131: time="2023-10-14T05:00:26.050504496Z" level=info

Check failure on line 85 in tests/bake.go

View workflow job for this annotation

GitHub Actions / test (docker-container, ./tests)

Failed: tests/TestIntegration/TestBakeLocalMulti/worker=docker-container

=== RUN TestIntegration/TestBakeLocalMulti/worker=docker-container === PAUSE TestIntegration/TestBakeLocalMulti/worker=docker-container === CONT TestIntegration/TestBakeLocalMulti/worker=docker-container bake.go:85: Error Trace: /src/tests/bake.go:85 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:91 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:205 Error: "#0 building with \"integration-container-gyl6mvp1mnj0b9or8fbf0abpq\" instance using docker-container driver\n\n#1 [internal] load local bake definitions\n#1 reading docker-bake.hcl 22B / 22B done\n#1 DONE 0.0s\n\n#2 [internal] load build definition from Dockerfile\n#2 transferring dockerfile: 66B done\n#2 DONE 0.0s\n\n#3 [internal] load .dockerignore\n#3 transferring context: 2B done\n#3 DONE 0.0s\n\n#4 [internal] load build context\n#4 transferring context: 33B done\n#4 DONE 0.0s\n\n#5 [1/1] COPY foo /foo\n#5 DONE 0.0s\n\n#6 exporting to client directory\n#6 copying files 29B done\n#6 DONE 0.0s\n" does not contain "#1 reading compose.yaml" Test: TestIntegration/TestBakeLocalMulti/worker=docker-container --- FAIL: TestIntegration/TestBakeLocalMulti/worker=docker-container (5.86s)

Check failure on line 85 in tests/bake.go

View workflow job for this annotation

GitHub Actions / test (remote, ./tests)

Failed: tests/TestIntegration/TestBakeLocalMulti/worker=remote

=== RUN TestIntegration/TestBakeLocalMulti/worker=remote === PAUSE TestIntegration/TestBakeLocalMulti/worker=remote === CONT TestIntegration/TestBakeLocalMulti/worker=remote bake.go:85: Error Trace: /src/tests/bake.go:85 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:91 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:205 Error: "#0 building with \"integration-remote-9o932vf93pxmj4u63olgq713n\" instance using remote driver\n\n#1 [internal] load local bake definitions\n#1 reading docker-bake.hcl 22B / 22B done\n#1 DONE 0.0s\n\n#2 [internal] load .dockerignore\n#2 transferring context: 2B done\n#2 DONE 0.0s\n\n#3 [internal] load build definition from Dockerfile\n#3 transferring dockerfile: 66B done\n#3 DONE 0.0s\n\n#4 [internal] load build context\n#4 transferring context: 33B done\n#4 DONE 0.0s\n\n#5 [1/1] COPY foo /foo\n#5 DONE 0.0s\n\n#6 exporting to client directory\n#6 copying files 29B done\n#6 DONE 0.0s\n" does not contain "#1 reading compose.yaml" Test: TestIntegration/TestBakeLocalMulti/worker=remote sandbox.go:128: stdout: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config3743446363/buildkitd.toml --root /tmp/bktest_buildkitd1393630752 --addr unix:///tmp/bktest_buildkitd1393630752/buildkitd.sock --debug sandbox.go:128: stderr: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config3743446363/buildkitd.toml --root /tmp/bktest_buildkitd1393630752 --addr unix:///tmp/bktest_buildkitd1393630752/buildkitd.sock --debug sandbox.go:131: > StartCmd 2023-10-14 05:00:17.716254367 +0000 UTC m=+7.869069285 /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config3743446363/buildkitd.toml --root /tmp/bktest_buildkitd1393630752 --addr unix:///tmp/bktest_buildkitd1393630752/buildkitd.sock --debug sandbox.go:131: time="2023-10-14T05:00:17Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:131: time="2023-10-14T05:00:17Z" level=warning msg="using host network as the default" sandbox.go:131: time="2023-10-14T05:00:17Z" level=info msg="found worker \"su4xdvcvy37osqlo79v9dj96d\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:04e8ac345eeb org.mobyproject.buildkit.worker.network:host org.mobyproject.buildkit.worker.oci.process-mode:sandbox org.mobyproject.buildkit.worker.sandbox:true org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/amd64/v4 linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/mips64le linux/mips64 linux/arm/v7 linux/arm/v6]" sandbox.go:131: time="2023-10-14T05:00:17Z" level=info msg="found 1 workers, default=\"su4xdvcvy37osqlo79v9dj96d\"" sandbox.go:131: time="2023-10-14T05:00:17Z" level=warning msg="currently, only the default worker can be used." sandbox.go:131: time="2023-10-14T05:00:17Z" level=info msg="running server on /tmp/bktest_buildkitd1393630752/buildkitd.sock" sandbox.go:131: time="2023-10-14T05:00:18Z" level=debug msg="session started" spanID=c5d7ad628c6c6ed7 traceID=3c719c7f44c12ae22825942d9984c03d sandbox.go:131: time="2023-10-14T05:00:18Z" level=debug msg="session finished: <nil>" spanID=c5d7ad628c6c6ed7 traceID=3c719c7f44c12ae22825942d9984c03d sandbox.go:131: time="2023-10-14T05:00:18Z" level=debug msg="session started" spanID=76f882aa4ccb6887 traceID=3c719c7f44c12ae22825942d9984c03d sandbox.go:131: time="2023-10-14T05:00:18Z" level=debug msg="new ref for local: k6prbe1wt4l65p4mgd0vrrodt" span="[internal] load .dockerignore" spanID=53a16738702331e4 traceID
require.Contains(t, string(out), `#1 reading docker-bake.hcl`)

require.FileExists(t, filepath.Join(dirDest, "foo"))
}
Expand Down Expand Up @@ -74,8 +112,11 @@ EOT
gitutil.GitCommit(git, t, "initial commit")
addr := gitutil.GitServeHTTP(git, t)

out, err := bakeCmd(sb, withDir(dir), withArgs(addr, "--set", "*.output=type=local,dest="+dirDest))
cmd := buildxCmd(sb, withDir(dir), withArgs("bake", addr, "--progress=plain", "--set", "*.output=type=local,dest="+dirDest))
out, err := cmd.CombinedOutput()
require.NoError(t, err, out)
require.Contains(t, string(out), `#1 [internal] load remote bake definitions`)
require.Contains(t, string(out), `#1 reading docker-bake.hcl`)

require.FileExists(t, filepath.Join(dirDest, "foo"))
}
Expand Down
2 changes: 1 addition & 1 deletion util/cobrautil/completion/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func Disable(cmd *cobra.Command, args []string, toComplete string) ([]string, co

func BakeTargets(files []string) ValidArgsFn {
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
f, err := bake.ReadLocalFiles(files, nil)
f, err := bake.ReadLocalFiles(files, nil, nil)
if err != nil {
return nil, cobra.ShellCompDirectiveError
}
Expand Down

0 comments on commit 30543f5

Please sign in to comment.