Merge pull request #23344 from pdalpra/timeout-as-time.Duration

Timeout as time.duration
Upstream-commit: 6fd8c96f6164fa70170a2400f8fa092de9507cf9
Component: engine
This commit is contained in:
Brian Goff
2016-06-08 16:37:08 -04:00
9 changed files with 67 additions and 22 deletions
@@ -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)
@@ -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)