From a465e26bb05083c247ba74e1092338c43c76be47 Mon Sep 17 00:00:00 2001 From: Peggy Li Date: Wed, 25 Mar 2015 19:31:29 -0700 Subject: [PATCH] Fix golint errors for casing in api/client package Signed-off-by: Peggy Li --- api/client/build.go | 8 ++++---- api/client/events.go | 4 ++-- api/client/images.go | 8 ++++---- api/client/ps.go | 4 ++-- api/client/rename.go | 8 ++++---- api/client/run.go | 8 ++++---- api/client/stats.go | 18 +++++++++--------- api/client/utils.go | 12 ++++++------ 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/api/client/build.go b/api/client/build.go index 91446132ab..0847a6c5aa 100644 --- a/api/client/build.go +++ b/api/client/build.go @@ -47,8 +47,8 @@ func (cli *DockerCli) CmdBuild(args ...string) error { dockerfileName := cmd.String([]string{"f", "-file"}, "", "Name of the Dockerfile (Default is 'PATH/Dockerfile')") 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)") - flCpuSetCpus := cmd.String([]string{"-cpuset-cpus"}, "", "CPUs in which to allow execution (0-3, 0,1)") + flCPUShares := cmd.Int64([]string{"c", "-cpu-shares"}, 0, "CPU shares (relative weight)") + flCPUSetCpus := cmd.String([]string{"-cpuset-cpus"}, "", "CPUs in which to allow execution (0-3, 0,1)") cmd.Require(flag.Exact, 1) @@ -271,8 +271,8 @@ func (cli *DockerCli) CmdBuild(args ...string) error { v.Set("pull", "1") } - v.Set("cpusetcpus", *flCpuSetCpus) - v.Set("cpushares", strconv.FormatInt(*flCpuShares, 10)) + v.Set("cpusetcpus", *flCPUSetCpus) + v.Set("cpushares", strconv.FormatInt(*flCPUShares, 10)) v.Set("memory", strconv.FormatInt(memory, 10)) v.Set("memswap", strconv.FormatInt(memorySwap, 10)) diff --git a/api/client/events.go b/api/client/events.go index bc39e3cfd0..4e60ec29f6 100644 --- a/api/client/events.go +++ b/api/client/events.go @@ -55,11 +55,11 @@ func (cli *DockerCli) CmdEvents(args ...string) error { setTime("until", *until) } if len(eventFilterArgs) > 0 { - filterJson, err := filters.ToParam(eventFilterArgs) + filterJSON, err := filters.ToParam(eventFilterArgs) if err != nil { return err } - v.Set("filters", filterJson) + v.Set("filters", filterJSON) } if err := cli.stream("GET", "/events?"+v.Encode(), nil, cli.out, nil); err != nil { return err diff --git a/api/client/images.go b/api/client/images.go index d59a0838aa..93959845c3 100644 --- a/api/client/images.go +++ b/api/client/images.go @@ -119,11 +119,11 @@ func (cli *DockerCli) CmdImages(args ...string) error { "all": []string{"1"}, } if len(imageFilterArgs) > 0 { - filterJson, err := filters.ToParam(imageFilterArgs) + filterJSON, err := filters.ToParam(imageFilterArgs) if err != nil { return err } - v.Set("filters", filterJson) + v.Set("filters", filterJSON) } body, _, err := readBody(cli.call("GET", "/images/json?"+v.Encode(), nil, false)) @@ -189,11 +189,11 @@ func (cli *DockerCli) CmdImages(args ...string) error { } else { v := url.Values{} if len(imageFilterArgs) > 0 { - filterJson, err := filters.ToParam(imageFilterArgs) + filterJSON, err := filters.ToParam(imageFilterArgs) if err != nil { return err } - v.Set("filters", filterJson) + v.Set("filters", filterJSON) } if cmd.NArg() == 1 { diff --git a/api/client/ps.go b/api/client/ps.go index fa9b2b4882..b4160d57a7 100644 --- a/api/client/ps.go +++ b/api/client/ps.go @@ -74,12 +74,12 @@ func (cli *DockerCli) CmdPs(args ...string) error { } if len(psFilterArgs) > 0 { - filterJson, err := filters.ToParam(psFilterArgs) + filterJSON, err := filters.ToParam(psFilterArgs) if err != nil { return err } - v.Set("filters", filterJson) + v.Set("filters", filterJSON) } body, _, err := readBody(cli.call("GET", "/containers/json?"+v.Encode(), nil, false)) diff --git a/api/client/rename.go b/api/client/rename.go index 82d2b74c32..11138cfc5c 100644 --- a/api/client/rename.go +++ b/api/client/rename.go @@ -12,12 +12,12 @@ func (cli *DockerCli) CmdRename(args ...string) error { cmd.Usage() return nil } - old_name := cmd.Arg(0) - new_name := cmd.Arg(1) + oldName := cmd.Arg(0) + newName := cmd.Arg(1) - if _, _, err := readBody(cli.call("POST", fmt.Sprintf("/containers/%s/rename?name=%s", old_name, new_name), nil, false)); err != nil { + if _, _, err := readBody(cli.call("POST", fmt.Sprintf("/containers/%s/rename?name=%s", oldName, newName), nil, false)); err != nil { fmt.Fprintf(cli.err, "%s\n", err) - return fmt.Errorf("Error: failed to rename container named %s", old_name) + return fmt.Errorf("Error: failed to rename container named %s", oldName) } return nil } diff --git a/api/client/run.go b/api/client/run.go index e00a3d78db..f3cace97b8 100644 --- a/api/client/run.go +++ b/api/client/run.go @@ -110,14 +110,14 @@ func (cli *DockerCli) CmdRun(args ...string) error { defer signal.StopCatch(sigc) } var ( - waitDisplayId chan struct{} + waitDisplayID chan struct{} errCh chan error ) if !config.AttachStdout && !config.AttachStderr { // Make this asynchronous to allow the client to write to stdin before having to read the ID - waitDisplayId = make(chan struct{}) + waitDisplayID = make(chan struct{}) go func() { - defer close(waitDisplayId) + defer close(waitDisplayID) fmt.Fprintf(cli.out, "%s\n", createResponse.ID) }() } @@ -207,7 +207,7 @@ func (cli *DockerCli) CmdRun(args ...string) error { // Detached mode: wait for the id to be displayed and return. if !config.AttachStdout && !config.AttachStderr { // Detached mode - <-waitDisplayId + <-waitDisplayID return nil } diff --git a/api/client/stats.go b/api/client/stats.go index 8999abdb2b..91f024247a 100644 --- a/api/client/stats.go +++ b/api/client/stats.go @@ -18,7 +18,7 @@ import ( type containerStats struct { Name string - CpuPercentage float64 + CPUPercentage float64 Memory float64 MemoryLimit float64 MemoryPercentage float64 @@ -36,7 +36,7 @@ func (s *containerStats) Collect(cli *DockerCli) { } defer stream.Close() var ( - previousCpu uint64 + previousCPU uint64 previousSystem uint64 start = true dec = json.NewDecoder(stream) @@ -54,18 +54,18 @@ func (s *containerStats) Collect(cli *DockerCli) { cpuPercent = 0.0 ) if !start { - cpuPercent = calculateCpuPercent(previousCpu, previousSystem, v) + cpuPercent = calculateCPUPercent(previousCPU, previousSystem, v) } start = false s.mu.Lock() - s.CpuPercentage = cpuPercent + s.CPUPercentage = cpuPercent s.Memory = float64(v.MemoryStats.Usage) s.MemoryLimit = float64(v.MemoryStats.Limit) s.MemoryPercentage = memPercent s.NetworkRx = float64(v.Network.RxBytes) s.NetworkTx = float64(v.Network.TxBytes) s.mu.Unlock() - previousCpu = v.CpuStats.CpuUsage.TotalUsage + previousCPU = v.CpuStats.CpuUsage.TotalUsage previousSystem = v.CpuStats.SystemUsage u <- nil } @@ -76,7 +76,7 @@ func (s *containerStats) Collect(cli *DockerCli) { // zero out the values if we have not received an update within // the specified duration. s.mu.Lock() - s.CpuPercentage = 0 + s.CPUPercentage = 0 s.Memory = 0 s.MemoryPercentage = 0 s.mu.Unlock() @@ -99,7 +99,7 @@ func (s *containerStats) Display(w io.Writer) error { } fmt.Fprintf(w, "%s\t%.2f%%\t%s/%s\t%.2f%%\t%s/%s\n", s.Name, - s.CpuPercentage, + s.CPUPercentage, units.BytesSize(s.Memory), units.BytesSize(s.MemoryLimit), s.MemoryPercentage, units.BytesSize(s.NetworkRx), units.BytesSize(s.NetworkTx)) @@ -161,11 +161,11 @@ func (cli *DockerCli) CmdStats(args ...string) error { return nil } -func calculateCpuPercent(previousCpu, previousSystem uint64, v *types.Stats) float64 { +func calculateCPUPercent(previousCPU, previousSystem uint64, v *types.Stats) float64 { var ( cpuPercent = 0.0 // calculate the change for the cpu usage of the container in between readings - cpuDelta = float64(v.CpuStats.CpuUsage.TotalUsage - previousCpu) + cpuDelta = float64(v.CpuStats.CpuUsage.TotalUsage - previousCPU) // calculate the change for the entire system between readings systemDelta = float64(v.CpuStats.SystemUsage - previousSystem) ) diff --git a/api/client/utils.go b/api/client/utils.go index 103bfdec3a..6e7784d0f3 100644 --- a/api/client/utils.go +++ b/api/client/utils.go @@ -200,8 +200,8 @@ func (cli *DockerCli) resizeTty(id string, isExec bool) { } } -func waitForExit(cli *DockerCli, containerId string) (int, error) { - stream, _, err := cli.call("POST", "/containers/"+containerId+"/wait", nil, false) +func waitForExit(cli *DockerCli, containerID string) (int, error) { + stream, _, err := cli.call("POST", "/containers/"+containerID+"/wait", nil, false) if err != nil { return -1, err } @@ -215,8 +215,8 @@ func waitForExit(cli *DockerCli, containerId string) (int, error) { // getExitCode perform an inspect on the container. It returns // the running state and the exit code. -func getExitCode(cli *DockerCli, containerId string) (bool, int, error) { - stream, _, err := cli.call("GET", "/containers/"+containerId+"/json", nil, false) +func getExitCode(cli *DockerCli, containerID string) (bool, int, error) { + stream, _, err := cli.call("GET", "/containers/"+containerID+"/json", nil, false) if err != nil { // If we can't connect, then the daemon probably died. if err != ErrConnectionRefused { @@ -236,8 +236,8 @@ func getExitCode(cli *DockerCli, containerId string) (bool, int, error) { // getExecExitCode perform an inspect on the exec command. It returns // the running state and the exit code. -func getExecExitCode(cli *DockerCli, execId string) (bool, int, error) { - stream, _, err := cli.call("GET", "/exec/"+execId+"/json", nil, false) +func getExecExitCode(cli *DockerCli, execID string) (bool, int, error) { + stream, _, err := cli.call("GET", "/exec/"+execID+"/json", nil, false) if err != nil { // If we can't connect, then the daemon probably died. if err != ErrConnectionRefused {