소스 검색

integration/container: 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 년 전
부모
커밋
89a4e6b889

+ 1 - 1
integration/container/copy_test.go

@@ -95,7 +95,7 @@ func TestCopyEmptyFile(t *testing.T) {
 func makeEmptyArchive(t *testing.T) (string, io.ReadCloser) {
 func makeEmptyArchive(t *testing.T) (string, io.ReadCloser) {
 	tmpDir := t.TempDir()
 	tmpDir := t.TempDir()
 	srcPath := filepath.Join(tmpDir, "empty-file.txt")
 	srcPath := filepath.Join(tmpDir, "empty-file.txt")
-	err := os.WriteFile(srcPath, []byte(""), 0400)
+	err := os.WriteFile(srcPath, []byte(""), 0o400)
 	assert.NilError(t, err)
 	assert.NilError(t, err)
 
 
 	// TODO(thaJeztah) Add utilities to the client to make steps below less complicated.
 	// TODO(thaJeztah) Add utilities to the client to make steps below less complicated.

+ 1 - 0
integration/container/create_test.go

@@ -176,6 +176,7 @@ func TestCreateTmpfsMountsTarget(t *testing.T) {
 		assert.Check(t, errdefs.IsInvalidParameter(err))
 		assert.Check(t, errdefs.IsInvalidParameter(err))
 	}
 	}
 }
 }
+
 func TestCreateWithCustomMaskedPaths(t *testing.T) {
 func TestCreateWithCustomMaskedPaths(t *testing.T) {
 	skip.If(t, testEnv.DaemonInfo.OSType != "linux")
 	skip.If(t, testEnv.DaemonInfo.OSType != "linux")
 
 

+ 4 - 3
integration/container/devices_windows_test.go

@@ -114,15 +114,16 @@ func TestWindowsDevices(t *testing.T) {
 
 
 			// /Windows/System32/HostDriverStore is mounted from the host when class GUID 5B45201D-F2F2-4F3B-85BB-30FF1F953599
 			// /Windows/System32/HostDriverStore is mounted from the host when class GUID 5B45201D-F2F2-4F3B-85BB-30FF1F953599
 			// is mounted. See `C:\windows\System32\containers\devices.def` on a Windows host for (slightly more) details.
 			// is mounted. See `C:\windows\System32\containers\devices.def` on a Windows host for (slightly more) details.
-			res, err := container.Exec(ctx, client, id, []string{"sh", "-c",
-				"ls -d /Windows/System32/HostDriverStore/* | grep /Windows/System32/HostDriverStore/FileRepository"})
+			res, err := container.Exec(ctx, client, id, []string{
+				"sh", "-c",
+				"ls -d /Windows/System32/HostDriverStore/* | grep /Windows/System32/HostDriverStore/FileRepository",
+			})
 			assert.NilError(t, err)
 			assert.NilError(t, err)
 			assert.Equal(t, d.expectedExitCode, res.ExitCode)
 			assert.Equal(t, d.expectedExitCode, res.ExitCode)
 			if d.expectedExitCode == 0 {
 			if d.expectedExitCode == 0 {
 				assert.Equal(t, d.expectedStdout, strings.TrimSpace(res.Stdout()))
 				assert.Equal(t, d.expectedStdout, strings.TrimSpace(res.Stdout()))
 				assert.Equal(t, d.expectedStderr, strings.TrimSpace(res.Stderr()))
 				assert.Equal(t, d.expectedStderr, strings.TrimSpace(res.Stderr()))
 			}
 			}
-
 		})
 		})
 	}
 	}
 }
 }

+ 11 - 12
integration/container/mounts_linux_test.go

@@ -34,7 +34,7 @@ func TestContainerNetworkMountsNoChown(t *testing.T) {
 
 
 	ctx := context.Background()
 	ctx := context.Background()
 
 
-	tmpDir := fs.NewDir(t, "network-file-mounts", fs.WithMode(0755), fs.WithFile("nwfile", "network file bind mount", fs.WithMode(0644)))
+	tmpDir := fs.NewDir(t, "network-file-mounts", fs.WithMode(0o755), fs.WithFile("nwfile", "network file bind mount", fs.WithMode(0o644)))
 	defer tmpDir.Remove()
 	defer tmpDir.Remove()
 
 
 	tmpNWFileMount := tmpDir.Join("nwfile")
 	tmpNWFileMount := tmpDir.Join("nwfile")
@@ -179,7 +179,6 @@ func TestMountDaemonRoot(t *testing.T) {
 						Image: "busybox",
 						Image: "busybox",
 						Cmd:   []string{"true"},
 						Cmd:   []string{"true"},
 					}, hc, nil, nil, "")
 					}, hc, nil, nil, "")
