Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plumb context.Context down into functions that use util/cmd functions #6468

Merged
merged 9 commits into from
Aug 23, 2021
12 changes: 6 additions & 6 deletions cmd/skaffold/app/cmd/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (r *mockRunner) Stop() error {
}

func TestTagFlag(t *testing.T) {
mockCreateRunner := func(io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
mockCreateRunner := func(context.Context, io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
return &mockRunner{}, []util.VersionedConfig{&latestV1.SkaffoldConfig{}}, nil, nil
}

Expand All @@ -70,7 +70,7 @@ func TestTagFlag(t *testing.T) {
}

func TestQuietFlag(t *testing.T) {
mockCreateRunner := func(io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
mockCreateRunner := func(context.Context, io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
return &mockRunner{}, []util.VersionedConfig{&latestV1.SkaffoldConfig{}}, nil, nil
}

Expand Down Expand Up @@ -116,7 +116,7 @@ func TestQuietFlag(t *testing.T) {
}

func TestFileOutputFlag(t *testing.T) {
mockCreateRunner := func(io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
mockCreateRunner := func(context.Context, io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
return &mockRunner{}, []util.VersionedConfig{&latestV1.SkaffoldConfig{}}, nil, nil
}

Expand Down Expand Up @@ -179,16 +179,16 @@ func TestFileOutputFlag(t *testing.T) {
}

func TestRunBuild(t *testing.T) {
errRunner := func(io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
errRunner := func(context.Context, io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
return nil, nil, nil, errors.New("some error")
}
mockCreateRunner := func(io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
mockCreateRunner := func(context.Context, io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
return &mockRunner{}, []util.VersionedConfig{&latestV1.SkaffoldConfig{}}, nil, nil
}

tests := []struct {
description string
mock func(io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error)
mock func(context.Context, io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error)
shouldErr bool
}{
{
Expand Down
4 changes: 2 additions & 2 deletions cmd/skaffold/app/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func NewSkaffoldCommand(out, errOut io.Writer) *cobra.Command {
// These are used for command completion and send debug messages on stderr.
if cmd.Name() != cobra.ShellCompRequestCmd && cmd.Name() != cobra.ShellCompNoDescRequestCmd {
instrumentation.SetCommand(cmd.Name())
out := output.GetWriter(out, defaultColor, forceColors, timestamps)
out := output.GetWriter(context.Background(), out, defaultColor, forceColors, timestamps)
cmd.Root().SetOutput(out)

// Setup logs
Expand Down Expand Up @@ -263,7 +263,7 @@ func setUpLogs(stdErr io.Writer, level string, timestamp bool) error {
logrus.SetFormatter(&logrus.TextFormatter{
FullTimestamp: timestamp,
})
logrus.AddHook(event.NewLogHook(constants.DevLoop, constants.SubtaskIDNone))
logrus.AddHook(event.NewLogHook())
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/skaffold/app/cmd/debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestNewCmdDebug(t *testing.T) {
func TestDebugIndependentFromDev(t *testing.T) {
mockRunner := &mockDevRunner{}
testutil.Run(t, "DevDebug", func(t *testutil.T) {
t.Override(&createRunner, func(io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
t.Override(&createRunner, func(context.Context, io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
return mockRunner, []util.VersionedConfig{&latestV1.SkaffoldConfig{}}, nil, nil
})
t.Override(&opts, config.SkaffoldOptions{})
Expand Down
4 changes: 2 additions & 2 deletions cmd/skaffold/app/cmd/dev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestDoDev(t *testing.T) {
hasDeployed: test.hasDeployed,
errDev: context.Canceled,
}
t.Override(&createRunner, func(io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
t.Override(&createRunner, func(context.Context, io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
return mockRunner, []util.VersionedConfig{&latestV1.SkaffoldConfig{}}, nil, nil
})
t.Override(&opts, config.SkaffoldOptions{
Expand Down Expand Up @@ -147,7 +147,7 @@ func TestDevConfigChange(t *testing.T) {
testutil.Run(t, "test config change", func(t *testutil.T) {
mockRunner := &mockConfigChangeRunner{}

t.Override(&createRunner, func(io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
t.Override(&createRunner, func(context.Context, io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
return mockRunner, []util.VersionedConfig{&latestV1.SkaffoldConfig{}}, nil, nil
})
t.Override(&opts, config.SkaffoldOptions{
Expand Down
4 changes: 2 additions & 2 deletions cmd/skaffold/app/cmd/diagnose.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func NewCmdDiagnose() *cobra.Command {
func doDiagnose(ctx context.Context, out io.Writer) error {
// force absolute path resolution during diagnose
opts.MakePathsAbsolute = util.BoolPtr(true)
configs, err := getCfgs(opts)
configs, err := getCfgs(ctx, opts)
if err != nil {
return err
}
Expand All @@ -79,7 +79,7 @@ func doDiagnose(ctx context.Context, out io.Writer) error {
}

func printArtifactDiagnostics(ctx context.Context, out io.Writer, configs []schemaUtil.VersionedConfig) error {
runCtx, err := getRunContext(opts, configs)
runCtx, err := getRunContext(ctx, opts, configs)
if err != nil {
return fmt.Errorf("getting run context: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/skaffold/app/cmd/diagnose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ metadata:

for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
t.Override(&getRunContext, func(config.SkaffoldOptions, []util.VersionedConfig) (*runcontext.RunContext, error) {
t.Override(&getRunContext, func(context.Context, config.SkaffoldOptions, []util.VersionedConfig) (*runcontext.RunContext, error) {
return nil, fmt.Errorf("cannot get the runtime context")
})
t.Override(&yamlOnly, test.yamlOnly)
t.Override(&getCfgs, func(opts config.SkaffoldOptions) ([]util.VersionedConfig, error) {
t.Override(&getCfgs, func(context.Context, config.SkaffoldOptions) ([]util.VersionedConfig, error) {
return []util.VersionedConfig{
&latestV1.SkaffoldConfig{
APIVersion: "testVersion",
Expand Down
2 changes: 1 addition & 1 deletion cmd/skaffold/app/cmd/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestDoRun(t *testing.T) {
for _, test := range tests {
testutil.Run(t, "", func(t *testutil.T) {
mockRunner := &mockRunRunner{}
t.Override(&createRunner, func(io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
t.Override(&createRunner, func(context.Context, io.Writer, config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
return mockRunner, []util.VersionedConfig{
&latestV1.SkaffoldConfig{
Pipeline: latestV1.Pipeline{
Expand Down
20 changes: 10 additions & 10 deletions cmd/skaffold/app/cmd/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import (
var createRunner = createNewRunner

func withRunner(ctx context.Context, out io.Writer, action func(runner.Runner, []util.VersionedConfig) error) error {
runner, config, runCtx, err := createRunner(out, opts)
runner, config, runCtx, err := createRunner(ctx, out, opts)
if err != nil {
return err
}
Expand All @@ -58,8 +58,8 @@ func withRunner(ctx context.Context, out io.Writer, action func(runner.Runner, [
}

// createNewRunner creates a Runner and returns the SkaffoldConfig associated with it.
func createNewRunner(out io.Writer, opts config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
runCtx, configs, err := runContext(out, opts)
func createNewRunner(ctx context.Context, out io.Writer, opts config.SkaffoldOptions) (runner.Runner, []util.VersionedConfig, *runcontext.RunContext, error) {
runCtx, configs, err := runContext(ctx, out, opts)
if err != nil {
return nil, nil, nil, err
}
Expand All @@ -70,16 +70,16 @@ func createNewRunner(out io.Writer, opts config.SkaffoldOptions) (runner.Runner,
}
instrumentation.Init(v1Configs, opts.User)
hooks.SetupStaticEnvOptions(runCtx)
runner, err := v1.NewForConfig(runCtx)
runner, err := v1.NewForConfig(ctx, runCtx)
if err != nil {
event.InititializationFailed(err)
return nil, nil, nil, fmt.Errorf("creating runner: %w", err)
}
return runner, configs, runCtx, nil
}

func runContext(out io.Writer, opts config.SkaffoldOptions) (*runcontext.RunContext, []util.VersionedConfig, error) {
cfgSet, err := withFallbackConfig(out, opts, parser.GetConfigSet)
func runContext(ctx context.Context, out io.Writer, opts config.SkaffoldOptions) (*runcontext.RunContext, []util.VersionedConfig, error) {
cfgSet, err := withFallbackConfig(ctx, out, opts, parser.GetConfigSet)
if err != nil {
return nil, nil, err
}
Expand All @@ -93,21 +93,21 @@ func runContext(out io.Writer, opts config.SkaffoldOptions) (*runcontext.RunCont
configs = append(configs, cfg.SkaffoldConfig)
}

runCtx, err := runcontext.GetRunContext(opts, configs)
runCtx, err := runcontext.GetRunContext(ctx, opts, configs)
if err != nil {
return nil, nil, fmt.Errorf("getting run context: %w", err)
}

if err := validation.ProcessWithRunContext(runCtx); err != nil {
if err := validation.ProcessWithRunContext(ctx, runCtx); err != nil {
return nil, nil, fmt.Errorf("invalid skaffold config: %w", err)
}

return runCtx, configs, nil
}

// withFallbackConfig will try to automatically generate a config if root `skaffold.yaml` file does not exist.
func withFallbackConfig(out io.Writer, opts config.SkaffoldOptions, getCfgs func(opts config.SkaffoldOptions) (parser.SkaffoldConfigSet, error)) (parser.SkaffoldConfigSet, error) {
configs, err := getCfgs(opts)
func withFallbackConfig(ctx context.Context, out io.Writer, opts config.SkaffoldOptions, getCfgs func(context.Context, config.SkaffoldOptions) (parser.SkaffoldConfigSet, error)) (parser.SkaffoldConfigSet, error) {
configs, err := getCfgs(ctx, opts)
if err == nil {
return configs, nil
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/skaffold/app/cmd/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package cmd

import (
"context"
"fmt"
"io/ioutil"
"testing"
Expand Down Expand Up @@ -88,7 +89,7 @@ func TestCreateNewRunner(t *testing.T) {
for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
t.Override(&validation.DefaultConfig, validation.Options{CheckDeploySource: false})
t.Override(&docker.NewAPIClient, func(docker.Config) (docker.LocalDaemon, error) {
t.Override(&docker.NewAPIClient, func(context.Context, docker.Config) (docker.LocalDaemon, error) {
return docker.NewLocalDaemon(&testutil.FakeAPIClient{
ErrVersion: true,
}, nil, false, nil), nil
Expand All @@ -101,7 +102,7 @@ func TestCreateNewRunner(t *testing.T) {
Write("skaffold.yaml", fmt.Sprintf("apiVersion: %s\nkind: Config\n%s", latestV1.Version, test.config)).
Chdir()

_, _, _, err := createNewRunner(ioutil.Discard, test.options)
_, _, _, err := createNewRunner(context.Background(), ioutil.Discard, test.options)

t.CheckError(test.shouldErr, err)
if test.expectedError != "" {
Expand Down
2 changes: 1 addition & 1 deletion cmd/skaffold/skaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func main() {
// As we allow some color setup using CLI flags for the main run, we can't run SetupColors()
// for the entire skaffold run here. It's possible SetupColors() was never called, so call it again
// before we print an error to get the right coloring.
errOut := output.GetWriter(os.Stderr, output.DefaultColorCode, false, false)
errOut := output.GetWriter(context.Background(), os.Stderr, output.DefaultColorCode, false, false)
output.Red.Fprintln(errOut, err)
code = app.ExitCode(err)
}
Expand Down
3 changes: 2 additions & 1 deletion hack/versions/pkg/schema/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package schema

import (
"context"
"fmt"
"os/exec"
"strings"
Expand Down Expand Up @@ -73,7 +74,7 @@ func (g *git) diffWithBaseline(path string) ([]byte, error) {

func (g *git) run(args ...string) ([]byte, error) {
cmd := exec.Command(g.path, args...)
out, err := util.RunCmdOut(cmd)
out, err := util.RunCmdOut(context.Background(), cmd)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is another PR to move replace context.Background to context.TODO.
Do you want to sync with that and see why TODO is preferred?

From docs, looks like Background context is never cancelled.
https://pkg.go.dev/context#Background

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that context.TODO is a hint to the dev that if ever a proper context becomes available in future by a change in the function parameters or something, then plumb that through. Whereas context.Background is a deliberate use even if a parent context is available. That's what I understood from @ahmetb's PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that's the case. ideally a context.Background() is for a call stack that can be cancelled from a central place, e.g. Ctrl-C. Background threads with separate lifecycle (as the name also says) get a new Background context.

If you don't plumb yet but intend do plumb someday, you can use context.TODO, which is identical to Background() functionally, only different in semantics and indicates your intention.

if err != nil {
return nil, fmt.Errorf("failed running %v: %s\n%s", cmd.Args, err, string(out))
}
Expand Down
6 changes: 3 additions & 3 deletions integration/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestBuild(t *testing.T) {
// TestExpectedBuildFailures verifies that `skaffold build` fails in expected ways
func TestExpectedBuildFailures(t *testing.T) {
MarkIntegrationTest(t, CanRunWithoutGcp)
if !jib.JVMFound() {
if !jib.JVMFound(context.Background()) {
t.Fatal("test requires Java VM")
}

Expand Down Expand Up @@ -155,7 +155,7 @@ func checkImageExists(t *testing.T, image string) {
failNowIfError(t, err)

// TODO: use the proper RunContext
client, err := docker.NewAPIClient(&runcontext.RunContext{
client, err := docker.NewAPIClient(context.Background(), &runcontext.RunContext{
KubeContext: cfg.CurrentContext,
})
failNowIfError(t, err)
Expand Down Expand Up @@ -183,7 +183,7 @@ func setupGitRepo(t *testing.T, dir string) {
for _, args := range gitArgs {
cmd := exec.Command("git", args...)
cmd.Dir = dir
if buf, err := util.RunCmdOut(cmd); err != nil {
if buf, err := util.RunCmdOut(context.Background(), cmd); err != nil {
t.Logf(string(buf))
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion integration/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ spec:
}
for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
deployer, err := helm.NewDeployer(&runcontext.RunContext{
deployer, err := helm.NewDeployer(context.Background(), &runcontext.RunContext{
Pipelines: runcontext.NewPipelines([]latestV1.Pipeline{{
Deploy: latestV1.DeployConfig{
DeployType: latestV1.DeployType{
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/build/bazel/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (b *Builder) buildTar(ctx context.Context, out io.Writer, workspace string,
cmd.Dir = workspace
cmd.Stdout = out
cmd.Stderr = out
if err := util.RunCmd(cmd); err != nil {
if err := util.RunCmd(ctx, cmd); err != nil {
return "", fmt.Errorf("running command: %w", err)
}

Expand Down Expand Up @@ -107,7 +107,7 @@ func bazelBin(ctx context.Context, workspace string, a *latestV1.BazelArtifact)
cmd := exec.CommandContext(ctx, "bazel", args...)
cmd.Dir = workspace

buf, err := util.RunCmdOut(cmd)
buf, err := util.RunCmdOut(ctx, cmd)
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/build/bazel/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func GetDependencies(ctx context.Context, dir string, a *latestV1.BazelArtifact)

cmd := exec.CommandContext(ctx, "bazel", "query", query(a.BuildTarget), "--noimplicit_deps", "--order_output=no", "--output=label")
cmd.Dir = dir
stdout, err := util.RunCmdOut(cmd)
stdout, err := util.RunCmdOut(ctx, cmd)
if err != nil {
return nil, fmt.Errorf("getting bazel dependencies: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/build/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type Config interface {
}

// NewCache returns the current state of the cache
func NewCache(cfg Config, isLocalImage func(imageName string) (bool, error), dependencies DependencyLister, graph graph.ArtifactGraph, store build.ArtifactStore) (Cache, error) {
func NewCache(ctx context.Context, cfg Config, isLocalImage func(imageName string) (bool, error), dependencies DependencyLister, graph graph.ArtifactGraph, store build.ArtifactStore) (Cache, error) {
if !cfg.CacheArtifacts() {
return &noCache{}, nil
}
Expand All @@ -91,7 +91,7 @@ func NewCache(cfg Config, isLocalImage func(imageName string) (bool, error), dep
return &noCache{}, nil
}

client, err := docker.NewAPIClient(cfg)
client, err := docker.NewAPIClient(ctx, cfg)
if err != nil {
// error only if any pipeline is local.
for _, p := range cfg.GetPipelines() {
Expand Down
12 changes: 6 additions & 6 deletions pkg/skaffold/build/cache/retrieve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func TestCacheBuildLocal(t *testing.T) {
// Mock Docker
t.Override(&docker.DefaultAuthHelper, stubAuth{})
dockerDaemon := fakeLocalDaemon(&testutil.FakeAPIClient{})
t.Override(&docker.NewAPIClient, func(docker.Config) (docker.LocalDaemon, error) {
t.Override(&docker.NewAPIClient, func(context.Context, docker.Config) (docker.LocalDaemon, error) {
return dockerDaemon, nil
})

Expand All @@ -142,7 +142,7 @@ func TestCacheBuildLocal(t *testing.T) {
cacheFile: tmpDir.Path("cache"),
}
store := make(mockArtifactStore)
artifactCache, err := NewCache(cfg, func(imageName string) (bool, error) { return true, nil }, deps, graph.ToArtifactGraph(artifacts), store)
artifactCache, err := NewCache(context.Background(), cfg, func(imageName string) (bool, error) { return true, nil }, deps, graph.ToArtifactGraph(artifacts), store)
t.CheckNoError(err)

// First build: Need to build both artifacts
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestCacheBuildRemote(t *testing.T) {

// Mock Docker
dockerDaemon := fakeLocalDaemon(&testutil.FakeAPIClient{})
t.Override(&docker.NewAPIClient, func(docker.Config) (docker.LocalDaemon, error) {
t.Override(&docker.NewAPIClient, func(context.Context, docker.Config) (docker.LocalDaemon, error) {
return dockerDaemon, nil
})
t.Override(&docker.DefaultAuthHelper, stubAuth{})
Expand All @@ -238,7 +238,7 @@ func TestCacheBuildRemote(t *testing.T) {
pipeline: latestV1.Pipeline{Build: latestV1.BuildConfig{BuildType: latestV1.BuildType{LocalBuild: &latestV1.LocalBuild{TryImportMissing: false}}}},
cacheFile: tmpDir.Path("cache"),
}
artifactCache, err := NewCache(cfg, func(imageName string) (bool, error) { return false, nil }, deps, graph.ToArtifactGraph(artifacts), make(mockArtifactStore))
artifactCache, err := NewCache(context.Background(), cfg, func(imageName string) (bool, error) { return false, nil }, deps, graph.ToArtifactGraph(artifacts), make(mockArtifactStore))
t.CheckNoError(err)

// First build: Need to build both artifacts
Expand Down Expand Up @@ -298,7 +298,7 @@ func TestCacheFindMissing(t *testing.T) {

// Mock Docker
dockerDaemon := fakeLocalDaemon(&testutil.FakeAPIClient{})
t.Override(&docker.NewAPIClient, func(docker.Config) (docker.LocalDaemon, error) {
t.Override(&docker.NewAPIClient, func(context.Context, docker.Config) (docker.LocalDaemon, error) {
return dockerDaemon, nil
})
t.Override(&docker.DefaultAuthHelper, stubAuth{})
Expand All @@ -323,7 +323,7 @@ func TestCacheFindMissing(t *testing.T) {
pipeline: latestV1.Pipeline{Build: latestV1.BuildConfig{BuildType: latestV1.BuildType{LocalBuild: &latestV1.LocalBuild{TryImportMissing: true}}}},
cacheFile: tmpDir.Path("cache"),
}
artifactCache, err := NewCache(cfg, func(imageName string) (bool, error) { return false, nil }, deps, graph.ToArtifactGraph(artifacts), make(mockArtifactStore))
artifactCache, err := NewCache(context.Background(), cfg, func(imageName string) (bool, error) { return false, nil }, deps, graph.ToArtifactGraph(artifacts), make(mockArtifactStore))
t.CheckNoError(err)

// Because the artifacts are in the docker registry, we expect them to be imported correctly.
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/build/custom/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func GetDependencies(ctx context.Context, workspace string, artifactName string,
case a.Dependencies.Command != "":
split := strings.Split(a.Dependencies.Command, " ")
cmd := exec.CommandContext(ctx, split[0], split[1:]...)
output, err := util.RunCmdOut(cmd)
output, err := util.RunCmdOut(ctx, cmd)
if err != nil {
return nil, fmt.Errorf("getting dependencies from command: %q: %w", a.Dependencies.Command, err)
}
Expand Down