Skip to content

Commit ac0ec94

Browse files
authored
Merge pull request #204 from nalind/copyinfo-subdir
calcCopyInfo: also trim leading path on rootPath
2 parents 06a1ba4 + a51a702 commit ac0ec94

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

dockerclient/conformance_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ func TestMultiStageBase(t *testing.T) {
257257
// TODO: ensure that the final built image has the right UIDs
258258
//
259259
func TestConformanceInternal(t *testing.T) {
260+
pwd, err := os.Getwd()
261+
if err != nil {
262+
t.Fatal(err)
263+
}
260264
testCases := []conformanceTest{
261265
{
262266
Name: "directory",
@@ -380,6 +384,14 @@ func TestConformanceInternal(t *testing.T) {
380384
Name: "wildcard",
381385
ContextDir: "testdata/wildcard",
382386
},
387+
{
388+
Name: "wildcard leading path",
389+
ContextDir: "./testdata/wildcard",
390+
},
391+
{
392+
Name: "wildcard absolute path",
393+
ContextDir: filepath.Join(pwd, "testdata", "wildcard"),
394+
},
383395
{
384396
Name: "volume",
385397
ContextDir: "testdata/volume",

dockerclient/copyinfo.go

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ func CalcCopyInfo(origPath, rootPath string, allowWildcards bool) ([]CopyInfo, e
3232

3333
func calcCopyInfo(origPath, rootPath string, allowWildcards, explicitDir bool) ([]CopyInfo, error) {
3434
origPath = trimLeadingPath(origPath)
35+
if !filepath.IsAbs(rootPath) {
36+
rootPath = trimLeadingPath(rootPath)
37+
}
3538
// Deal with wildcards
3639
if allowWildcards && containsWildcards(origPath) {
3740
matchPath := filepath.Join(rootPath, origPath)

0 commit comments

Comments
 (0)