mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-20 09:12:48 +02:00
Always add parent directories of files to snapshots.
During a snapshot, when a file changed and not its parent directories, the parent directories weren't added to the layer. This is inconsistent with Docker's behavior which always add parent directories to the layer. In some edge-cases, it could lead to problems with docker considering that parent directories where owned by root in forthcoming layers although they shouldn't (see #1163). Also, Docker seems to be POSIX compliant regarding the name of directories in the archive, which always have a slash appended. This commit also fixes this. Fixes #1163
This commit is contained in:
@@ -84,6 +84,10 @@ func (t *Tar) AddFileToTar(p string) error {
|
||||
hdr.Name = p
|
||||
}
|
||||
|
||||
if hdr.Typeflag == tar.TypeDir && !strings.HasSuffix(hdr.Name, "/") {
|
||||
hdr.Name = hdr.Name + "/"
|
||||
}
|
||||
|
||||
// rootfs may not have been extracted when using cache, preventing uname/gname from resolving
|
||||
// this makes this layer unnecessarily differ from a cached layer which does contain this information
|
||||
hdr.Uname = ""
|
||||
|
||||
Reference in New Issue
Block a user