-
 					if err != nil {
 					if err != nil {
 						if test.expected != "" {
 						if test.expected != "" {
 							t.Fatal(err)
 							t.Fatal(err)
@@ -222,12 +221,12 @@ func TestContainerBindMountNonRecursive(t *testing.T) {
 
 
 	defer setupTest(t)()
 	defer setupTest(t)()
 
 
-	tmpDir1 := fs.NewDir(t, "tmpdir1", fs.WithMode(0755),
-		fs.WithDir("mnt", fs.WithMode(0755)))
+	tmpDir1 := fs.NewDir(t, "tmpdir1", fs.WithMode(0o755),
+		fs.WithDir("mnt", fs.WithMode(0o755)))
 	defer tmpDir1.Remove()
 	defer tmpDir1.Remove()
 	tmpDir1Mnt := filepath.Join(tmpDir1.Path(), "mnt")
 	tmpDir1Mnt := filepath.Join(tmpDir1.Path(), "mnt")
-	tmpDir2 := fs.NewDir(t, "tmpdir2", fs.WithMode(0755),
-		fs.WithFile("file", "should not be visible when NonRecursive", fs.WithMode(0644)))
+	tmpDir2 := fs.NewDir(t, "tmpdir2", fs.WithMode(0o755),
+		fs.WithFile("file", "should not be visible when NonRecursive", fs.WithMode(0o644)))
 	defer tmpDir2.Remove()
 	defer tmpDir2.Remove()
 
 
 	err := mount.Mount(tmpDir2.Path(), tmpDir1Mnt, "none", "bind,ro")
 	err := mount.Mount(tmpDir2.Path(), tmpDir1Mnt, "none", "bind,ro")
@@ -281,8 +280,8 @@ func TestContainerVolumesMountedAsShared(t *testing.T) {
 	defer setupTest(t)()
 	defer setupTest(t)()
 
 
 	// Prepare a source directory to bind mount
 	// Prepare a source directory to bind mount
-	tmpDir1 := fs.NewDir(t, "volume-source", fs.WithMode(0755),
-		fs.WithDir("mnt1", fs.WithMode(0755)))
+	tmpDir1 := fs.NewDir(t, "volume-source", fs.WithMode(0o755),
+		fs.WithDir("mnt1", fs.WithMode(0o755)))
 	defer tmpDir1.Remove()
 	defer tmpDir1.Remove()
 	tmpDir1Mnt := filepath.Join(tmpDir1.Path(), "mnt1")
 	tmpDir1Mnt := filepath.Join(tmpDir1.Path(), "mnt1")
 
 
@@ -332,15 +331,15 @@ func TestContainerVolumesMountedAsSlave(t *testing.T) {
 	skip.If(t, testEnv.IsRootless, "cannot be tested because RootlessKit executes the daemon in private mount namespace (https://github.com/rootless-containers/rootlesskit/issues/97)")
 	skip.If(t, testEnv.IsRootless, "cannot be tested because RootlessKit executes the daemon in private mount namespace (https://github.com/rootless-containers/rootlesskit/issues/97)")
 
 
 	// Prepare a source directory to bind mount
 	// Prepare a source directory to bind mount
-	tmpDir1 := fs.NewDir(t, "volume-source", fs.WithMode(0755),
-		fs.WithDir("mnt1", fs.WithMode(0755)))
+	tmpDir1 := fs.NewDir(t, "volume-source", fs.WithMode(0o755),
+		fs.WithDir("mnt1", fs.WithMode(0o755)))
 	defer tmpDir1.Remove()
 	defer tmpDir1.Remove()
 	tmpDir1Mnt := filepath.Join(tmpDir1.Path(), "mnt1")
 	tmpDir1Mnt := filepath.Join(tmpDir1.Path(), "mnt1")
 
 
 	// Prepare a source directory with file in it. We will bind mount this
 	// Prepare a source directory with file in it. We will bind mount this
 	// directory and see if file shows up.
 	// directory and see if file shows up.
-	tmpDir2 := fs.NewDir(t, "volume-source2", fs.WithMode(0755),
-		fs.WithFile("slave-testfile", "Test", fs.WithMode(0644)))
+	tmpDir2 := fs.NewDir(t, "volume-source2", fs.WithMode(0o755),
+		fs.WithFile("slave-testfile", "Test", fs.WithMode(0o644)))
 	defer tmpDir2.Remove()
 	defer tmpDir2.Remove()
 
 
 	// Convert this directory into a shared mount point so that we do
 	// Convert this directory into a shared mount point so that we do

+ 1 - 1
integration/container/remove_test.go

@@ -34,7 +34,7 @@ func TestRemoveContainerWithRemovedVolume(t *testing.T) {
 
 
 	prefix, slash := getPrefixAndSlashFromDaemonPlatform()
 	prefix, slash := getPrefixAndSlashFromDaemonPlatform()
 
 
-	tempDir := fs.NewDir(t, "test-rm-container-with-removed-volume", fs.WithMode(0755))
+	tempDir := fs.NewDir(t, "test-rm-container-with-removed-volume", fs.WithMode(0o755))
 	defer tempDir.Remove()
 	defer tempDir.Remove()
 
 
 	cID := container.Run(ctx, t, client, container.WithCmd("true"), container.WithBind(tempDir.Path(), prefix+slash+"test"))
 	cID := container.Run(ctx, t, client, container.WithCmd("true"), container.WithBind(tempDir.Path(), prefix+slash+"test"))

+ 2 - 1
integration/container/restart_test.go

@@ -48,7 +48,8 @@ func TestDaemonRestartKillContainers(t *testing.T) {
 		},
 		},
 		{
 		{
 			desc: "container with restart=always and with healthcheck",
 			desc: "container with restart=always and with healthcheck",
-			config: &container.Config{Image: "busybox", Cmd: []string{"top"},
+			config: &container.Config{
+				Image: "busybox", Cmd: []string{"top"},
 				Healthcheck: &container.HealthConfig{
 				Healthcheck: &container.HealthConfig{
 					Test:     []string{"CMD-SHELL", "sleep 1"},
 					Test:     []string{"CMD-SHELL", "sleep 1"},
 					Interval: time.Second,
 					Interval: time.Second,

+ 4 - 4
integration/container/run_linux_test.go

@@ -155,15 +155,15 @@ func TestPrivilegedHostDevices(t *testing.T) {
 	)
 	)
 
 
 	// Create Null devices.
 	// Create Null devices.
-	if err := system.Mknod(devTest, unix.S_IFCHR|0600, int(system.Mkdev(1, 3))); err != nil {
+	if err := system.Mknod(devTest, unix.S_IFCHR|0o600, int(system.Mkdev(1, 3))); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 	defer os.Remove(devTest)
 	defer os.Remove(devTest)
-	if err := os.Mkdir(filepath.Dir(devRootOnlyTest), 0700); err != nil {
+	if err := os.Mkdir(filepath.Dir(devRootOnlyTest), 0o700); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 	defer os.RemoveAll(filepath.Dir(devRootOnlyTest))
 	defer os.RemoveAll(filepath.Dir(devRootOnlyTest))
-	if err := system.Mknod(devRootOnlyTest, unix.S_IFCHR|0600, int(system.Mkdev(1, 3))); err != nil {
+	if err := system.Mknod(devRootOnlyTest, unix.S_IFCHR|0o600, int(system.Mkdev(1, 3))); err != nil {
 		t.Fatal(err)
 		t.Fatal(err)
 	}
 	}
 	defer os.Remove(devRootOnlyTest)
 	defer os.Remove(devRootOnlyTest)
@@ -238,7 +238,7 @@ func TestRunWithAlternativeContainerdShim(t *testing.T) {
 			t.Errorf("shimDir RemoveAll cleanup: %v", err)
 			t.Errorf("shimDir RemoveAll cleanup: %v", err)
 		}
 		}
 	})
 	})
-	assert.Assert(t, os.Chmod(shimDir, 0777))
+	assert.Assert(t, os.Chmod(shimDir, 0o777))
 	shimDir, err = filepath.Abs(shimDir)
 	shimDir, err = filepath.Abs(shimDir)
 	assert.Assert(t, err)
 	assert.Assert(t, err)
 	assert.Assert(t, os.Symlink(realShimPath, filepath.Join(shimDir, "containerd-shim-realfake-v42")))
 	assert.Assert(t, os.Symlink(realShimPath, filepath.Join(shimDir, "containerd-shim-realfake-v42")))