Browse code

integration-cli: 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 authored on 2022/01/20 21:43:42
Showing 34 changed files
... ...
@@ -342,8 +342,7 @@ func TestDockerHubPullSuite(t *testing.T) {
342 342
 	suite.Run(t, newDockerHubPullSuite())
343 343
 }
344 344
 
345
-type DockerSuite struct {
346
-}
345
+type DockerSuite struct{}
347 346
 
348 347
 func (s *DockerSuite) OnTimeout(c *testing.T) {
349 348
 	if testEnv.IsRemoteDaemon() {
... ...
@@ -598,6 +597,7 @@ func (ps *DockerPluginSuite) registryHost() string {
598 598
 func (ps *DockerPluginSuite) getPluginRepo() string {
599 599
 	return path.Join(ps.registryHost(), "plugin", "basic")
600 600
 }
601
+
601 602
 func (ps *DockerPluginSuite) getPluginRepoWithTag() string {
602 603
 	return ps.getPluginRepo() + ":" + "latest"
603 604
 }
... ...
@@ -352,7 +352,7 @@ func (s *DockerAPISuite) TestBuildAddRemoteNoDecompress(c *testing.T) {
352 352
 	err := tw.WriteHeader(&tar.Header{
353 353
 		Name:     "foo",
354 354
 		Size:     int64(len(dt)),
355
-		Mode:     0600,
355
+		Mode:     0o600,
356 356
 		Typeflag: tar.TypeReg,
357 357
 	})
358 358
 	assert.NilError(c, err)
... ...
@@ -430,7 +430,7 @@ COPY file /file`
430 430
 		fakecontext.WithDockerfile(dockerfile),
431 431
 		fakecontext.WithFile("file", "bar"))
432 432
 
433
-	var build = func(ctx *fakecontext.Fake) string {
433
+	build := func(ctx *fakecontext.Fake) string {
434 434
 		res, body, err := request.Post("/build",
435 435
 			request.RawContent(ctx.AsTarReader(c)),
436 436
 			request.ContentType("application/x-tar"))
... ...
@@ -470,7 +470,7 @@ ADD file /file`
470 470
 		fakecontext.WithDockerfile(dockerfile),
471 471
 		fakecontext.WithFile("file", "bar"))
472 472
 
473
-	var build = func(ctx *fakecontext.Fake) string {
473
+	build := func(ctx *fakecontext.Fake) string {
474 474
 		res, body, err := request.Post("/build",
475 475
 			request.RawContent(ctx.AsTarReader(c)),
476 476
 			request.ContentType("application/x-tar"))
... ...
@@ -146,9 +146,7 @@ func (s *DockerAPISuite) TestContainerAPIGetChanges(c *testing.T) {
146 146
 }
147 147
 
148 148
 func (s *DockerAPISuite) TestGetContainerStats(c *testing.T) {
149
-	var (
150
-		name = "statscontainer"
151
-	)
149
+	const name = "statscontainer"
152 150
 	runSleepingContainer(c, "--name", name)
153 151
 
154 152
 	type b struct {
... ...
@@ -476,7 +474,8 @@ func (s *DockerAPISuite) TestContainerAPICommitWithLabelInConfig(c *testing.T) {
476 476
 	defer apiClient.Close()
477 477
 
478 478
 	config := container.Config{
479
-		Labels: map[string]string{"key1": "value1", "key2": "value2"}}
479
+		Labels: map[string]string{"key1": "value1", "key2": "value2"},
480
+	}
480 481
 
481 482
 	options := types.ContainerCommitOptions{
482 483
 		Reference: "testcontainerapicommitwithconfig",
... ...
@@ -513,7 +512,8 @@ func (s *DockerAPISuite) TestContainerAPIBadPort(c *testing.T) {
513 513
 			"8080/tcp": []nat.PortBinding{
514 514
 				{
515 515
 					HostIP:   "",
516
-					HostPort: "aa80"},
516
+					HostPort: "aa80",
517
+				},
517 518
 			},
518 519
 		},
519 520
 	}
... ...
@@ -1662,8 +1662,7 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
1662 1662
 				Mounts: []mount.Mount{{
1663 1663
 					Type:   "notreal",
1664 1664
 					Target: destPath,
1665
-				},
1666
-				},
1665
+				}},
1667 1666
 			},
1668 1667
 
1669 1668
 			msg: "mount type unknown",
... ...
@@ -1674,7 +1673,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
1674 1674
 			},
1675 1675
 			hostConfig: container.HostConfig{
1676 1676
 				Mounts: []mount.Mount{{
1677
-					Type: "bind"}}},
1677
+					Type: "bind",
1678
+				}},
1679
+			},
1678 1680
 			msg: "Target must not be empty",
1679 1681
 		},
1680 1682
 		{
... ...
@@ -1684,7 +1685,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
1684 1684
 			hostConfig: container.HostConfig{
1685 1685
 				Mounts: []mount.Mount{{
1686 1686
 					Type:   "bind",
1687
-					Target: destPath}}},
1687
+					Target: destPath,
1688
+				}},
1689
+			},
1688 1690
 			msg: "Source must not be empty",
1689 1691
 		},
1690 1692
 		{
... ...
@@ -1695,7 +1698,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
1695 1695
 				Mounts: []mount.Mount{{
1696 1696
 					Type:   "bind",
1697 1697
 					Source: notExistPath,
1698
-					Target: destPath}}},
1698
+					Target: destPath,
1699
+				}},
1700
+			},
1699 1701
 			msg: "source path does not exist",
1700 1702
 			// FIXME(vdemeester) fails into e2e, migrate to integration/container anyway
1701 1703
 			// msg: "source path does not exist: " + notExistPath,
... ...
@@ -1706,7 +1711,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
1706 1706
 			},
1707 1707
 			hostConfig: container.HostConfig{
1708 1708
 				Mounts: []mount.Mount{{
1709
-					Type: "volume"}}},
1709
+					Type: "volume",
1710
+				}},
1711
+			},
1710 1712
 			msg: "Target must not be empty",
1711 1713
 		},
1712 1714
 		{
... ...
@@ -1717,7 +1724,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
1717 1717
 				Mounts: []mount.Mount{{
1718 1718
 					Type:   "volume",
1719 1719
 					Source: "hello",
1720
-					Target: destPath}}},
1720
+					Target: destPath,
1721
+				}},
1722
+			},
1721 1723
 			msg: "",
1722 1724
 		},
1723 1725
 		{
... ...
@@ -1731,7 +1740,11 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
1731 1731
 					Target: destPath,
1732 1732
 					VolumeOptions: &mount.VolumeOptions{
1733 1733
 						DriverConfig: &mount.Driver{
1734
-							Name: "local"}}}}},
1734
+							Name: "local",
1735
+						},
1736
+					},
1737
+				}},
1738
+			},
1735 1739
 			msg: "",
1736 1740
 		},
1737 1741
 	}
... ...
@@ -1749,7 +1762,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
1749 1749
 					Mounts: []mount.Mount{{
1750 1750
 						Type:   "bind",
1751 1751
 						Source: tmpDir,
1752
-						Target: destPath}}},
1752
+						Target: destPath,
1753
+					}},
1754
+				},
1753 1755
 				msg: "",
1754 1756
 			},
1755 1757
 			{
... ...
@@ -1761,7 +1776,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
1761 1761
 						Type:          "bind",
1762 1762
 						Source:        tmpDir,
1763 1763
 						Target:        destPath,
1764
-						VolumeOptions: &mount.VolumeOptions{}}}},
1764
+						VolumeOptions: &mount.VolumeOptions{},
1765
+					}},
1766
+				},
1765 1767
 				msg: "VolumeOptions must not be specified",
1766 1768
 			},
1767 1769
 		}...)
... ...
@@ -1886,7 +1903,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
1886 1886
 				hostConfig: container.HostConfig{
1887 1887
 					Mounts: []mount.Mount{{
1888 1888
 						Type:   "tmpfs",
1889
-						Target: destPath}}},
1889
+						Target: destPath,
1890
+					}},
1891
+				},
1890 1892
 				msg: "",
1891 1893
 			},
1892 1894
 			{
... ...
@@ -1899,8 +1918,10 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
1899 1899
 						Target: destPath,
1900 1900
 						TmpfsOptions: &mount.TmpfsOptions{
1901 1901
 							SizeBytes: 4096 * 1024,
1902
-							Mode:      0700,
1903
-						}}}},
1902
+							Mode:      0o700,
1903
+						},
1904
+					}},
1905
+				},
1904 1906
 				msg: "",
1905 1907
 			},
1906 1908
 			{
... ...
@@ -1911,7 +1932,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsValidation(c *testing.T) {
1911 1911
 					Mounts: []mount.Mount{{
1912 1912
 						Type:   "tmpfs",
1913 1913
 						Source: "/shouldnotbespecified",
1914
-						Target: destPath}}},
1914
+						Target: destPath,
1915
+					}},
1916
+				},
1915 1917
 				msg: "Source must not be specified",
1916 1918
 			},
1917 1919
 		}...)
