Browse code

Merge pull request #27367 from Microsoft/jjh/fieldsincontainer

Windows: Factor out unused fields in container

Vincent Demeester authored on 2016/10/17 23:50:39
Showing 4 changed files
... ...
@@ -17,9 +17,6 @@ import (
17 17
 type Container struct {
18 18
 	CommonContainer
19 19
 
20
-	HostnamePath   string
21
-	HostsPath      string
22
-	ResolvConfPath string
23 20
 	// Fields below here are platform specific.
24 21
 }
25 22
 
... ...
@@ -63,17 +63,9 @@ func (daemon *Daemon) buildSandboxOptions(container *container.Container) ([]lib
63 63
 		sboxOptions = append(sboxOptions, libnetwork.OptionUseExternalKey())
64 64
 	}
65 65
 
66
-	container.HostsPath, err = container.GetRootResourcePath("hosts")
67
-	if err != nil {
68
-		return nil, err
69
-	}
70
-	sboxOptions = append(sboxOptions, libnetwork.OptionHostsPath(container.HostsPath))
71
-
72
-	container.ResolvConfPath, err = container.GetRootResourcePath("resolv.conf")
73
-	if err != nil {
66
+	if err = setupPathsAndSandboxOptions(container, &sboxOptions); err != nil {
74 67
 		return nil, err
75 68
 	}
76
-	sboxOptions = append(sboxOptions, libnetwork.OptionResolvConfPath(container.ResolvConfPath))
77 69
 
78 70
 	if len(container.HostConfig.DNS) > 0 {
79 71
 		dns = container.HostConfig.DNS
... ...
@@ -809,9 +801,7 @@ func (daemon *Daemon) initializeNetworking(container *container.Container) error
809 809
 		if err != nil {
810 810
 			return err
811 811
 		}
812
-		container.HostnamePath = nc.HostnamePath
813
-		container.HostsPath = nc.HostsPath
814
-		container.ResolvConfPath = nc.ResolvConfPath
812
+		initializeNetworkingPaths(container, nc)
815 813
 		container.Config.Hostname = nc.Config.Hostname
816 814
 		container.Config.Domainname = nc.Config.Domainname
817 815
 		return nil
... ...
@@ -20,6 +20,7 @@ import (
20 20
 	"github.com/docker/docker/pkg/mount"
21 21
 	"github.com/docker/docker/pkg/stringid"
22 22
 	"github.com/docker/docker/runconfig"
23
+	"github.com/docker/libnetwork"
23 24
 	"github.com/opencontainers/runc/libcontainer/configs"
24 25
 	"github.com/opencontainers/runc/libcontainer/devices"
25 26
 	"github.com/opencontainers/runc/libcontainer/label"
... ...
@@ -328,3 +329,26 @@ func enableIPOnPredefinedNetwork() bool {
328 328
 func (daemon *Daemon) isNetworkHotPluggable() bool {
329 329
 	return true
330 330
 }
331
+
332
+func setupPathsAndSandboxOptions(container *container.Container, sboxOptions *[]libnetwork.SandboxOption) error {
333
+	var err error
334
+
335
+	container.HostsPath, err = container.GetRootResourcePath("hosts")
336
+	if err != nil {
337
+		return err
338
+	}
339
+	*sboxOptions = append(*sboxOptions, libnetwork.OptionHostsPath(container.HostsPath))
340
+
341
+	container.ResolvConfPath, err = container.GetRootResourcePath("resolv.conf")
342
+	if err != nil {
343
+		return err
344
+	}
345
+	*sboxOptions = append(*sboxOptions, libnetwork.OptionResolvConfPath(container.ResolvConfPath))
346
+	return nil
347
+}
348
+
349
+func initializeNetworkingPaths(container *container.Container, nc *container.Container) {
350
+	container.HostnamePath = nc.HostnamePath
351
+	container.HostsPath = nc.HostsPath
352
+	container.ResolvConfPath = nc.ResolvConfPath
353
+}
... ...
@@ -2,7 +2,10 @@
2 2
 
3 3
 package daemon
4 4
 
5
-import "github.com/docker/docker/container"
5
+import (
6
+	"github.com/docker/docker/container"
7
+	"github.com/docker/libnetwork"
8
+)
6 9
 
7 10
 func (daemon *Daemon) setupLinkedContainers(container *container.Container) ([]string, error) {
8 11
 	return nil, nil
... ...
@@ -47,3 +50,10 @@ func enableIPOnPredefinedNetwork() bool {
47 47
 func (daemon *Daemon) isNetworkHotPluggable() bool {
48 48
 	return false
49 49
 }
50
+
51
+func setupPathsAndSandboxOptions(container *container.Container, sboxOptions *[]libnetwork.SandboxOption) error {
52
+	return nil
53
+}
54
+
55
+func initializeNetworkingPaths(container *container.Container, nc *container.Container) {
56
+}