Browse Source

pkg/archive: format code with gofumpt

Formatting the code with https://github.com/mvdan/gofumpt

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 3 years ago
parent
commit
f7552f1de4

+ 3 - 3
pkg/archive/archive.go

@@ -43,7 +43,7 @@ import (
 // This value is currently implementation-defined, and not captured in any cross-runtime specification. Thus, it is
 // This value is currently implementation-defined, and not captured in any cross-runtime specification. Thus, it is
 // subject to change in Moby at any time -- image authors who require consistent or known directory permissions
 // subject to change in Moby at any time -- image authors who require consistent or known directory permissions
 // should explicitly control them by ensuring that header entries exist for any applicable path.
 // should explicitly control them by ensuring that header entries exist for any applicable path.
-const ImpliedDirectoryMode = 0755
+const ImpliedDirectoryMode = 0o755
 
 
 type (
 type (
 	// Compression is the state represents if compressed or not.
 	// Compression is the state represents if compressed or not.
@@ -1312,7 +1312,7 @@ func (archiver *Archiver) CopyWithTar(src, dst string) error {
 	// as owner
 	// as owner
 	rootIDs := archiver.IDMapping.RootPair()
 	rootIDs := archiver.IDMapping.RootPair()
 	// Create dst, copy src's content into it
 	// Create dst, copy src's content into it
-	if err := idtools.MkdirAllAndChownNew(dst, 0755, rootIDs); err != nil {
+	if err := idtools.MkdirAllAndChownNew(dst, 0o755, rootIDs); err != nil {
 		return err
 		return err
 	}
 	}
 	return archiver.TarUntar(src, dst)
 	return archiver.TarUntar(src, dst)
@@ -1337,7 +1337,7 @@ func (archiver *Archiver) CopyFileWithTar(src, dst string) (err error) {
 		dst = filepath.Join(dst, filepath.Base(src))
 		dst = filepath.Join(dst, filepath.Base(src))
 	}
 	}
 	// Create the holding directory if necessary
 	// Create the holding directory if necessary
-	if err := system.MkdirAll(filepath.Dir(dst), 0700); err != nil {
+	if err := system.MkdirAll(filepath.Dir(dst), 0o700); err != nil {
 		return err
 		return err
 	}
 	}
 
 

+ 2 - 3
pkg/archive/archive_linux.go

@@ -21,8 +21,7 @@ func getWhiteoutConverter(format WhiteoutFormat, inUserNS bool) (tarWhiteoutConv
 	return nil, nil
 	return nil, nil
 }
 }
 
 
-type overlayWhiteoutConverter struct {
-}
+type overlayWhiteoutConverter struct{}
 
 
 func (overlayWhiteoutConverter) ConvertWrite(hdr *tar.Header, path string, fi os.FileInfo) (wo *tar.Header, err error) {
 func (overlayWhiteoutConverter) ConvertWrite(hdr *tar.Header, path string, fi os.FileInfo) (wo *tar.Header, err error) {
 	// convert whiteouts to AUFS format
 	// convert whiteouts to AUFS format
@@ -30,7 +29,7 @@ func (overlayWhiteoutConverter) ConvertWrite(hdr *tar.Header, path string, fi os
 		// we just rename the file and make it normal
 		// we just rename the file and make it normal
 		dir, filename := filepath.Split(hdr.Name)
 		dir, filename := filepath.Split(hdr.Name)
 		hdr.Name = filepath.Join(dir, WhiteoutPrefix+filename)
 		hdr.Name = filepath.Join(dir, WhiteoutPrefix+filename)
-		hdr.Mode = 0600
+		hdr.Mode = 0o600
 		hdr.Typeflag = tar.TypeReg
 		hdr.Typeflag = tar.TypeReg
 		hdr.Size = 0
 		hdr.Size = 0
 	}
 	}

+ 18 - 18
pkg/archive/archive_linux_test.go

@@ -27,27 +27,27 @@ func setupOverlayTestDir(t *testing.T, src string) {
 	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
 	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
 	skip.If(t, userns.RunningInUserNS(), "skipping test that requires initial userns (trusted.overlay.opaque xattr cannot be set in userns, even with Ubuntu kernel)")
 	skip.If(t, userns.RunningInUserNS(), "skipping test that requires initial userns (trusted.overlay.opaque xattr cannot be set in userns, even with Ubuntu kernel)")
 	// Create opaque directory containing single file and permission 0700
 	// Create opaque directory containing single file and permission 0700
-	err := os.Mkdir(filepath.Join(src, "d1"), 0700)
+	err := os.Mkdir(filepath.Join(src, "d1"), 0o700)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	err = system.Lsetxattr(filepath.Join(src, "d1"), "trusted.overlay.opaque", []byte("y"), 0)
 	err = system.Lsetxattr(filepath.Join(src, "d1"), "trusted.overlay.opaque", []byte("y"), 0)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
-	err = os.WriteFile(filepath.Join(src, "d1", "f1"), []byte{}, 0600)
+	err = os.WriteFile(filepath.Join(src, "d1", "f1"), []byte{}, 0o600)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	// Create another opaque directory containing single file but with permission 0750
 	// Create another opaque directory containing single file but with permission 0750
-	err = os.Mkdir(filepath.Join(src, "d2"), 0750)
+	err = os.Mkdir(filepath.Join(src, "d2"), 0o750)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	err = system.Lsetxattr(filepath.Join(src, "d2"), "trusted.overlay.opaque", []byte("y"), 0)
 	err = system.Lsetxattr(filepath.Join(src, "d2"), "trusted.overlay.opaque", []byte("y"), 0)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
-	err = os.WriteFile(filepath.Join(src, "d2", "f1"), []byte{}, 0660)
+	err = os.WriteFile(filepath.Join(src, "d2", "f1"), []byte{}, 0o660)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	// Create regular directory with deleted file
 	// Create regular directory with deleted file
-	err = os.Mkdir(filepath.Join(src, "d3"), 0700)
+	err = os.Mkdir(filepath.Join(src, "d3"), 0o700)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	err = system.Mknod(filepath.Join(src, "d3", "f1"), unix.S_IFCHR, 0)
 	err = system.Mknod(filepath.Join(src, "d3", "f1"), unix.S_IFCHR, 0)
@@ -110,11 +110,11 @@ func TestOverlayTarUntar(t *testing.T) {
 	err = Untar(archive, dst, options)
 	err = Untar(archive, dst, options)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
-	checkFileMode(t, filepath.Join(dst, "d1"), 0700|os.ModeDir)
-	checkFileMode(t, filepath.Join(dst, "d2"), 0750|os.ModeDir)
-	checkFileMode(t, filepath.Join(dst, "d3"), 0700|os.ModeDir)
-	checkFileMode(t, filepath.Join(dst, "d1", "f1"), 0600)
-	checkFileMode(t, filepath.Join(dst, "d2", "f1"), 0660)
+	checkFileMode(t, filepath.Join(dst, "d1"), 0o700|os.ModeDir)
+	checkFileMode(t, filepath.Join(dst, "d2"), 0o750|os.ModeDir)
+	checkFileMode(t, filepath.Join(dst, "d3"), 0o700|os.ModeDir)
+	checkFileMode(t, filepath.Join(dst, "d1", "f1"), 0o600)
+	checkFileMode(t, filepath.Join(dst, "d2", "f1"), 0o660)
 	checkFileMode(t, filepath.Join(dst, "d3", "f1"), os.ModeCharDevice|os.ModeDevice)
 	checkFileMode(t, filepath.Join(dst, "d3", "f1"), os.ModeCharDevice|os.ModeDevice)
 
 
 	checkOpaqueness(t, filepath.Join(dst, "d1"), "y")
 	checkOpaqueness(t, filepath.Join(dst, "d1"), "y")
@@ -150,12 +150,12 @@ func TestOverlayTarAUFSUntar(t *testing.T) {
 	})
 	})
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
-	checkFileMode(t, filepath.Join(dst, "d1"), 0700|os.ModeDir)
-	checkFileMode(t, filepath.Join(dst, "d1", WhiteoutOpaqueDir), 0700)
-	checkFileMode(t, filepath.Join(dst, "d2"), 0750|os.ModeDir)
-	checkFileMode(t, filepath.Join(dst, "d2", WhiteoutOpaqueDir), 0750)
-	checkFileMode(t, filepath.Join(dst, "d3"), 0700|os.ModeDir)
-	checkFileMode(t, filepath.Join(dst, "d1", "f1"), 0600)
-	checkFileMode(t, filepath.Join(dst, "d2", "f1"), 0660)
-	checkFileMode(t, filepath.Join(dst, "d3", WhiteoutPrefix+"f1"), 0600)
+	checkFileMode(t, filepath.Join(dst, "d1"), 0o700|os.ModeDir)
+	checkFileMode(t, filepath.Join(dst, "d1", WhiteoutOpaqueDir), 0o700)
+	checkFileMode(t, filepath.Join(dst, "d2"), 0o750|os.ModeDir)
+	checkFileMode(t, filepath.Join(dst, "d2", WhiteoutOpaqueDir), 0o750)
+	checkFileMode(t, filepath.Join(dst, "d3"), 0o700|os.ModeDir)
+	checkFileMode(t, filepath.Join(dst, "d1", "f1"), 0o600)
+	checkFileMode(t, filepath.Join(dst, "d2", "f1"), 0o660)
+	checkFileMode(t, filepath.Join(dst, "d3", WhiteoutPrefix+"f1"), 0o600)
 }
 }

