From 929f2c2f4074e66bb1e942a338e4d2a815096d45 Mon Sep 17 00:00:00 2001
From: root <root@ubuntu-14.04-amd64-vbox>
Date: Tue, 21 Jul 2015 00:55:30 +0000
Subject: [PATCH] api/client fix golint errors/warnings Addresses #14756

Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
---
 api/client/build.go          | 12 ++++++------
 api/client/cli.go            |  4 ++++
 api/client/export.go         |  3 +--
 api/client/network.go        |  1 +
 api/client/ps/custom_test.go |  4 ++--
 api/client/ps/formatter.go   | 14 +++++++++++---
 api/client/save.go           |  3 +--
 api/client/service.go        |  2 ++
 api/client/version.go        |  8 ++++----
 hack/make/validate-lint      |  2 ++
 10 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/api/client/build.go b/api/client/build.go
index 84f83f7a4f..05dec0bbfc 100644
--- a/api/client/build.go
+++ b/api/client/build.go
@@ -59,8 +59,8 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
 	flMemoryString := cmd.String([]string{"m", "-memory"}, "", "Memory limit")
 	flMemorySwap := cmd.String([]string{"-memory-swap"}, "", "Total memory (memory + swap), '-1' to disable swap")
 	flCPUShares := cmd.Int64([]string{"c", "-cpu-shares"}, 0, "CPU shares (relative weight)")
-	flCpuPeriod := cmd.Int64([]string{"-cpu-period"}, 0, "Limit the CPU CFS (Completely Fair Scheduler) period")
-	flCpuQuota := cmd.Int64([]string{"-cpu-quota"}, 0, "Limit the CPU CFS (Completely Fair Scheduler) quota")
+	flCPUPeriod := cmd.Int64([]string{"-cpu-period"}, 0, "Limit the CPU CFS (Completely Fair Scheduler) period")
+	flCPUQuota := cmd.Int64([]string{"-cpu-quota"}, 0, "Limit the CPU CFS (Completely Fair Scheduler) quota")
 	flCPUSetCpus := cmd.String([]string{"-cpuset-cpus"}, "", "CPUs in which to allow execution (0-3, 0,1)")
 	flCPUSetMems := cmd.String([]string{"-cpuset-mems"}, "", "MEMs in which to allow execution (0-3, 0,1)")
 	flCgroupParent := cmd.String([]string{"-cgroup-parent"}, "", "Optional parent cgroup for the container")
@@ -241,8 +241,8 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
 	v.Set("cpusetcpus", *flCPUSetCpus)
 	v.Set("cpusetmems", *flCPUSetMems)
 	v.Set("cpushares", strconv.FormatInt(*flCPUShares, 10))
-	v.Set("cpuquota", strconv.FormatInt(*flCpuQuota, 10))
-	v.Set("cpuperiod", strconv.FormatInt(*flCpuPeriod, 10))
+	v.Set("cpuquota", strconv.FormatInt(*flCPUQuota, 10))
+	v.Set("cpuperiod", strconv.FormatInt(*flCPUPeriod, 10))
 	v.Set("memory", strconv.FormatInt(memory, 10))
 	v.Set("memswap", strconv.FormatInt(memorySwap, 10))
 	v.Set("cgroupparent", *flCgroupParent)
@@ -250,11 +250,11 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
 	v.Set("dockerfile", relDockerfile)
 
 	ulimitsVar := flUlimits.GetList()
-	ulimitsJson, err := json.Marshal(ulimitsVar)
+	ulimitsJSON, err := json.Marshal(ulimitsVar)
 	if err != nil {
 		return err
 	}
-	v.Set("ulimits", string(ulimitsJson))
+	v.Set("ulimits", string(ulimitsJSON))
 
 	headers := http.Header(make(map[string][]string))
 	buf, err := json.Marshal(cli.configFile.AuthConfigs)
diff --git a/api/client/cli.go b/api/client/cli.go
index fc4e236285..c9b121ee6f 100644
--- a/api/client/cli.go
+++ b/api/client/cli.go
@@ -58,6 +58,8 @@ type DockerCli struct {
 	transport *http.Transport
 }
 
