1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix some context sharing/plumbing

With cobra switch (and maybe before), some context weren't *plumbed* the
right way, fixing that.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester 2016-06-09 17:58:10 +02:00
parent 63a7a59c92
commit 075b75fa14
No known key found for this signature in database
GPG key ID: 083CC6FD6EB699A3
3 changed files with 8 additions and 3 deletions

View file

@ -38,9 +38,10 @@ func NewRestartCommand(dockerCli *client.DockerCli) *cobra.Command {
} }
func runRestart(dockerCli *client.DockerCli, opts *restartOptions) error { func runRestart(dockerCli *client.DockerCli, opts *restartOptions) error {
ctx := context.Background()
var errs []string var errs []string
for _, name := range opts.containers { for _, name := range opts.containers {
if err := dockerCli.Client().ContainerRestart(context.Background(), name, time.Duration(opts.nSeconds)*time.Second); err != nil { if err := dockerCli.Client().ContainerRestart(ctx, 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)

View file

@ -35,8 +35,10 @@ func newInspectCommand(dockerCli *client.DockerCli) *cobra.Command {
func runInspect(dockerCli *client.DockerCli, opts inspectOptions) error { func runInspect(dockerCli *client.DockerCli, opts inspectOptions) error {
client := dockerCli.Client() client := dockerCli.Client()
ctx := context.Background()
getNetFunc := func(name string) (interface{}, []byte, error) { getNetFunc := func(name string) (interface{}, []byte, error) {
return client.NetworkInspectWithRaw(context.Background(), name) return client.NetworkInspectWithRaw(ctx, name)
} }
return inspect.Inspect(dockerCli.Out(), opts.names, opts.format, getNetFunc) return inspect.Inspect(dockerCli.Out(), opts.names, opts.format, getNetFunc)

View file

@ -35,8 +35,10 @@ func newInspectCommand(dockerCli *client.DockerCli) *cobra.Command {
func runInspect(dockerCli *client.DockerCli, opts inspectOptions) error { func runInspect(dockerCli *client.DockerCli, opts inspectOptions) error {
client := dockerCli.Client() client := dockerCli.Client()
ctx := context.Background()
getVolFunc := func(name string) (interface{}, []byte, error) { getVolFunc := func(name string) (interface{}, []byte, error) {
i, err := client.VolumeInspect(context.Background(), name) i, err := client.VolumeInspect(ctx, name)
return i, nil, err return i, nil, err
} }