Signed-off-by: yupeng <yu.peng36@zte.com.cn>
| ... | ... |
@@ -118,7 +118,7 @@ func runAttach(dockerCli *command.DockerCli, opts *attachOptions) error {
|
| 118 | 118 |
return errAttach |
| 119 | 119 |
} |
| 120 | 120 |
|
| 121 |
- _, status, err := getExitCode(dockerCli, ctx, opts.container) |
|
| 121 |
+ _, status, err := getExitCode(ctx, dockerCli, opts.container) |
|
| 122 | 122 |
if err != nil {
|
| 123 | 123 |
return err |
| 124 | 124 |
} |
| ... | ... |
@@ -211,7 +211,7 @@ func runRun(dockerCli *command.DockerCli, flags *pflag.FlagSet, opts *runOptions |
| 211 | 211 |
}) |
| 212 | 212 |
} |
| 213 | 213 |
|
| 214 |
- statusChan := waitExitOrRemoved(dockerCli, ctx, createResponse.ID, hostConfig.AutoRemove) |
|
| 214 |
+ statusChan := waitExitOrRemoved(ctx, dockerCli, createResponse.ID, hostConfig.AutoRemove) |
|
| 215 | 215 |
|
| 216 | 216 |
//start the container |
| 217 | 217 |
if err := client.ContainerStart(ctx, createResponse.ID, types.ContainerStartOptions{}); err != nil {
|
| ... | ... |
@@ -111,7 +111,7 @@ func runStart(dockerCli *command.DockerCli, opts *startOptions) error {
|
| 111 | 111 |
|
| 112 | 112 |
// 3. We should open a channel for receiving status code of the container |
| 113 | 113 |
// no matter it's detached, removed on daemon side(--rm) or exit normally. |
| 114 |
- statusChan := waitExitOrRemoved(dockerCli, ctx, c.ID, c.HostConfig.AutoRemove) |
|
| 114 |
+ statusChan := waitExitOrRemoved(ctx, dockerCli, c.ID, c.HostConfig.AutoRemove) |
|
| 115 | 115 |
startOptions := types.ContainerStartOptions{
|
| 116 | 116 |
CheckpointID: opts.checkpoint, |
| 117 | 117 |
CheckpointDir: opts.checkpointDir, |
| ... | ... |
@@ -108,7 +108,7 @@ func runStats(dockerCli *command.DockerCli, opts *statsOptions) error {
|
| 108 | 108 |
s := formatter.NewContainerStats(container.ID[:12], daemonOSType) |
| 109 | 109 |
if cStats.add(s) {
|
| 110 | 110 |
waitFirst.Add(1) |
| 111 |
- go collect(s, ctx, dockerCli.Client(), !opts.noStream, waitFirst) |
|
| 111 |
+ go collect(ctx, s, dockerCli.Client(), !opts.noStream, waitFirst) |
|
| 112 | 112 |
} |
| 113 | 113 |
} |
| 114 | 114 |
} |
| ... | ... |
@@ -125,7 +125,7 @@ func runStats(dockerCli *command.DockerCli, opts *statsOptions) error {
|
| 125 | 125 |
s := formatter.NewContainerStats(e.ID[:12], daemonOSType) |
| 126 | 126 |
if cStats.add(s) {
|
| 127 | 127 |
waitFirst.Add(1) |
| 128 |
- go collect(s, ctx, dockerCli.Client(), !opts.noStream, waitFirst) |
|
| 128 |
+ go collect(ctx, s, dockerCli.Client(), !opts.noStream, waitFirst) |
|
| 129 | 129 |
} |
| 130 | 130 |
} |
| 131 | 131 |
}) |
| ... | ... |
@@ -134,7 +134,7 @@ func runStats(dockerCli *command.DockerCli, opts *statsOptions) error {
|
| 134 | 134 |
s := formatter.NewContainerStats(e.ID[:12], daemonOSType) |
| 135 | 135 |
if cStats.add(s) {
|
| 136 | 136 |
waitFirst.Add(1) |
| 137 |
- go collect(s, ctx, dockerCli.Client(), !opts.noStream, waitFirst) |
|
| 137 |
+ go collect(ctx, s, dockerCli.Client(), !opts.noStream, waitFirst) |
|
| 138 | 138 |
} |
| 139 | 139 |
}) |
| 140 | 140 |
|
| ... | ... |
@@ -160,7 +160,7 @@ func runStats(dockerCli *command.DockerCli, opts *statsOptions) error {
|
| 160 | 160 |
s := formatter.NewContainerStats(name, daemonOSType) |
| 161 | 161 |
if cStats.add(s) {
|
| 162 | 162 |
waitFirst.Add(1) |
| 163 |
- go collect(s, ctx, dockerCli.Client(), !opts.noStream, waitFirst) |
|
| 163 |
+ go collect(ctx, s, dockerCli.Client(), !opts.noStream, waitFirst) |
|
| 164 | 164 |
} |
| 165 | 165 |
} |
| 166 | 166 |
|
| ... | ... |
@@ -53,7 +53,7 @@ func (s *stats) isKnownContainer(cid string) (int, bool) {
|
| 53 | 53 |
return -1, false |
| 54 | 54 |
} |
| 55 | 55 |
|
| 56 |
-func collect(s *formatter.ContainerStats, ctx context.Context, cli client.APIClient, streamStats bool, waitFirst *sync.WaitGroup) {
|
|
| 56 |
+func collect(ctx context.Context, s *formatter.ContainerStats, cli client.APIClient, streamStats bool, waitFirst *sync.WaitGroup) {
|
|
| 57 | 57 |
logrus.Debugf("collecting stats for %s", s.Container)
|
| 58 | 58 |
var ( |
| 59 | 59 |
getFirst bool |
| ... | ... |
@@ -13,7 +13,7 @@ import ( |
| 13 | 13 |
clientapi "github.com/docker/docker/client" |
| 14 | 14 |
) |
| 15 | 15 |
|
| 16 |
-func waitExitOrRemoved(dockerCli *command.DockerCli, ctx context.Context, containerID string, waitRemove bool) chan int {
|
|
| 16 |
+func waitExitOrRemoved(ctx context.Context, dockerCli *command.DockerCli, containerID string, waitRemove bool) chan int {
|
|
| 17 | 17 |
if len(containerID) == 0 {
|
| 18 | 18 |
// containerID can never be empty |
| 19 | 19 |
panic("Internal Error: waitExitOrRemoved needs a containerID as parameter")
|
| ... | ... |
@@ -87,7 +87,7 @@ func waitExitOrRemoved(dockerCli *command.DockerCli, ctx context.Context, contai |
| 87 | 87 |
|
| 88 | 88 |
// getExitCode performs an inspect on the container. It returns |
| 89 | 89 |
// the running state and the exit code. |
| 90 |
-func getExitCode(dockerCli *command.DockerCli, ctx context.Context, containerID string) (bool, int, error) {
|
|
| 90 |
+func getExitCode(ctx context.Context, dockerCli *command.DockerCli, containerID string) (bool, int, error) {
|
|
| 91 | 91 |
c, err := dockerCli.Client().ContainerInspect(ctx, containerID) |
| 92 | 92 |
if err != nil {
|
| 93 | 93 |
// If we can't connect, then the daemon probably died. |
| ... | ... |
@@ -34,7 +34,7 @@ func runSecretInspect(dockerCli *command.DockerCli, opts inspectOptions) error {
|
| 34 | 34 |
ctx := context.Background() |
| 35 | 35 |
|
| 36 | 36 |
// attempt to lookup secret by name |
| 37 |
- secrets, err := getSecretsByName(client, ctx, []string{opts.name})
|
|
| 37 |
+ secrets, err := getSecretsByName(ctx, client, []string{opts.name})
|
|
| 38 | 38 |
if err != nil {
|
| 39 | 39 |
return err |
| 40 | 40 |
} |
| ... | ... |
@@ -32,7 +32,7 @@ func runSecretRemove(dockerCli *command.DockerCli, opts removeOptions) error {
|
| 32 | 32 |
ctx := context.Background() |
| 33 | 33 |
|
| 34 | 34 |
// attempt to lookup secret by name |
| 35 |
- secrets, err := getSecretsByName(client, ctx, opts.ids) |
|
| 35 |
+ secrets, err := getSecretsByName(ctx, client, opts.ids) |
|
| 36 | 36 |
if err != nil {
|
| 37 | 37 |
return err |
| 38 | 38 |
} |
| ... | ... |
@@ -8,7 +8,7 @@ import ( |
| 8 | 8 |
"golang.org/x/net/context" |
| 9 | 9 |
) |
| 10 | 10 |
|
| 11 |
-func getSecretsByName(client client.APIClient, ctx context.Context, names []string) ([]swarm.Secret, error) {
|
|
| 11 |
+func getSecretsByName(ctx context.Context, client client.APIClient, names []string) ([]swarm.Secret, error) {
|
|
| 12 | 12 |
args := filters.NewArgs() |
| 13 | 13 |
for _, n := range names {
|
| 14 | 14 |
args.Add("names", n)
|