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

Pass in context to cnab-go Run() #3253

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,4 @@ require (
sigs.k8s.io/yaml v1.3.0 // indirect
)

//replace get.porter.sh/magefiles v0.3.3 => ../magefiles
replace github.com/cnabio/cnab-go v0.25.1 => ../cnabio-cnab-go
13 changes: 13 additions & 0 deletions pkg/cnab/provider/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ func (r *Runtime) ApplyConfig(ctx context.Context, args ActionArguments) cnabact
r.AddFiles(ctx, args),
r.AddEnvironment(args),
r.AddRelocation(args),
r.SetContext(ctx),
}
}

func (r *Runtime) SetContext(ctx context.Context) cnabaction.OperationConfigFunc {
return func(op *driver.Operation) error {
op.CTX = ctx
return nil
}
}

Expand Down Expand Up @@ -202,6 +210,11 @@ func (r *Runtime) Execute(ctx context.Context, args ActionArguments) error {
tracing.ObjectAttribute("cnab-credentials", cnabCreds))
opResult, result, err := a.Run(cnabClaim, cnabCreds, r.ApplyConfig(ctx, args)...)

// if the error was due to context, just stop and return the context error
if ctx.Err() != nil {
return ctx.Err()
}

if currentRun.ShouldRecord() {
if err != nil {
err = r.appendFailedResult(ctx, err, currentRun)
Expand Down
Loading