From 052f279de781735e9b9f6991f7b9f808b287eaa7 Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Thu, 1 Feb 2024 18:50:12 +0100 Subject: [PATCH] bake: fix definitions merge order Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- commands/bake.go | 12 ++++++++---- tests/bake.go | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/commands/bake.go b/commands/bake.go index 565a72b5c0d..4b0b9370b52 100644 --- a/commands/bake.go +++ b/commands/bake.go @@ -292,13 +292,17 @@ func saveLocalStateGroup(dockerCli command.Cli, ref string, lsg localstate.State } func readBakeFiles(ctx context.Context, nodes []builder.Node, url string, names []string, stdin io.Reader, pw progress.Writer) (files []bake.File, inp *bake.Input, err error) { - var lnames []string - var rnames []string + var lnames []string // local + var rnames []string // remote + var anames []string // both for _, v := range names { if strings.HasPrefix(v, "cwd://") { - lnames = append(lnames, strings.TrimPrefix(v, "cwd://")) + tname := strings.TrimPrefix(v, "cwd://") + lnames = append(lnames, tname) + anames = append(anames, tname) } else { rnames = append(rnames, v) + anames = append(anames, v) } } @@ -317,7 +321,7 @@ func readBakeFiles(ctx context.Context, nodes []builder.Node, url string, names if url != "" { lfiles, err = bake.ReadLocalFiles(lnames, stdin, sub) } else { - lfiles, err = bake.ReadLocalFiles(append(lnames, rnames...), stdin, sub) + lfiles, err = bake.ReadLocalFiles(anames, stdin, sub) } return nil }) diff --git a/tests/bake.go b/tests/bake.go index be4b27a6601..a2af62cf0f7 100644 --- a/tests/bake.go +++ b/tests/bake.go @@ -24,6 +24,7 @@ var bakeTests = []func(t *testing.T, sb integration.Sandbox){ testBakeRemote, testBakeRemoteCmdContext, testBakeRemoteLocalOverride, + testBakeLocalCwdOverride, testBakeRemoteCmdContextOverride, testBakeRemoteContextSubdir, testBakeRemoteCmdContextEscapeRoot, @@ -173,6 +174,41 @@ EOT require.FileExists(t, filepath.Join(dirDest, "bar")) } +func testBakeLocalCwdOverride(t *testing.T, sb integration.Sandbox) { + bakeFile := []byte(` +target "default" { + dockerfile-inline = <