Use time.Duration for container restart/stop timeouts

Signed-off-by: Pierre Dal-Pra <dalpra.pierre@gmail.com>
Upstream-commit: b29e8ea412534a857d76bc716b79c7483e347f3a
Component: engine
This commit is contained in:
Pierre Dal-Pra
2016-06-08 08:05:18 +02:00
parent 5b8c5d757b
commit 2193b7f2c7
2 changed files with 4 additions and 2 deletions

View File

@ -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)

View File

@ -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)