mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
pkg/archive: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
0fb5630784
commit
ecb898dcb9
3 changed files with 20 additions and 20 deletions
|
@ -442,7 +442,7 @@ func newTarAppender(idMapping *idtools.IdentityMapping, writer io.Writer, chownO
|
|||
}
|
||||
|
||||
// canonicalTarName provides a platform-independent and consistent posix-style
|
||||
//path for files and directories to be archived regardless of the platform.
|
||||
// path for files and directories to be archived regardless of the platform.
|
||||
func canonicalTarName(name string, isDir bool) string {
|
||||
name = CanonicalTarNameForPath(name)
|
||||
|
||||
|
@ -495,13 +495,13 @@ func (ta *tarAppender) addTarFile(path, name string) error {
|
|||
}
|
||||
}
|
||||
|
||||
//check whether the file is overlayfs whiteout
|
||||
//if yes, skip re-mapping container ID mappings.
|
||||
// check whether the file is overlayfs whiteout
|
||||
// if yes, skip re-mapping container ID mappings.
|
||||
isOverlayWhiteout := fi.Mode()&os.ModeCharDevice != 0 && hdr.Devmajor == 0 && hdr.Devminor == 0
|
||||
|
||||
//handle re-mapping container ID mappings back to host ID mappings before
|
||||
//writing tar headers/files. We skip whiteout files because they were written
|
||||
//by the kernel and already have proper ownership relative to the host
|
||||
// handle re-mapping container ID mappings back to host ID mappings before
|
||||
// writing tar headers/files. We skip whiteout files because they were written
|
||||
// by the kernel and already have proper ownership relative to the host
|
||||
if !isOverlayWhiteout && !strings.HasPrefix(filepath.Base(hdr.Name), WhiteoutPrefix) && !ta.IdentityMapping.Empty() {
|
||||
fileIDPair, err := getFileUIDGID(fi.Sys())
|
||||
if err != nil {
|
||||
|
|
|
@ -282,31 +282,31 @@ func TestCopyInfoDestinationPathSymlink(t *testing.T) {
|
|||
}
|
||||
|
||||
testData := []FileTestData{
|
||||
//Create a directory: /tmp/archive-copy-test*/dir1
|
||||
//Test will "copy" file1 to dir1
|
||||
// Create a directory: /tmp/archive-copy-test*/dir1
|
||||
// Test will "copy" file1 to dir1
|
||||
{resource: FileData{filetype: Dir, path: "dir1", permissions: 0740}, file: "file1", expected: CopyInfo{Path: root + "dir1/file1", Exists: false, IsDir: false}},
|
||||
|
||||
//Create a symlink directory to dir1: /tmp/archive-copy-test*/dirSymlink -> dir1
|
||||
//Test will "copy" file2 to dirSymlink
|
||||
// Create a symlink directory to dir1: /tmp/archive-copy-test*/dirSymlink -> dir1
|
||||
// Test will "copy" file2 to dirSymlink
|
||||
{resource: FileData{filetype: Symlink, path: "dirSymlink", contents: root + "dir1", permissions: 0600}, file: "file2", expected: CopyInfo{Path: root + "dirSymlink/file2", Exists: false, IsDir: false}},
|
||||
|
||||
//Create a file in tmp directory: /tmp/archive-copy-test*/file1
|
||||
//Test to cover when the full file path already exists.
|
||||
// Create a file in tmp directory: /tmp/archive-copy-test*/file1
|
||||
// Test to cover when the full file path already exists.
|
||||
{resource: FileData{filetype: Regular, path: "file1", permissions: 0600}, file: "", expected: CopyInfo{Path: root + "file1", Exists: true}},
|
||||
|
||||
//Create a directory: /tmp/archive-copy*/dir2
|
||||
//Test to cover when the full directory path already exists
|
||||
// Create a directory: /tmp/archive-copy*/dir2
|
||||
// Test to cover when the full directory path already exists
|
||||
{resource: FileData{filetype: Dir, path: "dir2", permissions: 0740}, file: "", expected: CopyInfo{Path: root + "dir2", Exists: true, IsDir: true}},
|
||||
|
||||
//Create a symlink to a non-existent target: /tmp/archive-copy*/symlink1 -> noSuchTarget
|
||||
//Negative test to cover symlinking to a target that does not exit
|
||||
// Create a symlink to a non-existent target: /tmp/archive-copy*/symlink1 -> noSuchTarget
|
||||
// Negative test to cover symlinking to a target that does not exit
|
||||
{resource: FileData{filetype: Symlink, path: "symlink1", contents: "noSuchTarget", permissions: 0600}, file: "", expected: CopyInfo{Path: root + "noSuchTarget", Exists: false}},
|
||||
|
||||
//Create a file in tmp directory for next test: /tmp/existingfile
|
||||
// Create a file in tmp directory for next test: /tmp/existingfile
|
||||
{resource: FileData{filetype: Regular, path: "existingfile", permissions: 0600}, file: "", expected: CopyInfo{Path: root + "existingfile", Exists: true}},
|
||||
|
||||
//Create a symlink to an existing file: /tmp/archive-copy*/symlink2 -> /tmp/existingfile
|
||||
//Test to cover when the parent directory of a new file is a symlink
|
||||
// Create a symlink to an existing file: /tmp/archive-copy*/symlink2 -> /tmp/existingfile
|
||||
// Test to cover when the parent directory of a new file is a symlink
|
||||
{resource: FileData{filetype: Symlink, path: "symlink2", contents: "existingfile", permissions: 0600}, file: "", expected: CopyInfo{Path: root + "existingfile", Exists: true}},
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ func CanonicalTarNameForPath(p string) string {
|
|||
// chmodTarEntry is used to adjust the file permissions used in tar header based
|
||||
// on the platform the archival is done.
|
||||
func chmodTarEntry(perm os.FileMode) os.FileMode {
|
||||
//perm &= 0755 // this 0-ed out tar flags (like link, regular file, directory marker etc.)
|
||||
// perm &= 0755 // this 0-ed out tar flags (like link, regular file, directory marker etc.)
|
||||
permPart := perm & os.ModePerm
|
||||
noPermPart := perm &^ os.ModePerm
|
||||
// Add the x bit: make everything +x from windows
|
||||
|
|
Loading…
Add table
Reference in a new issue