Skip to content

Commit

Permalink
Merge pull request #1930 from jedevc/revert-bc597e6b
Browse files Browse the repository at this point in the history
  • Loading branch information
jedevc authored Jul 5, 2023
2 parents f581942 + 5159571 commit b4df085
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions bake/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -1048,12 +1048,12 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
bi.DockerfileInline = *t.DockerfileInline
}
updateContext(&bi, inp)
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 strings.HasPrefix(bi.ContextPath, "cwd://") {
bi.ContextPath = path.Clean(strings.TrimPrefix(bi.ContextPath, "cwd://"))
}
for k, v := range bi.NamedContexts {
if strings.HasPrefix(v.Path, "cwd://") {
bi.NamedContexts[k] = build.NamedContext{Path: path.Clean(strings.TrimPrefix(v.Path, "cwd://"))}
Expand Down
15 changes: 7 additions & 8 deletions bake/bake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,19 +386,18 @@ func TestHCLCwdPrefix(t *testing.T) {
m, g, err := ReadTargets(ctx, []File{fp}, []string{"app"}, nil, nil)
require.NoError(t, err)

bo, err := TargetsToBuildOpt(m, &Input{})
require.NoError(t, err)
require.Equal(t, 1, len(m))
_, ok := m["app"]
require.True(t, ok)

require.Equal(t, 1, len(g))
require.Equal(t, []string{"app"}, g["default"].Targets)
_, err = TargetsToBuildOpt(m, &Input{})
require.NoError(t, err)

require.Equal(t, 1, len(m))
require.Contains(t, m, "app")
require.Equal(t, "test", *m["app"].Dockerfile)
require.Equal(t, "foo", *m["app"].Context)

require.Equal(t, "foo/test", bo["app"].Inputs.DockerfilePath)
require.Equal(t, "foo", bo["app"].Inputs.ContextPath)
require.Equal(t, 1, len(g))
require.Equal(t, []string{"app"}, g["default"].Targets)
}

func TestOverrideMerge(t *testing.T) {
Expand Down

0 comments on commit b4df085

Please sign in to comment.