Browse code

api/client fix golint errors/warnings Addresses #14756

Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>

root authored on 2015/07/21 09:55:30
Showing 10 changed files
... ...
@@ -59,8 +59,8 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
59 59
 	flMemoryString := cmd.String([]string{"m", "-memory"}, "", "Memory limit")
60 60
 	flMemorySwap := cmd.String([]string{"-memory-swap"}, "", "Total memory (memory + swap), '-1' to disable swap")
61 61
 	flCPUShares := cmd.Int64([]string{"c", "-cpu-shares"}, 0, "CPU shares (relative weight)")
62
-	flCpuPeriod := cmd.Int64([]string{"-cpu-period"}, 0, "Limit the CPU CFS (Completely Fair Scheduler) period")
63
-	flCpuQuota := cmd.Int64([]string{"-cpu-quota"}, 0, "Limit the CPU CFS (Completely Fair Scheduler) quota")
62
+	flCPUPeriod := cmd.Int64([]string{"-cpu-period"}, 0, "Limit the CPU CFS (Completely Fair Scheduler) period")
63
+	flCPUQuota := cmd.Int64([]string{"-cpu-quota"}, 0, "Limit the CPU CFS (Completely Fair Scheduler) quota")
64 64
 	flCPUSetCpus := cmd.String([]string{"-cpuset-cpus"}, "", "CPUs in which to allow execution (0-3, 0,1)")
65 65
 	flCPUSetMems := cmd.String([]string{"-cpuset-mems"}, "", "MEMs in which to allow execution (0-3, 0,1)")
66 66
 	flCgroupParent := cmd.String([]string{"-cgroup-parent"}, "", "Optional parent cgroup for the container")
... ...
@@ -241,8 +241,8 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
241 241
 	v.Set("cpusetcpus", *flCPUSetCpus)
242 242
 	v.Set("cpusetmems", *flCPUSetMems)
243 243
 	v.Set("cpushares", strconv.FormatInt(*flCPUShares, 10))
244
-	v.Set("cpuquota", strconv.FormatInt(*flCpuQuota, 10))
245
-	v.Set("cpuperiod", strconv.FormatInt(*flCpuPeriod, 10))
244
+	v.Set("cpuquota", strconv.FormatInt(*flCPUQuota, 10))
245
+	v.Set("cpuperiod", strconv.FormatInt(*flCPUPeriod, 10))
246 246
 	v.Set("memory", strconv.FormatInt(memory, 10))
247 247
 	v.Set("memswap", strconv.FormatInt(memorySwap, 10))
248 248
 	v.Set("cgroupparent", *flCgroupParent)
... ...
@@ -250,11 +250,11 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
250 250
 	v.Set("dockerfile", relDockerfile)
251 251
 
252 252
 	ulimitsVar := flUlimits.GetList()
253
-	ulimitsJson, err := json.Marshal(ulimitsVar)
253
+	ulimitsJSON, err := json.Marshal(ulimitsVar)
254 254
 	if err != nil {
255 255
 		return err
256 256
 	}
257
-	v.Set("ulimits", string(ulimitsJson))
257
+	v.Set("ulimits", string(ulimitsJSON))
258 258
 
259 259
 	headers := http.Header(make(map[string][]string))
260 260
 	buf, err := json.Marshal(cli.configFile.AuthConfigs)
... ...
@@ -58,6 +58,8 @@ type DockerCli struct {
58 58
 	transport *http.Transport
59 59
 }
60 60
 
