Browse code

daemon: address some minor linting issues and nits

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2019/08/09 19:30:18
Showing 2 changed files
... ...
@@ -290,7 +290,7 @@ func WithNamespaces(daemon *Daemon, c *container.Container) coci.SpecOpts {
290 290
 				setNamespace(s, nsUser)
291 291
 			}
292 292
 		case ipcMode.IsHost():
293
-			oci.RemoveNamespace(s, specs.LinuxNamespaceType("ipc"))
293
+			oci.RemoveNamespace(s, "ipc")
294 294
 		case ipcMode.IsEmpty():
295 295
 			// A container was created by an older version of the daemon.
296 296
 			// The default behavior used to be what is now called "shareable".
... ...
@@ -304,28 +304,32 @@ func WithNamespaces(daemon *Daemon, c *container.Container) coci.SpecOpts {
304 304
 
305 305
 		// pid
306 306
 		if c.HostConfig.PidMode.IsContainer() {
307
-			ns := specs.LinuxNamespace{Type: "pid"}
308 307
 			pc, err := daemon.getPidContainer(c)
309 308
 			if err != nil {
310 309
 				return err
311 310
 			}
312
-			ns.Path = fmt.Sprintf("/proc/%d/ns/pid", pc.State.GetPID())
311
+			ns := specs.LinuxNamespace{
312
+				Type: "pid",
313
+				Path: fmt.Sprintf("/proc/%d/ns/pid", pc.State.GetPID()),
314
+			}
313 315
 			setNamespace(s, ns)
314 316
 			if userNS {
315 317
 				// to share a PID namespace, they must also share a user namespace
316
-				nsUser := specs.LinuxNamespace{Type: "user"}
317
-				nsUser.Path = fmt.Sprintf("/proc/%d/ns/user", pc.State.GetPID())
318
+				nsUser := specs.LinuxNamespace{
319
+					Type: "user",
320
+					Path: fmt.Sprintf("/proc/%d/ns/user", pc.State.GetPID()),
321
+				}
318 322
 				setNamespace(s, nsUser)
319 323
 			}
320 324
 		} else if c.HostConfig.PidMode.IsHost() {
321
-			oci.RemoveNamespace(s, specs.LinuxNamespaceType("pid"))
325
+			oci.RemoveNamespace(s, "pid")
322 326
 		} else {
323 327
 			ns := specs.LinuxNamespace{Type: "pid"}
324 328
 			setNamespace(s, ns)
325 329
 		}
326 330
 		// uts
327 331
 		if c.HostConfig.UTSMode.IsHost() {
328
-			oci.RemoveNamespace(s, specs.LinuxNamespaceType("uts"))
332
+			oci.RemoveNamespace(s, "uts")
329 333
 			s.Hostname = ""
330 334
 		}
331 335
 
... ...
@@ -54,7 +54,7 @@ func setupFakeDaemon(t *testing.T, c *container.Container) *Daemon {
54 54
 }
55 55
 
56 56
 func cleanupFakeContainer(c *container.Container) {
57
-	os.RemoveAll(c.Root)
57
+	_ = os.RemoveAll(c.Root)
58 58
 }
59 59
 
60 60
 // TestTmpfsDevShmNoDupMount checks that a user-specified /dev/shm tmpfs