mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Use time.Duration for container restart/stop timeouts
Signed-off-by: Pierre Dal-Pra <dalpra.pierre@gmail.com>
This commit is contained in:
parent
66234eaf9b
commit
b29e8ea412
2 changed files with 4 additions and 2 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)
|
||||
|
|
Loading…
Add table
Reference in a new issue