61
+// Initialize calls the init function that will setup the configuration for the client
62
+// such as the TLS, tcp and other parameters used to run the client.
61 63
 func (cli *DockerCli) Initialize() error {
62 64
 	if cli.init == nil {
63 65
 		return nil
... ...
@@ -77,6 +79,8 @@ func (cli *DockerCli) CheckTtyInput(attachStdin, ttyMode bool) error {
77 77
 	return nil
78 78
 }
79 79
 
80
+// PsFormat returns the format string specified in the configuration.
81
+// String contains columns and format specification, for example {{ID}\t{{Name}}.
80 82
 func (cli *DockerCli) PsFormat() string {
81 83
 	return cli.configFile.PsFormat
82 84
 }
... ...
@@ -2,7 +2,6 @@ package client
2 2
 
3 3
 import (
4 4
 	"errors"
5
-	"io"
6 5
 	"os"
7 6
 
8 7
 	Cli "github.com/docker/docker/cli"
... ...
@@ -22,7 +21,7 @@ func (cli *DockerCli) CmdExport(args ...string) error {
22 22
 	cmd.ParseFlags(args, true)
23 23
 
24 24
 	var (
25
-		output io.Writer = cli.out
25
+		output = cli.out
26 26
 		err    error
27 27
 	)
28 28
 	if *outfile != "" {
... ...
@@ -8,6 +8,7 @@ import (
8 8
 	nwclient "github.com/docker/libnetwork/client"
9 9
 )
10 10
 
11
+// CmdNetwork is used to create, display and configure network endpoints.
11 12
 func (cli *DockerCli) CmdNetwork(args ...string) error {
12 13
 	nCli := nwclient.NewNetworkCli(cli.out, cli.err, nwclient.CallFunc(cli.callWrapper))
13 14
 	args = append([]string{"network"}, args...)
... ...
@@ -11,7 +11,7 @@ import (
11 11
 )
12 12
 
13 13
 func TestContainerContextID(t *testing.T) {
14
-	containerId := stringid.GenerateNonCryptoID()
14
+	containerID := stringid.GenerateRandomID()
15 15
 	unix := time.Now().Unix()
16 16
 
17 17
 	var ctx containerContext
... ...
@@ -22,7 +22,7 @@ func TestContainerContextID(t *testing.T) {
22 22
 		expHeader string
23 23
 		call      func() string
24 24
 	}{
25
-		{types.Container{ID: containerId}, true, stringid.TruncateID(containerId), idHeader, ctx.ID},
25
+		{types.Container{ID: containerID}, true, stringid.TruncateID(containerID), idHeader, ctx.ID},
26 26
 		{types.Container{Names: []string{"/foobar_baz"}}, true, "foobar_baz", namesHeader, ctx.Names},
27 27
 		{types.Container{Image: "ubuntu"}, true, "ubuntu", imageHeader, ctx.Image},
28 28
 		{types.Container{Image: ""}, true, "<no image>", imageHeader, ctx.Image},
... ...
@@ -14,14 +14,22 @@ const (
14 14
 	defaultQuietFormat = "{{.ID}}"
15 15
 )
16 16
 
17
+// Context contains information required by the formatter to print the output as desired.
17 18
 type Context struct {
19
+	// Output is the output stream to which the formatted string is written.
18 20
 	Output io.Writer
21
+	// Format is used to choose raw, table or custom format for the output.
19 22
 	Format string
20
-	Size   bool
21
-	Quiet  bool
22
-	Trunc  bool
23
+	// Size when set to true will display the size of the output.
24
+	Size bool
25
+	// Quiet when set to true will simply print minimal information.
26
+	Quiet bool
27
+	// Trunc when set to true will truncate the output of certain fields such as Container ID.
28
+	Trunc bool
23 29
 }
24 30
 
31
+// Format helps to format the output using the parameters set in the Context.
32
+// Currently Format allow to display in raw, table or custom format the output.
25 33
 func Format(ctx Context, containers []types.Container) {
26 34
 	switch ctx.Format {
27 35
 	case tableFormatKey:
... ...
@@ -2,7 +2,6 @@ package client
2 2
 
3 3
 import (
4 4
 	"errors"
5
-	"io"
6 5
 	"net/url"
7 6
 	"os"
8 7
 
... ...
@@ -23,7 +22,7 @@ func (cli *DockerCli) CmdSave(args ...string) error {
23 23
 	cmd.ParseFlags(args, true)
24 24
 
25 25
 	var (
26
-		output io.Writer = cli.out
26
+		output = cli.out
27 27
 		err    error
28 28
 	)
29 29
 	if *outfile != "" {
... ...
@@ -8,6 +8,8 @@ import (
8 8
 	nwclient "github.com/docker/libnetwork/client"
9 9
 )
10 10
 
11
+// CmdService is used to manage network services.
12
+// service command is user to publish, attach and list a service from a container.
11 13
 func (cli *DockerCli) CmdService(args ...string) error {
12 14
 	nCli := nwclient.NewNetworkCli(cli.out, cli.err, nwclient.CallFunc(cli.callWrapper))
13 15
 	args = append([]string{"service"}, args...)
... ...
@@ -13,7 +13,7 @@ import (
13 13
 	"github.com/docker/docker/utils"
14 14
 )
15 15
 
16
-var VersionTemplate = `Client:
16
+var versionTemplate = `Client:
17 17
  Version:      {{.Client.Version}}
18 18
  API version:  {{.Client.ApiVersion}}
19 19
  Go version:   {{.Client.GoVersion}}
... ...
@@ -31,7 +31,7 @@ Server:
31 31
  OS/Arch:      {{.Server.Os}}/{{.Server.Arch}}{{if .Server.Experimental}}
32 32
  Experimental: {{.Server.Experimental}}{{end}}{{end}}`
33 33
 
34
-type VersionData struct {
34
+type versionData struct {
35 35
 	Client   types.Version
36 36
 	ServerOK bool
37 37
 	Server   types.Version
... ...
@@ -49,7 +49,7 @@ func (cli *DockerCli) CmdVersion(args ...string) (err error) {
49 49
 
50 50
 	cmd.ParseFlags(args, true)
51 51
 	if *tmplStr == "" {
52
-		*tmplStr = VersionTemplate
52
+		*tmplStr = versionTemplate
53 53
 	}
54 54
 
55 55
 	var tmpl *template.Template
... ...
@@ -58,7 +58,7 @@ func (cli *DockerCli) CmdVersion(args ...string) (err error) {
58 58
 			Status: "Template parsing error: " + err.Error()}
59 59
 	}
60 60
 
61
-	vd := VersionData{
61
+	vd := versionData{
62 62
 		Client: types.Version{
63 63
 			Version:      dockerversion.VERSION,
64 64
 			ApiVersion:   api.Version,
... ...
@@ -9,6 +9,8 @@ source "${MAKEDIR}/.validate"
9 9
 
10 10
 packages=(
11 11
 	api/server
12
+	api/client
13
+	api/client/ps
12 14
 	builder
13 15
 	builder/command
14 16
 	builder/parser