ソースを参照

Use time.Duration for container restart/stop timeouts

Signed-off-by: Pierre Dal-Pra <dalpra.pierre@gmail.com>
Pierre Dal-Pra 9 年 前
コミット
b29e8ea412
2 ファイル変更4 行追加2 行削除
  1. 2 1
      api/client/container/restart.go
  2. 2 1
      api/client/container/stop.go

+ 2 - 1
api/client/container/restart.go

@@ -3,6 +3,7 @@ package container
 import (
 	"fmt"
 	"strings"
+	"time"
 
 	"golang.org/x/net/context"
 
@@ -39,7 +40,7 @@ func NewRestartCommand(dockerCli *client.DockerCli) *cobra.Command {
 func runRestart(dockerCli *client.DockerCli, opts *restartOptions) error {
 	var errs []string
 	for _, name := range opts.containers {
-		if err := dockerCli.Client().ContainerRestart(context.Background(), name, opts.nSeconds); err != nil {
+		if err := dockerCli.Client().ContainerRestart(context.Background(), name, time.Duration(opts.nSeconds)*time.Second); err != nil {
 			errs = append(errs, err.Error())
 		} else {
 			fmt.Fprintf(dockerCli.Out(), "%s\n", name)

+ 2 - 1
api/client/container/stop.go

@@ -3,6 +3,7 @@ package container
 import (
 	"fmt"
 	"strings"
+	"time"
 
 	"golang.org/x/net/context"
 
@@ -42,7 +43,7 @@ func runStop(dockerCli *client.DockerCli, opts *stopOptions) error {
 
 	var errs []string
 	for _, container := range opts.containers {
-		if err := dockerCli.Client().ContainerStop(ctx, container, opts.time); err != nil {
+		if err := dockerCli.Client().ContainerStop(ctx, container, time.Duration(opts.time)*time.Second); err != nil {
 			errs = append(errs, err.Error())
 		} else {
 			fmt.Fprintf(dockerCli.Out(), "%s\n", container)