+ 64 - 61
pkg/archive/archive_test.go

@@ -197,6 +197,7 @@ func TestExtensionUncompressed(t *testing.T) {
 		t.Fatalf("The extension of an uncompressed archive should be 'tar'.")
 		t.Fatalf("The extension of an uncompressed archive should be 'tar'.")
 	}
 	}
 }
 }
+
 func TestExtensionBzip2(t *testing.T) {
 func TestExtensionBzip2(t *testing.T) {
 	compression := Bzip2
 	compression := Bzip2
 	output := compression.Extension()
 	output := compression.Extension()
@@ -204,6 +205,7 @@ func TestExtensionBzip2(t *testing.T) {
 		t.Fatalf("The extension of a bzip2 archive should be 'tar.bz2'")
 		t.Fatalf("The extension of a bzip2 archive should be 'tar.bz2'")
 	}
 	}
 }
 }
+
 func TestExtensionGzip(t *testing.T) {
 func TestExtensionGzip(t *testing.T) {
 	compression := Gzip
 	compression := Gzip
 	output := compression.Extension()
 	output := compression.Extension()
@@ -211,6 +213,7 @@ func TestExtensionGzip(t *testing.T) {
 		t.Fatalf("The extension of a gzip archive should be 'tar.gz'")
 		t.Fatalf("The extension of a gzip archive should be 'tar.gz'")
 	}
 	}
 }
 }
+
 func TestExtensionXz(t *testing.T) {
 func TestExtensionXz(t *testing.T) {
 	compression := Xz
 	compression := Xz
 	output := compression.Extension()
 	output := compression.Extension()
@@ -218,6 +221,7 @@ func TestExtensionXz(t *testing.T) {
 		t.Fatalf("The extension of a xz archive should be 'tar.xz'")
 		t.Fatalf("The extension of a xz archive should be 'tar.xz'")
 	}
 	}
 }
 }
