From 24026078466197fd9110e01a4e0bfd2639b4fab6 Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Fri, 21 Apr 2023 10:52:03 +0100 Subject: [PATCH] build: use gateway's solve context to allow cancelling getResultAt Signed-off-by: Justin Chadwell --- build/build.go | 2 +- build/result.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/build/build.go b/build/build.go index f479aa65..942753cd 100644 --- a/build/build.go +++ b/build/build.go @@ -920,7 +920,7 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s } results.Set(resultKey(dp.driverIndex, k), res) if resultHandleFunc != nil { - resultCtx, err := NewResultContext(cc, so, res) + resultCtx, err := NewResultContext(ctx, cc, so, res) if err == nil { resultHandleFunc(dp.driverIndex, resultCtx) } else { diff --git a/build/result.go b/build/result.go index 3d394be7..79b4fd0d 100644 --- a/build/result.go +++ b/build/result.go @@ -19,8 +19,7 @@ import ( "github.com/sirupsen/logrus" ) -func NewResultContext(c *client.Client, solveOpt client.SolveOpt, res *gateway.Result) (*ResultContext, error) { - ctx := context.Background() +func NewResultContext(ctx context.Context, c *client.Client, solveOpt client.SolveOpt, res *gateway.Result) (*ResultContext, error) { def, err := getDefinition(ctx, res) if err != nil { return nil, err