mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #5977 from vbatts/vbatts-tarsum_xattrs
tarsum: include xattr headers in to the checksum
This commit is contained in:
commit
4da86f88a0
4 changed files with 28 additions and 1 deletions
|
@ -81,7 +81,7 @@ func (ts tarSum) selectHeaders(h *tar.Header, v Version) (set [][2]string) {
|
||||||
{"devmajor", strconv.Itoa(int(h.Devmajor))},
|
{"devmajor", strconv.Itoa(int(h.Devmajor))},
|
||||||
{"devminor", strconv.Itoa(int(h.Devminor))},
|
{"devminor", strconv.Itoa(int(h.Devminor))},
|
||||||
} {
|
} {
|
||||||
if v == VersionDev && elem[0] == "mtime" {
|
if v >= VersionDev && elem[0] == "mtime" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
set = append(set, elem)
|
set = append(set, elem)
|
||||||
|
@ -95,6 +95,20 @@ func (ts *tarSum) encodeHeader(h *tar.Header) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// include the additional pax headers, from an ordered list
|
||||||
|
if ts.Version() >= VersionDev {
|
||||||
|
var keys []string
|
||||||
|
for k := range h.Xattrs {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
for _, k := range keys {
|
||||||
|
if _, err := ts.h.Write([]byte(k + h.Xattrs[k])); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,18 @@ var testLayers = []testLayer{
|
||||||
jsonfile: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json",
|
jsonfile: "testdata/46af0962ab5afeb5ce6740d4d91652e69206fc991fd5328c1a94d364ad00e457/json",
|
||||||
gzip: true,
|
gzip: true,
|
||||||
tarsum: "tarsum+sha256:e58fcf7418d4390dec8e8fb69d88c06ec07039d651fedd3aa72af9972e7d046b"},
|
tarsum: "tarsum+sha256:e58fcf7418d4390dec8e8fb69d88c06ec07039d651fedd3aa72af9972e7d046b"},
|
||||||
|
{
|
||||||
|
// Tests existing version of TarSum when xattrs are present
|
||||||
|
filename: "testdata/xattr/layer.tar",
|
||||||
|
jsonfile: "testdata/xattr/json",
|
||||||
|
version: Version0,
|
||||||
|
tarsum: "tarsum+sha256:e86f81a4d552f13039b1396ed03ca968ea9717581f9577ef1876ea6ff9b38c98"},
|
||||||
|
{
|
||||||
|
// Tests next version of TarSum when xattrs are present
|
||||||
|
filename: "testdata/xattr/layer.tar",
|
||||||
|
jsonfile: "testdata/xattr/json",
|
||||||
|
version: VersionDev,
|
||||||
|
tarsum: "tarsum.dev+sha256:6235cd3a2afb7501bac541772a3d61a3634e95bc90bb39a4676e2cb98d08390d"},
|
||||||
{
|
{
|
||||||
filename: "testdata/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/layer.tar",
|
filename: "testdata/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/layer.tar",
|
||||||
jsonfile: "testdata/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/json",
|
jsonfile: "testdata/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/json",
|
||||||
|
|
1
pkg/tarsum/testdata/xattr/json
vendored
Normal file
1
pkg/tarsum/testdata/xattr/json
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"id":"4439c3c7f847954100b42b267e7e5529cac1d6934db082f65795c5ca2e594d93","parent":"73b164f4437db87e96e90083c73a6592f549646ae2ec00ed33c6b9b49a5c4470","created":"2014-05-16T17:19:44.091534414Z","container":"5f92fb06cc58f357f0cde41394e2bbbb664e663974b2ac1693ab07b7a306749b","container_config":{"Hostname":"9565c6517a0e","Domainname":"","User":"","Memory":0,"MemorySwap":0,"CpuShares":0,"Cpuset":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"PortSpecs":null,"ExposedPorts":null,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["HOME=/","PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh","-c","setcap 'cap_setgid,cap_setuid+ep' ./file \u0026\u0026 getcap ./file"],"Image":"73b164f4437db87e96e90083c73a6592f549646ae2ec00ed33c6b9b49a5c4470","Volumes":null,"WorkingDir":"","Entrypoint":null,"NetworkDisabled":false,"OnBuild":[]},"docker_version":"0.11.1-dev","config":{"Hostname":"9565c6517a0e","Domainname":"","User":"","Memory":0,"MemorySwap":0,"CpuShares":0,"Cpuset":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"PortSpecs":null,"ExposedPorts":null,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["HOME=/","PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":null,"Image":"73b164f4437db87e96e90083c73a6592f549646ae2ec00ed33c6b9b49a5c4470","Volumes":null,"WorkingDir":"","Entrypoint":null,"NetworkDisabled":false,"OnBuild":[]},"architecture":"amd64","os":"linux","Size":0}
|
BIN
pkg/tarsum/testdata/xattr/layer.tar
vendored
Normal file
BIN
pkg/tarsum/testdata/xattr/layer.tar
vendored
Normal file
Binary file not shown.
Loading…
Reference in a new issue