Browse code

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 authored on 2022/01/20 21:53:49
Showing 7 changed files
... ...
@@ -95,7 +95,7 @@ func TestCopyEmptyFile(t *testing.T) {
95 95
 func makeEmptyArchive(t *testing.T) (string, io.ReadCloser) {
96 96
 	tmpDir := t.TempDir()
97 97
 	srcPath := filepath.Join(tmpDir, "empty-file.txt")
98
-	err := os.WriteFile(srcPath, []byte(""), 0400)
98
+	err := os.WriteFile(srcPath, []byte(""), 0o400)
99 99
 	assert.NilError(t, err)
100 100
 
101 101
 	// TODO(thaJeztah) Add utilities to the client to make steps below less complicated.
... ...
@@ -176,6 +176,7 @@ func TestCreateTmpfsMountsTarget(t *testing.T) {
176 176
 		assert.Check(t, errdefs.IsInvalidParameter(err))
177 177
 	}
178 178
 }
179
+
179 180
 func TestCreateWithCustomMaskedPaths(t *testing.T) {
180 181
 	skip.If(t, testEnv.DaemonInfo.OSType != "linux")
181 182
 
... ...
@@ -114,15 +114,16 @@ func TestWindowsDevices(t *testing.T) {
114 114
 
115 115
 			// /Windows/System32/HostDriverStore is mounted from the host when class GUID 5B45201D-F2F2-4F3B-85BB-30FF1F953599
116 116
 			// is mounted. See `C:\windows\System32\containers\devices.def` on a Windows host for (slightly more) details.
117
-			res, err := container.Exec(ctx, client, id, []string{"sh", "-c",
118
-				"ls -d /Windows/System32/HostDriverStore/* | grep /Windows/System32/HostDriverStore/FileRepository"})
117
+			res, err := container.Exec(ctx, client, id, []string{
118
+				"sh", "-c",
119
+				"ls -d /Windows/System32/HostDriverStore/* | grep /Windows/System32/HostDriverStore/FileRepository",
120
+			})
119 121
 			assert.NilError(t, err)
120 122
 			assert.Equal(t, d.expectedExitCode, res.ExitCode)
121 123
 			if d.expectedExitCode == 0 {
122 124
 				assert.Equal(t, d.expectedStdout, strings.TrimSpace(res.Stdout()))
123 125
 				assert.Equal(t, d.expectedStderr, strings.TrimSpace(res.Stderr()))
124 126
 			}
125
-
126 127
 		})
127 128
 	}
128 129
 }
... ...
@@ -34,7 +34,7 @@ func TestContainerNetworkMountsNoChown(t *testing.T) {
34 34
 
35 35
 	ctx := context.Background()
36 36
 
37
-	tmpDir := fs.NewDir(t, "network-file-mounts", fs.WithMode(0755), fs.WithFile("nwfile", "network file bind mount", fs.WithMode(0644)))
37
+	tmpDir := fs.NewDir(t, "network-file-mounts", fs.WithMode(0o755), fs.WithFile("nwfile", "network file bind mount", fs.WithMode(0o644)))
38 38
 	defer tmpDir.Remove()
39 39
 
40 40
 	tmpNWFileMount := tmpDir.Join("nwfile")
... ...
@@ -179,7 +179,6 @@ func TestMountDaemonRoot(t *testing.T) {
179 179
 						Image: "busybox",
180 180
 						Cmd:   []string{"true"},
181 181
 					}, hc, nil, nil, "")
