зеркало из https://github.com/microsoft/docker.git
build: fix add from remote url
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Родитель
bcc8b2bc47
Коммит
2981667e11
|
@ -35,6 +35,7 @@ type copyInfo struct {
|
||||||
root string
|
root string
|
||||||
path string
|
path string
|
||||||
hash string
|
hash string
|
||||||
|
noDecompress bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c copyInfo) fullPath() (string, error) {
|
func (c copyInfo) fullPath() (string, error) {
|
||||||
|
@ -124,7 +125,9 @@ func (o *copier) getCopyInfoForSourcePath(orig string) ([]copyInfo, error) {
|
||||||
o.tmpPaths = append(o.tmpPaths, remote.Root())
|
o.tmpPaths = append(o.tmpPaths, remote.Root())
|
||||||
|
|
||||||
hash, err := remote.Hash(path)
|
hash, err := remote.Hash(path)
|
||||||
return newCopyInfos(newCopyInfoFromSource(remote, path, hash)), err
|
ci := newCopyInfoFromSource(remote, path, hash)
|
||||||
|
ci.noDecompress = true // data from http shouldn't be extracted even on ADD
|
||||||
|
return newCopyInfos(ci), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup removes any temporary directories created as part of downloading
|
// Cleanup removes any temporary directories created as part of downloading
|
||||||
|
@ -387,7 +390,7 @@ func performCopyForInfo(dest copyInfo, source copyInfo, options copyFileOptions)
|
||||||
if src.IsDir() {
|
if src.IsDir() {
|
||||||
return copyDirectory(archiver, srcPath, destPath)
|
return copyDirectory(archiver, srcPath, destPath)
|
||||||
}
|
}
|
||||||
if options.decompress && archive.IsArchivePath(srcPath) {
|
if options.decompress && archive.IsArchivePath(srcPath) && !source.noDecompress {
|
||||||
return archiver.UntarPath(srcPath, destPath)
|
return archiver.UntarPath(srcPath, destPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -366,6 +366,50 @@ func (s *DockerRegistrySuite) TestBuildCopyFromForcePull(c *check.C) {
|
||||||
assert.Contains(c, string(out), "Successfully built")
|
assert.Contains(c, string(out), "Successfully built")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DockerSuite) TestBuildAddRemoteNoDecompress(c *check.C) {
|
||||||
|
buffer := new(bytes.Buffer)
|
||||||
|
tw := tar.NewWriter(buffer)
|
||||||
|
dt := []byte("contents")
|
||||||
|
err := tw.WriteHeader(&tar.Header{
|
||||||
|
Name: "foo",
|
||||||
|
Size: int64(len(dt)),
|
||||||
|
Mode: 0600,
|
||||||
|
Typeflag: tar.TypeReg,
|
||||||
|
})
|
||||||
|
require.NoError(c, err)
|
||||||
|
_, err = tw.Write(dt)
|
||||||
|
require.NoError(c, err)
|
||||||
|
err = tw.Close()
|
||||||
|
require.NoError(c, err)
|
||||||
|
|
||||||
|
server := fakestorage.New(c, "", fakecontext.WithBinaryFiles(map[string]*bytes.Buffer{
|
||||||
|
"test.tar": buffer,
|
||||||
|
}))
|
||||||
|
defer server.Close()
|
||||||
|
|
||||||
|
dockerfile := fmt.Sprintf(`
|
||||||
|
FROM busybox
|
||||||
|
ADD %s/test.tar /
|
||||||
|
RUN [ -f test.tar ]
|
||||||
|
`, server.URL())
|
||||||
|
|
||||||
|
ctx := fakecontext.New(c, "",
|
||||||
|
fakecontext.WithDockerfile(dockerfile),
|
||||||
|
)
|
||||||
|
defer ctx.Close()
|
||||||
|
|
||||||
|
res, body, err := request.Post(
|
||||||
|
"/build",
|
||||||
|
request.RawContent(ctx.AsTarReader(c)),
|
||||||
|
request.ContentType("application/x-tar"))
|
||||||
|
require.NoError(c, err)
|
||||||
|
assert.Equal(c, http.StatusOK, res.StatusCode)
|
||||||
|
|
||||||
|
out, err := testutil.ReadBody(body)
|
||||||
|
require.NoError(c, err)
|
||||||
|
assert.Contains(c, string(out), "Successfully built")
|
||||||
|
}
|
||||||
|
|
||||||
func (s *DockerSuite) TestBuildWithSession(c *check.C) {
|
func (s *DockerSuite) TestBuildWithSession(c *check.C) {
|
||||||
testRequires(c, ExperimentalDaemon)
|
testRequires(c, ExperimentalDaemon)
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче