Browse code

Lint fixes on runconfig

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Vincent Demeester authored on 2015/07/25 18:11:45
Showing 17 changed files
... ...
@@ -63,11 +63,11 @@ func (cli *DockerCli) CmdRun(args ...string) error {
63 63
 		os.Exit(1)
64 64
 	}
65 65
 
66
-	if len(hostConfig.Dns) > 0 {
66
+	if len(hostConfig.DNS) > 0 {
67 67
 		// check the DNS settings passed via --dns against
68 68
 		// localhost regexp to warn if they are trying to
69 69
 		// set a DNS to a localhost address
70
-		for _, dnsIP := range hostConfig.Dns {
70
+		for _, dnsIP := range hostConfig.DNS {
71 71
 			if dns.IsLocalhost(dnsIP) {
72 72
 				fmt.Fprintf(cli.err, "WARNING: Localhost DNS setting (--dns=%s) may fail in containers.\n", dnsIP)
73 73
 				break
... ...
@@ -109,14 +109,14 @@ func allocateDaemonPort(addr string) error {
109 109
 
110 110
 func adjustCpuShares(version version.Version, hostConfig *runconfig.HostConfig) {
111 111
 	if version.LessThan("1.19") {
112
-		if hostConfig != nil && hostConfig.CpuShares > 0 {
112
+		if hostConfig != nil && hostConfig.CPUShares > 0 {
113 113
 			// Handle unsupported CpuShares
114
-			if hostConfig.CpuShares < linuxMinCpuShares {
115
-				logrus.Warnf("Changing requested CpuShares of %d to minimum allowed of %d", hostConfig.CpuShares, linuxMinCpuShares)
116
-				hostConfig.CpuShares = linuxMinCpuShares
117
-			} else if hostConfig.CpuShares > linuxMaxCpuShares {
118
-				logrus.Warnf("Changing requested CpuShares of %d to maximum allowed of %d", hostConfig.CpuShares, linuxMaxCpuShares)
119
-				hostConfig.CpuShares = linuxMaxCpuShares
114
+			if hostConfig.CPUShares < linuxMinCpuShares {
115
+				logrus.Warnf("Changing requested CpuShares of %d to minimum allowed of %d", hostConfig.CPUShares, linuxMinCpuShares)
116
+				hostConfig.CPUShares = linuxMinCpuShares
117
+			} else if hostConfig.CPUShares > linuxMaxCpuShares {
118
+				logrus.Warnf("Changing requested CpuShares of %d to maximum allowed of %d", hostConfig.CPUShares, linuxMaxCpuShares)
119
+				hostConfig.CPUShares = linuxMaxCpuShares
120 120
 			}
121 121
 		}
122 122
 	}
... ...
@@ -12,28 +12,28 @@ import (
12 12
 func TestAdjustCpuSharesOldApi(t *testing.T) {
13 13
 	apiVersion := version.Version("1.18")
14 14
 	hostConfig := &runconfig.HostConfig{
15
-		CpuShares: linuxMinCpuShares - 1,
15
+		CPUShares: linuxMinCpuShares - 1,
16 16
 	}
17 17
 	adjustCpuShares(apiVersion, hostConfig)
18
-	if hostConfig.CpuShares != linuxMinCpuShares {
18
+	if hostConfig.CPUShares != linuxMinCpuShares {
19 19
 		t.Errorf("Expected CpuShares to be %d", linuxMinCpuShares)
20 20
 	}
21 21
 
22
-	hostConfig.CpuShares = linuxMaxCpuShares + 1
22
+	hostConfig.CPUShares = linuxMaxCpuShares + 1
23 23
 	adjustCpuShares(apiVersion, hostConfig)
24
-	if hostConfig.CpuShares != linuxMaxCpuShares {
24
+	if hostConfig.CPUShares != linuxMaxCpuShares {
25 25
 		t.Errorf("Expected CpuShares to be %d", linuxMaxCpuShares)
26 26
 	}
27 27
 
28
-	hostConfig.CpuShares = 0
28
+	hostConfig.CPUShares = 0
29 29
 	adjustCpuShares(apiVersion, hostConfig)
30
-	if hostConfig.CpuShares != 0 {
30
+	if hostConfig.CPUShares != 0 {
31 31
 		t.Error("Expected CpuShares to be unchanged")
32 32
 	}
33 33
 
34
-	hostConfig.CpuShares = 1024
34
+	hostConfig.CPUShares = 1024
35 35
 	adjustCpuShares(apiVersion, hostConfig)
36
-	if hostConfig.CpuShares != 1024 {
36
+	if hostConfig.CPUShares != 1024 {
37 37
 		t.Error("Expected CpuShares to be unchanged")
38 38
 	}
39 39
 }
... ...
@@ -41,28 +41,28 @@ func TestAdjustCpuSharesOldApi(t *testing.T) {
41 41
 func TestAdjustCpuSharesNoAdjustment(t *testing.T) {
42 42
 	apiVersion := version.Version("1.19")
43 43
 	hostConfig := &runconfig.HostConfig{
44
-		CpuShares: linuxMinCpuShares - 1,
44
+		CPUShares: linuxMinCpuShares - 1,
45 45
 	}
46 46
 	adjustCpuShares(apiVersion, hostConfig)
47
-	if hostConfig.CpuShares != linuxMinCpuShares-1 {
47
+	if hostConfig.CPUShares != linuxMinCpuShares-1 {
48 48
 		t.Errorf("Expected CpuShares to be %d", linuxMinCpuShares-1)
49 49
 	}
50 50
 
51
-	hostConfig.CpuShares = linuxMaxCpuShares + 1
51
+	hostConfig.CPUShares = linuxMaxCpuShares + 1
52 52
 	adjustCpuShares(apiVersion, hostConfig)
53
-	if hostConfig.CpuShares != linuxMaxCpuShares+1 {
53
+	if hostConfig.CPUShares != linuxMaxCpuShares+1 {
54 54
 		t.Errorf("Expected CpuShares to be %d", linuxMaxCpuShares+1)
55 55
 	}
56 56
 
57
-	hostConfig.CpuShares = 0
57
+	hostConfig.CPUShares = 0
58 58
 	adjustCpuShares(apiVersion, hostConfig)
59
-	if hostConfig.CpuShares != 0 {
59
+	if hostConfig.CPUShares != 0 {
60 60
 		t.Error("Expected CpuShares to be unchanged")
61 61
 	}
62 62
 
63
-	hostConfig.CpuShares = 1024
63
+	hostConfig.CPUShares = 1024
64 64
 	adjustCpuShares(apiVersion, hostConfig)
65
-	if hostConfig.CpuShares != 1024 {
65
+	if hostConfig.CPUShares != 1024 {
66 66
 		t.Error("Expected CpuShares to be unchanged")
67 67
 	}
68 68
 }
... ...
@@ -607,9 +607,9 @@ func (b *builder) create() (*daemon.Container, error) {
607 607
 	b.Config.Image = b.image
608 608
 
609 609
 	hostConfig := &runconfig.HostConfig{
610
-		CpuShares:    b.cpuShares,
611
-		CpuPeriod:    b.cpuPeriod,
612
-		CpuQuota:     b.cpuQuota,
610
+		CPUShares:    b.cpuShares,
611
+		CPUPeriod:    b.cpuPeriod,
612
+		CPUQuota:     b.cpuQuota,
613 613
 		CpusetCpus:   b.cpuSetCpus,
614 614
 		CpusetMems:   b.cpuSetMems,
615 615
 		CgroupParent: b.cgroupParent,
... ...
@@ -264,11 +264,11 @@ func populateCommand(c *Container, env []string) error {
264 264
 	resources := &execdriver.Resources{
265 265
 		Memory:           c.hostConfig.Memory,
266 266
 		MemorySwap:       c.hostConfig.MemorySwap,
267
-		CpuShares:        c.hostConfig.CpuShares,
267
+		CpuShares:        c.hostConfig.CPUShares,
268 268
 		CpusetCpus:       c.hostConfig.CpusetCpus,
269 269
 		CpusetMems:       c.hostConfig.CpusetMems,
270
-		CpuPeriod:        c.hostConfig.CpuPeriod,
271
-		CpuQuota:         c.hostConfig.CpuQuota,
270
+		CpuPeriod:        c.hostConfig.CPUPeriod,
271
+		CpuQuota:         c.hostConfig.CPUQuota,
272 272
 		BlkioWeight:      c.hostConfig.BlkioWeight,
273 273
 		Rlimits:          rlimits,
274 274
 		OomKillDisable:   c.hostConfig.OomKillDisable,
... ...
@@ -423,8 +423,8 @@ func (container *Container) buildJoinOptions() ([]libnetwork.EndpointOption, err
423 423
 	}
424 424
 	joinOptions = append(joinOptions, libnetwork.JoinOptionResolvConfPath(container.ResolvConfPath))
425 425
 
426
-	if len(container.hostConfig.Dns) > 0 {
427
-		dns = container.hostConfig.Dns
426
+	if len(container.hostConfig.DNS) > 0 {
427
+		dns = container.hostConfig.DNS
428 428
 	} else if len(container.daemon.config.Dns) > 0 {
429 429
 		dns = container.daemon.config.Dns
430 430
 	}
... ...
@@ -433,8 +433,8 @@ func (container *Container) buildJoinOptions() ([]libnetwork.EndpointOption, err
433 433
 		joinOptions = append(joinOptions, libnetwork.JoinOptionDNS(d))
434 434
 	}
435 435
 
436
-	if len(container.hostConfig.DnsSearch) > 0 {
437
-		dnsSearch = container.hostConfig.DnsSearch
436
+	if len(container.hostConfig.DNSSearch) > 0 {
437
+		dnsSearch = container.hostConfig.DNSSearch
438 438
 	} else if len(container.daemon.config.DnsSearch) > 0 {
439 439
 		dnsSearch = container.daemon.config.DnsSearch
440 440
 	}
... ...
@@ -543,7 +543,7 @@ func (container *Container) buildPortMapInfo(n libnetwork.Network, ep libnetwork
543 543
 			for _, tp := range exposedPorts {
544 544
 				natPort, err := nat.NewPort(tp.Proto.String(), strconv.Itoa(int(tp.Port)))
545 545
 				if err != nil {
546
-					return nil, fmt.Errorf("Error parsing Port value(%s):%v", tp.Port, err)
546
+					return nil, fmt.Errorf("Error parsing Port value(%v):%v", tp.Port, err)
547 547
 				}
548 548
 				networkSettings.Ports[natPort] = nil
549 549
 			}
... ...
@@ -185,15 +185,15 @@ func (daemon *Daemon) verifyContainerSettings(hostConfig *runconfig.HostConfig,
185 185
 	if hostConfig.MemorySwappiness != -1 && (hostConfig.MemorySwappiness < 0 || hostConfig.MemorySwappiness > 100) {
186 186
 		return warnings, fmt.Errorf("Invalid value: %d, valid memory swappiness range is 0-100.", hostConfig.MemorySwappiness)
187 187
 	}
188
-	if hostConfig.CpuPeriod > 0 && !daemon.SystemConfig().CpuCfsPeriod {
188
+	if hostConfig.CPUPeriod > 0 && !daemon.SystemConfig().CpuCfsPeriod {
189 189
 		warnings = append(warnings, "Your kernel does not support CPU cfs period. Period discarded.")
190 190
 		logrus.Warnf("Your kernel does not support CPU cfs period. Period discarded.")
191
-		hostConfig.CpuPeriod = 0
191
+		hostConfig.CPUPeriod = 0
192 192
 	}
193
-	if hostConfig.CpuQuota > 0 && !daemon.SystemConfig().CpuCfsQuota {
193
+	if hostConfig.CPUQuota > 0 && !daemon.SystemConfig().CpuCfsQuota {
194 194
 		warnings = append(warnings, "Your kernel does not support CPU cfs quota. Quota discarded.")
195 195
 		logrus.Warnf("Your kernel does not support CPU cfs quota. Quota discarded.")
196
-		hostConfig.CpuQuota = 0
196
+		hostConfig.CPUQuota = 0
197 197
 	}
198 198
 	if hostConfig.BlkioWeight > 0 && (hostConfig.BlkioWeight < 10 || hostConfig.BlkioWeight > 1000) {
199 199
 		return warnings, fmt.Errorf("Range of blkio weight is from 10 to 1000.")
... ...
@@ -61,7 +61,7 @@ func (daemon *Daemon) ContainerInspectPre120(name string) (*types.ContainerJSONP
61 61
 		container.Config,
62 62
 		container.hostConfig.Memory,
63 63
 		container.hostConfig.MemorySwap,
64
-		container.hostConfig.CpuShares,
64
+		container.hostConfig.CPUShares,
65 65
 		container.hostConfig.CpusetCpus,
66 66
 	}
67 67
 
... ...
@@ -38,6 +38,7 @@ packages=(
38 38
 	pkg/urlutil
39 39
 	pkg/version
40 40
 	registry
41
+	runconfig
41 42
 	utils
42 43
 )
43 44
 
... ...
@@ -17,6 +17,8 @@ type Entrypoint struct {
17 17
 	parts []string
18 18
 }
19 19
 
20
+// MarshalJSON Marshals (or serializes) the Entrypoint into the json format.
21
+// This method is needed to implement json.Marshaller.
20 22
 func (e *Entrypoint) MarshalJSON() ([]byte, error) {
21 23
 	if e == nil {
22 24
 		return []byte{}, nil
... ...
@@ -24,7 +26,8 @@ func (e *Entrypoint) MarshalJSON() ([]byte, error) {
24 24
 	return json.Marshal(e.Slice())
25 25
 }
26 26
 
27
-// UnmarshalJSON decoded the entrypoint whether it's a string or an array of strings.
27
+// UnmarshalJSON decodes the entrypoint whether it's a string or an array of strings.
28
+// This method is needed to implement json.Unmarshaler.
28 29
 func (e *Entrypoint) UnmarshalJSON(b []byte) error {
29 30
 	if len(b) == 0 {
30 31
 		return nil
... ...
@@ -42,6 +45,7 @@ func (e *Entrypoint) UnmarshalJSON(b []byte) error {
42 42
 	return nil
43 43
 }
44 44
 
45
+// Len returns the number of parts of the Entrypoint.
45 46
 func (e *Entrypoint) Len() int {
46 47
 	if e == nil {
47 48
 		return 0
... ...
@@ -49,6 +53,7 @@ func (e *Entrypoint) Len() int {
49 49
 	return len(e.parts)
50 50
 }
51 51
 
52
+// Slice gets the parts of the Entrypoint as a Slice of string.
52 53
 func (e *Entrypoint) Slice() []string {
53 54
 	if e == nil {
54 55
 		return nil
... ...
@@ -56,18 +61,27 @@ func (e *Entrypoint) Slice() []string {
56 56
 	return e.parts
57 57
 }
58 58
 
59
+// NewEntrypoint creates an Entrypoint based on the specified parts (as strings).
59 60
 func NewEntrypoint(parts ...string) *Entrypoint {
60 61
 	return &Entrypoint{parts}
61 62
 }
62 63
 
64
+// Command encapsulates the container command.
65
+// It might be represented as a string or an array of strings.
66
+// We need to override the json decoder to accept both options.
67
+// The JSON decoder will fail if the api sends an string and
68
+//  we try to decode it into an array of string.
63 69
 type Command struct {
64 70
 	parts []string
65 71
 }
66 72
 
73
+// ToString gets a string representing a Command.
67 74
 func (e *Command) ToString() string {
68 75
 	return strings.Join(e.parts, " ")
69 76
 }
70 77
 
78
+// MarshalJSON Marshals (or serializes) the Command into the json format.
79
+// This method is needed to implement json.Marshaller.
71 80
 func (e *Command) MarshalJSON() ([]byte, error) {
72 81
 	if e == nil {
73 82
 		return []byte{}, nil
... ...
@@ -75,7 +89,8 @@ func (e *Command) MarshalJSON() ([]byte, error) {
75 75
 	return json.Marshal(e.Slice())
76 76
 }
77 77
 
78
-// UnmarshalJSON decoded the entrypoint whether it's a string or an array of strings.
78
+// UnmarshalJSON decodes the entrypoint whether it's a string or an array of strings.
79
+// This method is needed to implement json.Unmarshaler.
79 80
 func (e *Command) UnmarshalJSON(b []byte) error {
80 81
 	if len(b) == 0 {
81 82
 		return nil
... ...
@@ -93,6 +108,7 @@ func (e *Command) UnmarshalJSON(b []byte) error {
93 93
 	return nil
94 94
 }
95 95
 
96
+// Len returns the number of parts of the Entrypoint.
96 97
 func (e *Command) Len() int {
97 98
 	if e == nil {
98 99
 		return 0
... ...
@@ -100,6 +116,7 @@ func (e *Command) Len() int {
100 100
 	return len(e.parts)
101 101
 }
102 102
 
103
+// Slice gets the parts of the Entrypoint as a Slice of string.
103 104
 func (e *Command) Slice() []string {
104 105
 	if e == nil {
105 106
 		return nil
... ...
@@ -107,38 +124,42 @@ func (e *Command) Slice() []string {
107 107
 	return e.parts
108 108
 }
109 109
 
110
+// NewCommand creates a Command based on the specified parts (as strings).
110 111
 func NewCommand(parts ...string) *Command {
111 112
 	return &Command{parts}
112 113
 }
113 114
 
114
-// Note: the Config structure should hold only portable information about the container.
115
+// Config contains the configuration data about a container.
116
+// It should hold only portable information about the container.
115 117
 // Here, "portable" means "independent from the host we are running on".
116 118
 // Non-portable information *should* appear in HostConfig.
117 119
 type Config struct {
118
-	Hostname        string
119
-	Domainname      string
120
-	User            string
121
-	AttachStdin     bool
122
-	AttachStdout    bool
123
-	AttachStderr    bool
124
-	ExposedPorts    map[nat.Port]struct{}
125
-	PublishService  string
126
-	Tty             bool // Attach standard streams to a tty, including stdin if it is not closed.
127
-	OpenStdin       bool // Open stdin
128
-	StdinOnce       bool // If true, close stdin after the 1 attached client disconnects.
129
-	Env             []string
130
-	Cmd             *Command
131
-	Image           string // Name of the image as it was passed by the operator (eg. could be symbolic)
132
-	Volumes         map[string]struct{}
133
-	VolumeDriver    string
134
-	WorkingDir      string
135
-	Entrypoint      *Entrypoint
136
-	NetworkDisabled bool
137
-	MacAddress      string
138
-	OnBuild         []string
139
-	Labels          map[string]string
140
-}
141
-
120
+	Hostname        string                // Hostname
121
+	Domainname      string                // Domainname
122
+	User            string                // User that will run the command(s) inside the container
123
+	AttachStdin     bool                  // Attach the standard input, makes possible user interaction
124
+	AttachStdout    bool                  // Attach the standard output
125
+	AttachStderr    bool                  // Attach the standard error
126
+	ExposedPorts    map[nat.Port]struct{} // List of exposed ports
127
+	PublishService  string                // Name of the network service exposed by the container
128
+	Tty             bool                  // Attach standard streams to a tty, including stdin if it is not closed.
129
+	OpenStdin       bool                  // Open stdin
130
+	StdinOnce       bool                  // If true, close stdin after the 1 attached client disconnects.
131
+	Env             []string              // List of environment variable to set in the container
132
+	Cmd             *Command              // Command to run when starting the container
133
+	Image           string                // Name of the image as it was passed by the operator (eg. could be symbolic)
134
+	Volumes         map[string]struct{}   // List of volumes (mounts) used for the container
135
+	VolumeDriver    string                // Name of the volume driver used to mount volumes
136
+	WorkingDir      string                // Current directory (PWD) in the command will be launched
137
+	Entrypoint      *Entrypoint           // Entrypoint to run when starting the container
138
+	NetworkDisabled bool                  // Is network disabled
139
+	MacAddress      string                // Mac Address of the container
140
+	OnBuild         []string              // ONBUILD metadata that were defined on the image Dockerfile
141
+	Labels          map[string]string     // List of labels set to this container
142
+}
143
+
144
+// ContainerConfigWrapper is a Config wrapper that hold the container Config (portable)
145
+// and the corresponding HostConfig (non-portable).
142 146
 type ContainerConfigWrapper struct {
143 147
 	*Config
144 148
 	InnerHostConfig *HostConfig `json:"HostConfig,omitempty"`
... ...
@@ -147,6 +168,8 @@ type ContainerConfigWrapper struct {
147 147
 
148 148
 }
149 149
 
150
+// GetHostConfig gets the HostConfig of the Config.
151
+// It's mostly there to handle Deprecated fields of the ContainerConfigWrapper
150 152
 func (w *ContainerConfigWrapper) GetHostConfig() *HostConfig {
151 153
 	hc := w.HostConfig
152 154
 
... ...
@@ -159,8 +182,8 @@ func (w *ContainerConfigWrapper) GetHostConfig() *HostConfig {
159 159
 		if hc.MemorySwap != 0 && w.InnerHostConfig.MemorySwap == 0 {
160 160
 			w.InnerHostConfig.MemorySwap = hc.MemorySwap
161 161
 		}
162
-		if hc.CpuShares != 0 && w.InnerHostConfig.CpuShares == 0 {
163
-			w.InnerHostConfig.CpuShares = hc.CpuShares
162
+		if hc.CPUShares != 0 && w.InnerHostConfig.CPUShares == 0 {
163
+			w.InnerHostConfig.CPUShares = hc.CPUShares
164 164
 		}
165 165
 
166 166
 		hc = w.InnerHostConfig
... ...
@@ -4,18 +4,24 @@ import (
4 4
 	flag "github.com/docker/docker/pkg/mflag"
5 5
 )
6 6
 
7
+// ExecConfig is a small subset of the Config struct that hold the configuration
8
+// for the exec feature of docker.
7 9
 type ExecConfig struct {
8
-	User         string
9
-	Privileged   bool
10
-	Tty          bool
11
-	Container    string
12
-	AttachStdin  bool
13
-	AttachStderr bool
14
-	AttachStdout bool
15
-	Detach       bool
16
-	Cmd          []string
10
+	User         string   // User that will run the command
11
+	Privileged   bool     // Is the container in privileged mode
12
+	Tty          bool     // Attach standard streams to a tty.
13
+	Container    string   // Name of the container (to execute in)
14
+	AttachStdin  bool     // Attach the standard input, makes possible user interaction
15
+	AttachStderr bool     // Attach the standard output
16
+	AttachStdout bool     // Attach the standard error
17
+	Detach       bool     // Execute in detach mode
18
+	Cmd          []string // Execution commands and args
17 19
 }
18 20
 
21
+// ParseExec parses the specified args for the specified command and generates
22
+// an ExecConfig from it.
23
+// If the minimal number of specified args is not right or if specified args are
24
+// not valid, it will return an error.
19 25
 func ParseExec(cmd *flag.FlagSet, args []string) (*ExecConfig, error) {
20 26
 	var (
21 27
 		flStdin   = cmd.Bool([]string{"i", "-interactive"}, false, "Keep STDIN open even if not attached")
... ...
@@ -9,29 +9,35 @@ import (
9 9
 	"github.com/docker/docker/pkg/ulimit"
10 10
 )
11 11
 
12
+// KeyValuePair is a structure that hold a value for a key.
12 13
 type KeyValuePair struct {
13 14
 	Key   string
14 15
 	Value string
15 16
 }
16 17
 
18
+// NetworkMode represents the container network stack.
17 19
 type NetworkMode string
18 20
 
21
+// IpcMode represents the container ipc stack.
19 22
 type IpcMode string
20 23
 
21
-// IsPrivate indicates whether container use it's private ipc stack
24
+// IsPrivate indicates whether the container uses it's private ipc stack.
22 25
 func (n IpcMode) IsPrivate() bool {
23 26
 	return !(n.IsHost() || n.IsContainer())
24 27
 }
25 28
 
29
+// IsHost indicates whether the container uses the host's ipc stack.
26 30
 func (n IpcMode) IsHost() bool {
27 31
 	return n == "host"
28 32
 }
29 33
 
34
+// IsContainer indicates whether the container uses a container's ipc stack.
30 35
 func (n IpcMode) IsContainer() bool {
31 36
 	parts := strings.SplitN(string(n), ":", 2)
32 37
 	return len(parts) > 1 && parts[0] == "container"
33 38
 }
34 39
 
40
+// Valid indicates whether the ipc stack is valid.
35 41
 func (n IpcMode) Valid() bool {
36 42
 	parts := strings.Split(string(n), ":")
37 43
 	switch mode := parts[0]; mode {
... ...
@@ -46,6 +52,7 @@ func (n IpcMode) Valid() bool {
46 46
 	return true
47 47
 }
48 48
 
49
+// Container returns the name of the container ipc stack is going to be used.
49 50
 func (n IpcMode) Container() string {
50 51
 	parts := strings.SplitN(string(n), ":", 2)
51 52
 	if len(parts) > 1 {
... ...
@@ -54,17 +61,20 @@ func (n IpcMode) Container() string {
54 54
 	return ""
55 55
 }
56 56
 
57
+// UTSMode represents the UTS namespace of the container.
57 58
 type UTSMode string
58 59
 
59
-// IsPrivate indicates whether container use it's private UTS namespace
60
+// IsPrivate indicates whether the container uses it's private UTS namespace.
60 61
 func (n UTSMode) IsPrivate() bool {
61 62
 	return !(n.IsHost())
62 63
 }
63 64
 
65
+// IsHost indicates whether the container uses the host's UTS namespace.
64 66
 func (n UTSMode) IsHost() bool {
65 67
 	return n == "host"
66 68
 }
67 69
 
70
+// Valid indicates whether the UTS namespace is valid.
68 71
 func (n UTSMode) Valid() bool {
69 72
 	parts := strings.Split(string(n), ":")
70 73
 	switch mode := parts[0]; mode {
... ...
@@ -75,17 +85,20 @@ func (n UTSMode) Valid() bool {
75 75
 	return true
76 76
 }
77 77
 
78
+// PidMode represents the pid stack of the container.
78 79
 type PidMode string
79 80
 
80
-// IsPrivate indicates whether container use it's private pid stack
81
+// IsPrivate indicates whether the container uses it's private pid stack.
81 82
 func (n PidMode) IsPrivate() bool {
82 83
 	return !(n.IsHost())
83 84
 }
84 85
 
86
+// IsHost indicates whether the container uses the host's pid stack.
85 87
 func (n PidMode) IsHost() bool {
86 88
 	return n == "host"
87 89
 }
88 90
 
91
+// Valid indicates whether the pid stack is valid.
89 92
 func (n PidMode) Valid() bool {
90 93
 	parts := strings.Split(string(n), ":")
91 94
 	switch mode := parts[0]; mode {
... ...
@@ -96,38 +109,49 @@ func (n PidMode) Valid() bool {
96 96
 	return true
97 97
 }
98 98
 
99
+// DeviceMapping represents the device mapping between the host and the container.
99 100
 type DeviceMapping struct {
100 101
 	PathOnHost        string
101 102
 	PathInContainer   string
102 103
 	CgroupPermissions string
103 104
 }
104 105
 
106
+// RestartPolicy represents the restart policies of the container.
105 107
 type RestartPolicy struct {
106 108
 	Name              string
107 109
 	MaximumRetryCount int
108 110
 }
109 111
 
112
+// IsNone indicates whether the container has the "no" restart policy.
113
+// This means the container will not automatically restart when exiting.
110 114
 func (rp *RestartPolicy) IsNone() bool {
111 115
 	return rp.Name == "no"
112 116
 }
113 117
 
118
+// IsAlways indicates whether the container has the "always" restart policy.
119
+// This means the container will automatically restart regardless of the exit status.
114 120
 func (rp *RestartPolicy) IsAlways() bool {
115 121
 	return rp.Name == "always"
116 122
 }
117 123
 
124
+// IsOnFailure indicates whether the container has the "on-failure" restart policy.
125
+// This means the contain will automatically restart of exiting with a non-zero exit status.
118 126
 func (rp *RestartPolicy) IsOnFailure() bool {
119 127
 	return rp.Name == "on-failure"
120 128
 }
121 129
 
130
+// LogConfig represents the logging configuration of the container.
122 131
 type LogConfig struct {
123 132
 	Type   string
124 133
 	Config map[string]string
125 134
 }
126 135
 
136
+// LxcConfig represents the specific LXC configuration of the container.
127 137
 type LxcConfig struct {
128 138
 	values []KeyValuePair
129 139
 }
130 140
 
141
+// MarshalJSON marshals (or serializes) the LxcConfig into JSON.
131 142
 func (c *LxcConfig) MarshalJSON() ([]byte, error) {
132 143
 	if c == nil {
133 144
 		return []byte{}, nil
... ...
@@ -135,6 +159,8 @@ func (c *LxcConfig) MarshalJSON() ([]byte, error) {
135 135
 	return json.Marshal(c.Slice())
136 136
 }
137 137
 
138
+// UnmarshalJSON unmarshals (or deserializes) the specified byte slices from JSON to
139
+// a LxcConfig.
138 140
 func (c *LxcConfig) UnmarshalJSON(b []byte) error {
139 141
 	if len(b) == 0 {
140 142
 		return nil
... ...
@@ -155,6 +181,7 @@ func (c *LxcConfig) UnmarshalJSON(b []byte) error {
155 155
 	return nil
156 156
 }
157 157
 
158
+// Len returns the number of specific lxc configuration.
158 159
 func (c *LxcConfig) Len() int {
159 160
 	if c == nil {
160 161
 		return 0
... ...
@@ -162,6 +189,7 @@ func (c *LxcConfig) Len() int {
162 162
 	return len(c.values)
163 163
 }
164 164
 
165
+// Slice returns the specific lxc configuration into a slice of KeyValuePair.
165 166
 func (c *LxcConfig) Slice() []KeyValuePair {
166 167
 	if c == nil {
167 168
 		return nil
... ...
@@ -169,14 +197,17 @@ func (c *LxcConfig) Slice() []KeyValuePair {
169 169
 	return c.values
170 170
 }
171 171
 
172
+// NewLxcConfig creates a LxcConfig from the specified slice of KeyValuePair.
172 173
 func NewLxcConfig(values []KeyValuePair) *LxcConfig {
173 174
 	return &LxcConfig{values}
174 175
 }
175 176
 
177
+// CapList represents the list of capabilities of the container.
176 178
 type CapList struct {
177 179
 	caps []string
178 180
 }
179 181
 
182
+// MarshalJSON marshals (or serializes) the CapList into JSON.
180 183
 func (c *CapList) MarshalJSON() ([]byte, error) {
181 184
 	if c == nil {
182 185
 		return []byte{}, nil
... ...
@@ -184,6 +215,8 @@ func (c *CapList) MarshalJSON() ([]byte, error) {
184 184
 	return json.Marshal(c.Slice())
185 185
 }
186 186
 
187
+// UnmarshalJSON unmarshals (or deserializes) the specified byte slices
188
+// from JSON to a CapList.
187 189
 func (c *CapList) UnmarshalJSON(b []byte) error {
188 190
 	if len(b) == 0 {
189 191
 		return nil
... ...
@@ -202,6 +235,7 @@ func (c *CapList) UnmarshalJSON(b []byte) error {
202 202
 	return nil
203 203
 }
204 204
 
205
+// Len returns the number of specific kernel capabilities.
205 206
 func (c *CapList) Len() int {
206 207
 	if c == nil {
207 208
 		return 0
... ...
@@ -209,6 +243,7 @@ func (c *CapList) Len() int {
209 209
 	return len(c.caps)
210 210
 }
211 211
 
212
+// Slice returns the specific capabilities into a slice of KeyValuePair.
212 213
 func (c *CapList) Slice() []string {
213 214
 	if c == nil {
214 215
 		return nil
... ...
@@ -216,49 +251,55 @@ func (c *CapList) Slice() []string {
216 216
 	return c.caps
217 217
 }
218 218
 
219
+// NewCapList creates a CapList from a slice of string.
219 220
 func NewCapList(caps []string) *CapList {
220 221
 	return &CapList{caps}
221 222
 }
222 223
 
224
+// HostConfig the non-portable Config structure of a container.
225
+// Here, "non-portable" means "dependent of the host we are running on".
226
+// Portable information *should* appear in Config.
223 227
 type HostConfig struct {
224
-	Binds            []string
225
-	ContainerIDFile  string
226
-	LxcConf          *LxcConfig
227
-	Memory           int64 // Memory limit (in bytes)
228
-	MemorySwap       int64 // Total memory usage (memory + swap); set `-1` to disable swap
229
-	CpuShares        int64 // CPU shares (relative weight vs. other containers)
230
-	CpuPeriod        int64
231
-	CpusetCpus       string // CpusetCpus 0-2, 0,1
232
-	CpusetMems       string // CpusetMems 0-2, 0,1
233
-	CpuQuota         int64
234
-	BlkioWeight      int64 // Block IO weight (relative weight vs. other containers)
235
-	OomKillDisable   bool  // Whether to disable OOM Killer or not
236
-	MemorySwappiness int64 // Tuning container memory swappiness behaviour
237
-	Privileged       bool
238
-	PortBindings     nat.PortMap
239
-	Links            []string
240
-	PublishAllPorts  bool
241
-	Dns              []string
242
-	DnsSearch        []string
243
-	ExtraHosts       []string
244
-	VolumesFrom      []string
245
-	Devices          []DeviceMapping
246
-	NetworkMode      NetworkMode
247
-	IpcMode          IpcMode
248
-	PidMode          PidMode
249
-	UTSMode          UTSMode
250
-	CapAdd           *CapList
251
-	CapDrop          *CapList
252
-	GroupAdd         []string
253
-	RestartPolicy    RestartPolicy
254
-	SecurityOpt      []string
255
-	ReadonlyRootfs   bool
256
-	Ulimits          []*ulimit.Ulimit
257
-	LogConfig        LogConfig
258
-	CgroupParent     string // Parent cgroup.
259
-	ConsoleSize      [2]int // Initial console size on Windows
260
-}
261
-
228
+	Binds            []string         // List of volume bindings for this container
229
+	ContainerIDFile  string           // File (path) where the containerId is written
230
+	LxcConf          *LxcConfig       // Additional lxc configuration
231
+	Memory           int64            // Memory limit (in bytes)
232
+	MemorySwap       int64            // Total memory usage (memory + swap); set `-1` to disable swap
233
+	CPUShares        int64            `json:"CpuShares"` // CPU shares (relative weight vs. other containers)
234
+	CPUPeriod        int64            `json:"CpuPeriod"` // CPU CFS (Completely Fair Scheduler) period
235
+	CpusetCpus       string           // CpusetCpus 0-2, 0,1
236
+	CpusetMems       string           // CpusetMems 0-2, 0,1
237
+	CPUQuota         int64            `json:"CpuQuota"` // CPU CFS (Completely Fair Scheduler) quota
238
+	BlkioWeight      int64            // Block IO weight (relative weight vs. other containers)
239
+	OomKillDisable   bool             // Whether to disable OOM Killer or not
240
+	MemorySwappiness int64            // Tuning container memory swappiness behaviour
241
+	Privileged       bool             // Is the container in privileged mode
242
+	PortBindings     nat.PortMap      // Port mapping between the exposed port (container) and the host
243
+	Links            []string         // List of links (in the name:alias form)
244
+	PublishAllPorts  bool             // Should docker publish all exposed port for the container
245
+	DNS              []string         `json:"Dns"`       // List of DNS server to lookup
246
+	DNSSearch        []string         `json:"DnsSearch"` // List of DNSSearch to look for
247
+	ExtraHosts       []string         // List of extra hosts
248
+	VolumesFrom      []string         // List of volumes to take from other container
249
+	Devices          []DeviceMapping  // List of devices to map inside the container
250
+	NetworkMode      NetworkMode      // Network namespace to use for the container
251
+	IpcMode          IpcMode          // IPC namespace to use for the container
252
+	PidMode          PidMode          // PID namespace to use for the container
253
+	UTSMode          UTSMode          // UTS namespace to use for the container
254
+	CapAdd           *CapList         // List of kernel capabilities to add to the container
255
+	CapDrop          *CapList         // List of kernel capabilities to remove from the container
256
+	GroupAdd         []string         // List of additional groups that the container process will run as
257
+	RestartPolicy    RestartPolicy    // Restart policy to be used for the container
258
+	SecurityOpt      []string         // List of string values to customize labels for MLS systems, such as SELinux.
259
+	ReadonlyRootfs   bool             // Is the container root filesystem in read-only
260
+	Ulimits          []*ulimit.Ulimit // List of ulimits to be set in the container
261
+	LogConfig        LogConfig        // Configuration of the logs for this container
262
+	CgroupParent     string           // Parent cgroup.
263
+	ConsoleSize      [2]int           // Initial console size on Windows
264
+}
265
+
266
+// MergeConfigs merges the specified container Config and HostConfig.
267
+// It creates a ContainerConfigWrapper.
262 268
 func MergeConfigs(config *Config, hostConfig *HostConfig) *ContainerConfigWrapper {
263 269
 	return &ContainerConfigWrapper{
264 270
 		config,
... ...
@@ -267,6 +308,8 @@ func MergeConfigs(config *Config, hostConfig *HostConfig) *ContainerConfigWrappe
267 267
 	}
268 268
 }
269 269
 
270
+// DecodeHostConfig creates a HostConfig based on the specified Reader.
271
+// It assumes the content of the reader will be JSON, and decodes it.
270 272
 func DecodeHostConfig(src io.Reader) (*HostConfig, error) {
271 273
 	decoder := json.NewDecoder(src)
272 274
 
... ...
@@ -6,19 +6,23 @@ import (
6 6
 	"strings"
7 7
 )
8 8
 
9
-// IsPrivate indicates whether container use it's private network stack
9
+// IsPrivate indicates whether container uses it's private network stack.
10 10
 func (n NetworkMode) IsPrivate() bool {
11 11
 	return !(n.IsHost() || n.IsContainer())
12 12
 }
13 13
 
14
+// IsDefault indicates whether container uses the default network stack.
14 15
 func (n NetworkMode) IsDefault() bool {
15 16
 	return n == "default"
16 17
 }
17 18
 
19
+// DefaultDaemonNetworkMode returns the default network stack the daemon should
20
+// use.
18 21
 func DefaultDaemonNetworkMode() NetworkMode {
19 22
 	return NetworkMode("bridge")
20 23
 }
21 24
 
25
+// NetworkName returns the name of the network stack.
22 26
 func (n NetworkMode) NetworkName() string {
23 27
 	if n.IsBridge() {
24 28
 		return "bridge"
... ...
@@ -34,19 +38,23 @@ func (n NetworkMode) NetworkName() string {
34 34
 	return ""
35 35
 }
36 36
 
37
+// IsBridge indicates whether container uses the bridge network stack
37 38
 func (n NetworkMode) IsBridge() bool {
38 39
 	return n == "bridge"
39 40
 }
40 41
 
42
+// IsHost indicates whether container uses the host network stack.
41 43
 func (n NetworkMode) IsHost() bool {
42 44
 	return n == "host"
43 45
 }
44 46
 
47
+// IsContainer indicates whether container uses a container network stack.
45 48
 func (n NetworkMode) IsContainer() bool {
46 49
 	parts := strings.SplitN(string(n), ":", 2)
47 50
 	return len(parts) > 1 && parts[0] == "container"
48 51
 }
49 52
 
53
+// IsNone indicates whether container isn't using a network stack.
50 54
 func (n NetworkMode) IsNone() bool {
51 55
 	return n == "none"
52 56
 }
... ...
@@ -1,13 +1,17 @@
1 1
 package runconfig
2 2
 
3
+// IsDefault indicates whether container uses the default network stack.
3 4
 func (n NetworkMode) IsDefault() bool {
4 5
 	return n == "default"
5 6
 }
6 7
 
8
+// DefaultDaemonNetworkMode returns the default network stack the daemon should
9
+// use.
7 10
 func DefaultDaemonNetworkMode() NetworkMode {
8 11
 	return NetworkMode("default")
9 12
 }
10 13
 
14
+// NetworkName returns the name of the network stack.
11 15
 func (n NetworkMode) NetworkName() string {
12 16
 	if n.IsDefault() {
13 17
 		return "default"
... ...
@@ -6,6 +6,11 @@ import (
6 6
 	"github.com/docker/docker/pkg/nat"
7 7
 )
8 8
 
9
+// Merge merges two Config, the image container configuration (defaults values),
10
+// and the user container configuration, either passed by the API or generated
11
+// by the cli.
12
+// It will mutate the specified user configuration (userConf) with the image
13
+// configuration where the user configuration is incomplete.
9 14
 func Merge(userConf, imageConf *Config) error {
10 15
 	if userConf.User == "" {
11 16
 		userConf.User = imageConf.User
... ...
@@ -13,14 +13,22 @@ import (
13 13
 )
14 14
 
15 15
 var (
16
+	// ErrConflictContainerNetworkAndLinks conflict between --net=container and links
16 17
 	ErrConflictContainerNetworkAndLinks = fmt.Errorf("Conflicting options: --net=container can't be used with links. This would result in undefined behavior")
17
-	ErrConflictNetworkAndDns            = fmt.Errorf("Conflicting options: --dns and the network mode (--net)")
18
-	ErrConflictNetworkHostname          = fmt.Errorf("Conflicting options: -h and the network mode (--net)")
19
-	ErrConflictHostNetworkAndLinks      = fmt.Errorf("Conflicting options: --net=host can't be used with links. This would result in undefined behavior")
20
-	ErrConflictContainerNetworkAndMac   = fmt.Errorf("Conflicting options: --mac-address and the network mode (--net)")
21
-	ErrConflictNetworkHosts             = fmt.Errorf("Conflicting options: --add-host and the network mode (--net)")
22
-	ErrConflictNetworkPublishPorts      = fmt.Errorf("Conflicting options: -p, -P, --publish-all, --publish and the network mode (--net)")
23
-	ErrConflictNetworkExposePorts       = fmt.Errorf("Conflicting options: --expose and the network mode (--expose)")
18
+	// ErrConflictNetworkAndDNS conflict between --dns and the network mode
19
+	ErrConflictNetworkAndDNS = fmt.Errorf("Conflicting options: --dns and the network mode (--net)")
20
+	// ErrConflictNetworkHostname conflict between the hostname and the network mode
21
+	ErrConflictNetworkHostname = fmt.Errorf("Conflicting options: -h and the network mode (--net)")
22
+	// ErrConflictHostNetworkAndLinks conflict between --net=host and links
23
+	ErrConflictHostNetworkAndLinks = fmt.Errorf("Conflicting options: --net=host can't be used with links. This would result in undefined behavior")
24
+	// ErrConflictContainerNetworkAndMac conflict between the mac address and the network mode
25
+	ErrConflictContainerNetworkAndMac = fmt.Errorf("Conflicting options: --mac-address and the network mode (--net)")
26
+	// ErrConflictNetworkHosts conflict between add-host and the network mode
27
+	ErrConflictNetworkHosts = fmt.Errorf("Conflicting options: --add-host and the network mode (--net)")
28
+	// ErrConflictNetworkPublishPorts conflict between the pulbish options and the network mode
29
+	ErrConflictNetworkPublishPorts = fmt.Errorf("Conflicting options: -p, -P, --publish-all, --publish and the network mode (--net)")
30
+	// ErrConflictNetworkExposePorts conflict between the expose option and the network mode
31
+	ErrConflictNetworkExposePorts = fmt.Errorf("Conflicting options: --expose and the network mode (--expose)")
24 32
 )
25 33
 
26 34
 // validateNM is the set of fields passed to validateNetMode()
... ...
@@ -28,7 +36,7 @@ type validateNM struct {
28 28
 	netMode        NetworkMode
29 29
 	flHostname     *string
30 30
 	flLinks        opts.ListOpts
31
-	flDns          opts.ListOpts
31
+	flDNS          opts.ListOpts
32 32
 	flExtraHosts   opts.ListOpts
33 33
 	flMacAddress   *string
34 34
 	flPublish      opts.ListOpts
... ...
@@ -37,6 +45,9 @@ type validateNM struct {
37 37
 	flVolumeDriver string
38 38
 }
39 39
 
40
+// Parse parses the specified args for the specified command and generates a Config,
41
+// a HostConfig and returns them with the specified command.
42
+// If the specified args are not valid, it will return an error.
40 43
 func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSet, error) {
41 44
 	var (
42 45
 		// FIXME: use utils.ListOpts for attach and volumes?
... ...
@@ -51,8 +62,8 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe
51 51
 
52 52
 		flPublish     = opts.NewListOpts(nil)
53 53
 		flExpose      = opts.NewListOpts(nil)
54
-		flDns         = opts.NewListOpts(opts.ValidateIPAddress)
55
-		flDnsSearch   = opts.NewListOpts(opts.ValidateDNSSearch)
54
+		flDNS         = opts.NewListOpts(opts.ValidateIPAddress)
55
+		flDNSSearch   = opts.NewListOpts(opts.ValidateDNSSearch)
56 56
 		flExtraHosts  = opts.NewListOpts(opts.ValidateExtraHost)
57 57
 		flVolumesFrom = opts.NewListOpts(nil)
58 58
 		flLxcOpts     = opts.NewListOpts(nil)
... ...
@@ -79,9 +90,9 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe
79 79
 		flMemorySwap      = cmd.String([]string{"-memory-swap"}, "", "Total memory (memory + swap), '-1' to disable swap")
80 80
 		flUser            = cmd.String([]string{"u", "-user"}, "", "Username or UID (format: <name|uid>[:<group|gid>])")
81 81
 		flWorkingDir      = cmd.String([]string{"w", "-workdir"}, "", "Working directory inside the container")
82
-		flCpuShares       = cmd.Int64([]string{"c", "-cpu-shares"}, 0, "CPU shares (relative weight)")
83
-		flCpuPeriod       = cmd.Int64([]string{"-cpu-period"}, 0, "Limit CPU CFS (Completely Fair Scheduler) period")
84
-		flCpuQuota        = cmd.Int64([]string{"-cpu-quota"}, 0, "Limit CPU CFS (Completely Fair Scheduler) quota")
82
+		flCPUShares       = cmd.Int64([]string{"c", "-cpu-shares"}, 0, "CPU shares (relative weight)")
83
+		flCPUPeriod       = cmd.Int64([]string{"-cpu-period"}, 0, "Limit CPU CFS (Completely Fair Scheduler) period")
84
+		flCPUQuota        = cmd.Int64([]string{"-cpu-quota"}, 0, "Limit CPU CFS (Completely Fair Scheduler) quota")
85 85
 		flCpusetCpus      = cmd.String([]string{"#-cpuset", "-cpuset-cpus"}, "", "CPUs in which to allow execution (0-3, 0,1)")
86 86
 		flCpusetMems      = cmd.String([]string{"-cpuset-mems"}, "", "MEMs in which to allow execution (0-3, 0,1)")
87 87
 		flBlkioWeight     = cmd.Int64([]string{"-blkio-weight"}, 0, "Block IO (relative weight), between 10 and 1000")
... ...
@@ -106,8 +117,8 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe
106 106
 	cmd.Var(&flEnvFile, []string{"-env-file"}, "Read in a file of environment variables")
107 107
 	cmd.Var(&flPublish, []string{"p", "-publish"}, "Publish a container's port(s) to the host")
108 108
 	cmd.Var(&flExpose, []string{"#expose", "-expose"}, "Expose a port or a range of ports")
109
-	cmd.Var(&flDns, []string{"#dns", "-dns"}, "Set custom DNS servers")
110
-	cmd.Var(&flDnsSearch, []string{"-dns-search"}, "Set custom DNS search domains")
109
+	cmd.Var(&flDNS, []string{"#dns", "-dns"}, "Set custom DNS servers")
110
+	cmd.Var(&flDNSSearch, []string{"-dns-search"}, "Set custom DNS search domains")
111 111
 	cmd.Var(&flExtraHosts, []string{"-add-host"}, "Add a custom host-to-IP mapping (host:ip)")
112 112
 	cmd.Var(&flVolumesFrom, []string{"#volumes-from", "-volumes-from"}, "Mount volumes from the specified container(s)")
113 113
 	cmd.Var(&flLxcOpts, []string{"#lxc-conf", "-lxc-conf"}, "Add custom lxc options")
... ...
@@ -141,7 +152,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe
141 141
 		netMode:      netMode,
142 142
 		flHostname:   flHostname,
143 143
 		flLinks:      flLinks,
144
-		flDns:        flDns,
144
+		flDNS:        flDNS,
145 145
 		flExtraHosts: flExtraHosts,
146 146
 		flMacAddress: flMacAddress,
147 147
 		flPublish:    flPublish,
... ...
@@ -272,7 +283,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe
272 272
 	// parse device mappings
273 273
 	deviceMappings := []DeviceMapping{}
274 274
 	for _, device := range flDevices.GetAll() {
275
-		deviceMapping, err := ParseDevice(device)
275
+		deviceMapping, err := parseDevice(device)
276 276
 		if err != nil {
277 277
 			return nil, nil, cmd, err
278 278
 		}
... ...
@@ -344,11 +355,11 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe
344 344
 		LxcConf:          lxcConf,
345 345
 		Memory:           flMemory,
346 346
 		MemorySwap:       MemorySwap,
347
-		CpuShares:        *flCpuShares,
348
-		CpuPeriod:        *flCpuPeriod,
347
+		CPUShares:        *flCPUShares,
348
+		CPUPeriod:        *flCPUPeriod,
349 349
 		CpusetCpus:       *flCpusetCpus,
350 350
 		CpusetMems:       *flCpusetMems,
351
-		CpuQuota:         *flCpuQuota,
351
+		CPUQuota:         *flCPUQuota,
352 352
 		BlkioWeight:      *flBlkioWeight,
353 353
 		OomKillDisable:   *flOomKillDisable,
354 354
 		MemorySwappiness: swappiness,
... ...
@@ -356,8 +367,8 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe
356 356
 		PortBindings:     portBindings,
357 357
 		Links:            flLinks.GetAll(),
358 358
 		PublishAllPorts:  *flPublishAll,
359
-		Dns:              flDns.GetAll(),
360
-		DnsSearch:        flDnsSearch.GetAll(),
359
+		DNS:              flDNS.GetAll(),
360
+		DNSSearch:        flDNSSearch.GetAll(),
361 361
 		ExtraHosts:       flExtraHosts.GetAll(),
362 362
 		VolumesFrom:      flVolumesFrom.GetAll(),
363 363
 		NetworkMode:      netMode,
... ...
@@ -476,7 +487,7 @@ func parseKeyValueOpts(opts opts.ListOpts) ([]KeyValuePair, error) {
476 476
 	return out, nil
477 477
 }
478 478
 
479
-func ParseDevice(device string) (DeviceMapping, error) {
479
+func parseDevice(device string) (DeviceMapping, error) {
480 480
 	src := ""
481 481
 	dst := ""
482 482
 	permissions := "rwm"
... ...
@@ -246,10 +246,10 @@ func TestConflictContainerNetworkAndLinks(t *testing.T) {
246 246
 }
247 247
 
248 248
 func TestConflictNetworkModeAndOptions(t *testing.T) {
249
-	if _, _, _, err := parseRun([]string{"--net=host", "--dns=8.8.8.8", "img", "cmd"}); err != ErrConflictNetworkAndDns {
249
+	if _, _, _, err := parseRun([]string{"--net=host", "--dns=8.8.8.8", "img", "cmd"}); err != ErrConflictNetworkAndDNS {
250 250
 		t.Fatalf("Expected error ErrConflictNetworkAndDns, got %s", err)
251 251
 	}
252
-	if _, _, _, err := parseRun([]string{"--net=container:other", "--dns=8.8.8.8", "img", "cmd"}); err != ErrConflictNetworkAndDns {
252
+	if _, _, _, err := parseRun([]string{"--net=container:other", "--dns=8.8.8.8", "img", "cmd"}); err != ErrConflictNetworkAndDNS {
253 253
 		t.Fatalf("Expected error ErrConflictNetworkAndDns, got %s", err)
254 254
 	}
255 255
 	if _, _, _, err := parseRun([]string{"--net=host", "--add-host=name:8.8.8.8", "img", "cmd"}); err != ErrConflictNetworkHosts {
... ...
@@ -35,8 +35,8 @@ func validateNetMode(vals *validateNM) error {
35 35
 		return ErrConflictContainerNetworkAndLinks
36 36
 	}
37 37
 
38
-	if (vals.netMode.IsHost() || vals.netMode.IsContainer()) && vals.flDns.Len() > 0 {
39
-		return ErrConflictNetworkAndDns
38
+	if (vals.netMode.IsHost() || vals.netMode.IsContainer()) && vals.flDNS.Len() > 0 {
39
+		return ErrConflictNetworkAndDNS
40 40
 	}
41 41
 
42 42
 	if (vals.netMode.IsContainer() || vals.netMode.IsHost()) && vals.flExtraHosts.Len() > 0 {