Skip to content

Commit 07e9ba3

Browse files
committed
Pass context
Signed-off-by: David Gageot <david.gageot@docker.com>
1 parent 4e0861d commit 07e9ba3

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

cmd/root/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (f *runExecFlags) runRunCommand(cmd *cobra.Command, args []string) (command
146146

147147
// If --sandbox is set, delegate everything to docker sandbox.
148148
if f.sandbox {
149-
return runInSandbox(cmd, &f.runConfig, f.sandboxTemplate)
149+
return runInSandbox(ctx, &f.runConfig, f.sandboxTemplate)
150150
}
151151

152152
out := cli.NewPrinter(cmd.OutOrStdout())

cmd/root/sandbox.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package root
22

33
import (
44
"cmp"
5+
"context"
56
"errors"
67
"fmt"
78
"log/slog"
89
"os"
910
"os/exec"
1011

1112
"github.com/docker/cli/cli"
12-
"github.com/spf13/cobra"
1313

1414
"github.com/docker/docker-agent/pkg/config"
1515
"github.com/docker/docker-agent/pkg/environment"
@@ -20,12 +20,11 @@ import (
2020
// runInSandbox delegates the current command to a Docker sandbox.
2121
// It ensures a sandbox exists (creating or recreating as needed), then
2222
// executes docker agent inside it via `docker sandbox exec`.
23-
func runInSandbox(cmd *cobra.Command, runConfig *config.RuntimeConfig, template string) error {
23+
func runInSandbox(ctx context.Context, runConfig *config.RuntimeConfig, template string) error {
2424
if environment.InSandbox() {
2525
return fmt.Errorf("already running inside a Docker sandbox (VM %s)", os.Getenv("SANDBOX_VM_ID"))
2626
}
2727

28-
ctx := cmd.Context()
2928
if err := sandbox.CheckAvailable(ctx); err != nil {
3029
return err
3130
}

0 commit comments

Comments
 (0)