+// Initialize calls the init function that will setup the configuration for the client
+// such as the TLS, tcp and other parameters used to run the client.
 func (cli *DockerCli) Initialize() error {
 	if cli.init == nil {
 		return nil
@@ -77,6 +79,8 @@ func (cli *DockerCli) CheckTtyInput(attachStdin, ttyMode bool) error {
 	return nil
 }
 
+// PsFormat returns the format string specified in the configuration.
+// String contains columns and format specification, for example {{ID}\t{{Name}}.
 func (cli *DockerCli) PsFormat() string {
 	return cli.configFile.PsFormat
 }
diff --git a/api/client/export.go b/api/client/export.go
index 78594997be..4d35d54b6e 100644
--- a/api/client/export.go
+++ b/api/client/export.go
@@ -2,7 +2,6 @@ package client
 
 import (
 	"errors"
-	"io"
 	"os"
 
 	Cli "github.com/docker/docker/cli"
@@ -22,7 +21,7 @@ func (cli *DockerCli) CmdExport(args ...string) error {
 	cmd.ParseFlags(args, true)
 
 	var (
-		output io.Writer = cli.out
+		output = cli.out
 		err    error
 	)
 	if *outfile != "" {
diff --git a/api/client/network.go b/api/client/network.go
index b550668be5..a1de26993c 100644
--- a/api/client/network.go
+++ b/api/client/network.go
@@ -8,6 +8,7 @@ import (
 	nwclient "github.com/docker/libnetwork/client"
 )
 
+// CmdNetwork is used to create, display and configure network endpoints.
 func (cli *DockerCli) CmdNetwork(args ...string) error {
 	nCli := nwclient.NewNetworkCli(cli.out, cli.err, nwclient.CallFunc(cli.callWrapper))
 	args = append([]string{"network"}, args...)
diff --git a/api/client/ps/custom_test.go b/api/client/ps/custom_test.go
index 2e2adacda7..e657537536 100644
--- a/api/client/ps/custom_test.go
+++ b/api/client/ps/custom_test.go
@@ -11,7 +11,7 @@ import (
 )
 
 func TestContainerContextID(t *testing.T) {
-	containerId := stringid.GenerateNonCryptoID()
+	containerID := stringid.GenerateRandomID()
 	unix := time.Now().Unix()
 
 	var ctx containerContext
@@ -22,7 +22,7 @@ func TestContainerContextID(t *testing.T) {
 		expHeader string
 		call      func() string
 	}{
-		{types.Container{ID: containerId}, true, stringid.TruncateID(containerId), idHeader, ctx.ID},
+		{types.Container{ID: containerID}, true, stringid.TruncateID(containerID), idHeader, ctx.ID},
 		{types.Container{Names: []string{"/foobar_baz"}}, true, "foobar_baz", namesHeader, ctx.Names},
 		{types.Container{Image: "ubuntu"}, true, "ubuntu", imageHeader, ctx.Image},
 		{types.Container{Image: ""}, true, "<no image>", imageHeader, ctx.Image},
diff --git a/api/client/ps/formatter.go b/api/client/ps/formatter.go
index 9b3bdc812a..1a1323ac1c 100644
--- a/api/client/ps/formatter.go
+++ b/api/client/ps/formatter.go
@@ -14,14 +14,22 @@ const (
 	defaultQuietFormat = "{{.ID}}"
 )
 
+// Context contains information required by the formatter to print the output as desired.
 type Context struct {
+	// Output is the output stream to which the formatted string is written.
 	Output io.Writer
+	// Format is used to choose raw, table or custom format for the output.
 	Format string
-	Size   bool
-	Quiet  bool
-	Trunc  bool
+	// Size when set to true will display the size of the output.
+	Size bool
+	// Quiet when set to true will simply print minimal information.
+	Quiet bool
+	// Trunc when set to true will truncate the output of certain fields such as Container ID.
+	Trunc bool
 }
 
+// Format helps to format the output using the parameters set in the Context.
+// Currently Format allow to display in raw, table or custom format the output.
 func Format(ctx Context, containers []types.Container) {
 	switch ctx.Format {
 	case tableFormatKey:
diff --git a/api/client/save.go b/api/client/save.go
index 5155319c80..ee19d7767d 100644
--- a/api/client/save.go
+++ b/api/client/save.go
@@ -2,7 +2,6 @@ package client
 
 import (
 	"errors"
-	"io"
 	"net/url"
 	"os"
 
@@ -23,7 +22,7 @@ func (cli *DockerCli) CmdSave(args ...string) error {
 	cmd.ParseFlags(args, true)
 
 	var (
-		output io.Writer = cli.out
+		output = cli.out
 		err    error
 	)
 	if *outfile != "" {
diff --git a/api/client/service.go b/api/client/service.go
index 6a1e3da87b..9f0b1fcfc4 100644
--- a/api/client/service.go
+++ b/api/client/service.go
@@ -8,6 +8,8 @@ import (
 	nwclient "github.com/docker/libnetwork/client"
 )
 
+// CmdService is used to manage network services.
+// service command is user to publish, attach and list a service from a container.
 func (cli *DockerCli) CmdService(args ...string) error {
 	nCli := nwclient.NewNetworkCli(cli.out, cli.err, nwclient.CallFunc(cli.callWrapper))
 	args = append([]string{"service"}, args...)
diff --git a/api/client/version.go b/api/client/version.go
index 4c42a32de8..2f1dba0714 100644
--- a/api/client/version.go
+++ b/api/client/version.go
@@ -13,7 +13,7 @@ import (
 	"github.com/docker/docker/utils"
 )
 
-var VersionTemplate = `Client:
+var versionTemplate = `Client:
  Version:      {{.Client.Version}}
  API version:  {{.Client.ApiVersion}}
  Go version:   {{.Client.GoVersion}}
@@ -31,7 +31,7 @@ Server:
  OS/Arch:      {{.Server.Os}}/{{.Server.Arch}}{{if .Server.Experimental}}
  Experimental: {{.Server.Experimental}}{{end}}{{end}}`
 
-type VersionData struct {
+type versionData struct {
 	Client   types.Version
 	ServerOK bool
 	Server   types.Version
@@ -49,7 +49,7 @@ func (cli *DockerCli) CmdVersion(args ...string) (err error) {
 
 	cmd.ParseFlags(args, true)
 	if *tmplStr == "" {
-		*tmplStr = VersionTemplate
+		*tmplStr = versionTemplate
 	}
 
 	var tmpl *template.Template
@@ -58,7 +58,7 @@ func (cli *DockerCli) CmdVersion(args ...string) (err error) {
 			Status: "Template parsing error: " + err.Error()}
 	}
 
-	vd := VersionData{
+	vd := versionData{
 		Client: types.Version{
 			Version:      dockerversion.VERSION,
 			ApiVersion:   api.Version,
diff --git a/hack/make/validate-lint b/hack/make/validate-lint
index cbe9d5ccf1..5995af21d0 100644
--- a/hack/make/validate-lint
+++ b/hack/make/validate-lint
@@ -9,6 +9,8 @@ source "${MAKEDIR}/.validate"
 
 packages=(
 	api/server
+	api/client
+	api/client/ps
 	builder
 	builder/command
 	builder/parser