+
 func TestExtensionZstd(t *testing.T) {
 func TestExtensionZstd(t *testing.T) {
 	compression := Zstd
 	compression := Zstd
 	output := compression.Extension()
 	output := compression.Extension()
@@ -330,7 +334,7 @@ func TestUntarPath(t *testing.T) {
 	os.Create(filepath.Join(tmpFolder, "src"))
 	os.Create(filepath.Join(tmpFolder, "src"))
 
 
 	destFolder := filepath.Join(tmpFolder, "dest")
 	destFolder := filepath.Join(tmpFolder, "dest")
-	err = os.MkdirAll(destFolder, 0740)
+	err = os.MkdirAll(destFolder, 0o740)
 	if err != nil {
 	if err != nil {
 		t.Fatalf("Fail to create the destination file")
 		t.Fatalf("Fail to create the destination file")
 	}
 	}
@@ -418,13 +422,13 @@ func TestUntarPathWithDestinationSrcFileAsFolder(t *testing.T) {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 	destFolder := filepath.Join(tmpFolder, "dest")
 	destFolder := filepath.Join(tmpFolder, "dest")
-	err = os.MkdirAll(destFolder, 0740)
+	err = os.MkdirAll(destFolder, 0o740)
 	if err != nil {
 	if err != nil {
 		t.Fatalf("Fail to create the destination folder")
 		t.Fatalf("Fail to create the destination folder")
 	}
 	}
 	// Let's create a folder that will has the same path as the extracted file (from tar)
 	// Let's create a folder that will has the same path as the extracted file (from tar)
 	destSrcFileAsFolder := filepath.Join(destFolder, srcFileU)
 	destSrcFileAsFolder := filepath.Join(destFolder, srcFileU)
-	err = os.MkdirAll(destSrcFileAsFolder, 0740)
+	err = os.MkdirAll(destSrcFileAsFolder, 0o740)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -441,7 +445,7 @@ func TestCopyWithTarInvalidSrc(t *testing.T) {
 	}
 	}
 	destFolder := filepath.Join(tempFolder, "dest")
 	destFolder := filepath.Join(tempFolder, "dest")
 	invalidSrc := filepath.Join(tempFolder, "doesnotexists")
 	invalidSrc := filepath.Join(tempFolder, "doesnotexists")
-	err = os.MkdirAll(destFolder, 0740)
+	err = os.MkdirAll(destFolder, 0o740)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -459,7 +463,7 @@ func TestCopyWithTarInexistentDestWillCreateIt(t *testing.T) {
 	}
 	}
 	srcFolder := filepath.Join(tempFolder, "src")
 	srcFolder := filepath.Join(tempFolder, "src")
 	inexistentDestFolder := filepath.Join(tempFolder, "doesnotexists")
 	inexistentDestFolder := filepath.Join(tempFolder, "doesnotexists")
-	err = os.MkdirAll(srcFolder, 0740)
+	err = os.MkdirAll(srcFolder, 0o740)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -483,15 +487,15 @@ func TestCopyWithTarSrcFile(t *testing.T) {
 	dest := filepath.Join(folder, "dest")
 	dest := filepath.Join(folder, "dest")
 	srcFolder := filepath.Join(folder, "src")
 	srcFolder := filepath.Join(folder, "src")
 	src := filepath.Join(folder, filepath.Join("src", "src"))
 	src := filepath.Join(folder, filepath.Join("src", "src"))
-	err = os.MkdirAll(srcFolder, 0740)
+	err = os.MkdirAll(srcFolder, 0o740)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	err = os.MkdirAll(dest, 0740)
+	err = os.MkdirAll(dest, 0o740)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	os.WriteFile(src, []byte("content"), 0777)
+	os.WriteFile(src, []byte("content"), 0o777)
 	err = defaultCopyWithTar(src, dest)
 	err = defaultCopyWithTar(src, dest)
 	if err != nil {
 	if err != nil {
 		t.Fatalf("archiver.CopyWithTar shouldn't throw an error, %s.", err)
 		t.Fatalf("archiver.CopyWithTar shouldn't throw an error, %s.", err)
@@ -512,15 +516,15 @@ func TestCopyWithTarSrcFolder(t *testing.T) {
 	defer os.RemoveAll(folder)
 	defer os.RemoveAll(folder)
 	dest := filepath.Join(folder, "dest")
 	dest := filepath.Join(folder, "dest")
 	src := filepath.Join(folder, filepath.Join("src", "folder"))
 	src := filepath.Join(folder, filepath.Join("src", "folder"))
-	err = os.MkdirAll(src, 0740)
+	err = os.MkdirAll(src, 0o740)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	err = os.MkdirAll(dest, 0740)
+	err = os.MkdirAll(dest, 0o740)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	os.WriteFile(filepath.Join(src, "file"), []byte("content"), 0777)
+	os.WriteFile(filepath.Join(src, "file"), []byte("content"), 0o777)
 	err = defaultCopyWithTar(src, dest)
 	err = defaultCopyWithTar(src, dest)
 	if err != nil {
 	if err != nil {
 		t.Fatalf("archiver.CopyWithTar shouldn't throw an error, %s.", err)
 		t.Fatalf("archiver.CopyWithTar shouldn't throw an error, %s.", err)
@@ -539,7 +543,7 @@ func TestCopyFileWithTarInvalidSrc(t *testing.T) {
 	}
 	}
 	defer os.RemoveAll(tempFolder)
 	defer os.RemoveAll(tempFolder)
 	destFolder := filepath.Join(tempFolder, "dest")
 	destFolder := filepath.Join(tempFolder, "dest")
-	err = os.MkdirAll(destFolder, 0740)
+	err = os.MkdirAll(destFolder, 0o740)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -581,11 +585,11 @@ func TestCopyFileWithTarSrcFolder(t *testing.T) {
 	defer os.RemoveAll(folder)
 	defer os.RemoveAll(folder)
 	dest := filepath.Join(folder, "dest")
 	dest := filepath.Join(folder, "dest")
 	src := filepath.Join(folder, "srcfolder")
 	src := filepath.Join(folder, "srcfolder")
-	err = os.MkdirAll(src, 0740)
+	err = os.MkdirAll(src, 0o740)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	err = os.MkdirAll(dest, 0740)
+	err = os.MkdirAll(dest, 0o740)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
@@ -604,15 +608,15 @@ func TestCopyFileWithTarSrcFile(t *testing.T) {
 	dest := filepath.Join(folder, "dest")
 	dest := filepath.Join(folder, "dest")
 	srcFolder := filepath.Join(folder, "src")
 	srcFolder := filepath.Join(folder, "src")
 	src := filepath.Join(folder, filepath.Join("src", "src"))
 	src := filepath.Join(folder, filepath.Join("src", "src"))
-	err = os.MkdirAll(srcFolder, 0740)
+	err = os.MkdirAll(srcFolder, 0o740)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	err = os.MkdirAll(dest, 0740)
+	err = os.MkdirAll(dest, 0o740)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	os.WriteFile(src, []byte("content"), 0777)
+	os.WriteFile(src, []byte("content"), 0o777)
 	err = defaultCopyWithTar(src, dest+"/")
 	err = defaultCopyWithTar(src, dest+"/")
 	if err != nil {
 	if err != nil {
 		t.Fatalf("archiver.CopyFileWithTar shouldn't throw an error, %s.", err)
 		t.Fatalf("archiver.CopyFileWithTar shouldn't throw an error, %s.", err)
@@ -735,13 +739,13 @@ func TestTarUntar(t *testing.T) {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 	defer os.RemoveAll(origin)
 	defer os.RemoveAll(origin)
-	if err := os.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700); err != nil {
+	if err := os.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0o700); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	if err := os.WriteFile(filepath.Join(origin, "2"), []byte("welcome!"), 0700); err != nil {
+	if err := os.WriteFile(filepath.Join(origin, "2"), []byte("welcome!"), 0o700); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	if err := os.WriteFile(filepath.Join(origin, "3"), []byte("will be ignored"), 0700); err != nil {
+	if err := os.WriteFile(filepath.Join(origin, "3"), []byte("will be ignored"), 0o700); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 
@@ -753,7 +757,6 @@ func TestTarUntar(t *testing.T) {
 			Compression:     c,
 			Compression:     c,
 			ExcludePatterns: []string{"3"},
 			ExcludePatterns: []string{"3"},
 		})
 		})
-
 		if err != nil {
 		if err != nil {
 			t.Fatalf("Error tar/untar for compression %s: %s", c.Extension(), err)
 			t.Fatalf("Error tar/untar for compression %s: %s", c.Extension(), err)
 		}
 		}
@@ -770,7 +773,7 @@ func TestTarWithOptionsChownOptsAlwaysOverridesIdPair(t *testing.T) {
 
 
 	defer os.RemoveAll(origin)
 	defer os.RemoveAll(origin)
 	filePath := filepath.Join(origin, "1")
 	filePath := filepath.Join(origin, "1")
-	err = os.WriteFile(filePath, []byte("hello world"), 0700)
+	err = os.WriteFile(filePath, []byte("hello world"), 0o700)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	idMaps := []idtools.IDMap{
 	idMaps := []idtools.IDMap{
@@ -824,10 +827,10 @@ func TestTarWithOptions(t *testing.T) {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 	defer os.RemoveAll(origin)
 	defer os.RemoveAll(origin)
-	if err := os.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700); err != nil {
+	if err := os.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0o700); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	if err := os.WriteFile(filepath.Join(origin, "2"), []byte("welcome!"), 0700); err != nil {
+	if err := os.WriteFile(filepath.Join(origin, "2"), []byte("welcome!"), 0o700); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 
 
@@ -904,7 +907,7 @@ func prepareUntarSourceDirectory(numberOfFiles int, targetPath string, makeLinks
 	fileData := []byte("fooo")
 	fileData := []byte("fooo")
 	for n := 0; n < numberOfFiles; n++ {
 	for n := 0; n < numberOfFiles; n++ {
 		fileName := fmt.Sprintf("file-%d", n)
 		fileName := fmt.Sprintf("file-%d", n)
-		if err := os.WriteFile(filepath.Join(targetPath, fileName), fileData, 0700); err != nil {
+		if err := os.WriteFile(filepath.Join(targetPath, fileName), fileData, 0o700); err != nil {
 			return 0, err
 			return 0, err
 		}
 		}
 		if makeLinks {
 		if makeLinks {
@@ -979,7 +982,7 @@ func TestUntarInvalidFilenames(t *testing.T) {
 			{
 			{
 				Name:     "../victim/dotdot",
 				Name:     "../victim/dotdot",
 				Typeflag: tar.TypeReg,
 				Typeflag: tar.TypeReg,
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{
 		{
@@ -987,7 +990,7 @@ func TestUntarInvalidFilenames(t *testing.T) {
 				// Note the leading slash
 				// Note the leading slash
 				Name:     "/../victim/slash-dotdot",
 				Name:     "/../victim/slash-dotdot",
 				Typeflag: tar.TypeReg,
 				Typeflag: tar.TypeReg,
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 	} {
 	} {
@@ -1005,18 +1008,18 @@ func TestUntarHardlinkToSymlink(t *testing.T) {
 				Name:     "symlink1",
 				Name:     "symlink1",
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				Linkname: "regfile",
 				Linkname: "regfile",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 			{
 			{
 				Name:     "symlink2",
 				Name:     "symlink2",
 				Typeflag: tar.TypeLink,
 				Typeflag: tar.TypeLink,
 				Linkname: "symlink1",
 				Linkname: "symlink1",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 			{
 			{
 				Name:     "regfile",
 				Name:     "regfile",
 				Typeflag: tar.TypeReg,
 				Typeflag: tar.TypeReg,
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 	} {
 	} {
@@ -1033,7 +1036,7 @@ func TestUntarInvalidHardlink(t *testing.T) {
 				Name:     "dotdot",
 				Name:     "dotdot",
 				Typeflag: tar.TypeLink,
 				Typeflag: tar.TypeLink,
 				Linkname: "../victim/hello",
 				Linkname: "../victim/hello",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // try reading victim/hello (/../)
 		{ // try reading victim/hello (/../)
@@ -1042,7 +1045,7 @@ func TestUntarInvalidHardlink(t *testing.T) {
 				Typeflag: tar.TypeLink,
 				Typeflag: tar.TypeLink,
 				// Note the leading slash
 				// Note the leading slash
 				Linkname: "/../victim/hello",
 				Linkname: "/../victim/hello",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // try writing victim/file
 		{ // try writing victim/file
@@ -1050,12 +1053,12 @@ func TestUntarInvalidHardlink(t *testing.T) {
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeLink,
 				Typeflag: tar.TypeLink,
 				Linkname: "../victim",
 				Linkname: "../victim",
-				Mode:     0755,
+				Mode:     0o755,
 			},
 			},
 			{
 			{
 				Name:     "loophole-victim/file",
 				Name:     "loophole-victim/file",
 				Typeflag: tar.TypeReg,
 				Typeflag: tar.TypeReg,
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // try reading victim/hello (hardlink, symlink)
 		{ // try reading victim/hello (hardlink, symlink)
@@ -1063,13 +1066,13 @@ func TestUntarInvalidHardlink(t *testing.T) {
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeLink,
 				Typeflag: tar.TypeLink,
 				Linkname: "../victim",
 				Linkname: "../victim",
-				Mode:     0755,
+				Mode:     0o755,
 			},
 			},
 			{
 			{
 				Name:     "symlink",
 				Name:     "symlink",
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				Linkname: "loophole-victim/hello",
 				Linkname: "loophole-victim/hello",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // Try reading victim/hello (hardlink, hardlink)
 		{ // Try reading victim/hello (hardlink, hardlink)
@@ -1077,13 +1080,13 @@ func TestUntarInvalidHardlink(t *testing.T) {
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeLink,
 				Typeflag: tar.TypeLink,
 				Linkname: "../victim",
 				Linkname: "../victim",
-				Mode:     0755,
+				Mode:     0o755,
 			},
 			},
 			{
 			{
 				Name:     "hardlink",
 				Name:     "hardlink",
 				Typeflag: tar.TypeLink,
 				Typeflag: tar.TypeLink,
 				Linkname: "loophole-victim/hello",
 				Linkname: "loophole-victim/hello",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // Try removing victim directory (hardlink)
 		{ // Try removing victim directory (hardlink)
@@ -1091,12 +1094,12 @@ func TestUntarInvalidHardlink(t *testing.T) {
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeLink,
 				Typeflag: tar.TypeLink,
 				Linkname: "../victim",
 				Linkname: "../victim",
-				Mode:     0755,
+				Mode:     0o755,
 			},
 			},
 			{
 			{
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeReg,
 				Typeflag: tar.TypeReg,
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 	} {
 	} {
@@ -1113,7 +1116,7 @@ func TestUntarInvalidSymlink(t *testing.T) {
 				Name:     "dotdot",
 				Name:     "dotdot",
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				Linkname: "../victim/hello",
 				Linkname: "../victim/hello",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // try reading victim/hello (/../)
 		{ // try reading victim/hello (/../)
@@ -1122,7 +1125,7 @@ func TestUntarInvalidSymlink(t *testing.T) {
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				// Note the leading slash
 				// Note the leading slash
 				Linkname: "/../victim/hello",
 				Linkname: "/../victim/hello",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // try writing victim/file
 		{ // try writing victim/file
@@ -1130,12 +1133,12 @@ func TestUntarInvalidSymlink(t *testing.T) {
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				Linkname: "../victim",
 				Linkname: "../victim",
-				Mode:     0755,
+				Mode:     0o755,
 			},
 			},
 			{
 			{
 				Name:     "loophole-victim/file",
 				Name:     "loophole-victim/file",
 				Typeflag: tar.TypeReg,
 				Typeflag: tar.TypeReg,
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // try reading victim/hello (symlink, symlink)
 		{ // try reading victim/hello (symlink, symlink)
@@ -1143,13 +1146,13 @@ func TestUntarInvalidSymlink(t *testing.T) {
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				Linkname: "../victim",
 				Linkname: "../victim",
-				Mode:     0755,
+				Mode:     0o755,
 			},
 			},
 			{
 			{
 				Name:     "symlink",
 				Name:     "symlink",
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				Linkname: "loophole-victim/hello",
 				Linkname: "loophole-victim/hello",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // try reading victim/hello (symlink, hardlink)
 		{ // try reading victim/hello (symlink, hardlink)
@@ -1157,13 +1160,13 @@ func TestUntarInvalidSymlink(t *testing.T) {
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				Linkname: "../victim",
 				Linkname: "../victim",
-				Mode:     0755,
+				Mode:     0o755,
 			},
 			},
 			{
 			{
 				Name:     "hardlink",
 				Name:     "hardlink",
 				Typeflag: tar.TypeLink,
 				Typeflag: tar.TypeLink,
 				Linkname: "loophole-victim/hello",
 				Linkname: "loophole-victim/hello",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // try removing victim directory (symlink)
 		{ // try removing victim directory (symlink)
@@ -1171,12 +1174,12 @@ func TestUntarInvalidSymlink(t *testing.T) {
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				Linkname: "../victim",
 				Linkname: "../victim",
-				Mode:     0755,
+				Mode:     0o755,
 			},
 			},
 			{
 			{
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeReg,
 				Typeflag: tar.TypeReg,
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // try writing to victim/newdir/newfile with a symlink in the path
 		{ // try writing to victim/newdir/newfile with a symlink in the path
@@ -1185,12 +1188,12 @@ func TestUntarInvalidSymlink(t *testing.T) {
 				Name:     "dir/loophole",
 				Name:     "dir/loophole",
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				Linkname: "../../victim",
 				Linkname: "../../victim",
-				Mode:     0755,
+				Mode:     0o755,
 			},
 			},
 			{
 			{
 				Name:     "dir/loophole/newdir/newfile",
 				Name:     "dir/loophole/newdir/newfile",
 				Typeflag: tar.TypeReg,
 				Typeflag: tar.TypeReg,
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 	} {
 	} {
@@ -1248,13 +1251,13 @@ func TestImpliedDirectoryPermissions(t *testing.T) {
 		Name: "deeply/nested/and/implied",
 		Name: "deeply/nested/and/implied",
 	}, {
 	}, {
 		Name: "explicit/",
 		Name: "explicit/",
-		Mode: 0644,
+		Mode: 0o644,
 	}, {
 	}, {
 		Name: "explicit/permissions/",
 		Name: "explicit/permissions/",
-		Mode: 0600,
+		Mode: 0o600,
 	}, {
 	}, {
 		Name: "explicit/permissions/specified",
 		Name: "explicit/permissions/specified",
-		Mode: 0400,
+		Mode: 0o400,
 	}}
 	}}
 
 
 	w := tar.NewWriter(buf)
 	w := tar.NewWriter(buf)
@@ -1279,9 +1282,9 @@ func TestImpliedDirectoryPermissions(t *testing.T) {
 	assertMode("deeply/nested", ImpliedDirectoryMode)
 	assertMode("deeply/nested", ImpliedDirectoryMode)
 	assertMode("deeply/nested/and", ImpliedDirectoryMode)
 	assertMode("deeply/nested/and", ImpliedDirectoryMode)
 
 
-	assertMode("explicit", 0644)
-	assertMode("explicit/permissions", 0600)
-	assertMode("explicit/permissions/specified", 0400)
+	assertMode("explicit", 0o644)
+	assertMode("explicit/permissions", 0o600)
+	assertMode("explicit/permissions/specified", 0o400)
 }
 }
 
 
 func TestReplaceFileTarWrapper(t *testing.T) {
 func TestReplaceFileTarWrapper(t *testing.T) {
@@ -1342,7 +1345,7 @@ func TestPrefixHeaderReadable(t *testing.T) {
 	skip.If(t, runtime.GOOS != "windows" && os.Getuid() != 0, "skipping test that requires root")
 	skip.If(t, runtime.GOOS != "windows" && os.Getuid() != 0, "skipping test that requires root")
 	skip.If(t, userns.RunningInUserNS(), "skipping test that requires more than 010000000 UIDs, which is unlikely to be satisfied when running in userns")
 	skip.If(t, userns.RunningInUserNS(), "skipping test that requires more than 010000000 UIDs, which is unlikely to be satisfied when running in userns")
 	// https://gist.github.com/stevvooe/e2a790ad4e97425896206c0816e1a882#file-out-go
 	// https://gist.github.com/stevvooe/e2a790ad4e97425896206c0816e1a882#file-out-go
-	var testFile = []byte("\x1f\x8b\x08\x08\x44\x21\x68\x59\x00\x03\x74\x2e\x74\x61\x72\x00\x4b\xcb\xcf\x67\xa0\x35\x30\x80\x00\x86\x06\x10\x47\x01\xc1\x37\x40\x00\x54\xb6\xb1\xa1\xa9\x99\x09\x48\x25\x1d\x40\x69\x71\x49\x62\x91\x02\xe5\x76\xa1\x79\x84\x21\x91\xd6\x80\x72\xaf\x8f\x82\x51\x30\x0a\x46\x36\x00\x00\xf0\x1c\x1e\x95\x00\x06\x00\x00")
+	testFile := []byte("\x1f\x8b\x08\x08\x44\x21\x68\x59\x00\x03\x74\x2e\x74\x61\x72\x00\x4b\xcb\xcf\x67\xa0\x35\x30\x80\x00\x86\x06\x10\x47\x01\xc1\x37\x40\x00\x54\xb6\xb1\xa1\xa9\x99\x09\x48\x25\x1d\x40\x69\x71\x49\x62\x91\x02\xe5\x76\xa1\x79\x84\x21\x91\xd6\x80\x72\xaf\x8f\x82\x51\x30\x0a\x46\x36\x00\x00\xf0\x1c\x1e\x95\x00\x06\x00\x00")
 
 
 	tmpDir, err := os.MkdirTemp("", "prefix-test")
 	tmpDir, err := os.MkdirTemp("", "prefix-test")
 	assert.NilError(t, err)
 	assert.NilError(t, err)
@@ -1374,7 +1377,7 @@ func buildSourceArchive(t *testing.T, numberOfFiles int) (io.ReadCloser, func())
 
 
 func createOrReplaceModifier(path string, header *tar.Header, content io.Reader) (*tar.Header, []byte, error) {
 func createOrReplaceModifier(path string, header *tar.Header, content io.Reader) (*tar.Header, []byte, error) {
 	return &tar.Header{
 	return &tar.Header{
-		Mode:     0600,
+		Mode:     0o600,
 		Typeflag: tar.TypeReg,
 		Typeflag: tar.TypeReg,
 	}, []byte("the new content"), nil
 	}, []byte("the new content"), nil
 }
 }
@@ -1394,7 +1397,7 @@ func appendModifier(path string, header *tar.Header, content io.Reader) (*tar.He
 		}
 		}
 	}
 	}
 	buffer.WriteString("\nnext line")
 	buffer.WriteString("\nnext line")
-	return &tar.Header{Mode: 0600, Typeflag: tar.TypeReg}, buffer.Bytes(), nil
+	return &tar.Header{Mode: 0o600, Typeflag: tar.TypeReg}, buffer.Bytes(), nil
 }
 }
 
 
 func readFileFromArchive(t *testing.T, archive io.ReadCloser, name string, expectedCount int, doc string) string {
 func readFileFromArchive(t *testing.T, archive io.ReadCloser, name string, expectedCount int, doc string) string {

+ 1 - 1
pkg/archive/archive_unix.go

@@ -82,7 +82,7 @@ func getFileUIDGID(stat interface{}) (idtools.Identity, error) {
 // handleTarTypeBlockCharFifo is an OS-specific helper function used by
 // handleTarTypeBlockCharFifo is an OS-specific helper function used by
 // createTarFile to handle the following types of header: Block; Char; Fifo
 // createTarFile to handle the following types of header: Block; Char; Fifo
 func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error {
 func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error {
-	mode := uint32(hdr.Mode & 07777)
+	mode := uint32(hdr.Mode & 0o7777)
 	switch hdr.Typeflag {
 	switch hdr.Typeflag {
 	case tar.TypeBlock:
 	case tar.TypeBlock:
 		mode |= unix.S_IFBLK
 		mode |= unix.S_IFBLK

+ 20 - 21
pkg/archive/archive_unix_test.go

@@ -44,11 +44,11 @@ func TestChmodTarEntry(t *testing.T) {
 	cases := []struct {
 	cases := []struct {
 		in, expected os.FileMode
 		in, expected os.FileMode
 	}{
 	}{
-		{0000, 0000},
-		{0777, 0777},
-		{0644, 0644},
-		{0755, 0755},
-		{0444, 0444},
+		{0o000, 0o000},
+		{0o777, 0o777},
+		{0o644, 0o644},
+		{0o755, 0o755},
+		{0o444, 0o444},
 	}
 	}
 	for _, v := range cases {
 	for _, v := range cases {
 		if out := chmodTarEntry(v.in); out != v.expected {
 		if out := chmodTarEntry(v.in); out != v.expected {
@@ -62,7 +62,7 @@ func TestTarWithHardLink(t *testing.T) {
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 	defer os.RemoveAll(origin)
 	defer os.RemoveAll(origin)
 
 
-	err = os.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700)
+	err = os.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0o700)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	err = os.Link(filepath.Join(origin, "1"), filepath.Join(origin, "2"))
 	err = os.Link(filepath.Join(origin, "1"), filepath.Join(origin, "2"))
@@ -108,10 +108,10 @@ func TestTarWithHardLinkAndRebase(t *testing.T) {
 	defer os.RemoveAll(tmpDir)
 	defer os.RemoveAll(tmpDir)
 
 
 	origin := filepath.Join(tmpDir, "origin")
 	origin := filepath.Join(tmpDir, "origin")
-	err = os.Mkdir(origin, 0700)
+	err = os.Mkdir(origin, 0o700)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
-	err = os.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700)
+	err = os.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0o700)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	err = os.Link(filepath.Join(origin, "1"), filepath.Join(origin, "2"))
 	err = os.Link(filepath.Join(origin, "1"), filepath.Join(origin, "2"))
@@ -160,7 +160,7 @@ func TestUntarParentPathPermissions(t *testing.T) {
 
 
 	fi, err := os.Lstat(filepath.Join(tmpDir, "foo"))
 	fi, err := os.Lstat(filepath.Join(tmpDir, "foo"))
 	assert.NilError(t, err)
 	assert.NilError(t, err)
-	assert.Equal(t, fi.Mode(), 0755|os.ModeDir)
+	assert.Equal(t, fi.Mode(), 0o755|os.ModeDir)
 }
 }
 
 
 func getNlink(path string) (uint64, error) {
 func getNlink(path string) (uint64, error) {
@@ -196,7 +196,7 @@ func TestTarWithBlockCharFifo(t *testing.T) {
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	defer os.RemoveAll(origin)
 	defer os.RemoveAll(origin)
-	err = os.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700)
+	err = os.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0o700)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	err = system.Mknod(filepath.Join(origin, "2"), unix.S_IFBLK, int(system.Mkdev(int64(12), int64(5))))
 	err = system.Mknod(filepath.Join(origin, "2"), unix.S_IFBLK, int(system.Mkdev(int64(12), int64(5))))
@@ -243,12 +243,12 @@ func TestTarUntarWithXattr(t *testing.T) {
 	origin, err := os.MkdirTemp("", "docker-test-untar-origin")
 	origin, err := os.MkdirTemp("", "docker-test-untar-origin")
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 	defer os.RemoveAll(origin)
 	defer os.RemoveAll(origin)
-	err = os.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0700)
+	err = os.WriteFile(filepath.Join(origin, "1"), []byte("hello world"), 0o700)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
-	err = os.WriteFile(filepath.Join(origin, "2"), []byte("welcome!"), 0700)
+	err = os.WriteFile(filepath.Join(origin, "2"), []byte("welcome!"), 0o700)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
-	err = os.WriteFile(filepath.Join(origin, "3"), []byte("will be ignored"), 0700)
+	err = os.WriteFile(filepath.Join(origin, "3"), []byte("will be ignored"), 0o700)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 	// there is no known Go implementation of setcap/getcap with support for v3 file capability
 	// there is no known Go implementation of setcap/getcap with support for v3 file capability
 	out, err := exec.Command("setcap", "cap_block_suspend+ep", filepath.Join(origin, "2")).CombinedOutput()
 	out, err := exec.Command("setcap", "cap_block_suspend+ep", filepath.Join(origin, "2")).CombinedOutput()
@@ -262,7 +262,6 @@ func TestTarUntarWithXattr(t *testing.T) {
 			Compression:     c,
 			Compression:     c,
 			ExcludePatterns: []string{"3"},
 			ExcludePatterns: []string{"3"},
 		})
 		})
-
 		if err != nil {
 		if err != nil {
 			t.Fatalf("Error tar/untar for compression %s: %s", c.Extension(), err)
 			t.Fatalf("Error tar/untar for compression %s: %s", c.Extension(), err)
 		}
 		}
@@ -291,30 +290,30 @@ func TestCopyInfoDestinationPathSymlink(t *testing.T) {
 	testData := []FileTestData{
 	testData := []FileTestData{
 		// Create a directory: /tmp/archive-copy-test*/dir1
 		// Create a directory: /tmp/archive-copy-test*/dir1
 		// Test will "copy" file1 to 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}},
+		{resource: FileData{filetype: Dir, path: "dir1", permissions: 0o740}, file: "file1", expected: CopyInfo{Path: root + "dir1/file1", Exists: false, IsDir: false}},
 
 
 		// Create a symlink directory to dir1: /tmp/archive-copy-test*/dirSymlink -> dir1
 		// Create a symlink directory to dir1: /tmp/archive-copy-test*/dirSymlink -> dir1
 		// Test will "copy" file2 to dirSymlink
 		// 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}},
+		{resource: FileData{filetype: Symlink, path: "dirSymlink", contents: root + "dir1", permissions: 0o600}, file: "file2", expected: CopyInfo{Path: root + "dirSymlink/file2", Exists: false, IsDir: false}},
 
 
 		// Create a file in tmp directory: /tmp/archive-copy-test*/file1
 		// Create a file in tmp directory: /tmp/archive-copy-test*/file1
 		// Test to cover when the full file path already exists.
 		// 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}},
+		{resource: FileData{filetype: Regular, path: "file1", permissions: 0o600}, file: "", expected: CopyInfo{Path: root + "file1", Exists: true}},
 
 
 		// Create a directory: /tmp/archive-copy*/dir2
 		// Create a directory: /tmp/archive-copy*/dir2
 		// Test to cover when the full directory path already exists
 		// 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}},
+		{resource: FileData{filetype: Dir, path: "dir2", permissions: 0o740}, file: "", expected: CopyInfo{Path: root + "dir2", Exists: true, IsDir: true}},
 
 
 		// Create a symlink to a non-existent target: /tmp/archive-copy*/symlink1 -> noSuchTarget
 		// 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
 		// 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}},
+		{resource: FileData{filetype: Symlink, path: "symlink1", contents: "noSuchTarget", permissions: 0o600}, 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}},
+		{resource: FileData{filetype: Regular, path: "existingfile", permissions: 0o600}, file: "", expected: CopyInfo{Path: root + "existingfile", Exists: true}},
 
 
 		// Create a symlink to an existing file: /tmp/archive-copy*/symlink2 -> /tmp/existingfile
 		// 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
 		// 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}},
+		{resource: FileData{filetype: Symlink, path: "symlink2", contents: "existingfile", permissions: 0o600}, file: "", expected: CopyInfo{Path: root + "existingfile", Exists: true}},
 	}
 	}
 
 
 	var dirs []FileData
 	var dirs []FileData

+ 7 - 7
pkg/archive/archive_windows_test.go

@@ -21,11 +21,11 @@ func TestCopyFileWithInvalidDest(t *testing.T) {
 	dest := "c:dest"
 	dest := "c:dest"
 	srcFolder := filepath.Join(folder, "src")
 	srcFolder := filepath.Join(folder, "src")
 	src := filepath.Join(folder, "src", "src")
 	src := filepath.Join(folder, "src", "src")
-	err = os.MkdirAll(srcFolder, 0740)
+	err = os.MkdirAll(srcFolder, 0o740)
 	if err != nil {
 	if err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
-	os.WriteFile(src, []byte("content"), 0777)
+	os.WriteFile(src, []byte("content"), 0o777)
 	err = defaultCopyWithTar(src, dest)
 	err = defaultCopyWithTar(src, dest)
 	if err == nil {
 	if err == nil {
 		t.Fatalf("archiver.CopyWithTar should throw an error on invalid dest.")
 		t.Fatalf("archiver.CopyWithTar should throw an error on invalid dest.")
@@ -54,11 +54,11 @@ func TestChmodTarEntry(t *testing.T) {
 	cases := []struct {
 	cases := []struct {
 		in, expected os.FileMode
 		in, expected os.FileMode
 	}{
 	}{
-		{0000, 0111},
-		{0777, 0755},
-		{0644, 0755},
-		{0755, 0755},
-		{0444, 0555},
+		{0o000, 0o111},
+		{0o777, 0o755},
+		{0o644, 0o755},
+		{0o755, 0o755},
+		{0o444, 0o555},
 	}
 	}
 	for _, v := range cases {
 	for _, v := range cases {
 		if out := chmodTarEntry(v.in); out != v.expected {
 		if out := chmodTarEntry(v.in); out != v.expected {

+ 5 - 5
pkg/archive/changes.go

@@ -108,8 +108,10 @@ func aufsDeletedFile(root, path string, fi os.FileInfo) (string, error) {
 	return "", nil
 	return "", nil
 }
 }
 
 
-type skipChange func(string) (bool, error)
-type deleteChange func(string, string, os.FileInfo) (string, error)
+type (
+	skipChange   func(string) (bool, error)
+	deleteChange func(string, string, os.FileInfo) (string, error)
+)
 
 
 func changes(layers []string, rw string, dc deleteChange, sc skipChange) ([]Change, error) {
 func changes(layers []string, rw string, dc deleteChange, sc skipChange) ([]Change, error) {
 	var (
 	var (
@@ -342,9 +344,7 @@ func newRootFileInfo() *FileInfo {
 // ChangesDirs compares two directories and generates an array of Change objects describing the changes.
 // ChangesDirs compares two directories and generates an array of Change objects describing the changes.
 // If oldDir is "", then all files in newDir will be Add-Changes.
 // If oldDir is "", then all files in newDir will be Add-Changes.
 func ChangesDirs(newDir, oldDir string) ([]Change, error) {
 func ChangesDirs(newDir, oldDir string) ([]Change, error) {
-	var (
-		oldRoot, newRoot *FileInfo
-	)
+	var oldRoot, newRoot *FileInfo
 	if oldDir == "" {
 	if oldDir == "" {
 		emptyDir, err := os.MkdirTemp("", "empty")
 		emptyDir, err := os.MkdirTemp("", "empty")
 		if err != nil {
 		if err != nil {

+ 1 - 1
pkg/archive/changes_linux.go

@@ -267,7 +267,7 @@ func parseDirent(buf []byte, names []nameIno) (consumed int, newnames []nameIno)
 			continue
 			continue
 		}
 		}
 		bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
 		bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0]))
-		var name = string(bytes[0:clen(bytes[:])])
+		name := string(bytes[0:clen(bytes[:])])
 		if name == "." || name == ".." { // Useless names
 		if name == "." || name == ".." { // Useless names
 			continue
 			continue
 		}
 		}

+ 42 - 42
pkg/archive/changes_test.go

@@ -66,30 +66,30 @@ type FileData struct {
 
 
 func createSampleDir(t *testing.T, root string) {
 func createSampleDir(t *testing.T, root string) {
 	files := []FileData{
 	files := []FileData{
-		{filetype: Regular, path: "file1", contents: "file1\n", permissions: 0600},
-		{filetype: Regular, path: "file2", contents: "file2\n", permissions: 0666},
-		{filetype: Regular, path: "file3", contents: "file3\n", permissions: 0404},
-		{filetype: Regular, path: "file4", contents: "file4\n", permissions: 0600},
-		{filetype: Regular, path: "file5", contents: "file5\n", permissions: 0600},
-		{filetype: Regular, path: "file6", contents: "file6\n", permissions: 0600},
-		{filetype: Regular, path: "file7", contents: "file7\n", permissions: 0600},
-		{filetype: Dir, path: "dir1", contents: "", permissions: 0740},
-		{filetype: Regular, path: "dir1/file1-1", contents: "file1-1\n", permissions: 01444},
-		{filetype: Regular, path: "dir1/file1-2", contents: "file1-2\n", permissions: 0666},
-		{filetype: Dir, path: "dir2", contents: "", permissions: 0700},
-		{filetype: Regular, path: "dir2/file2-1", contents: "file2-1\n", permissions: 0666},
-		{filetype: Regular, path: "dir2/file2-2", contents: "file2-2\n", permissions: 0666},
-		{filetype: Dir, path: "dir3", contents: "", permissions: 0700},
-		{filetype: Regular, path: "dir3/file3-1", contents: "file3-1\n", permissions: 0666},
-		{filetype: Regular, path: "dir3/file3-2", contents: "file3-2\n", permissions: 0666},
-		{filetype: Dir, path: "dir4", contents: "", permissions: 0700},
-		{filetype: Regular, path: "dir4/file3-1", contents: "file4-1\n", permissions: 0666},
-		{filetype: Regular, path: "dir4/file3-2", contents: "file4-2\n", permissions: 0666},
-		{filetype: Symlink, path: "symlink1", contents: "target1", permissions: 0666},
-		{filetype: Symlink, path: "symlink2", contents: "target2", permissions: 0666},
-		{filetype: Symlink, path: "symlink3", contents: root + "/file1", permissions: 0666},
-		{filetype: Symlink, path: "symlink4", contents: root + "/symlink3", permissions: 0666},
-		{filetype: Symlink, path: "dirSymlink", contents: root + "/dir1", permissions: 0740},
+		{filetype: Regular, path: "file1", contents: "file1\n", permissions: 0o600},
+		{filetype: Regular, path: "file2", contents: "file2\n", permissions: 0o666},
+		{filetype: Regular, path: "file3", contents: "file3\n", permissions: 0o404},
+		{filetype: Regular, path: "file4", contents: "file4\n", permissions: 0o600},
+		{filetype: Regular, path: "file5", contents: "file5\n", permissions: 0o600},
+		{filetype: Regular, path: "file6", contents: "file6\n", permissions: 0o600},
+		{filetype: Regular, path: "file7", contents: "file7\n", permissions: 0o600},
+		{filetype: Dir, path: "dir1", contents: "", permissions: 0o740},
+		{filetype: Regular, path: "dir1/file1-1", contents: "file1-1\n", permissions: 0o1444},
+		{filetype: Regular, path: "dir1/file1-2", contents: "file1-2\n", permissions: 0o666},
+		{filetype: Dir, path: "dir2", contents: "", permissions: 0o700},
+		{filetype: Regular, path: "dir2/file2-1", contents: "file2-1\n", permissions: 0o666},
+		{filetype: Regular, path: "dir2/file2-2", contents: "file2-2\n", permissions: 0o666},
+		{filetype: Dir, path: "dir3", contents: "", permissions: 0o700},
+		{filetype: Regular, path: "dir3/file3-1", contents: "file3-1\n", permissions: 0o666},
+		{filetype: Regular, path: "dir3/file3-2", contents: "file3-2\n", permissions: 0o666},
+		{filetype: Dir, path: "dir4", contents: "", permissions: 0o700},
+		{filetype: Regular, path: "dir4/file3-1", contents: "file4-1\n", permissions: 0o666},
+		{filetype: Regular, path: "dir4/file3-2", contents: "file4-2\n", permissions: 0o666},
+		{filetype: Symlink, path: "symlink1", contents: "target1", permissions: 0o666},
+		{filetype: Symlink, path: "symlink2", contents: "target2", permissions: 0o666},
+		{filetype: Symlink, path: "symlink3", contents: root + "/file1", permissions: 0o666},
+		{filetype: Symlink, path: "symlink4", contents: root + "/symlink3", permissions: 0o666},
+		{filetype: Symlink, path: "dirSymlink", contents: root + "/dir1", permissions: 0o740},
 	}
 	}
 	provisionSampleDir(t, root, files)
 	provisionSampleDir(t, root, files)
 }
 }
@@ -156,7 +156,7 @@ func TestChangesWithChanges(t *testing.T) {
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 	defer os.RemoveAll(layer)
 	defer os.RemoveAll(layer)
 	createSampleDir(t, layer)
 	createSampleDir(t, layer)
-	os.MkdirAll(path.Join(layer, "dir1/subfolder"), 0740)
+	os.MkdirAll(path.Join(layer, "dir1/subfolder"), 0o740)
 
 
 	// Mock the RW layer
 	// Mock the RW layer
 	rwLayer, err := os.MkdirTemp("", "docker-changes-test")
 	rwLayer, err := os.MkdirTemp("", "docker-changes-test")
@@ -165,16 +165,16 @@ func TestChangesWithChanges(t *testing.T) {
 
 
 	// Create a folder in RW layer
 	// Create a folder in RW layer
 	dir1 := path.Join(rwLayer, "dir1")
 	dir1 := path.Join(rwLayer, "dir1")
-	os.MkdirAll(dir1, 0740)
+	os.MkdirAll(dir1, 0o740)
 	deletedFile := path.Join(dir1, ".wh.file1-2")
 	deletedFile := path.Join(dir1, ".wh.file1-2")
-	os.WriteFile(deletedFile, []byte{}, 0600)
+	os.WriteFile(deletedFile, []byte{}, 0o600)
 	modifiedFile := path.Join(dir1, "file1-1")
 	modifiedFile := path.Join(dir1, "file1-1")
-	os.WriteFile(modifiedFile, []byte{0x00}, 01444)
+	os.WriteFile(modifiedFile, []byte{0x00}, 0o1444)
 	// Let's add a subfolder for a newFile
 	// Let's add a subfolder for a newFile
 	subfolder := path.Join(dir1, "subfolder")
 	subfolder := path.Join(dir1, "subfolder")
-	os.MkdirAll(subfolder, 0740)
+	os.MkdirAll(subfolder, 0o740)
 	newFile := path.Join(subfolder, "newFile")
 	newFile := path.Join(subfolder, "newFile")
-	os.WriteFile(newFile, []byte{}, 0740)
+	os.WriteFile(newFile, []byte{}, 0o740)
 
 
 	changes, err := Changes([]string{layer}, rwLayer)
 	changes, err := Changes([]string{layer}, rwLayer)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
@@ -200,10 +200,10 @@ func TestChangesWithChangesGH13590(t *testing.T) {
 	defer os.RemoveAll(baseLayer)
 	defer os.RemoveAll(baseLayer)
 
 
 	dir3 := path.Join(baseLayer, "dir1/dir2/dir3")
 	dir3 := path.Join(baseLayer, "dir1/dir2/dir3")
-	os.MkdirAll(dir3, 07400)
+	os.MkdirAll(dir3, 0o7400)
 
 
 	file := path.Join(dir3, "file.txt")
 	file := path.Join(dir3, "file.txt")
-	os.WriteFile(file, []byte("hello"), 0666)
+	os.WriteFile(file, []byte("hello"), 0o666)
 
 
 	layer, err := os.MkdirTemp("", "docker-changes-test2.")
 	layer, err := os.MkdirTemp("", "docker-changes-test2.")
 	assert.NilError(t, err)
 	assert.NilError(t, err)
@@ -216,7 +216,7 @@ func TestChangesWithChangesGH13590(t *testing.T) {
 
 
 	os.Remove(path.Join(layer, "dir1/dir2/dir3/file.txt"))
 	os.Remove(path.Join(layer, "dir1/dir2/dir3/file.txt"))
 	file = path.Join(layer, "dir1/dir2/dir3/file1.txt")
 	file = path.Join(layer, "dir1/dir2/dir3/file1.txt")
-	os.WriteFile(file, []byte("bye"), 0666)
+	os.WriteFile(file, []byte("bye"), 0o666)
 
 
 	changes, err := Changes([]string{baseLayer}, layer)
 	changes, err := Changes([]string{baseLayer}, layer)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
@@ -237,7 +237,7 @@ func TestChangesWithChangesGH13590(t *testing.T) {
 	}
 	}
 
 
 	file = path.Join(layer, "dir1/dir2/dir3/file.txt")
 	file = path.Join(layer, "dir1/dir2/dir3/file.txt")
-	os.WriteFile(file, []byte("bye"), 0666)
+	os.WriteFile(file, []byte("bye"), 0o666)
 
 
 	changes, err = Changes([]string{baseLayer}, layer)
 	changes, err = Changes([]string{baseLayer}, layer)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
@@ -294,13 +294,13 @@ func mutateSampleDir(t *testing.T, root string) {
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	// Rewrite a file
 	// Rewrite a file
-	err = os.WriteFile(path.Join(root, "file2"), []byte("fileNN\n"), 0777)
+	err = os.WriteFile(path.Join(root, "file2"), []byte("fileNN\n"), 0o777)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	// Replace a file
 	// Replace a file
 	err = os.RemoveAll(path.Join(root, "file3"))
 	err = os.RemoveAll(path.Join(root, "file3"))
 	assert.NilError(t, err)
 	assert.NilError(t, err)
-	err = os.WriteFile(path.Join(root, "file3"), []byte("fileMM\n"), 0404)
+	err = os.WriteFile(path.Join(root, "file3"), []byte("fileMM\n"), 0o404)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	// Touch file
 	// Touch file
@@ -310,15 +310,15 @@ func mutateSampleDir(t *testing.T, root string) {
 	// Replace file with dir
 	// Replace file with dir
 	err = os.RemoveAll(path.Join(root, "file5"))
 	err = os.RemoveAll(path.Join(root, "file5"))
 	assert.NilError(t, err)
 	assert.NilError(t, err)
-	err = os.MkdirAll(path.Join(root, "file5"), 0666)
+	err = os.MkdirAll(path.Join(root, "file5"), 0o666)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	// Create new file
 	// Create new file
-	err = os.WriteFile(path.Join(root, "filenew"), []byte("filenew\n"), 0777)
+	err = os.WriteFile(path.Join(root, "filenew"), []byte("filenew\n"), 0o777)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	// Create new dir
 	// Create new dir
-	err = os.MkdirAll(path.Join(root, "dirnew"), 0766)
+	err = os.MkdirAll(path.Join(root, "dirnew"), 0o766)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	// Create a new symlink
 	// Create a new symlink
@@ -335,7 +335,7 @@ func mutateSampleDir(t *testing.T, root string) {
 	// Replace dir with file
 	// Replace dir with file
 	err = os.RemoveAll(path.Join(root, "dir2"))
 	err = os.RemoveAll(path.Join(root, "dir2"))
 	assert.NilError(t, err)
 	assert.NilError(t, err)
-	err = os.WriteFile(path.Join(root, "dir2"), []byte("dir2\n"), 0777)
+	err = os.WriteFile(path.Join(root, "dir2"), []byte("dir2\n"), 0o777)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	// Touch dir
 	// Touch dir
@@ -510,10 +510,10 @@ func TestChangesSize(t *testing.T) {
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 	defer os.RemoveAll(parentPath)
 	defer os.RemoveAll(parentPath)
 	addition := path.Join(parentPath, "addition")
 	addition := path.Join(parentPath, "addition")
-	err = os.WriteFile(addition, []byte{0x01, 0x01, 0x01}, 0744)
+	err = os.WriteFile(addition, []byte{0x01, 0x01, 0x01}, 0o744)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 	modification := path.Join(parentPath, "modification")
 	modification := path.Join(parentPath, "modification")
-	err = os.WriteFile(modification, []byte{0x01, 0x01, 0x01}, 0744)
+	err = os.WriteFile(modification, []byte{0x01, 0x01, 0x01}, 0o744)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	changes := []Change{
 	changes := []Change{

+ 8 - 8
pkg/archive/copy_unix_test.go

@@ -472,7 +472,7 @@ func TestCopyCaseD(t *testing.T) {
 		t.Fatalf("unable to remove dstDir: %s", err)
 		t.Fatalf("unable to remove dstDir: %s", err)
 	}
 	}
 
 
-	if err = os.MkdirAll(dstDir, os.FileMode(0755)); err != nil {
+	if err = os.MkdirAll(dstDir, os.FileMode(0o755)); err != nil {
 		t.Fatalf("unable to make dstDir: %s", err)
 		t.Fatalf("unable to make dstDir: %s", err)
 	}
 	}
 
 
@@ -523,7 +523,7 @@ func TestCopyCaseDFSym(t *testing.T) {
 		t.Fatalf("unable to remove dstDir: %s", err)
 		t.Fatalf("unable to remove dstDir: %s", err)
 	}
 	}
 
 
-	if err = os.MkdirAll(dstDir, os.FileMode(0755)); err != nil {
+	if err = os.MkdirAll(dstDir, os.FileMode(0o755)); err != nil {
 		t.Fatalf("unable to make dstDir: %s", err)
 		t.Fatalf("unable to make dstDir: %s", err)
 	}
 	}
 
 
@@ -693,7 +693,7 @@ func TestCopyCaseG(t *testing.T) {
 		t.Fatalf("unable to remove dstDir: %s", err)
 		t.Fatalf("unable to remove dstDir: %s", err)
 	}
 	}
 
 
-	if err = os.MkdirAll(dstDir, os.FileMode(0755)); err != nil {
+	if err = os.MkdirAll(dstDir, os.FileMode(0o755)); err != nil {
 		t.Fatalf("unable to make dstDir: %s", err)
 		t.Fatalf("unable to make dstDir: %s", err)
 	}
 	}
 
 
@@ -739,7 +739,7 @@ func TestCopyCaseGFSym(t *testing.T) {
 		t.Fatalf("unable to remove dstDir: %s", err)
 		t.Fatalf("unable to remove dstDir: %s", err)
 	}
 	}
 
 
-	if err = os.MkdirAll(dstDir, os.FileMode(0755)); err != nil {
+	if err = os.MkdirAll(dstDir, os.FileMode(0o755)); err != nil {
 		t.Fatalf("unable to make dstDir: %s", err)
 		t.Fatalf("unable to make dstDir: %s", err)
 	}
 	}
 
 
@@ -905,7 +905,7 @@ func TestCopyCaseJ(t *testing.T) {
 	var err error
 	var err error
 
 
 	// first to create an empty dir
 	// first to create an empty dir
-	if err = os.MkdirAll(dstDir, os.FileMode(0755)); err != nil {
+	if err = os.MkdirAll(dstDir, os.FileMode(0o755)); err != nil {
 		t.Fatalf("unable to make dstDir: %s", err)
 		t.Fatalf("unable to make dstDir: %s", err)
 	}
 	}
 
 
@@ -922,7 +922,7 @@ func TestCopyCaseJ(t *testing.T) {
 		t.Fatalf("unable to remove dstDir: %s", err)
 		t.Fatalf("unable to remove dstDir: %s", err)
 	}
 	}
 
 
-	if err = os.MkdirAll(dstDir, os.FileMode(0755)); err != nil {
+	if err = os.MkdirAll(dstDir, os.FileMode(0o755)); err != nil {
 		t.Fatalf("unable to make dstDir: %s", err)
 		t.Fatalf("unable to make dstDir: %s", err)
 	}
 	}
 
 
@@ -956,7 +956,7 @@ func TestCopyCaseJFSym(t *testing.T) {
 	var err error
 	var err error
 
 
 	// first to create an empty dir
 	// first to create an empty dir
-	if err = os.MkdirAll(dstDir, os.FileMode(0755)); err != nil {
+	if err = os.MkdirAll(dstDir, os.FileMode(0o755)); err != nil {
 		t.Fatalf("unable to make dstDir: %s", err)
 		t.Fatalf("unable to make dstDir: %s", err)
 	}
 	}
 
 
@@ -973,7 +973,7 @@ func TestCopyCaseJFSym(t *testing.T) {
 		t.Fatalf("unable to remove dstDir: %s", err)
 		t.Fatalf("unable to remove dstDir: %s", err)
 	}
 	}
 
 
-	if err = os.MkdirAll(dstDir, os.FileMode(0755)); err != nil {
+	if err = os.MkdirAll(dstDir, os.FileMode(0o755)); err != nil {
 		t.Fatalf("unable to make dstDir: %s", err)
 		t.Fatalf("unable to make dstDir: %s", err)
 	}
 	}
 
 

+ 24 - 24
pkg/archive/diff_test.go

@@ -17,7 +17,7 @@ func TestApplyLayerInvalidFilenames(t *testing.T) {
 			{
 			{
 				Name:     "../victim/dotdot",
 				Name:     "../victim/dotdot",
 				Typeflag: tar.TypeReg,
 				Typeflag: tar.TypeReg,
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{
 		{
@@ -25,7 +25,7 @@ func TestApplyLayerInvalidFilenames(t *testing.T) {
 				// Note the leading slash
 				// Note the leading slash
 				Name:     "/../victim/slash-dotdot",
 				Name:     "/../victim/slash-dotdot",
 				Typeflag: tar.TypeReg,
 				Typeflag: tar.TypeReg,
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 	} {
 	} {
@@ -42,7 +42,7 @@ func TestApplyLayerInvalidHardlink(t *testing.T) {
 				Name:     "dotdot",
 				Name:     "dotdot",
 				Typeflag: tar.TypeLink,
 				Typeflag: tar.TypeLink,
 				Linkname: "../victim/hello",
 				Linkname: "../victim/hello",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // try reading victim/hello (/../)
 		{ // try reading victim/hello (/../)
@@ -51,7 +51,7 @@ func TestApplyLayerInvalidHardlink(t *testing.T) {
 				Typeflag: tar.TypeLink,
 				Typeflag: tar.TypeLink,
 				// Note the leading slash
 				// Note the leading slash
 				Linkname: "/../victim/hello",
 				Linkname: "/../victim/hello",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // try writing victim/file
 		{ // try writing victim/file
@@ -59,12 +59,12 @@ func TestApplyLayerInvalidHardlink(t *testing.T) {
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeLink,
 				Typeflag: tar.TypeLink,
 				Linkname: "../victim",
 				Linkname: "../victim",
-				Mode:     0755,
+				Mode:     0o755,
 			},
 			},
 			{
 			{
 				Name:     "loophole-victim/file",
 				Name:     "loophole-victim/file",
 				Typeflag: tar.TypeReg,
 				Typeflag: tar.TypeReg,
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // try reading victim/hello (hardlink, symlink)
 		{ // try reading victim/hello (hardlink, symlink)
@@ -72,13 +72,13 @@ func TestApplyLayerInvalidHardlink(t *testing.T) {
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeLink,
 				Typeflag: tar.TypeLink,
 				Linkname: "../victim",
 				Linkname: "../victim",
-				Mode:     0755,
+				Mode:     0o755,
 			},
 			},
 			{
 			{
 				Name:     "symlink",
 				Name:     "symlink",
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				Linkname: "loophole-victim/hello",
 				Linkname: "loophole-victim/hello",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // Try reading victim/hello (hardlink, hardlink)
 		{ // Try reading victim/hello (hardlink, hardlink)
@@ -86,13 +86,13 @@ func TestApplyLayerInvalidHardlink(t *testing.T) {
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeLink,
 				Typeflag: tar.TypeLink,
 				Linkname: "../victim",
 				Linkname: "../victim",
-				Mode:     0755,
+				Mode:     0o755,
 			},
 			},
 			{
 			{
 				Name:     "hardlink",
 				Name:     "hardlink",
 				Typeflag: tar.TypeLink,
 				Typeflag: tar.TypeLink,
 				Linkname: "loophole-victim/hello",
 				Linkname: "loophole-victim/hello",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // Try removing victim directory (hardlink)
 		{ // Try removing victim directory (hardlink)
@@ -100,12 +100,12 @@ func TestApplyLayerInvalidHardlink(t *testing.T) {
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeLink,
 				Typeflag: tar.TypeLink,
 				Linkname: "../victim",
 				Linkname: "../victim",
-				Mode:     0755,
+				Mode:     0o755,
 			},
 			},
 			{
 			{
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeReg,
 				Typeflag: tar.TypeReg,
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 	} {
 	} {
@@ -122,7 +122,7 @@ func TestApplyLayerInvalidSymlink(t *testing.T) {
 				Name:     "dotdot",
 				Name:     "dotdot",
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				Linkname: "../victim/hello",
 				Linkname: "../victim/hello",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // try reading victim/hello (/../)
 		{ // try reading victim/hello (/../)
@@ -131,7 +131,7 @@ func TestApplyLayerInvalidSymlink(t *testing.T) {
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				// Note the leading slash
 				// Note the leading slash
 				Linkname: "/../victim/hello",
 				Linkname: "/../victim/hello",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // try writing victim/file
 		{ // try writing victim/file
@@ -139,12 +139,12 @@ func TestApplyLayerInvalidSymlink(t *testing.T) {
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				Linkname: "../victim",
 				Linkname: "../victim",
-				Mode:     0755,
+				Mode:     0o755,
 			},
 			},
 			{
 			{
 				Name:     "loophole-victim/file",
 				Name:     "loophole-victim/file",
 				Typeflag: tar.TypeReg,
 				Typeflag: tar.TypeReg,
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // try reading victim/hello (symlink, symlink)
 		{ // try reading victim/hello (symlink, symlink)
@@ -152,13 +152,13 @@ func TestApplyLayerInvalidSymlink(t *testing.T) {
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				Linkname: "../victim",
 				Linkname: "../victim",
-				Mode:     0755,
+				Mode:     0o755,
 			},
 			},
 			{
 			{
 				Name:     "symlink",
 				Name:     "symlink",
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				Linkname: "loophole-victim/hello",
 				Linkname: "loophole-victim/hello",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // try reading victim/hello (symlink, hardlink)
 		{ // try reading victim/hello (symlink, hardlink)
@@ -166,13 +166,13 @@ func TestApplyLayerInvalidSymlink(t *testing.T) {
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				Linkname: "../victim",
 				Linkname: "../victim",
-				Mode:     0755,
+				Mode:     0o755,
 			},
 			},
 			{
 			{
 				Name:     "hardlink",
 				Name:     "hardlink",
 				Typeflag: tar.TypeLink,
 				Typeflag: tar.TypeLink,
 				Linkname: "loophole-victim/hello",
 				Linkname: "loophole-victim/hello",
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 		{ // try removing victim directory (symlink)
 		{ // try removing victim directory (symlink)
@@ -180,12 +180,12 @@ func TestApplyLayerInvalidSymlink(t *testing.T) {
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeSymlink,
 				Typeflag: tar.TypeSymlink,
 				Linkname: "../victim",
 				Linkname: "../victim",
-				Mode:     0755,
+				Mode:     0o755,
 			},
 			},
 			{
 			{
 				Name:     "loophole-victim",
 				Name:     "loophole-victim",
 				Typeflag: tar.TypeReg,
 				Typeflag: tar.TypeReg,
-				Mode:     0644,
+				Mode:     0o644,
 			},
 			},
 		},
 		},
 	} {
 	} {
@@ -324,11 +324,11 @@ func makeTestLayer(paths []string) (rc io.ReadCloser, err error) {
 		// Source files are always in Unix format. But we use filepath on
 		// Source files are always in Unix format. But we use filepath on
 		// creation to be platform agnostic.
 		// creation to be platform agnostic.
 		if p[len(p)-1] == '/' {
 		if p[len(p)-1] == '/' {
-			if err = os.MkdirAll(filepath.Join(tmpDir, p), 0700); err != nil {
+			if err = os.MkdirAll(filepath.Join(tmpDir, p), 0o700); err != nil {
 				return
 				return
 			}
 			}
 		} else {
 		} else {
-			if err = os.WriteFile(filepath.Join(tmpDir, p), nil, 0600); err != nil {
+			if err = os.WriteFile(filepath.Join(tmpDir, p), nil, 0o600); err != nil {
 				return
 				return
 			}
 			}
 		}
 		}

+ 2 - 2
pkg/archive/example_changes.go

@@ -12,8 +12,8 @@ import (
 	"os"
 	"os"
 	"path"
 	"path"
 
 
-	"github.com/docker/docker/pkg/archive"
 	"github.com/containerd/containerd/log"
 	"github.com/containerd/containerd/log"
+	"github.com/docker/docker/pkg/archive"
 )
 )
 
 
 var (
 var (
@@ -82,7 +82,7 @@ func prepareUntarSourceDirectory(numberOfFiles int, targetPath string, makeLinks
 	fileData := []byte("fooo")
 	fileData := []byte("fooo")
 	for n := 0; n < numberOfFiles; n++ {
 	for n := 0; n < numberOfFiles; n++ {
 		fileName := fmt.Sprintf("file-%d", n)
 		fileName := fmt.Sprintf("file-%d", n)
-		if err := os.WriteFile(path.Join(targetPath, fileName), fileData, 0700); err != nil {
+		if err := os.WriteFile(path.Join(targetPath, fileName), fileData, 0o700); err != nil {
 			return 0, err
 			return 0, err
 		}
 		}
 		if makeLinks {
 		if makeLinks {

+ 3 - 3
pkg/archive/utils_test.go

@@ -40,12 +40,12 @@ func testBreakout(untarFn string, tmpdir string, headers []*tar.Header) error {
 	defer os.RemoveAll(tmpdir)
 	defer os.RemoveAll(tmpdir)
 
 
 	dest := filepath.Join(tmpdir, "dest")
 	dest := filepath.Join(tmpdir, "dest")
-	if err := os.Mkdir(dest, 0755); err != nil {
+	if err := os.Mkdir(dest, 0o755); err != nil {
 		return err
 		return err
 	}
 	}
 
 
 	victim := filepath.Join(tmpdir, "victim")
 	victim := filepath.Join(tmpdir, "victim")
-	if err := os.Mkdir(victim, 0755); err != nil {
+	if err := os.Mkdir(victim, 0o755); err != nil {
 		return err
 		return err
 	}
 	}
 	hello := filepath.Join(victim, "hello")
 	hello := filepath.Join(victim, "hello")
@@ -53,7 +53,7 @@ func testBreakout(untarFn string, tmpdir string, headers []*tar.Header) error {
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
-	if err := os.WriteFile(hello, helloData, 0644); err != nil {
+	if err := os.WriteFile(hello, helloData, 0o644); err != nil {
 		return err
 		return err
 	}
 	}
 	helloStat, err := os.Stat(hello)
 	helloStat, err := os.Stat(hello)