182
-
183 182
 					if err != nil {
184 183
 						if test.expected != "" {
185 184
 							t.Fatal(err)
... ...
@@ -222,12 +221,12 @@ func TestContainerBindMountNonRecursive(t *testing.T) {
222 222
 
223 223
 	defer setupTest(t)()
224 224
 
225
-	tmpDir1 := fs.NewDir(t, "tmpdir1", fs.WithMode(0755),
226
-		fs.WithDir("mnt", fs.WithMode(0755)))
225
+	tmpDir1 := fs.NewDir(t, "tmpdir1", fs.WithMode(0o755),
226
+		fs.WithDir("mnt", fs.WithMode(0o755)))
227 227
 	defer tmpDir1.Remove()
228 228
 	tmpDir1Mnt := filepath.Join(tmpDir1.Path(), "mnt")
229
-	tmpDir2 := fs.NewDir(t, "tmpdir2", fs.WithMode(0755),
230
-		fs.WithFile("file", "should not be visible when NonRecursive", fs.WithMode(0644)))
229
+	tmpDir2 := fs.NewDir(t, "tmpdir2", fs.WithMode(0o755),
230
+		fs.WithFile("file", "should not be visible when NonRecursive", fs.WithMode(0o644)))
231 231
 	defer tmpDir2.Remove()
232 232
 
233 233
 	err := mount.Mount(tmpDir2.Path(), tmpDir1Mnt, "none", "bind,ro")
... ...
@@ -281,8 +280,8 @@ func TestContainerVolumesMountedAsShared(t *testing.T) {
281 281
 	defer setupTest(t)()
282 282
 
283 283
 	// Prepare a source directory to bind mount
284
-	tmpDir1 := fs.NewDir(t, "volume-source", fs.WithMode(0755),
285
-		fs.WithDir("mnt1", fs.WithMode(0755)))
284
+	tmpDir1 := fs.NewDir(t, "volume-source", fs.WithMode(0o755),
285
+		fs.WithDir("mnt1", fs.WithMode(0o755)))
286 286
 	defer tmpDir1.Remove()
287 287
 	tmpDir1Mnt := filepath.Join(tmpDir1.Path(), "mnt1")
288 288
 
... ...
@@ -332,15 +331,15 @@ func TestContainerVolumesMountedAsSlave(t *testing.T) {
332 332
 	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)")
333 333
 
334 334
 	// Prepare a source directory to bind mount
335
-	tmpDir1 := fs.NewDir(t, "volume-source", fs.WithMode(0755),
336
-		fs.WithDir("mnt1", fs.WithMode(0755)))
335
+	tmpDir1 := fs.NewDir(t, "volume-source", fs.WithMode(0o755),
336
+		fs.WithDir("mnt1", fs.WithMode(0o755)))
337 337
 	defer tmpDir1.Remove()
338 338
 	tmpDir1Mnt := filepath.Join(tmpDir1.Path(), "mnt1")
339 339
 
340 340
 	// Prepare a source directory with file in it. We will bind mount this
341 341
 	// directory and see if file shows up.
342
-	tmpDir2 := fs.NewDir(t, "volume-source2", fs.WithMode(0755),
343
-		fs.WithFile("slave-testfile", "Test", fs.WithMode(0644)))
342
+	tmpDir2 := fs.NewDir(t, "volume-source2", fs.WithMode(0o755),
343
+		fs.WithFile("slave-testfile", "Test", fs.WithMode(0o644)))
344 344
 	defer tmpDir2.Remove()
345 345
 
346 346
 	// Convert this directory into a shared mount point so that we do
... ...
@@ -34,7 +34,7 @@ func TestRemoveContainerWithRemovedVolume(t *testing.T) {
34 34
 
35 35
 	prefix, slash := getPrefixAndSlashFromDaemonPlatform()
36 36
 
37
-	tempDir := fs.NewDir(t, "test-rm-container-with-removed-volume", fs.WithMode(0755))
37
+	tempDir := fs.NewDir(t, "test-rm-container-with-removed-volume", fs.WithMode(0o755))
38 38
 	defer tempDir.Remove()
39 39
 
40 40
 	cID := container.Run(ctx, t, client, container.WithCmd("true"), container.WithBind(tempDir.Path(), prefix+slash+"test"))
... ...
@@ -48,7 +48,8 @@ func TestDaemonRestartKillContainers(t *testing.T) {
48 48
 		},
49 49
 		{
50 50
 			desc: "container with restart=always and with healthcheck",
51
-			config: &container.Config{Image: "busybox", Cmd: []string{"top"},
51
+			config: &container.Config{
52
+				Image: "busybox", Cmd: []string{"top"},
52 53
 				Healthcheck: &container.HealthConfig{
53 54
 					Test:     []string{"CMD-SHELL", "sleep 1"},
54 55
 					Interval: time.Second,
... ...
@@ -155,15 +155,15 @@ func TestPrivilegedHostDevices(t *testing.T) {
155 155
 	)
156 156
 
157 157
 	// Create Null devices.
158
-	if err := system.Mknod(devTest, unix.S_IFCHR|0600, int(system.Mkdev(1, 3))); err != nil {
158
+	if err := system.Mknod(devTest, unix.S_IFCHR|0o600, int(system.Mkdev(1, 3))); err != nil {
159 159
 		t.Fatal(err)
160 160
 	}
161 161
 	defer os.Remove(devTest)
162
-	if err := os.Mkdir(filepath.Dir(devRootOnlyTest), 0700); err != nil {
162
+	if err := os.Mkdir(filepath.Dir(devRootOnlyTest), 0o700); err != nil {
163 163
 		t.Fatal(err)
164 164
 	}
165 165
 	defer os.RemoveAll(filepath.Dir(devRootOnlyTest))
166
-	if err := system.Mknod(devRootOnlyTest, unix.S_IFCHR|0600, int(system.Mkdev(1, 3))); err != nil {
166
+	if err := system.Mknod(devRootOnlyTest, unix.S_IFCHR|0o600, int(system.Mkdev(1, 3))); err != nil {
167 167
 		t.Fatal(err)
168 168
 	}
169 169
 	defer os.Remove(devRootOnlyTest)
... ...
@@ -238,7 +238,7 @@ func TestRunWithAlternativeContainerdShim(t *testing.T) {
238 238
 			t.Errorf("shimDir RemoveAll cleanup: %v", err)
239 239
 		}
240 240
 	})
241
-	assert.Assert(t, os.Chmod(shimDir, 0777))
241
+	assert.Assert(t, os.Chmod(shimDir, 0o777))
242 242
 	shimDir, err = filepath.Abs(shimDir)
243 243
 	assert.Assert(t, err)
244 244
 	assert.Assert(t, os.Symlink(realShimPath, filepath.Join(shimDir, "containerd-shim-realfake-v42")))