浏览代码

integration-cli: add a integration test to avoid parsing null string in ADD, COPY and VOLUME to nil slice

Signed-off-by: Soshi Katsuta <katsuta_soshi@cyberagent.co.jp>
Soshi Katsuta 10 年之前
父节点
当前提交
d45fcc6c80
共有 2 个文件被更改,包括 28 次插入1 次删除
  1. 1 1
      builder/parser/line_parsers.go
  2. 27 0
      integration-cli/docker_cli_build_test.go

+ 1 - 1
builder/parser/line_parsers.go

@@ -234,7 +234,7 @@ func parseString(rest string) (*Node, map[string]bool, error) {
 func parseJSON(rest string) (*Node, map[string]bool, error) {
 func parseJSON(rest string) (*Node, map[string]bool, error) {
 	rest = strings.TrimLeftFunc(rest, unicode.IsSpace)
 	rest = strings.TrimLeftFunc(rest, unicode.IsSpace)
 	if !strings.HasPrefix(rest, "[") {
 	if !strings.HasPrefix(rest, "[") {
-		return nil, nil, fmt.Errorf("Error parsing \"%s\" as a JSON array", rest)
+		return nil, nil, fmt.Errorf(`Error parsing "%s" as a JSON array`, rest)
 	}
 	}
 
 
 	var myJSON []interface{}
 	var myJSON []interface{}

+ 27 - 0
integration-cli/docker_cli_build_test.go

@@ -5444,3 +5444,30 @@ func (s *DockerTrustSuite) TestBuildContextDirIsSymlink(c *check.C) {
 		c.Fatalf("build failed with exit status %d: %s", exitStatus, out)
 		c.Fatalf("build failed with exit status %d: %s", exitStatus, out)
 	}
 	}
 }
 }
+
+// Issue #15634: COPY fails when path starts with "null"
+func (s *DockerSuite) TestBuildNullStringInAddCopyVolume(c *check.C) {
+	name := "testbuildnullstringinaddcopyvolume"
+
+	ctx, err := fakeContext(`
+		FROM busybox
+		
+		ADD null /
+		COPY nullfile /
+		VOLUME nullvolume
+		`,
+		map[string]string{
+			"null":     "test1",
+			"nullfile": "test2",
+		},
+	)
+
+	if err != nil {
+		c.Fatal(err)
+	}
+	defer ctx.Close()
+
+	if _, err := buildImageFromContext(name, ctx, true); err != nil {
+		c.Fatal(err)
+	}
+}