Browse Source

Merge pull request #26553 from darrenstahlmsft/FixWildcard

Windows: Fix wildcard expansion after slash in filename
John Howard 8 years ago
parent
commit
39f5d97cde

+ 0 - 12
builder/dockerfile/internals.go

@@ -375,18 +375,6 @@ func (b *Builder) calcCopyInfo(cmdName, origPath string, allowLocalDecompression
 	return copyInfos, nil
 	return copyInfos, nil
 }
 }
 
 
-func containsWildcards(name string) bool {
-	for i := 0; i < len(name); i++ {
-		ch := name[i]
-		if ch == '\\' {
-			i++
-		} else if ch == '*' || ch == '?' || ch == '[' {
-			return true
-		}
-	}
-	return false
-}
-
 func (b *Builder) processImageFrom(img builder.Image) error {
 func (b *Builder) processImageFrom(img builder.Image) error {
 	if img != nil {
 	if img != nil {
 		b.image = img.ImageID()
 		b.image = img.ImageID()

+ 12 - 0
builder/dockerfile/internals_unix.go

@@ -24,3 +24,15 @@ func normaliseDest(cmdName, workingDir, requested string) (string, error) {
 	}
 	}
 	return dest, nil
 	return dest, nil
 }
 }
+
+func containsWildcards(name string) bool {
+	for i := 0; i < len(name); i++ {
+		ch := name[i]
+		if ch == '\\' {
+			i++
+		} else if ch == '*' || ch == '?' || ch == '[' {
+			return true
+		}
+	}
+	return false
+}

+ 10 - 0
builder/dockerfile/internals_windows.go

@@ -54,3 +54,13 @@ func normaliseDest(cmdName, workingDir, requested string) (string, error) {
 	}
 	}
 	return dest, nil
 	return dest, nil
 }
 }
+
+func containsWildcards(name string) bool {
+	for i := 0; i < len(name); i++ {
+		ch := name[i]
+		if ch == '*' || ch == '?' || ch == '[' {
+			return true
+		}
+	}
+	return false
+}

+ 2 - 3
integration-cli/docker_cli_build_test.go

@@ -868,7 +868,6 @@ RUN find "test6" "C:/test dir/test_file6"`
 }
 }
 
 
 func (s *DockerSuite) TestBuildCopyWildcard(c *check.C) {
 func (s *DockerSuite) TestBuildCopyWildcard(c *check.C) {
-	testRequires(c, DaemonIsLinux) // Windows doesn't have httpserver image yet
 	name := "testcopywildcard"
 	name := "testcopywildcard"
 	server, err := fakeStorage(map[string]string{
 	server, err := fakeStorage(map[string]string{
 		"robots.txt": "hello",
 		"robots.txt": "hello",
@@ -882,10 +881,10 @@ func (s *DockerSuite) TestBuildCopyWildcard(c *check.C) {
 	ctx, err := fakeContext(fmt.Sprintf(`FROM busybox
 	ctx, err := fakeContext(fmt.Sprintf(`FROM busybox
 	COPY file*.txt /tmp/
 	COPY file*.txt /tmp/
 	RUN ls /tmp/file1.txt /tmp/file2.txt
 	RUN ls /tmp/file1.txt /tmp/file2.txt
-	RUN mkdir /tmp1
+	RUN [ "mkdir",  "/tmp1" ]
 	COPY dir* /tmp1/
 	COPY dir* /tmp1/
 	RUN ls /tmp1/dirt /tmp1/nested_file /tmp1/nested_dir/nest_nest_file
 	RUN ls /tmp1/dirt /tmp1/nested_file /tmp1/nested_dir/nest_nest_file
-	RUN mkdir /tmp2
+	RUN [ "mkdir",  "/tmp2" ]
         ADD dir/*dir %s/robots.txt /tmp2/
         ADD dir/*dir %s/robots.txt /tmp2/
 	RUN ls /tmp2/nest_nest_file /tmp2/robots.txt
 	RUN ls /tmp2/nest_nest_file /tmp2/robots.txt
 	`, server.URL()),
 	`, server.URL()),