mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-07 06:22:03 +00:00
Merge pull request #12278 from duglin/12267-Wildcards
Fix for Daemon crashing when wildcards are used for COPY/ADD
This commit is contained in:
@@ -1112,10 +1112,10 @@ func (s *DockerSuite) TestBuildCopyWildcard(c *check.C) {
|
||||
"dir/nested_dir/nest_nest_file": "2 times nested",
|
||||
"dirt": "dirty",
|
||||
})
|
||||
defer ctx.Close()
|
||||
if err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
defer ctx.Close()
|
||||
|
||||
id1, err := buildImageFromContext(name, ctx, true)
|
||||
if err != nil {
|
||||
@@ -1154,6 +1154,31 @@ func (s *DockerSuite) TestBuildCopyWildcardNoFind(c *check.C) {
|
||||
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestBuildCopyWildcardInName(c *check.C) {
|
||||
name := "testcopywildcardinname"
|
||||
defer deleteImages(name)
|
||||
ctx, err := fakeContext(`FROM busybox
|
||||
COPY *.txt /tmp/
|
||||
RUN [ "$(cat /tmp/\*.txt)" = 'hi there' ]
|
||||
`, map[string]string{"*.txt": "hi there"})
|
||||
|
||||
if err != nil {
|
||||
// Normally we would do c.Fatal(err) here but given that
|
||||
// the odds of this failing are so rare, it must be because
|
||||
// the OS we're running the client on doesn't support * in
|
||||
// filenames (like windows). So, instead of failing the test
|
||||
// just let it pass. Then we don't need to explicitly
|
||||
// say which OSs this works on or not.
|
||||
return
|
||||
}
|
||||
defer ctx.Close()
|
||||
|
||||
_, err = buildImageFromContext(name, ctx, true)
|
||||
if err != nil {
|
||||
c.Fatalf("should have built: %q", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestBuildCopyWildcardCache(c *check.C) {
|
||||
name := "testcopywildcardcache"
|
||||
ctx, err := fakeContext(`FROM busybox
|
||||
|
||||
@@ -687,7 +687,6 @@ func fakeContextAddDockerfile(ctx *FakeContext, dockerfile string) error {
|
||||
func fakeContext(dockerfile string, files map[string]string) (*FakeContext, error) {
|
||||
ctx, err := fakeContextWithFiles(files)
|
||||
if err != nil {
|
||||
ctx.Close()
|
||||
return nil, err
|
||||
}
|
||||
if err := fakeContextAddDockerfile(ctx, dockerfile); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user