From c370f90b734dfecc87ad8ac5f76e7cd8cc115d55 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Tue, 22 Apr 2025 11:15:45 +0200 Subject: [PATCH] use filepath.IsAbs to support windows paths Signed-off-by: Nicolas De Loof --- bake/bake.go | 4 ++-- bake/bake_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bake/bake.go b/bake/bake.go index 3eb41158..fd7f901b 100644 --- a/bake/bake.go +++ b/bake/bake.go @@ -1360,8 +1360,8 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) { if strings.HasPrefix(bi.ContextPath, "cwd://") { bi.ContextPath = path.Clean(strings.TrimPrefix(bi.ContextPath, "cwd://")) } - if !build.IsRemoteURL(bi.ContextPath) && bi.ContextState == nil && !path.IsAbs(bi.DockerfilePath) { - bi.DockerfilePath = path.Join(bi.ContextPath, bi.DockerfilePath) + if !build.IsRemoteURL(bi.ContextPath) && bi.ContextState == nil && !filepath.IsAbs(bi.DockerfilePath) { + bi.DockerfilePath = filepath.Join(bi.ContextPath, bi.DockerfilePath) } for k, v := range bi.NamedContexts { if strings.HasPrefix(v.Path, "cwd://") { diff --git a/bake/bake_test.go b/bake/bake_test.go index 03bc532d..40ff01bd 100644 --- a/bake/bake_test.go +++ b/bake/bake_test.go @@ -692,7 +692,7 @@ func TestHCLContextCwdPrefix(t *testing.T) { require.Contains(t, m, "app") assert.Equal(t, "test", *m["app"].Dockerfile) assert.Equal(t, "foo", *m["app"].Context) - assert.Equal(t, "foo/test", bo["app"].Inputs.DockerfilePath) + assert.Equal(t, filepath.Clean("foo/test"), bo["app"].Inputs.DockerfilePath) assert.Equal(t, "foo", bo["app"].Inputs.ContextPath) }