Signed-off-by: Peggy Li <peggyli.224@gmail.com>
| ... | ... |
@@ -47,8 +47,8 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
| 47 | 47 |
dockerfileName := cmd.String([]string{"f", "-file"}, "", "Name of the Dockerfile (Default is 'PATH/Dockerfile')")
|
| 48 | 48 |
flMemoryString := cmd.String([]string{"m", "-memory"}, "", "Memory limit")
|
| 49 | 49 |
flMemorySwap := cmd.String([]string{"-memory-swap"}, "", "Total memory (memory + swap), '-1' to disable swap")
|
| 50 |
- flCpuShares := cmd.Int64([]string{"c", "-cpu-shares"}, 0, "CPU shares (relative weight)")
|
|
| 51 |
- flCpuSetCpus := cmd.String([]string{"-cpuset-cpus"}, "", "CPUs in which to allow execution (0-3, 0,1)")
|
|
| 50 |
+ flCPUShares := cmd.Int64([]string{"c", "-cpu-shares"}, 0, "CPU shares (relative weight)")
|
|
| 51 |
+ flCPUSetCpus := cmd.String([]string{"-cpuset-cpus"}, "", "CPUs in which to allow execution (0-3, 0,1)")
|
|
| 52 | 52 |
|
| 53 | 53 |
cmd.Require(flag.Exact, 1) |
| 54 | 54 |
|
| ... | ... |
@@ -271,8 +271,8 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
| 271 | 271 |
v.Set("pull", "1")
|
| 272 | 272 |
} |
| 273 | 273 |
|
| 274 |
- v.Set("cpusetcpus", *flCpuSetCpus)
|
|
| 275 |
- v.Set("cpushares", strconv.FormatInt(*flCpuShares, 10))
|
|
| 274 |
+ v.Set("cpusetcpus", *flCPUSetCpus)
|
|
| 275 |
+ v.Set("cpushares", strconv.FormatInt(*flCPUShares, 10))
|
|
| 276 | 276 |
v.Set("memory", strconv.FormatInt(memory, 10))
|
| 277 | 277 |
v.Set("memswap", strconv.FormatInt(memorySwap, 10))
|
| 278 | 278 |
|
| ... | ... |
@@ -55,11 +55,11 @@ func (cli *DockerCli) CmdEvents(args ...string) error {
|
| 55 | 55 |
setTime("until", *until)
|
| 56 | 56 |
} |
| 57 | 57 |
if len(eventFilterArgs) > 0 {
|
| 58 |
- filterJson, err := filters.ToParam(eventFilterArgs) |
|
| 58 |
+ filterJSON, err := filters.ToParam(eventFilterArgs) |
|
| 59 | 59 |
if err != nil {
|
| 60 | 60 |
return err |
| 61 | 61 |
} |
| 62 |
- v.Set("filters", filterJson)
|
|
| 62 |
+ v.Set("filters", filterJSON)
|
|
| 63 | 63 |
} |
| 64 | 64 |
if err := cli.stream("GET", "/events?"+v.Encode(), nil, cli.out, nil); err != nil {
|
| 65 | 65 |
return err |
| ... | ... |
@@ -119,11 +119,11 @@ func (cli *DockerCli) CmdImages(args ...string) error {
|
| 119 | 119 |
"all": []string{"1"},
|
| 120 | 120 |
} |
| 121 | 121 |
if len(imageFilterArgs) > 0 {
|
| 122 |
- filterJson, err := filters.ToParam(imageFilterArgs) |
|
| 122 |
+ filterJSON, err := filters.ToParam(imageFilterArgs) |
|
| 123 | 123 |
if err != nil {
|
| 124 | 124 |
return err |
| 125 | 125 |
} |
| 126 |
- v.Set("filters", filterJson)
|
|
| 126 |
+ v.Set("filters", filterJSON)
|
|
| 127 | 127 |
} |
| 128 | 128 |
|
| 129 | 129 |
body, _, err := readBody(cli.call("GET", "/images/json?"+v.Encode(), nil, false))
|
| ... | ... |
@@ -189,11 +189,11 @@ func (cli *DockerCli) CmdImages(args ...string) error {
|
| 189 | 189 |
} else {
|
| 190 | 190 |
v := url.Values{}
|
| 191 | 191 |
if len(imageFilterArgs) > 0 {
|
| 192 |
- filterJson, err := filters.ToParam(imageFilterArgs) |
|
| 192 |
+ filterJSON, err := filters.ToParam(imageFilterArgs) |
|
| 193 | 193 |
if err != nil {
|
| 194 | 194 |
return err |
| 195 | 195 |
} |
| 196 |
- v.Set("filters", filterJson)
|
|
| 196 |
+ v.Set("filters", filterJSON)
|
|
| 197 | 197 |
} |
| 198 | 198 |
|
| 199 | 199 |
if cmd.NArg() == 1 {
|
| ... | ... |
@@ -74,12 +74,12 @@ func (cli *DockerCli) CmdPs(args ...string) error {
|
| 74 | 74 |
} |
| 75 | 75 |
|
| 76 | 76 |
if len(psFilterArgs) > 0 {
|
| 77 |
- filterJson, err := filters.ToParam(psFilterArgs) |
|
| 77 |
+ filterJSON, err := filters.ToParam(psFilterArgs) |
|
| 78 | 78 |
if err != nil {
|
| 79 | 79 |
return err |
| 80 | 80 |
} |
| 81 | 81 |
|
| 82 |
- v.Set("filters", filterJson)
|
|
| 82 |
+ v.Set("filters", filterJSON)
|
|
| 83 | 83 |
} |
| 84 | 84 |
|
| 85 | 85 |
body, _, err := readBody(cli.call("GET", "/containers/json?"+v.Encode(), nil, false))
|
| ... | ... |
@@ -12,12 +12,12 @@ func (cli *DockerCli) CmdRename(args ...string) error {
|
| 12 | 12 |
cmd.Usage() |
| 13 | 13 |
return nil |
| 14 | 14 |
} |
| 15 |
- old_name := cmd.Arg(0) |
|
| 16 |
- new_name := cmd.Arg(1) |
|
| 15 |
+ oldName := cmd.Arg(0) |
|
| 16 |
+ newName := cmd.Arg(1) |
|
| 17 | 17 |
|
| 18 |
- if _, _, err := readBody(cli.call("POST", fmt.Sprintf("/containers/%s/rename?name=%s", old_name, new_name), nil, false)); err != nil {
|
|
| 18 |
+ if _, _, err := readBody(cli.call("POST", fmt.Sprintf("/containers/%s/rename?name=%s", oldName, newName), nil, false)); err != nil {
|
|
| 19 | 19 |
fmt.Fprintf(cli.err, "%s\n", err) |
| 20 |
- return fmt.Errorf("Error: failed to rename container named %s", old_name)
|
|
| 20 |
+ return fmt.Errorf("Error: failed to rename container named %s", oldName)
|
|
| 21 | 21 |
} |
| 22 | 22 |
return nil |
| 23 | 23 |
} |
| ... | ... |
@@ -110,14 +110,14 @@ func (cli *DockerCli) CmdRun(args ...string) error {
|
| 110 | 110 |
defer signal.StopCatch(sigc) |
| 111 | 111 |
} |
| 112 | 112 |
var ( |
| 113 |
- waitDisplayId chan struct{}
|
|
| 113 |
+ waitDisplayID chan struct{}
|
|
| 114 | 114 |
errCh chan error |
| 115 | 115 |
) |
| 116 | 116 |
if !config.AttachStdout && !config.AttachStderr {
|
| 117 | 117 |
// Make this asynchronous to allow the client to write to stdin before having to read the ID |
| 118 |
- waitDisplayId = make(chan struct{})
|
|
| 118 |
+ waitDisplayID = make(chan struct{})
|
|
| 119 | 119 |
go func() {
|
| 120 |
- defer close(waitDisplayId) |
|
| 120 |
+ defer close(waitDisplayID) |
|
| 121 | 121 |
fmt.Fprintf(cli.out, "%s\n", createResponse.ID) |
| 122 | 122 |
}() |
| 123 | 123 |
} |
| ... | ... |
@@ -207,7 +207,7 @@ func (cli *DockerCli) CmdRun(args ...string) error {
|
| 207 | 207 |
// Detached mode: wait for the id to be displayed and return. |
| 208 | 208 |
if !config.AttachStdout && !config.AttachStderr {
|
| 209 | 209 |
// Detached mode |
| 210 |
- <-waitDisplayId |
|
| 210 |
+ <-waitDisplayID |
|
| 211 | 211 |
return nil |
| 212 | 212 |
} |
| 213 | 213 |
|
| ... | ... |
@@ -18,7 +18,7 @@ import ( |
| 18 | 18 |
|
| 19 | 19 |
type containerStats struct {
|
| 20 | 20 |
Name string |
| 21 |
- CpuPercentage float64 |
|
| 21 |
+ CPUPercentage float64 |
|
| 22 | 22 |
Memory float64 |
| 23 | 23 |
MemoryLimit float64 |
| 24 | 24 |
MemoryPercentage float64 |
| ... | ... |
@@ -36,7 +36,7 @@ func (s *containerStats) Collect(cli *DockerCli) {
|
| 36 | 36 |
} |
| 37 | 37 |
defer stream.Close() |
| 38 | 38 |
var ( |
| 39 |
- previousCpu uint64 |
|
| 39 |
+ previousCPU uint64 |
|
| 40 | 40 |
previousSystem uint64 |
| 41 | 41 |
start = true |
| 42 | 42 |
dec = json.NewDecoder(stream) |
| ... | ... |
@@ -54,18 +54,18 @@ func (s *containerStats) Collect(cli *DockerCli) {
|
| 54 | 54 |
cpuPercent = 0.0 |
| 55 | 55 |
) |
| 56 | 56 |
if !start {
|
| 57 |
- cpuPercent = calculateCpuPercent(previousCpu, previousSystem, v) |
|
| 57 |
+ cpuPercent = calculateCPUPercent(previousCPU, previousSystem, v) |
|
| 58 | 58 |
} |
| 59 | 59 |
start = false |
| 60 | 60 |
s.mu.Lock() |
| 61 |
- s.CpuPercentage = cpuPercent |
|
| 61 |
+ s.CPUPercentage = cpuPercent |
|
| 62 | 62 |
s.Memory = float64(v.MemoryStats.Usage) |
| 63 | 63 |
s.MemoryLimit = float64(v.MemoryStats.Limit) |
| 64 | 64 |
s.MemoryPercentage = memPercent |
| 65 | 65 |
s.NetworkRx = float64(v.Network.RxBytes) |
| 66 | 66 |
s.NetworkTx = float64(v.Network.TxBytes) |
| 67 | 67 |
s.mu.Unlock() |
| 68 |
- previousCpu = v.CpuStats.CpuUsage.TotalUsage |
|
| 68 |
+ previousCPU = v.CpuStats.CpuUsage.TotalUsage |
|
| 69 | 69 |
previousSystem = v.CpuStats.SystemUsage |
| 70 | 70 |
u <- nil |
| 71 | 71 |
} |
| ... | ... |
@@ -76,7 +76,7 @@ func (s *containerStats) Collect(cli *DockerCli) {
|
| 76 | 76 |
// zero out the values if we have not received an update within |
| 77 | 77 |
// the specified duration. |
| 78 | 78 |
s.mu.Lock() |
| 79 |
- s.CpuPercentage = 0 |
|
| 79 |
+ s.CPUPercentage = 0 |
|
| 80 | 80 |
s.Memory = 0 |
| 81 | 81 |
s.MemoryPercentage = 0 |
| 82 | 82 |
s.mu.Unlock() |
| ... | ... |
@@ -99,7 +99,7 @@ func (s *containerStats) Display(w io.Writer) error {
|
| 99 | 99 |
} |
| 100 | 100 |
fmt.Fprintf(w, "%s\t%.2f%%\t%s/%s\t%.2f%%\t%s/%s\n", |
| 101 | 101 |
s.Name, |
| 102 |
- s.CpuPercentage, |
|
| 102 |
+ s.CPUPercentage, |
|
| 103 | 103 |
units.BytesSize(s.Memory), units.BytesSize(s.MemoryLimit), |
| 104 | 104 |
s.MemoryPercentage, |
| 105 | 105 |
units.BytesSize(s.NetworkRx), units.BytesSize(s.NetworkTx)) |
| ... | ... |
@@ -161,11 +161,11 @@ func (cli *DockerCli) CmdStats(args ...string) error {
|
| 161 | 161 |
return nil |
| 162 | 162 |
} |
| 163 | 163 |
|
| 164 |
-func calculateCpuPercent(previousCpu, previousSystem uint64, v *types.Stats) float64 {
|
|
| 164 |
+func calculateCPUPercent(previousCPU, previousSystem uint64, v *types.Stats) float64 {
|
|
| 165 | 165 |
var ( |
| 166 | 166 |
cpuPercent = 0.0 |
| 167 | 167 |
// calculate the change for the cpu usage of the container in between readings |
| 168 |
- cpuDelta = float64(v.CpuStats.CpuUsage.TotalUsage - previousCpu) |
|
| 168 |
+ cpuDelta = float64(v.CpuStats.CpuUsage.TotalUsage - previousCPU) |
|
| 169 | 169 |
// calculate the change for the entire system between readings |
| 170 | 170 |
systemDelta = float64(v.CpuStats.SystemUsage - previousSystem) |
| 171 | 171 |
) |
| ... | ... |
@@ -200,8 +200,8 @@ func (cli *DockerCli) resizeTty(id string, isExec bool) {
|
| 200 | 200 |
} |
| 201 | 201 |
} |
| 202 | 202 |
|
| 203 |
-func waitForExit(cli *DockerCli, containerId string) (int, error) {
|
|
| 204 |
- stream, _, err := cli.call("POST", "/containers/"+containerId+"/wait", nil, false)
|
|
| 203 |
+func waitForExit(cli *DockerCli, containerID string) (int, error) {
|
|
| 204 |
+ stream, _, err := cli.call("POST", "/containers/"+containerID+"/wait", nil, false)
|
|
| 205 | 205 |
if err != nil {
|
| 206 | 206 |
return -1, err |
| 207 | 207 |
} |
| ... | ... |
@@ -215,8 +215,8 @@ func waitForExit(cli *DockerCli, containerId string) (int, error) {
|
| 215 | 215 |
|
| 216 | 216 |
// getExitCode perform an inspect on the container. It returns |
| 217 | 217 |
// the running state and the exit code. |
| 218 |
-func getExitCode(cli *DockerCli, containerId string) (bool, int, error) {
|
|
| 219 |
- stream, _, err := cli.call("GET", "/containers/"+containerId+"/json", nil, false)
|
|
| 218 |
+func getExitCode(cli *DockerCli, containerID string) (bool, int, error) {
|
|
| 219 |
+ stream, _, err := cli.call("GET", "/containers/"+containerID+"/json", nil, false)
|
|
| 220 | 220 |
if err != nil {
|
| 221 | 221 |
// If we can't connect, then the daemon probably died. |
| 222 | 222 |
if err != ErrConnectionRefused {
|
| ... | ... |
@@ -236,8 +236,8 @@ func getExitCode(cli *DockerCli, containerId string) (bool, int, error) {
|
| 236 | 236 |
|
| 237 | 237 |
// getExecExitCode perform an inspect on the exec command. It returns |
| 238 | 238 |
// the running state and the exit code. |
| 239 |
-func getExecExitCode(cli *DockerCli, execId string) (bool, int, error) {
|
|
| 240 |
- stream, _, err := cli.call("GET", "/exec/"+execId+"/json", nil, false)
|
|
| 239 |
+func getExecExitCode(cli *DockerCli, execID string) (bool, int, error) {
|
|
| 240 |
+ stream, _, err := cli.call("GET", "/exec/"+execID+"/json", nil, false)
|
|
| 241 | 241 |
if err != nil {
|
| 242 | 242 |
// If we can't connect, then the daemon probably died. |
| 243 | 243 |
if err != ErrConnectionRefused {
|