@@ -16,17 +16,18 @@ import (
1616 "github.com/sirupsen/logrus"
1717)
1818
19- // NewResultHandle stores a gateway client, gateway result , and the error from
19+ // NewResultHandle stores a gateway client, gateway reference , and the error from
2020// an evaluate call if it is present.
2121//
2222// This ResultHandle can be used to execute additional build steps in the same
2323// context as the build occurred, which can allow easy debugging of build
2424// failures and successes.
2525//
2626// If the returned ResultHandle is not nil, the caller must call Done() on it.
27- func NewResultHandle (ctx context.Context , c gateway.Client , res * gateway.Result , err error ) * ResultHandle {
27+ func NewResultHandle (ctx context.Context , c gateway.Client , ref gateway.Reference , meta map [ string ][] byte , err error ) * ResultHandle {
2828 rCtx := & ResultHandle {
29- res : res ,
29+ ref : ref ,
30+ meta : meta ,
3031 gwClient : c ,
3132 }
3233 if err != nil && ! errors .As (err , & rCtx .solveErr ) {
@@ -37,8 +38,9 @@ func NewResultHandle(ctx context.Context, c gateway.Client, res *gateway.Result,
3738
3839// ResultHandle is a build result with the client that built it.
3940type ResultHandle struct {
40- res * gateway.Result
41+ ref gateway.Reference
4142 solveErr * errdefs.SolveError
43+ meta map [string ][]byte
4244 gwClient gateway.Client
4345
4446 doneOnce sync.Once
@@ -74,9 +76,9 @@ func (r *ResultHandle) NewContainer(ctx context.Context, cfg *InvokeConfig) (gat
7476}
7577
7678func (r * ResultHandle ) getContainerConfig (cfg * InvokeConfig ) (containerCfg gateway.NewContainerRequest , _ error ) {
77- if r .res != nil && r .solveErr == nil {
79+ if r .ref != nil && r .solveErr == nil {
7880 logrus .Debugf ("creating container from successful build" )
79- ccfg , err := containerConfigFromResult (r .res , cfg )
81+ ccfg , err := containerConfigFromResult (r .ref , cfg )
8082 if err != nil {
8183 return containerCfg , err
8284 }
@@ -94,9 +96,9 @@ func (r *ResultHandle) getContainerConfig(cfg *InvokeConfig) (containerCfg gatew
9496
9597func (r * ResultHandle ) getProcessConfig (cfg * InvokeConfig , stdin io.ReadCloser , stdout io.WriteCloser , stderr io.WriteCloser ) (_ gateway.StartRequest , err error ) {
9698 processCfg := newStartRequest (stdin , stdout , stderr )
97- if r .res != nil && r .solveErr == nil {
99+ if r .ref != nil && r .solveErr == nil {
98100 logrus .Debugf ("creating container from successful build" )
99- if err := populateProcessConfigFromResult (& processCfg , r .res , cfg ); err != nil {
101+ if err := populateProcessConfigFromResult (& processCfg , r .meta , cfg ); err != nil {
100102 return processCfg , err
101103 }
102104 } else {
@@ -108,20 +110,11 @@ func (r *ResultHandle) getProcessConfig(cfg *InvokeConfig, stdin io.ReadCloser,
108110 return processCfg , nil
109111}
110112
111- func containerConfigFromResult (res * gateway.Result , cfg * InvokeConfig ) (* gateway.NewContainerRequest , error ) {
113+ func containerConfigFromResult (ref gateway.Reference , cfg * InvokeConfig ) (* gateway.NewContainerRequest , error ) {
112114 if cfg .Initial {
113115 return nil , errors .Errorf ("starting from the container from the initial state of the step is supported only on the failed steps" )
114116 }
115117
116- ps , err := exptypes .ParsePlatforms (res .Metadata )
117- if err != nil {
118- return nil , err
119- }
120- ref , ok := res .FindRef (ps .Platforms [0 ].ID )
121- if ! ok {
122- return nil , errors .Errorf ("no reference found" )
123- }
124-
125118 return & gateway.NewContainerRequest {
126119 Mounts : []gateway.Mount {
127120 {
@@ -133,8 +126,8 @@ func containerConfigFromResult(res *gateway.Result, cfg *InvokeConfig) (*gateway
133126 }, nil
134127}
135128
136- func populateProcessConfigFromResult (req * gateway.StartRequest , res * gateway. Result , cfg * InvokeConfig ) error {
137- imgData := res . Metadata [exptypes .ExporterImageConfigKey ]
129+ func populateProcessConfigFromResult (req * gateway.StartRequest , meta map [ string ][] byte , cfg * InvokeConfig ) error {
130+ imgData := meta [exptypes .ExporterImageConfigKey ]
138131 var img * ocispecs.Image
139132 if len (imgData ) > 0 {
140133 img = & ocispecs.Image {}
0 commit comments