... ...
@@ -1942,7 +1965,7 @@ func (s *DockerAPISuite) TestContainerAPICreateMountsBindRead(c *testing.T) {
1942 1942
 	tmpDir, err := os.MkdirTemp("", "test-mounts-api-bind")
1943 1943
 	assert.NilError(c, err)
1944 1944
 	defer os.RemoveAll(tmpDir)
1945
-	err = os.WriteFile(filepath.Join(tmpDir, "bar"), []byte("hello"), 0666)
1945
+	err = os.WriteFile(filepath.Join(tmpDir, "bar"), []byte("hello"), 0o666)
1946 1946
 	assert.NilError(c, err)
1947 1947
 	config := container.Config{
1948 1948
 		Image: "busybox",
... ...
@@ -1969,9 +1992,7 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsCreate(c *testing.T) {
1969 1969
 	prefix, slash := getPrefixAndSlashFromDaemonPlatform()
1970 1970
 	destPath := prefix + slash + "foo"
1971 1971
 
1972
-	var (
1973
-		testImg string
1974
-	)
1972
+	var testImg string
1975 1973
 	if testEnv.DaemonInfo.OSType != "windows" {
1976 1974
 		testImg = "test-mount-config"
1977 1975
 		buildImageSuccessfully(c, testImg, build.WithDockerfile(`
... ...
@@ -2184,7 +2205,8 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsTmpfs(c *testing.T) {
2184 2184
 		{
2185 2185
 			cfg: mount.Mount{
2186 2186
 				Type:   "tmpfs",
2187
-				Target: target},
2187
+				Target: target,
2188
+			},
2188 2189
 			expectedOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime"},
2189 2190
 		},
2190 2191
 		{
... ...
@@ -2192,7 +2214,9 @@ func (s *DockerAPISuite) TestContainersAPICreateMountsTmpfs(c *testing.T) {
2192 2192
 				Type:   "tmpfs",
2193 2193
 				Target: target,
2194 2194
 				TmpfsOptions: &mount.TmpfsOptions{
2195
-					SizeBytes: 4096 * 1024, Mode: 0700}},
2195
+					SizeBytes: 4096 * 1024, Mode: 0o700,
2196
+				},
2197
+			},
2196 2198
 			expectedOptions: []string{"rw", "nosuid", "nodev", "noexec", "relatime", "size=4096k", "mode=700"},
2197 2199
 		},
2198 2200
 	}
... ...
@@ -17,8 +17,10 @@ func (s *DockerAPISuite) TestInspectAPIContainerResponse(c *testing.T) {
17 17
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "true")
18 18
 
19 19
 	cleanedContainerID := strings.TrimSpace(out)
20
-	keysBase := []string{"Id", "State", "Created", "Path", "Args", "Config", "Image", "NetworkSettings",
21
-		"ResolvConfPath", "HostnamePath", "HostsPath", "LogPath", "Name", "Driver", "MountLabel", "ProcessLabel", "GraphDriver"}
20
+	keysBase := []string{
21
+		"Id", "State", "Created", "Path", "Args", "Config", "Image", "NetworkSettings",
22
+		"ResolvConfPath", "HostnamePath", "HostsPath", "LogPath", "Name", "Driver", "MountLabel", "ProcessLabel", "GraphDriver",
23
+	}
22 24
 
23 25
 	type acase struct {
24 26
 		version string
... ...
@@ -40,7 +40,7 @@ func (s *DockerAPISuite) TestAPIStatsNoStreamGetCpu(c *testing.T) {
40 40
 	assert.NilError(c, err)
41 41
 	body.Close()
42 42
 
43
-	var cpuPercent = 0.0
43
+	cpuPercent := 0.0
44 44
 
45 45
 	if testEnv.DaemonInfo.OSType != "windows" {
46 46
 		cpuDelta := float64(v.CPUStats.CPUUsage.TotalUsage - v.PreCPUStats.CPUUsage.TotalUsage)
... ...
@@ -732,9 +732,7 @@ func checkClusterHealth(c *testing.T, cl []*daemon.Daemon, managerCount, workerC
732 732
 	var totalMCount, totalWCount int
733 733
 
734 734
 	for _, d := range cl {
735
-		var (
736
-			info swarm.Info
737
-		)
735
+		var info swarm.Info
738 736
 
739 737
 		// check info in a poll.WaitOn(), because if the cluster doesn't have a leader, `info` will return an error
740 738
 		checkInfo := func(c *testing.T) (interface{}, string) {
... ...
@@ -933,9 +933,7 @@ func (s *DockerCLIBuildSuite) TestBuildAddBadLinks(c *testing.T) {
933 933
 		ADD foo.txt /symlink/
934 934
 		`
935 935
 	targetFile := "foo.txt"
936
-	var (
937
-		name = "test-link-absolute"
938
-	)
936
+	name := "test-link-absolute"
939 937
 	ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(dockerfile))
940 938
 	defer ctx.Close()
941 939
 
... ...
@@ -974,7 +972,7 @@ func (s *DockerCLIBuildSuite) TestBuildAddBadLinks(c *testing.T) {
974 974
 		Name:     "symlink",
975 975
 		Typeflag: tar.TypeSymlink,
976 976
 		Linkname: symlinkTarget,
977
-		Mode:     0755,
977
+		Mode:     0o755,
978 978
 		Uid:      0,
979 979
 		Gid:      0,
980 980
 	}
... ...
@@ -1061,7 +1059,7 @@ func (s *DockerCLIBuildSuite) TestBuildWithInaccessibleFilesInContext(c *testing
1061 1061
 		if err := os.Chown(pathToFileWithoutReadAccess, 0, 0); err != nil {
1062 1062
 			c.Fatalf("failed to chown file to root: %s", err)
1063 1063
 		}
1064
-		if err := os.Chmod(pathToFileWithoutReadAccess, 0700); err != nil {
1064
+		if err := os.Chmod(pathToFileWithoutReadAccess, 0o700); err != nil {
1065 1065
 			c.Fatalf("failed to chmod file to 700: %s", err)
1066 1066
 		}
1067 1067
 		result := icmd.RunCmd(icmd.Cmd{
... ...
@@ -1095,10 +1093,10 @@ func (s *DockerCLIBuildSuite) TestBuildWithInaccessibleFilesInContext(c *testing
1095 1095
 		if err := os.Chown(pathToDirectoryWithoutReadAccess, 0, 0); err != nil {
1096 1096
 			c.Fatalf("failed to chown directory to root: %s", err)
1097 1097
 		}
1098
-		if err := os.Chmod(pathToDirectoryWithoutReadAccess, 0444); err != nil {
1098
+		if err := os.Chmod(pathToDirectoryWithoutReadAccess, 0o444); err != nil {
1099 1099
 			c.Fatalf("failed to chmod directory to 444: %s", err)
1100 1100
 		}
1101
-		if err := os.Chmod(pathToFileInDirectoryWithoutReadAccess, 0700); err != nil {
1101
+		if err := os.Chmod(pathToFileInDirectoryWithoutReadAccess, 0o700); err != nil {
1102 1102
 			c.Fatalf("failed to chmod file to 700: %s", err)
1103 1103
 		}
1104 1104
 
... ...
@@ -1149,17 +1147,19 @@ func (s *DockerCLIBuildSuite) TestBuildWithInaccessibleFilesInContext(c *testing
1149 1149
 		if err := os.Chown(pathToDirectoryWithoutReadAccess, 0, 0); err != nil {
1150 1150
 			c.Fatalf("failed to chown directory to root: %s", err)
1151 1151
 		}
1152
-		if err := os.Chmod(pathToDirectoryWithoutReadAccess, 0444); err != nil {
1152
+		if err := os.Chmod(pathToDirectoryWithoutReadAccess, 0o444); err != nil {
1153 1153
 			c.Fatalf("failed to chmod directory to 444: %s", err)
1154 1154
 		}
1155
-		if err := os.Chmod(pathToFileInDirectoryWithoutReadAccess, 0700); err != nil {
1155
+		if err := os.Chmod(pathToFileInDirectoryWithoutReadAccess, 0o700); err != nil {
1156 1156
 			c.Fatalf("failed to chmod file to 700: %s", err)
1157 1157
 		}
1158 1158
 
1159 1159
 		result := icmd.RunCmd(icmd.Cmd{
1160 1160
 			Dir: ctx.Dir,
1161
-			Command: []string{"su", "unprivilegeduser", "-c",
1162
-				fmt.Sprintf("%s build -t %s .", dockerBinary, name)},
1161
+			Command: []string{
1162
+				"su", "unprivilegeduser", "-c",
1163
+				fmt.Sprintf("%s build -t %s .", dockerBinary, name),
1164
+			},
1163 1165
 		})
1164 1166
 		result.Assert(c, icmd.Expected{})
1165 1167
 	}
... ...
@@ -2061,7 +2061,7 @@ func (s *DockerCLIBuildSuite) TestBuildDockerfileStdin(c *testing.T) {
2061 2061
 	name := "stdindockerfile"
2062 2062
 	tmpDir, err := os.MkdirTemp("", "fake-context")
2063 2063
 	assert.NilError(c, err)
2064
-	err = os.WriteFile(filepath.Join(tmpDir, "foo"), []byte("bar"), 0600)
2064
+	err = os.WriteFile(filepath.Join(tmpDir, "foo"), []byte("bar"), 0o600)
2065 2065
 	assert.NilError(c, err)
2066 2066
 
2067 2067
 	icmd.RunCmd(icmd.Cmd{
... ...
@@ -2106,7 +2106,7 @@ func (s *DockerCLIBuildSuite) testBuildDockerfileStdinNoExtraFiles(c *testing.T,
2106 2106
 	defer os.RemoveAll(tmpDir)
2107 2107
 
2108 2108
 	writeFile := func(filename, content string) {
2109
-		err = os.WriteFile(filepath.Join(tmpDir, filename), []byte(content), 0600)
2109
+		err = os.WriteFile(filepath.Join(tmpDir, filename), []byte(content), 0o600)
2110 2110
 		assert.NilError(c, err)
2111 2111
 	}
2112 2112
 
... ...
@@ -2856,7 +2856,7 @@ RUN cat /existing-directory-trailing-slash/test/foo | grep Hi`
2856 2856
 			c.Fatalf("failed to close tar archive: %v", err)
2857 2857
 		}
2858 2858
 
2859
-		if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0644); err != nil {
2859
+		if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0o644); err != nil {
2860 2860
 			c.Fatalf("failed to open destination dockerfile: %v", err)
2861 2861
 		}
2862 2862
 		return fakecontext.New(c, tmpDir)
... ...
@@ -2905,7 +2905,7 @@ ADD test.tar /`
2905 2905
 			c.Fatalf("failed to truncate tar archive: %v", err)
2906 2906
 		}
2907 2907
 
2908
-		if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0644); err != nil {
2908
+		if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0o644); err != nil {
2909 2909
 			c.Fatalf("failed to open destination dockerfile: %v", err)
2910 2910
 		}
2911 2911
 		return fakecontext.New(c, tmpDir)
... ...
@@ -2968,7 +2968,7 @@ func (s *DockerCLIBuildSuite) TestBuildAddTarXz(c *testing.T) {
2968 2968
 			Command: []string{"xz", "-k", "test.tar"},
2969 2969
 			Dir:     tmpDir,
2970 2970
 		}).Assert(c, icmd.Success)
2971
-		if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0644); err != nil {
2971
+		if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0o644); err != nil {
2972 2972
 			c.Fatalf("failed to open destination dockerfile: %v", err)
2973 2973
 		}
2974 2974
 		return fakecontext.New(c, tmpDir)
... ...
@@ -3020,7 +3020,7 @@ func (s *DockerCLIBuildSuite) TestBuildAddTarXzGz(c *testing.T) {
3020 3020
 			Command: []string{"gzip", "test.tar.xz"},
3021 3021
 			Dir:     tmpDir,
3022 3022
 		})
3023
-		if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0644); err != nil {
3023
+		if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0o644); err != nil {
3024 3024
 			c.Fatalf("failed to open destination dockerfile: %v", err)
3025 3025
 		}
3026 3026
 		return fakecontext.New(c, tmpDir)
... ...
@@ -3587,18 +3587,18 @@ func (s *DockerCLIBuildSuite) TestBuildSymlinkBreakout(c *testing.T) {
3587 3587
 
3588 3588
 	defer os.RemoveAll(tmpdir)
3589 3589
 	ctx := filepath.Join(tmpdir, "context")
3590
-	if err := os.MkdirAll(ctx, 0755); err != nil {
3590
+	if err := os.MkdirAll(ctx, 0o755); err != nil {
3591 3591
 		c.Fatal(err)
3592 3592
 	}
3593 3593
 	if err := os.WriteFile(filepath.Join(ctx, "Dockerfile"), []byte(`
3594 3594
 	from busybox
3595 3595
 	add symlink.tar /
3596 3596
 	add inject /symlink/
3597
-	`), 0644); err != nil {
3597
+	`), 0o644); err != nil {
3598 3598
 		c.Fatal(err)
3599 3599
 	}
3600 3600
 	inject := filepath.Join(ctx, "inject")
3601
-	if err := os.WriteFile(inject, nil, 0644); err != nil {
3601
+	if err := os.WriteFile(inject, nil, 0o644); err != nil {
3602 3602
 		c.Fatal(err)
3603 3603
 	}
3604 3604
 	f, err := os.Create(filepath.Join(ctx, "symlink.tar"))
... ...
@@ -4747,7 +4747,7 @@ func (s *DockerCLIBuildSuite) TestBuildCacheBrokenSymlink(c *testing.T) {
4747 4747
 	cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
4748 4748
 
4749 4749
 	// add new file to context, should invalidate cache
4750
-	err = os.WriteFile(filepath.Join(ctx.Dir, "newfile"), []byte("foo"), 0644)
4750
+	err = os.WriteFile(filepath.Join(ctx.Dir, "newfile"), []byte("foo"), 0o644)
4751 4751
 	assert.NilError(c, err)
4752 4752
 
4753 4753
 	result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
... ...
@@ -4776,14 +4776,13 @@ func (s *DockerCLIBuildSuite) TestBuildFollowSymlinkToFile(c *testing.T) {
4776 4776
 	assert.Assert(c, cmp.Regexp("^bar$", out))
4777 4777
 
4778 4778
 	// change target file should invalidate cache
4779
-	err = os.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("baz"), 0644)
4779
+	err = os.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("baz"), 0o644)
4780 4780
 	assert.NilError(c, err)
4781 4781
 
4782 4782
 	result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
4783 4783
 	assert.Assert(c, !strings.Contains(result.Combined(), "Using cache"))
4784 4784
 	out = cli.DockerCmd(c, "run", "--rm", name, "cat", "target").Combined()
4785 4785
 	assert.Assert(c, cmp.Regexp("^baz$", out))
4786
-
4787 4786
 }
4788 4787
 
4789 4788
 func (s *DockerCLIBuildSuite) TestBuildFollowSymlinkToDir(c *testing.T) {
... ...
@@ -4807,7 +4806,7 @@ func (s *DockerCLIBuildSuite) TestBuildFollowSymlinkToDir(c *testing.T) {
4807 4807
 	assert.Assert(c, cmp.Regexp("^barbaz$", out))
4808 4808
 
4809 4809
 	// change target file should invalidate cache
4810
-	err = os.WriteFile(filepath.Join(ctx.Dir, "foo/def"), []byte("bax"), 0644)
4810
+	err = os.WriteFile(filepath.Join(ctx.Dir, "foo/def"), []byte("bax"), 0o644)
4811 4811
 	assert.NilError(c, err)
4812 4812
 
4813 4813
 	result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
... ...
@@ -4854,7 +4853,7 @@ func (s *DockerCLIBuildSuite) TestBuildCacheRootSource(c *testing.T) {
4854 4854
 	cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
4855 4855
 
4856 4856
 	// change file, should invalidate cache
4857
-	err := os.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("baz"), 0644)
4857
+	err := os.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("baz"), 0o644)
4858 4858
 	assert.NilError(c, err)
4859 4859
 
4860 4860
 	result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
... ...
@@ -5004,7 +5003,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestBuildWithExternalAuth(c *testing.T
5004 5004
 	externalAuthConfig := `{ "credsStore": "shell-test" }`
5005 5005
 
5006 5006
 	configPath := filepath.Join(tmp, "config.json")
5007
-	err = os.WriteFile(configPath, []byte(externalAuthConfig), 0644)
5007
+	err = os.WriteFile(configPath, []byte(externalAuthConfig), 0o644)
5008 5008
 	assert.NilError(c, err)
5009 5009
 
5010 5010
 	dockerCmd(c, "--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
... ...
@@ -5464,7 +5463,7 @@ func (s *DockerCLIBuildSuite) TestBuildCacheFrom(c *testing.T) {
5464 5464
 		ENV FOO=bar
5465 5465
 		ADD baz /
5466 5466
 		RUN touch newfile`
5467
-	err = os.WriteFile(filepath.Join(ctx.Dir, "Dockerfile"), []byte(dockerfile), 0644)
5467
+	err = os.WriteFile(filepath.Join(ctx.Dir, "Dockerfile"), []byte(dockerfile), 0o644)
5468 5468
 	assert.NilError(c, err)
5469 5469
 
5470 5470
 	result = cli.BuildCmd(c, "build2", cli.WithFlags("--cache-from=build1"), build.WithExternalBuildContext(ctx))
... ...
@@ -5621,14 +5620,14 @@ func (s *DockerCLIBuildSuite) TestBuildMultiStageCopyFromSyntax(c *testing.T) {
5621 5621
 	assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 7)
5622 5622
 	assert.Equal(c, getIDByName(c, "build1"), getIDByName(c, "build2"))
5623 5623
 
5624
-	err := os.WriteFile(filepath.Join(ctx.Dir, "Dockerfile"), []byte(fmt.Sprintf(dockerfile, "COPY baz/aa foo")), 0644)
5624
+	err := os.WriteFile(filepath.Join(ctx.Dir, "Dockerfile"), []byte(fmt.Sprintf(dockerfile, "COPY baz/aa foo")), 0o644)
5625 5625
 	assert.NilError(c, err)
5626 5626
 
5627 5627
 	// changing file in parent block should not affect last block
5628 5628
 	result = cli.BuildCmd(c, "build3", build.WithExternalBuildContext(ctx))
5629 5629
 	assert.Equal(c, strings.Count(result.Combined(), "Using cache"), 5)
5630 5630
 
5631
-	err = os.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("pqr"), 0644)
5631
+	err = os.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("pqr"), 0o644)
5632 5632
 	assert.NilError(c, err)
5633 5633
 
5634 5634
 	// changing file in parent block should affect both first and last block
... ...
@@ -6145,7 +6144,7 @@ func (s *DockerCLIBuildSuite) TestBuildIidFileCleanupOnFail(c *testing.T) {
6145 6145
 	defer os.RemoveAll(tmpDir)
6146 6146
 	tmpIidFile := filepath.Join(tmpDir, "iid")
6147 6147
 
6148
-	err = os.WriteFile(tmpIidFile, []byte("Dummy"), 0666)
6148
+	err = os.WriteFile(tmpIidFile, []byte("Dummy"), 0o666)
6149 6149
 	assert.NilError(c, err)
6150 6150
 
6151 6151
 	cli.Docker(cli.Args("build", "-t", "testbuildiidfilecleanuponfail"),
... ...
@@ -107,7 +107,7 @@ func (s *DockerCLIBuildSuite) TestBuildAddChangeOwnership(c *testing.T) {
107 107
 			Dir:     tmpDir,
108 108
 		}).Assert(c, icmd.Success)
109 109
 
110
-		if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0644); err != nil {
110
+		if err := os.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0o644); err != nil {
111 111
 			c.Fatalf("failed to open destination dockerfile: %v", err)
112 112
 		}
113 113
 		return fakecontext.New(c, tmpDir)
... ...
@@ -182,7 +182,7 @@ func (s *DockerCLICpSuite) TestCpFromCaseD(c *testing.T) {
182 182
 	// Now try again but using a trailing path separator for dstDir.
183 183
 
184 184
 	assert.NilError(c, os.RemoveAll(dstDir), "unable to remove dstDir")
185
-	assert.NilError(c, os.MkdirAll(dstDir, os.FileMode(0755)), "unable to make dstDir")
185
+	assert.NilError(c, os.MkdirAll(dstDir, os.FileMode(0o755)), "unable to make dstDir")
186 186
 
187 187
 	dstDir = cpPathTrailingSep(tmpDir, "dir1")
188 188
 
... ...
@@ -268,7 +268,7 @@ func (s *DockerCLICpSuite) TestCpFromCaseG(c *testing.T) {
268 268
 	// Now try again but using a trailing path separator for dstDir.
269 269
 
270 270
 	assert.NilError(c, os.RemoveAll(dstDir), "unable to remove dstDir")
271
-	assert.NilError(c, os.MkdirAll(dstDir, os.FileMode(0755)), "unable to make dstDir")
271
+	assert.NilError(c, os.MkdirAll(dstDir, os.FileMode(0o755)), "unable to make dstDir")
272 272
 
273 273
 	dstDir = cpPathTrailingSep(tmpDir, "dir2")
274 274
 
... ...
@@ -354,7 +354,7 @@ func (s *DockerCLICpSuite) TestCpFromCaseJ(c *testing.T) {
354 354
 	// Now try again but using a trailing path separator for dstDir.
355 355
 
356 356
 	assert.NilError(c, os.RemoveAll(dstDir), "unable to remove dstDir")
357
-	assert.NilError(c, os.MkdirAll(dstDir, os.FileMode(0755)), "unable to make dstDir")
357
+	assert.NilError(c, os.MkdirAll(dstDir, os.FileMode(0o755)), "unable to make dstDir")
358 358
 
359 359
 	dstDir = cpPathTrailingSep(tmpDir, "dir2")
360 360
 
... ...
@@ -265,8 +265,8 @@ func (s *DockerCLICpSuite) TestCpToSymlinkToDirectory(c *testing.T) {
265 265
 	// This file will be at "/testDir/some/path/test" and will be copied into
266 266
 	// the test volume later.
267 267
 	hostTestFilename := filepath.Join(testDir, cpFullPath)
268
-	assert.NilError(c, os.MkdirAll(filepath.Dir(hostTestFilename), os.FileMode(0700)))
269
-	assert.NilError(c, os.WriteFile(hostTestFilename, []byte(cpHostContents), os.FileMode(0600)))
268
+	assert.NilError(c, os.MkdirAll(filepath.Dir(hostTestFilename), os.FileMode(0o700)))
269
+	assert.NilError(c, os.WriteFile(hostTestFilename, []byte(cpHostContents), os.FileMode(0o600)))
270 270
 
271 271
 	// Now create another temp directory to hold a symlink to the
272 272
 	// "/testDir/some" directory.
... ...
@@ -375,7 +375,7 @@ func (s *DockerCLICpSuite) TestCpUnprivilegedUser(c *testing.T) {
375 375
 
376 376
 	defer os.RemoveAll(tmpdir)
377 377
 
378
-	err = os.Chmod(tmpdir, 0777)
378
+	err = os.Chmod(tmpdir, 0o777)
379 379
 	assert.NilError(c, err)
380 380
 
381 381
 	result := icmd.RunCommand("su", "unprivilegeduser", "-c",
... ...
@@ -59,33 +59,33 @@ func mkFilesCommand(fds []fileData) string {
59 59
 }
60 60
 
61 61
 var defaultFileData = []fileData{
62
-	{ftRegular, "file1", "file1", 0, 0, 0666},
63
-	{ftRegular, "file2", "file2", 0, 0, 0666},
64
-	{ftRegular, "file3", "file3", 0, 0, 0666},
65
-	{ftRegular, "file4", "file4", 0, 0, 0666},
66
-	{ftRegular, "file5", "file5", 0, 0, 0666},
67
-	{ftRegular, "file6", "file6", 0, 0, 0666},
68
-	{ftRegular, "file7", "file7", 0, 0, 0666},
69
-	{ftDir, "dir1", "", 0, 0, 0777},
70
-	{ftRegular, "dir1/file1-1", "file1-1", 0, 0, 0666},
71
-	{ftRegular, "dir1/file1-2", "file1-2", 0, 0, 0666},
72
-	{ftDir, "dir2", "", 0, 0, 0666},
73
-	{ftRegular, "dir2/file2-1", "file2-1", 0, 0, 0666},
74
-	{ftRegular, "dir2/file2-2", "file2-2", 0, 0, 0666},
75
-	{ftDir, "dir3", "", 0, 0, 0666},
76
-	{ftRegular, "dir3/file3-1", "file3-1", 0, 0, 0666},
77
-	{ftRegular, "dir3/file3-2", "file3-2", 0, 0, 0666},
78
-	{ftDir, "dir4", "", 0, 0, 0666},
79
-	{ftRegular, "dir4/file3-1", "file4-1", 0, 0, 0666},
80
-	{ftRegular, "dir4/file3-2", "file4-2", 0, 0, 0666},
81
-	{ftDir, "dir5", "", 0, 0, 0666},
82
-	{ftSymlink, "symlinkToFile1", "file1", 0, 0, 0666},
83
-	{ftSymlink, "symlinkToDir1", "dir1", 0, 0, 0666},
84
-	{ftSymlink, "brokenSymlinkToFileX", "fileX", 0, 0, 0666},
85
-	{ftSymlink, "brokenSymlinkToDirX", "dirX", 0, 0, 0666},
86
-	{ftSymlink, "symlinkToAbsDir", "/root", 0, 0, 0666},
87
-	{ftDir, "permdirtest", "", 2, 2, 0700},
88
-	{ftRegular, "permdirtest/permtest", "perm_test", 65534, 65534, 0400},
62
+	{ftRegular, "file1", "file1", 0, 0, 0o666},
63
+	{ftRegular, "file2", "file2", 0, 0, 0o666},
64
+	{ftRegular, "file3", "file3", 0, 0, 0o666},
65
+	{ftRegular, "file4", "file4", 0, 0, 0o666},
66
+	{ftRegular, "file5", "file5", 0, 0, 0o666},
67
+	{ftRegular, "file6", "file6", 0, 0, 0o666},
68
+	{ftRegular, "file7", "file7", 0, 0, 0o666},
69
+	{ftDir, "dir1", "", 0, 0, 0o777},
70
+	{ftRegular, "dir1/file1-1", "file1-1", 0, 0, 0o666},
71
+	{ftRegular, "dir1/file1-2", "file1-2", 0, 0, 0o666},
72
+	{ftDir, "dir2", "", 0, 0, 0o666},
73
+	{ftRegular, "dir2/file2-1", "file2-1", 0, 0, 0o666},
74
+	{ftRegular, "dir2/file2-2", "file2-2", 0, 0, 0o666},
75
+	{ftDir, "dir3", "", 0, 0, 0o666},
76
+	{ftRegular, "dir3/file3-1", "file3-1", 0, 0, 0o666},
77
+	{ftRegular, "dir3/file3-2", "file3-2", 0, 0, 0o666},
78
+	{ftDir, "dir4", "", 0, 0, 0o666},
79
+	{ftRegular, "dir4/file3-1", "file4-1", 0, 0, 0o666},
80
+	{ftRegular, "dir4/file3-2", "file4-2", 0, 0, 0o666},
81
+	{ftDir, "dir5", "", 0, 0, 0o666},
82
+	{ftSymlink, "symlinkToFile1", "file1", 0, 0, 0o666},
83
+	{ftSymlink, "symlinkToDir1", "dir1", 0, 0, 0o666},
84
+	{ftSymlink, "brokenSymlinkToFileX", "fileX", 0, 0, 0o666},
85
+	{ftSymlink, "brokenSymlinkToDirX", "dirX", 0, 0, 0o666},
86
+	{ftSymlink, "symlinkToAbsDir", "/root", 0, 0, 0o666},
87
+	{ftDir, "permdirtest", "", 2, 2, 0o700},
88
+	{ftRegular, "permdirtest/permtest", "perm_test", 65534, 65534, 0o400},
89 89
 }
90 90
 
91 91
 func defaultMkContentCommand() string {
... ...
@@ -2215,7 +2215,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) {
2215 2215
     }
2216 2216
 }
2217 2217
 `
2218
-	os.WriteFile(configName, []byte(config), 0644)
2218
+	os.WriteFile(configName, []byte(config), 0o644)
2219 2219
 	s.d.StartWithBusybox(c, "--config-file", configName)
2220 2220
 
2221 2221
 	// Run with default runtime
... ...
@@ -2241,7 +2241,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) {
2241 2241
     }
2242 2242
 }
2243 2243
 `
2244
-	os.WriteFile(configName, []byte(config), 0644)
2244
+	os.WriteFile(configName, []byte(config), 0o644)
2245 2245
 	assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
2246 2246
 	// Give daemon time to reload config
2247 2247
 	<-time.After(1 * time.Second)
... ...
@@ -2268,7 +2268,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) {
2268 2268
     }
2269 2269
 }
2270 2270
 `
2271
-	os.WriteFile(configName, []byte(config), 0644)
2271
+	os.WriteFile(configName, []byte(config), 0o644)
2272 2272
 	assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
2273 2273
 	// Give daemon time to reload config
2274 2274
 	<-time.After(1 * time.Second)
... ...
@@ -2293,7 +2293,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *testing.T) {
2293 2293
     }
2294 2294
 }
2295 2295
 `
2296
-	os.WriteFile(configName, []byte(config), 0644)
2296
+	os.WriteFile(configName, []byte(config), 0o644)
2297 2297
 	assert.Assert(c, s.d.Signal(unix.SIGHUP) == nil)
2298 2298
 	// Give daemon time to reload config
2299 2299
 	<-time.After(1 * time.Second)
... ...
@@ -2654,7 +2654,7 @@ func (s *DockerDaemonSuite) TestShmSizeReload(c *testing.T) {
2654 2654
 
2655 2655
 	size := 67108864 * 2
2656 2656
 	configData := []byte(fmt.Sprintf(`{"default-shm-size": "%dM"}`, size/1024/1024))
2657
-	assert.Assert(c, os.WriteFile(configFile, configData, 0666) == nil, "could not write temp file for config reload")
2657
+	assert.Assert(c, os.WriteFile(configFile, configData, 0o666) == nil, "could not write temp file for config reload")
2658 2658
 	pattern := regexp.MustCompile(fmt.Sprintf("shm on /dev/shm type tmpfs(.*)size=%dk", size/1024))
2659 2659
 
2660 2660
 	s.d.StartWithBusybox(c, "--config-file", configFile)
... ...
@@ -2669,7 +2669,7 @@ func (s *DockerDaemonSuite) TestShmSizeReload(c *testing.T) {
2669 2669
 
2670 2670
 	size = 67108864 * 3
2671 2671
 	configData = []byte(fmt.Sprintf(`{"default-shm-size": "%dM"}`, size/1024/1024))
2672
-	assert.Assert(c, os.WriteFile(configFile, configData, 0666) == nil, "could not write temp file for config reload")
2672
+	assert.Assert(c, os.WriteFile(configFile, configData, 0o666) == nil, "could not write temp file for config reload")
2673 2673
 	pattern = regexp.MustCompile(fmt.Sprintf("shm on /dev/shm type tmpfs(.*)size=%dk", size/1024))
2674 2674
 
2675 2675
 	err = s.d.ReloadConfig()
... ...
@@ -395,14 +395,14 @@ func (s *DockerDaemonSuite) TestDaemonEvents(c *testing.T) {
395 395
 	defer os.Remove(configFilePath)
396 396
 
397 397
 	daemonConfig := `{"labels":["foo=bar"]}`
398
-	err := os.WriteFile(configFilePath, []byte(daemonConfig), 0644)
398
+	err := os.WriteFile(configFilePath, []byte(daemonConfig), 0o644)
399 399
 	assert.NilError(c, err)
400 400
 	s.d.Start(c, "--config-file="+configFilePath)
401 401
 
402 402
 	info := s.d.Info(c)
403 403
 
404 404
 	daemonConfig = `{"max-concurrent-downloads":1,"labels":["bar=foo"], "shutdown-timeout": 10}`
405
-	err = os.WriteFile(configFilePath, []byte(daemonConfig), 0644)
405
+	err = os.WriteFile(configFilePath, []byte(daemonConfig), 0o644)
406 406
 	assert.NilError(c, err)
407 407
 
408 408
 	assert.NilError(c, s.d.Signal(unix.SIGHUP))
... ...
@@ -442,7 +442,7 @@ func (s *DockerDaemonSuite) TestDaemonEventsWithFilters(c *testing.T) {
442 442
 	defer os.Remove(configFilePath)
443 443
 
444 444
 	daemonConfig := `{"labels":["foo=bar"]}`
445
-	err := os.WriteFile(configFilePath, []byte(daemonConfig), 0644)
445
+	err := os.WriteFile(configFilePath, []byte(daemonConfig), 0o644)
446 446
 	assert.NilError(c, err)
447 447
 	s.d.Start(c, "--config-file="+configFilePath)
448 448
 
... ...
@@ -408,7 +408,7 @@ func (s *DockerCLIExecSuite) TestRunMutableNetworkFiles(c *testing.T) {
408 408
 		contID := strings.TrimSpace(out)
409 409
 		netFilePath := containerStorageFile(contID, fn)
410 410
 
411
-		f, err := os.OpenFile(netFilePath, os.O_WRONLY|os.O_SYNC|os.O_APPEND, 0644)
411
+		f, err := os.OpenFile(netFilePath, os.O_WRONLY|os.O_SYNC|os.O_APPEND, 0o644)
412 412
 		assert.NilError(c, err)
413 413
 
414 414
 		if _, err := f.Seek(0, 0); err != nil {
... ...
@@ -216,17 +216,17 @@ func newVolumePlugin(c *testing.T, name string) *volumePlugin {
216 216
 		}
217 217
 
218 218
 		p := hostVolumePath(pr.Name)
219
-		if err := os.MkdirAll(p, 0755); err != nil {
219
+		if err := os.MkdirAll(p, 0o755); err != nil {
220 220
 			send(w, &pluginResp{Err: err.Error()})
221 221
 			return
222 222
 		}
223 223
 
224
-		if err := os.WriteFile(filepath.Join(p, "test"), []byte(s.Server.URL), 0644); err != nil {
224
+		if err := os.WriteFile(filepath.Join(p, "test"), []byte(s.Server.URL), 0o644); err != nil {
225 225
 			send(w, err)
226 226
 			return
227 227
 		}
228 228
 
229
-		if err := os.WriteFile(filepath.Join(p, "mountID"), []byte(pr.ID), 0644); err != nil {
229
+		if err := os.WriteFile(filepath.Join(p, "mountID"), []byte(pr.ID), 0o644); err != nil {
230 230
 			send(w, err)
231 231
 			return
232 232
 		}
... ...
@@ -258,10 +258,10 @@ func newVolumePlugin(c *testing.T, name string) *volumePlugin {
258 258
 		send(w, `{"Capabilities": { "Scope": "global" }}`)
259 259
 	})
260 260
 
261
-	err := os.MkdirAll("/etc/docker/plugins", 0755)
261
+	err := os.MkdirAll("/etc/docker/plugins", 0o755)
262 262
 	assert.NilError(c, err)
263 263
 
264
-	err = os.WriteFile("/etc/docker/plugins/"+name+".spec", []byte(s.Server.URL), 0644)
264
+	err = os.WriteFile("/etc/docker/plugins/"+name+".spec", []byte(s.Server.URL), 0o644)
265 265
 	assert.NilError(c, err)
266 266
 	return s
267 267
 }
... ...
@@ -360,7 +360,7 @@ func hostVolumePath(name string) string {
360 360
 // Make sure a request to use a down driver doesn't block other requests
361 361
 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverLookupNotBlocked(c *testing.T) {
362 362
 	specPath := "/etc/docker/plugins/down-driver.spec"
363
-	err := os.WriteFile(specPath, []byte("tcp://127.0.0.7:9999"), 0644)
363
+	err := os.WriteFile(specPath, []byte("tcp://127.0.0.7:9999"), 0o644)
364 364
 	assert.NilError(c, err)
365 365
 	defer os.RemoveAll(specPath)
366 366
 
... ...
@@ -367,7 +367,7 @@ func (s *DockerCLIImagesSuite) TestImagesFormatDefaultFormat(c *testing.T) {
367 367
 	assert.NilError(c, err)
368 368
 	defer os.RemoveAll(d)
369 369
 
370
-	err = os.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0644)
370
+	err = os.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0o644)
371 371
 	assert.NilError(c, err)
372 372
 
373 373
 	out, _ = dockerCmd(c, "--config", d, "images", "-q", "myimage")
... ...
@@ -110,7 +110,7 @@ func (s *DockerCLILinksSuite) TestLinksInspectLinksStarted(c *testing.T) {
110 110
 	err := json.Unmarshal([]byte(links), &result)
111 111
 	assert.NilError(c, err)
112 112
 
113
-	var expected = []string{
113
+	expected := []string{
114 114
 		"/container1:/testinspectlink/alias1",
115 115
 		"/container2:/testinspectlink/alias2",
116 116
 	}
... ...
@@ -130,7 +130,7 @@ func (s *DockerCLILinksSuite) TestLinksInspectLinksStopped(c *testing.T) {
130 130
 	err := json.Unmarshal([]byte(links), &result)
131 131
 	assert.NilError(c, err)
132 132
 
133
-	var expected = []string{
133
+	expected := []string{
134 134
 		"/container1:/testinspectlink/alias1",
135 135
 		"/container2:/testinspectlink/alias2",
136 136
 	}
... ...
@@ -33,7 +33,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithExternalAuth(c *testing.
33 33
 	externalAuthConfig := `{ "credsStore": "shell-test" }`
34 34
 
35 35
 	configPath := filepath.Join(tmp, "config.json")
36
-	err = os.WriteFile(configPath, []byte(externalAuthConfig), 0644)
36
+	err = os.WriteFile(configPath, []byte(externalAuthConfig), 0o644)
37 37
 	assert.NilError(c, err)
38 38
 
39 39
 	_, err = s.d.Cmd("--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
... ...
@@ -83,7 +83,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestLogoutWithWrongHostnamesStored(c *
83 83
 	externalAuthConfig := fmt.Sprintf(`{ "auths": {"https://%s": {}}, "credsStore": "shell-test" }`, privateRegistryURL)
84 84
 
85 85
 	configPath := filepath.Join(tmp, "config.json")
86
-	err = os.WriteFile(configPath, []byte(externalAuthConfig), 0644)
86
+	err = os.WriteFile(configPath, []byte(externalAuthConfig), 0o644)
87 87
 	assert.NilError(c, err)
88 88
 
89 89
 	dockerCmd(c, "--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
... ...
@@ -31,8 +31,10 @@ import (
31 31
 	"gotest.tools/v3/icmd"
32 32
 )
33 33
 
34
-const dummyNetworkDriver = "dummy-network-driver"
35
-const dummyIPAMDriver = "dummy-ipam-driver"
34
+const (
35
+	dummyNetworkDriver = "dummy-network-driver"
36
+	dummyIPAMDriver    = "dummy-ipam-driver"
37
+)
36 38
 
37 39
 var remoteDriverNetworkRequest remoteapi.CreateNetworkRequest
38 40
 
... ...
@@ -90,7 +92,8 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip
90 90
 		w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
91 91
 
92 92
 		veth := &netlink.Veth{
93
-			LinkAttrs: netlink.LinkAttrs{Name: "randomIfName", TxQLen: 0}, PeerName: "cnt0"}
93
+			LinkAttrs: netlink.LinkAttrs{Name: "randomIfName", TxQLen: 0}, PeerName: "cnt0",
94
+		}
94 95
 		if err := netlink.LinkAdd(veth); err != nil {
95 96
 			fmt.Fprintf(w, `{"Error":"failed to add veth pair: `+err.Error()+`"}`)
96 97
 		} else {
... ...
@@ -194,15 +197,15 @@ func setupRemoteNetworkDrivers(c *testing.T, mux *http.ServeMux, url, netDrv, ip
194 194
 		}
195 195
 	})
196 196
 
197
-	err := os.MkdirAll("/etc/docker/plugins", 0755)
197
+	err := os.MkdirAll("/etc/docker/plugins", 0o755)
198 198
 	assert.NilError(c, err)
199 199
 
200 200
 	fileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", netDrv)
201
-	err = os.WriteFile(fileName, []byte(url), 0644)
201
+	err = os.WriteFile(fileName, []byte(url), 0o644)
202 202
 	assert.NilError(c, err)
203 203
 
204 204
 	ipamFileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", ipamDrv)
205
-	err = os.WriteFile(ipamFileName, []byte(url), 0644)
205
+	err = os.WriteFile(ipamFileName, []byte(url), 0o644)
206 206
 	assert.NilError(c, err)
207 207
 }
208 208
 
... ...
@@ -261,10 +261,10 @@ func (ps *DockerPluginSuite) TestPluginCreate(c *testing.T) {
261 261
 	defer os.RemoveAll(temp)
262 262
 
263 263
 	data := `{"description": "foo plugin"}`
264
-	err = os.WriteFile(filepath.Join(temp, "config.json"), []byte(data), 0644)
264
+	err = os.WriteFile(filepath.Join(temp, "config.json"), []byte(data), 0o644)
265 265
 	assert.NilError(c, err)
266 266
 
267
-	err = os.MkdirAll(filepath.Join(temp, "rootfs"), 0700)
267
+	err = os.MkdirAll(filepath.Join(temp, "rootfs"), 0o700)
268 268
 	assert.NilError(c, err)
269 269
 
270 270
 	out, _, err := dockerCmdWithError("plugin", "create", name, temp)
... ...
@@ -400,7 +400,7 @@ func (ps *DockerPluginSuite) TestPluginListDefaultFormat(c *testing.T) {
400 400
 	assert.NilError(c, err)
401 401
 	defer os.RemoveAll(config)
402 402
 
403
-	err = os.WriteFile(filepath.Join(config, "config.json"), []byte(`{"pluginsFormat": "raw"}`), 0644)
403
+	err = os.WriteFile(filepath.Join(config, "config.json"), []byte(`{"pluginsFormat": "raw"}`), 0o644)
404 404
 	assert.NilError(c, err)
405 405
 
406 406
 	name := "test:latest"
... ...
@@ -156,7 +156,7 @@ func (s *DockerCLIPruneSuite) TestPruneContainerLabel(c *testing.T) {
156 156
 	d, err := os.MkdirTemp("", "integration-cli-")
157 157
 	assert.NilError(c, err)
158 158
 	defer os.RemoveAll(d)
159
-	err = os.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0644)
159
+	err = os.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0o644)
160 160
 	assert.NilError(c, err)
161 161
 
162 162
 	// With config.json only, prune based on label=foobar
... ...
@@ -208,7 +208,7 @@ func (s *DockerCLIPruneSuite) TestPruneVolumeLabel(c *testing.T) {
208 208
 	d, err := os.MkdirTemp("", "integration-cli-")
209 209
 	assert.NilError(c, err)
210 210
 	defer os.RemoveAll(d)
211
-	err = os.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0644)
211
+	err = os.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0o644)
212 212
 	assert.NilError(c, err)
213 213
 
214 214
 	// With config.json only, prune based on label=foobar
... ...
@@ -356,7 +356,7 @@ func (s *DockerCLIPsSuite) TestPsListContainersFilterAncestorImage(c *testing.T)
356 356
 	dockerCmd(c, "run", "--name=fifth", imageName2, "echo", "hello")
357 357
 	fifthID := getIDByName(c, "fifth")
358 358
 
359
-	var filterTestSuite = []struct {
359
+	filterTestSuite := []struct {
360 360
 		filterName  string
361 361
 		expectedIDs []string
362 362
 	}{
... ...
@@ -329,23 +329,23 @@ func (s *DockerRegistrySuite) TestPullManifestList(c *testing.T) {
329 329
 
330 330
 	// Write manifest list to blob store
331 331
 	blobDir := filepath.Join(registryV2Path, "blobs", "sha256", hexDigest[:2], hexDigest)
332
-	err = os.MkdirAll(blobDir, 0755)
332
+	err = os.MkdirAll(blobDir, 0o755)
333 333
 	assert.NilError(c, err, "error creating blob dir")
334 334
 	blobPath := filepath.Join(blobDir, "data")
335
-	err = os.WriteFile(blobPath, manifestListJSON, 0644)
335
+	err = os.WriteFile(blobPath, manifestListJSON, 0o644)
336 336
 	assert.NilError(c, err, "error writing manifest list")
337 337
 
338 338
 	// Add to revision store
339 339
 	revisionDir := filepath.Join(registryV2Path, "repositories", remoteRepoName, "_manifests", "revisions", "sha256", hexDigest)
340
-	err = os.Mkdir(revisionDir, 0755)
340
+	err = os.Mkdir(revisionDir, 0o755)
341 341
 	assert.Assert(c, err == nil, "error creating revision dir")
342 342
 	revisionPath := filepath.Join(revisionDir, "link")
343
-	err = os.WriteFile(revisionPath, []byte(manifestListDigest.String()), 0644)
343
+	err = os.WriteFile(revisionPath, []byte(manifestListDigest.String()), 0o644)
344 344
 	assert.Assert(c, err == nil, "error writing revision link")
345 345
 
346 346
 	// Update tag
347 347
 	tagPath := filepath.Join(registryV2Path, "repositories", remoteRepoName, "_manifests", "tags", "latest", "current", "link")
348
-	err = os.WriteFile(tagPath, []byte(manifestListDigest.String()), 0644)
348
+	err = os.WriteFile(tagPath, []byte(manifestListDigest.String()), 0o644)
349 349
 	assert.NilError(c, err, "error writing tag link")
350 350
 
351 351
 	// Verify that the image can be pulled through the manifest list.
... ...
@@ -384,7 +384,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuthLoginWithSchem
384 384
 	externalAuthConfig := `{ "credsStore": "shell-test" }`
385 385
 
386 386
 	configPath := filepath.Join(tmp, "config.json")
387
-	err = os.WriteFile(configPath, []byte(externalAuthConfig), 0644)
387
+	err = os.WriteFile(configPath, []byte(externalAuthConfig), 0o644)
388 388
 	assert.NilError(c, err)
389 389
 
390 390
 	dockerCmd(c, "--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
... ...
@@ -426,7 +426,7 @@ func (s *DockerRegistryAuthHtpasswdSuite) TestPullWithExternalAuth(c *testing.T)
426 426
 	externalAuthConfig := `{ "credsStore": "shell-test" }`
427 427
 
428 428
 	configPath := filepath.Join(tmp, "config.json")
429
-	err = os.WriteFile(configPath, []byte(externalAuthConfig), 0644)
429
+	err = os.WriteFile(configPath, []byte(externalAuthConfig), 0o644)
430 430
 	assert.NilError(c, err)
431 431
 
432 432
 	dockerCmd(c, "--config", tmp, "login", "-u", s.reg.Username(), "-p", s.reg.Password(), privateRegistryURL)
... ...
@@ -281,8 +281,8 @@ func (s *DockerRegistryAuthTokenSuite) TestPushMisconfiguredTokenServiceResponse
281 281
 	out, _, err := dockerCmdWithError("push", repoName)
282 282
 	assert.ErrorContains(c, err, "", out)
283 283
 	// TODO: isolate test so that it can be guaranteed that the 503 will trigger xfer retries
284
-	//assert.Assert(c, strings.Contains(out, "Retrying"))
285
-	//assert.Assert(c, !strings.Contains(out, "Retrying in 15"))
284
+	// assert.Assert(c, strings.Contains(out, "Retrying"))
285
+	// assert.Assert(c, !strings.Contains(out, "Retrying in 15"))
286 286
 	split := strings.Split(out, "\n")
287 287
 	assert.Equal(c, split[len(split)-2], "toomanyrequests: out of tokens")
288 288
 }
... ...
@@ -406,7 +406,7 @@ func (s *DockerCLIRunSuite) TestRunCreateVolumesInSymlinkDir(c *testing.T) {
406 406
 		c.Skip("Requires TEMP to point to C: drive")
407 407
 	}
408 408
 
409
-	f, err := os.OpenFile(filepath.Join(dir, "test"), os.O_CREATE, 0700)
409
+	f, err := os.OpenFile(filepath.Join(dir, "test"), os.O_CREATE, 0o700)
410 410
 	if err != nil {
411 411
 		c.Fatal(err)
412 412
 	}
... ...
@@ -504,7 +504,7 @@ func (s *DockerCLIRunSuite) TestVolumesFromGetsProperMode(c *testing.T) {
504 504
 	testRequires(c, testEnv.IsLocalDaemon)
505 505
 	prefix, slash := getPrefixAndSlashFromDaemonPlatform()
506 506
 	hostpath := RandomTmpDirPath("test", testEnv.DaemonInfo.OSType)
507
-	if err := os.MkdirAll(hostpath, 0755); err != nil {
507
+	if err := os.MkdirAll(hostpath, 0o755); err != nil {
508 508
 		c.Fatalf("Failed to create %s: %q", hostpath, err)
509 509
 	}
510 510
 	defer os.RemoveAll(hostpath)
... ...
@@ -534,11 +534,11 @@ func (s *DockerCLIRunSuite) TestRunNoDupVolumes(c *testing.T) {
534 534
 		// Windows requires that the source directory exists before calling HCS
535 535
 		testRequires(c, testEnv.IsLocalDaemon)
536 536
 		someplace = `:c:\someplace`
537
-		if err := os.MkdirAll(path1, 0755); err != nil {
537
+		if err := os.MkdirAll(path1, 0o755); err != nil {
538 538
 			c.Fatalf("Failed to create %s: %q", path1, err)
539 539
 		}
540 540
 		defer os.RemoveAll(path1)
541
-		if err := os.MkdirAll(path2, 0755); err != nil {
541
+		if err := os.MkdirAll(path2, 0o755); err != nil {
542 542
 			c.Fatalf("Failed to create %s: %q", path1, err)
543 543
 		}
544 544
 		defer os.RemoveAll(path2)
... ...
@@ -1269,7 +1269,7 @@ func (s *DockerCLIRunSuite) TestRunDNSDefaultOptions(c *testing.T) {
1269 1269
 	}
1270 1270
 	// defer restored original conf
1271 1271
 	defer func() {
1272
-		if err := os.WriteFile("/etc/resolv.conf", origResolvConf, 0644); err != nil {
1272
+		if err := os.WriteFile("/etc/resolv.conf", origResolvConf, 0o644); err != nil {
1273 1273
 			c.Fatal(err)
1274 1274
 		}
1275 1275
 	}()
... ...
@@ -1278,7 +1278,7 @@ func (s *DockerCLIRunSuite) TestRunDNSDefaultOptions(c *testing.T) {
1278 1278
 	// 2 are removed from the file at container start, and the 3rd (commented out) one is ignored by
1279 1279
 	// GetNameservers(), leading to a replacement of nameservers with the default set
1280 1280
 	tmpResolvConf := []byte("nameserver 127.0.0.1\n#nameserver 127.0.2.1\nnameserver ::1")
1281
-	if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0644); err != nil {
1281
+	if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0o644); err != nil {
1282 1282
 		c.Fatal(err)
1283 1283
 	}
1284 1284
 
... ...
@@ -1373,12 +1373,12 @@ func (s *DockerCLIRunSuite) TestRunDNSOptionsBasedOnHostResolvConf(c *testing.T)
1373 1373
 
1374 1374
 	// test with file
1375 1375
 	tmpResolvConf := []byte("search example.com\nnameserver 12.34.56.78\nnameserver 127.0.0.1")
1376
-	if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0644); err != nil {
1376
+	if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0o644); err != nil {
1377 1377
 		c.Fatal(err)
1378 1378
 	}
1379 1379
 	// put the old resolvconf back
1380 1380
 	defer func() {
1381
-		if err := os.WriteFile("/etc/resolv.conf", origResolvConf, 0644); err != nil {
1381
+		if err := os.WriteFile("/etc/resolv.conf", origResolvConf, 0o644); err != nil {
1382 1382
 			c.Fatal(err)
1383 1383
 		}
1384 1384
 	}()
... ...
@@ -1416,7 +1416,7 @@ func (s *DockerCLIRunSuite) TestRunNonRootUserResolvName(c *testing.T) {
1416 1416
 
1417 1417
 	cID := getIDByName(c, "testperm")
1418 1418
 
1419
-	fmode := (os.FileMode)(0644)
1419
+	fmode := (os.FileMode)(0o644)
1420 1420
 	finfo, err := os.Stat(containerStorageFile(cID, "resolv.conf"))
1421 1421
 	if err != nil {
1422 1422
 		c.Fatal(err)
... ...
@@ -1457,7 +1457,7 @@ func (s *DockerCLIRunSuite) TestRunResolvconfUpdate(c *testing.T) {
1457 1457
 
1458 1458
 	// cleanup
1459 1459
 	defer func() {
1460
-		if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0644); err != nil {
1460
+		if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0o644); err != nil {
1461 1461
 			c.Fatal(err)
1462 1462
 		}
1463 1463
 	}()
... ...
@@ -1467,7 +1467,7 @@ func (s *DockerCLIRunSuite) TestRunResolvconfUpdate(c *testing.T) {
1467 1467
 	containerID1 := getIDByName(c, "first")
1468 1468
 
1469 1469
 	// replace resolv.conf with our temporary copy
1470
-	if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0644); err != nil {
1470
+	if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0o644); err != nil {
1471 1471
 		c.Fatal(err)
1472 1472
 	}
1473 1473
 
... ...
@@ -1490,7 +1490,7 @@ func (s *DockerCLIRunSuite) TestRunResolvconfUpdate(c *testing.T) {
1490 1490
 	containerID2 := getIDByName(c, "second")
1491 1491
 
1492 1492
 	// make a change to resolv.conf (in this case replacing our tmp copy with orig copy)
1493
-	if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0644); err != nil {
1493
+	if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0o644); err != nil {
1494 1494
 		c.Fatal(err)
1495 1495
 	}
1496 1496
 
... ...
@@ -1508,7 +1508,7 @@ func (s *DockerCLIRunSuite) TestRunResolvconfUpdate(c *testing.T) {
1508 1508
 	runningContainerID := strings.TrimSpace(out)
1509 1509
 
1510 1510
 	// replace resolv.conf
1511
-	if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0644); err != nil {
1511
+	if err := os.WriteFile("/etc/resolv.conf", tmpResolvConf, 0o644); err != nil {
1512 1512
 		c.Fatal(err)
1513 1513
 	}
1514 1514
 
... ...
@@ -1532,7 +1532,7 @@ func (s *DockerCLIRunSuite) TestRunResolvconfUpdate(c *testing.T) {
1532 1532
 	//   host resolv.conf before updating container's resolv.conf copies
1533 1533
 
1534 1534
 	// replace resolv.conf with a localhost-only nameserver copy
1535
-	if err = os.WriteFile("/etc/resolv.conf", tmpLocalhostResolvConf, 0644); err != nil {
1535
+	if err = os.WriteFile("/etc/resolv.conf", tmpLocalhostResolvConf, 0o644); err != nil {
1536 1536
 		c.Fatal(err)
1537 1537
 	}
1538 1538
 
... ...
@@ -1551,7 +1551,7 @@ func (s *DockerCLIRunSuite) TestRunResolvconfUpdate(c *testing.T) {
1551 1551
 	//   of containers' resolv.conf.
1552 1552
 
1553 1553
 	// Restore the original resolv.conf
1554
-	if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0644); err != nil {
1554
+	if err := os.WriteFile("/etc/resolv.conf", resolvConfSystem, 0o644); err != nil {
1555 1555
 		c.Fatal(err)
1556 1556
 	}
1557 1557
 
... ...
@@ -1560,7 +1560,7 @@ func (s *DockerCLIRunSuite) TestRunResolvconfUpdate(c *testing.T) {
1560 1560
 	containerID3 := getIDByName(c, "third")
1561 1561
 
1562 1562
 	// Create a modified resolv.conf.aside and override resolv.conf with it
1563
-	if err := os.WriteFile("/etc/resolv.conf.aside", tmpResolvConf, 0644); err != nil {
1563
+	if err := os.WriteFile("/etc/resolv.conf.aside", tmpResolvConf, 0o644); err != nil {
1564 1564
 		c.Fatal(err)
1565 1565
 	}
1566 1566
 
... ...
@@ -2097,19 +2097,19 @@ func (s *DockerCLIRunSuite) TestRunMountOrdering(c *testing.T) {
2097 2097
 
2098 2098
 	// Create a temporary tmpfs mounc.
2099 2099
 	fooDir := filepath.Join(tmpDir, "foo")
2100
-	if err := os.MkdirAll(filepath.Join(tmpDir, "foo"), 0755); err != nil {
2100
+	if err := os.MkdirAll(filepath.Join(tmpDir, "foo"), 0o755); err != nil {
2101 2101
 		c.Fatalf("failed to mkdir at %s - %s", fooDir, err)
2102 2102
 	}
2103 2103
 
2104
-	if err := os.WriteFile(fmt.Sprintf("%s/touch-me", fooDir), []byte{}, 0644); err != nil {
2104
+	if err := os.WriteFile(fmt.Sprintf("%s/touch-me", fooDir), []byte{}, 0o644); err != nil {
2105 2105
 		c.Fatal(err)
2106 2106
 	}
2107 2107
 
2108
-	if err := os.WriteFile(fmt.Sprintf("%s/touch-me", tmpDir), []byte{}, 0644); err != nil {
2108
+	if err := os.WriteFile(fmt.Sprintf("%s/touch-me", tmpDir), []byte{}, 0o644); err != nil {
2109 2109
 		c.Fatal(err)
2110 2110
 	}
2111 2111
 
2112
-	if err := os.WriteFile(fmt.Sprintf("%s/touch-me", tmpDir2), []byte{}, 0644); err != nil {
2112
+	if err := os.WriteFile(fmt.Sprintf("%s/touch-me", tmpDir2), []byte{}, 0o644); err != nil {
2113 2113
 		c.Fatal(err)
2114 2114
 	}
2115 2115
 
... ...
@@ -3055,7 +3055,7 @@ func (s *DockerCLIRunSuite) TestRunNetworkFilesBindMount(c *testing.T) {
3055 3055
 	defer os.Remove(filename)
3056 3056
 
3057 3057
 	// for user namespaced test runs, the temp file must be accessible to unprivileged root
3058
-	if err := os.Chmod(filename, 0646); err != nil {
3058
+	if err := os.Chmod(filename, 0o646); err != nil {
3059 3059
 		c.Fatalf("error modifying permissions of %s: %v", filename, err)
3060 3060
 	}
3061 3061
 
... ...
@@ -3077,7 +3077,7 @@ func (s *DockerCLIRunSuite) TestRunNetworkFilesBindMountRO(c *testing.T) {
3077 3077
 	defer os.Remove(filename)
3078 3078
 
3079 3079
 	// for user namespaced test runs, the temp file must be accessible to unprivileged root
3080
-	if err := os.Chmod(filename, 0646); err != nil {
3080
+	if err := os.Chmod(filename, 0o646); err != nil {
3081 3081
 		c.Fatalf("error modifying permissions of %s: %v", filename, err)
3082 3082
 	}
3083 3083
 
... ...
@@ -3099,7 +3099,7 @@ func (s *DockerCLIRunSuite) TestRunNetworkFilesBindMountROFilesystem(c *testing.
3099 3099
 	defer os.Remove(filename)
3100 3100
 
3101 3101
 	// for user namespaced test runs, the temp file must be accessible to unprivileged root
3102
-	if err := os.Chmod(filename, 0646); err != nil {
3102
+	if err := os.Chmod(filename, 0o646); err != nil {
3103 3103
 		c.Fatalf("error modifying permissions of %s: %v", filename, err)
3104 3104
 	}
3105 3105
 
... ...
@@ -4223,16 +4223,16 @@ func (s *DockerCLIRunSuite) TestRunMount(c *testing.T) {
4223 4223
 	}
4224 4224
 	defer os.RemoveAll(tmpDir)
4225 4225
 	mnt1, mnt2 := path.Join(tmpDir, "mnt1"), path.Join(tmpDir, "mnt2")
4226
-	if err := os.Mkdir(mnt1, 0755); err != nil {
4226
+	if err := os.Mkdir(mnt1, 0o755); err != nil {
4227 4227
 		c.Fatal(err)
4228 4228
 	}
4229
-	if err := os.Mkdir(mnt2, 0755); err != nil {
4229
+	if err := os.Mkdir(mnt2, 0o755); err != nil {
4230 4230
 		c.Fatal(err)
4231 4231
 	}
4232
-	if err := os.WriteFile(path.Join(mnt1, "test1"), []byte("test1"), 0644); err != nil {
4232
+	if err := os.WriteFile(path.Join(mnt1, "test1"), []byte("test1"), 0o644); err != nil {
4233 4233
 		c.Fatal(err)
4234 4234
 	}
4235
-	if err := os.WriteFile(path.Join(mnt2, "test2"), []byte("test2"), 0644); err != nil {
4235
+	if err := os.WriteFile(path.Join(mnt2, "test2"), []byte("test2"), 0o644); err != nil {
4236 4236
 		c.Fatal(err)
4237 4237
 	}
4238 4238
 	testCatFooBar := func(cName string) error {
... ...
@@ -68,7 +68,7 @@ func (s *DockerCLIRunSuite) TestRunWithVolumesIsRecursive(c *testing.T) {
68 68
 
69 69
 	// Create a temporary tmpfs mount.
70 70
 	tmpfsDir := filepath.Join(tmpDir, "tmpfs")
71
-	assert.Assert(c, os.MkdirAll(tmpfsDir, 0777) == nil, "failed to mkdir at %s", tmpfsDir)
71
+	assert.Assert(c, os.MkdirAll(tmpfsDir, 0o777) == nil, "failed to mkdir at %s", tmpfsDir)
72 72
 	assert.Assert(c, mount.Mount("tmpfs", tmpfsDir, "tmpfs", "") == nil, "failed to create a tmpfs mount at %s", tmpfsDir)
73 73
 
74 74
 	f, err := os.CreateTemp(tmpfsDir, "touch-me")
... ...
@@ -247,7 +247,7 @@ func (s *DockerCLIRunSuite) TestRunAttachDetachFromConfig(c *testing.T) {
247 247
 	defer os.RemoveAll(tmpDir)
248 248
 
249 249
 	dotDocker := filepath.Join(tmpDir, ".docker")
250
-	os.Mkdir(dotDocker, 0600)
250
+	os.Mkdir(dotDocker, 0o600)
251 251
 	tmpCfg := filepath.Join(dotDocker, "config.json")
252 252
 
253 253
 	if runtime.GOOS == "windows" {
... ...
@@ -260,7 +260,7 @@ func (s *DockerCLIRunSuite) TestRunAttachDetachFromConfig(c *testing.T) {
260 260
 		"detachKeys": "ctrl-a,a"
261 261
 	}`
262 262
 
263
-	err = os.WriteFile(tmpCfg, []byte(data), 0600)
263
+	err = os.WriteFile(tmpCfg, []byte(data), 0o600)
264 264
 	assert.NilError(c, err)
265 265
 
266 266
 	// Then do the work
... ...
@@ -331,7 +331,7 @@ func (s *DockerCLIRunSuite) TestRunAttachDetachKeysOverrideConfig(c *testing.T)
331 331
 	defer os.RemoveAll(tmpDir)
332 332
 
333 333
 	dotDocker := filepath.Join(tmpDir, ".docker")
334
-	os.Mkdir(dotDocker, 0600)
334
+	os.Mkdir(dotDocker, 0o600)
335 335
 	tmpCfg := filepath.Join(dotDocker, "config.json")
336 336
 
337 337
 	if runtime.GOOS == "windows" {
... ...
@@ -344,7 +344,7 @@ func (s *DockerCLIRunSuite) TestRunAttachDetachKeysOverrideConfig(c *testing.T)
344 344
 		"detachKeys": "ctrl-e,e"
345 345
 	}`
346 346
 
347
-	err = os.WriteFile(tmpCfg, []byte(data), 0600)
347
+	err = os.WriteFile(tmpCfg, []byte(data), 0o600)
348 348
 	assert.NilError(c, err)
349 349
 
350 350
 	// Then do the work
... ...
@@ -1362,7 +1362,7 @@ func (s *DockerCLIRunSuite) TestRunDeviceSymlink(c *testing.T) {
1362 1362
 	// Create a temporary file "temp" inside tmpDir, write some data to "tmpDir/temp",
1363 1363
 	// then create a symlink "tmpDir/file" to the temporary file "tmpDir/temp".
1364 1364
 	tmpFile := filepath.Join(tmpDir, "temp")
1365
-	err = os.WriteFile(tmpFile, []byte("temp"), 0666)
1365
+	err = os.WriteFile(tmpFile, []byte("temp"), 0o666)
1366 1366
 	assert.NilError(c, err)
1367 1367
 	symFile := filepath.Join(tmpDir, "file")
1368 1368
 	err = os.Symlink(tmpFile, symFile)
... ...
@@ -202,9 +202,7 @@ func (s *DockerCLISaveLoadSuite) TestSaveLoadParents(c *testing.T) {
202 202
 	testRequires(c, DaemonIsLinux)
203 203
 
204 204
 	makeImage := func(from string, addfile string) string {
205
-		var (
206
-			out string
207
-		)
205
+		var out string
208 206
 		out, _ = dockerCmd(c, "run", "-d", from, "touch", addfile)
209 207
 		cleanedContainerID := strings.TrimSpace(out)
210 208
 
... ...
@@ -101,6 +101,6 @@ func (s *DockerCLISaveLoadSuite) TestLoadNoStdinFail(c *testing.T) {
101 101
 	buf := make([]byte, 1024)
102 102
 
103 103
 	n, err := pty.Read(buf)
104
-	assert.NilError(c, err) //could not read tty output
104
+	assert.NilError(c, err) // could not read tty output
105 105
 	assert.Assert(c, strings.Contains(string(buf[:n]), "requested load from stdin, but stdin is empty"))
106 106
 }
... ...
@@ -610,8 +610,10 @@ func (s *DockerSwarmSuite) TestPsListContainersFilterIsTask(c *testing.T) {
610 610
 	assert.Assert(c, lines[0] != bareID, "Expected not %s, but got it for is-task label, output %q", bareID, out)
611 611
 }
612 612
 
613
-const globalNetworkPlugin = "global-network-plugin"
614
-const globalIPAMPlugin = "global-ipam-plugin"
613
+const (
614
+	globalNetworkPlugin = "global-network-plugin"
615
+	globalIPAMPlugin    = "global-ipam-plugin"
616
+)
615 617
 
616 618
 func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDrv, ipamDrv string) {
617 619
 	mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
... ...
@@ -664,7 +666,8 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr
664 664
 		w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
665 665
 
666 666
 		veth := &netlink.Veth{
667
-			LinkAttrs: netlink.LinkAttrs{Name: "randomIfName", TxQLen: 0}, PeerName: "cnt0"}
667
+			LinkAttrs: netlink.LinkAttrs{Name: "randomIfName", TxQLen: 0}, PeerName: "cnt0",
668
+		}
668 669
 		if err := netlink.LinkAdd(veth); err != nil {
669 670
 			fmt.Fprintf(w, `{"Error":"failed to add veth pair: `+err.Error()+`"}`)
670 671
 		} else {
... ...
@@ -768,15 +771,15 @@ func setupRemoteGlobalNetworkPlugin(c *testing.T, mux *http.ServeMux, url, netDr
768 768
 		}
769 769
 	})
770 770
 
771
-	err := os.MkdirAll("/etc/docker/plugins", 0755)
771
+	err := os.MkdirAll("/etc/docker/plugins", 0o755)
772 772
 	assert.NilError(c, err)
773 773
 
774 774
 	fileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", netDrv)
775
-	err = os.WriteFile(fileName, []byte(url), 0644)
775
+	err = os.WriteFile(fileName, []byte(url), 0o644)
776 776
 	assert.NilError(c, err)
777 777
 
778 778
 	ipamFileName := fmt.Sprintf("/etc/docker/plugins/%s.spec", ipamDrv)
779
-	err = os.WriteFile(ipamFileName, []byte(url), 0644)
779
+	err = os.WriteFile(ipamFileName, []byte(url), 0o644)
780 780
 	assert.NilError(c, err)
781 781
 }
782 782
 
... ...
@@ -803,7 +806,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceEnvFile(c *testing.T) {
803 803
 	d := s.AddDaemon(c, true, true)
804 804
 
805 805
 	path := filepath.Join(d.Folder, "env.txt")
806
-	err := os.WriteFile(path, []byte("VAR1=A\nVAR2=A\n"), 0644)
806
+	err := os.WriteFile(path, []byte("VAR1=A\nVAR2=A\n"), 0o644)
807 807
 	assert.NilError(c, err)
808 808
 
809 809
 	name := "worker"
... ...
@@ -109,7 +109,7 @@ func (s *DockerCLIVolumeSuite) TestVolumeLsFormatDefaultFormat(c *testing.T) {
109 109
 	assert.NilError(c, err)
110 110
 	defer os.RemoveAll(d)
111 111
 
112
-	err = os.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0644)
112
+	err = os.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0o644)
113 113
 	assert.NilError(c, err)
114 114
 
115 115
 	out, _ := dockerCmd(c, "--config", d, "volume", "ls")
... ...
@@ -567,7 +567,7 @@ func (s *DockerCLIVolumeSuite) TestDuplicateMountpointsForVolumesFromAndMounts(c
567 567
 	out, _ = dockerCmd(c, "volume", "ls", "-q")
568 568
 	assert.Assert(c, strings.Contains(strings.TrimSpace(out), data1))
569 569
 	assert.Assert(c, strings.Contains(strings.TrimSpace(out), data2))
570
-	err := os.MkdirAll("/tmp/data", 0755)
570
+	err := os.MkdirAll("/tmp/data", 0o755)
571 571
 	assert.NilError(c, err)
572 572
 	// Mounts is available in API
573 573
 	apiClient, err := client.NewClientWithOpts(client.FromEnv)
... ...
@@ -186,8 +186,8 @@ func buildImage(name string, cmdOperators ...cli.CmdOperator) *icmd.Result {
186 186
 func writeFile(dst, content string, c *testing.T) {
187 187
 	c.Helper()
188 188
 	// Create subdirectories if necessary
189
-	assert.Assert(c, os.MkdirAll(path.Dir(dst), 0700) == nil)
190
-	f, err := os.OpenFile(dst, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0700)
189
+	assert.Assert(c, os.MkdirAll(path.Dir(dst), 0o700) == nil)
190
+	f, err := os.OpenFile(dst, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0o700)
191 191
 	assert.NilError(c, err)
192 192
 	defer f.Close()
193 193
 	// Write content (truncate if it exists)
... ...
@@ -302,7 +302,7 @@ func createTmpFile(c *testing.T, content string) string {
302 302
 
303 303
 	filename := f.Name()
304 304
 
305
-	err = os.WriteFile(filename, []byte(content), 0644)
305
+	err = os.WriteFile(filename, []byte(content), 0o644)
306 306
 	assert.NilError(c, err)
307 307
 
308 308
 	return filename
... ...
@@ -403,8 +403,10 @@ func getErrorMessage(c *testing.T, body []byte) string {
403 403
 	return strings.TrimSpace(resp.Message)
404 404
 }
405 405
 
406
-type checkF func(*testing.T) (interface{}, string)
407
-type reducer func(...interface{}) interface{}
406
+type (
407
+	checkF  func(*testing.T) (interface{}, string)
408
+	reducer func(...interface{}) interface{}
409
+)
408 410
 
409 411
 func pollCheck(t *testing.T, f checkF, compare func(x interface{}) assert.BoolOrComparison) poll.Check {
410 412
 	return func(poll.LogT) poll.Result {
... ...
@@ -7,10 +7,8 @@ import (
7 7
 	"github.com/docker/docker/testutil/environment"
8 8
 )
9 9
 
10
-var (
11
-	// DefaultClientBinary is the name of the docker binary
12
-	DefaultClientBinary = os.Getenv("TEST_CLIENT_BINARY")
13
-)
10
+// DefaultClientBinary is the name of the docker binary
11
+var DefaultClientBinary = os.Getenv("TEST_CLIENT_BINARY")
14 12
 
15 13
 func init() {
16 14
 	if DefaultClientBinary == "" {
... ...
@@ -51,7 +51,7 @@ func ensureSyscallTest(c *testing.T) {
51 51
 	FROM debian:bullseye-slim
52 52
 	COPY . /usr/bin/
53 53
 	`)
54
-	err = os.WriteFile(dockerFile, content, 0600)
54
+	err = os.WriteFile(dockerFile, content, 0o600)
55 55
 	assert.NilError(c, err)
56 56
 
57 57
 	var buildArgs []string
... ...
@@ -106,7 +106,7 @@ func ensureNNPTest(c *testing.T) {
106 106
 	COPY . /usr/bin
107 107
 	RUN chmod +s /usr/bin/nnp-test
108 108
 	`
109
-	err = os.WriteFile(dockerfile, []byte(content), 0600)
109
+	err = os.WriteFile(dockerfile, []byte(content), 0o600)
110 110
 	assert.NilError(c, err, "could not write Dockerfile for nnp-test image")
111 111
 
112 112
 	var buildArgs []string
... ...
@@ -11,10 +11,8 @@ import (
11 11
 	"github.com/docker/docker/pkg/sysinfo"
12 12
 )
13 13
 
14
-var (
15
-	// SysInfo stores information about which features a kernel supports.
16
-	SysInfo *sysinfo.SysInfo
17
-)
14
+// SysInfo stores information about which features a kernel supports.
15
+var SysInfo *sysinfo.SysInfo
18 16
 
19 17
 func cpuCfsPeriod() bool {
20 18
 	return testEnv.DaemonInfo.CPUCfsPeriod