mirror of https://github.com/docker/docs.git
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
|
|
@ -3,6 +3,7 @@ package container
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
|
|
||||||
|
|
@ -39,7 +40,7 @@ func NewRestartCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||||
func runRestart(dockerCli *client.DockerCli, opts *restartOptions) error {
|
func runRestart(dockerCli *client.DockerCli, opts *restartOptions) error {
|
||||||
var errs []string
|
var errs []string
|
||||||
for _, name := range opts.containers {
|
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())
|
errs = append(errs, err.Error())
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(dockerCli.Out(), "%s\n", name)
|
fmt.Fprintf(dockerCli.Out(), "%s\n", name)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package container
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
|
|
||||||
|
|
@ -42,7 +43,7 @@ func runStop(dockerCli *client.DockerCli, opts *stopOptions) error {
|
||||||
|
|
||||||
var errs []string
|
var errs []string
|
||||||
for _, container := range opts.containers {
|
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())
|
errs = append(errs, err.Error())
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(dockerCli.Out(), "%s\n", container)
|
fmt.Fprintf(dockerCli.Out(), "%s\n", container)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue