Browse code

Use time.Duration for container restart/stop timeouts

Signed-off-by: Pierre Dal-Pra <dalpra.pierre@gmail.com>

Pierre Dal-Pra authored on 2016/06/08 15:05:18
Showing 2 changed files
... ...
@@ -3,6 +3,7 @@ package container
3 3
 import (
4 4
 	"fmt"
5 5
 	"strings"
6
+	"time"
6 7
 
7 8
 	"golang.org/x/net/context"
8 9
 
... ...
@@ -39,7 +40,7 @@ func NewRestartCommand(dockerCli *client.DockerCli) *cobra.Command {
39 39
 func runRestart(dockerCli *client.DockerCli, opts *restartOptions) error {
40 40
 	var errs []string
41 41
 	for _, name := range opts.containers {
42
-		if err := dockerCli.Client().ContainerRestart(context.Background(), name, opts.nSeconds); err != nil {
42
+		if err := dockerCli.Client().ContainerRestart(context.Background(), name, time.Duration(opts.nSeconds)*time.Second); err != nil {
43 43
 			errs = append(errs, err.Error())
44 44
 		} else {
45 45
 			fmt.Fprintf(dockerCli.Out(), "%s\n", name)
... ...
@@ -3,6 +3,7 @@ package container
3 3
 import (
4 4
 	"fmt"
5 5
 	"strings"
6
+	"time"
6 7
 
7 8
 	"golang.org/x/net/context"
8 9
 
... ...
@@ -42,7 +43,7 @@ func runStop(dockerCli *client.DockerCli, opts *stopOptions) error {
42 42
 
43 43
 	var errs []string
44 44
 	for _, container := range opts.containers {
45
-		if err := dockerCli.Client().ContainerStop(ctx, container, opts.time); err != nil {
45
+		if err := dockerCli.Client().ContainerStop(ctx, container, time.Duration(opts.time)*time.Second); err != nil {
46 46
 			errs = append(errs, err.Error())
47 47
 		} else {
48 48
 			fmt.Fprintf(dockerCli.Out(), "%s\n", container)