@@ -15,6 +15,7 @@ import (
1515 "github.com/docker/buildx/store/storeutil"
1616 "github.com/docker/buildx/util/buildflags"
1717 "github.com/docker/buildx/util/confutil"
18+ "github.com/docker/buildx/util/desktop"
1819 "github.com/docker/buildx/util/dockerutil"
1920 "github.com/docker/buildx/util/platformutil"
2021 "github.com/docker/buildx/util/progress"
@@ -36,9 +37,9 @@ const defaultTargetName = "default"
3637// NOTE: When an error happens during the build and this function acquires the debuggable *build.ResultContext,
3738// this function returns it in addition to the error (i.e. it does "return nil, res, err"). The caller can
3839// inspect the result and debug the cause of that error.
39- func RunBuild (ctx context.Context , dockerCli command.Cli , in controllerapi.BuildOptions , inStream io.Reader , progress progress.Writer , generateResult bool ) (* client.SolveResponse , * build.ResultContext , error ) {
40+ func RunBuild (ctx context.Context , dockerCli command.Cli , in controllerapi.BuildOptions , inStream io.Reader , progress progress.Writer , generateResult bool ) (* client.SolveResponse , map [ string ]desktop. BuildDetails , * build.ResultContext , error ) {
4041 if in .NoCache && len (in .NoCacheFilter ) > 0 {
41- return nil , nil , errors .Errorf ("--no-cache and --no-cache-filter cannot currently be used together" )
42+ return nil , nil , nil , errors .Errorf ("--no-cache and --no-cache-filter cannot currently be used together" )
4243 }
4344
4445 contexts := map [string ]build.NamedContext {}
@@ -68,7 +69,7 @@ func RunBuild(ctx context.Context, dockerCli command.Cli, in controllerapi.Build
6869
6970 platforms , err := platformutil .Parse (in .Platforms )
7071 if err != nil {
71- return nil , nil , err
72+ return nil , nil , nil , err
7273 }
7374 opts .Platforms = platforms
7475
@@ -77,7 +78,7 @@ func RunBuild(ctx context.Context, dockerCli command.Cli, in controllerapi.Build
7778
7879 secrets , err := controllerapi .CreateSecrets (in .Secrets )
7980 if err != nil {
80- return nil , nil , err
81+ return nil , nil , nil , err
8182 }
8283 opts .Session = append (opts .Session , secrets )
8384
@@ -87,17 +88,17 @@ func RunBuild(ctx context.Context, dockerCli command.Cli, in controllerapi.Build
8788 }
8889 ssh , err := controllerapi .CreateSSH (sshSpecs )
8990 if err != nil {
90- return nil , nil , err
91+ return nil , nil , nil , err
9192 }
9293 opts .Session = append (opts .Session , ssh )
9394
9495 outputs , err := controllerapi .CreateExports (in .Exports )
9596 if err != nil {
96- return nil , nil , err
97+ return nil , nil , nil , err
9798 }
9899 if in .ExportPush {
99100 if in .ExportLoad {
100- return nil , nil , errors .Errorf ("push and load may not be set together at the moment" )
101+ return nil , nil , nil , errors .Errorf ("push and load may not be set together at the moment" )
101102 }
102103 if len (outputs ) == 0 {
103104 outputs = []client.ExportEntry {{
@@ -111,7 +112,7 @@ func RunBuild(ctx context.Context, dockerCli command.Cli, in controllerapi.Build
111112 case "image" :
112113 outputs [0 ].Attrs ["push" ] = "true"
113114 default :
114- return nil , nil , errors .Errorf ("push and %q output can't be used together" , outputs [0 ].Type )
115+ return nil , nil , nil , errors .Errorf ("push and %q output can't be used together" , outputs [0 ].Type )
115116 }
116117 }
117118 }
@@ -125,7 +126,7 @@ func RunBuild(ctx context.Context, dockerCli command.Cli, in controllerapi.Build
125126 switch outputs [0 ].Type {
126127 case "docker" :
127128 default :
128- return nil , nil , errors .Errorf ("load and %q output can't be used together" , outputs [0 ].Type )
129+ return nil , nil , nil , errors .Errorf ("load and %q output can't be used together" , outputs [0 ].Type )
129130 }
130131 }
131132 }
@@ -140,7 +141,7 @@ func RunBuild(ctx context.Context, dockerCli command.Cli, in controllerapi.Build
140141
141142 allow , err := buildflags .ParseEntitlements (in .Allow )
142143 if err != nil {
143- return nil , nil , err
144+ return nil , nil , nil , err
144145 }
145146 opts .Allow = allow
146147
@@ -163,51 +164,52 @@ func RunBuild(ctx context.Context, dockerCli command.Cli, in controllerapi.Build
163164 builder .WithContextPathHash (contextPathHash ),
164165 )
165166 if err != nil {
166- return nil , nil , err
167+ return nil , nil , nil , err
167168 }
168169 if err = updateLastActivity (dockerCli , b .NodeGroup ); err != nil {
169- return nil , nil , errors .Wrapf (err , "failed to update builder last activity time" )
170+ return nil , nil , nil , errors .Wrapf (err , "failed to update builder last activity time" )
170171 }
171172 nodes , err := b .LoadNodes (ctx , false )
172173 if err != nil {
173- return nil , nil , err
174+ return nil , nil , nil , err
174175 }
175176
176- resp , res , err := buildTargets (ctx , dockerCli , b .NodeGroup , nodes , map [string ]build.Options {defaultTargetName : opts }, progress , generateResult )
177+ resp , bd , res , err := buildTargets (ctx , dockerCli , b .NodeGroup , nodes , map [string ]build.Options {defaultTargetName : opts }, progress , generateResult )
177178 err = wrapBuildError (err , false )
178179 if err != nil {
179180 // NOTE: buildTargets can return *build.ResultContext even on error.
180- return nil , res , err
181+ return nil , bd , res , err
181182 }
182- return resp , res , nil
183+ return resp , bd , res , nil
183184}
184185
185186// buildTargets runs the specified build and returns the result.
186187//
187188// NOTE: When an error happens during the build and this function acquires the debuggable *build.ResultContext,
188189// this function returns it in addition to the error (i.e. it does "return nil, res, err"). The caller can
189190// inspect the result and debug the cause of that error.
190- func buildTargets (ctx context.Context , dockerCli command.Cli , ng * store.NodeGroup , nodes []builder.Node , opts map [string ]build.Options , progress progress.Writer , generateResult bool ) (* client.SolveResponse , * build.ResultContext , error ) {
191+ func buildTargets (ctx context.Context , dockerCli command.Cli , ng * store.NodeGroup , nodes []builder.Node , opts map [string ]build.Options , progress progress.Writer , generateResult bool ) (* client.SolveResponse , map [ string ]desktop. BuildDetails , * build.ResultContext , error ) {
191192 var res * build.ResultContext
192193 var resp map [string ]* client.SolveResponse
194+ var bd map [string ]desktop.BuildDetails
193195 var err error
194196 if generateResult {
195197 var mu sync.Mutex
196198 var idx int
197- resp , err = build .BuildWithResultHandler (ctx , nodes , opts , dockerutil .NewClient (dockerCli ), confutil .ConfigDir (dockerCli ), progress , func (driverIndex int , gotRes * build.ResultContext ) {
199+ resp , bd , err = build .BuildWithResultHandler (ctx , nodes , opts , dockerutil .NewClient (dockerCli ), confutil .ConfigDir (dockerCli ), progress , func (driverIndex int , gotRes * build.ResultContext ) {
198200 mu .Lock ()
199201 defer mu .Unlock ()
200202 if res == nil || driverIndex < idx {
201203 idx , res = driverIndex , gotRes
202204 }
203205 })
204206 } else {
205- resp , err = build .Build (ctx , nodes , opts , dockerutil .NewClient (dockerCli ), confutil .ConfigDir (dockerCli ), progress )
207+ resp , bd , err = build .Build (ctx , nodes , opts , dockerutil .NewClient (dockerCli ), confutil .ConfigDir (dockerCli ), progress )
206208 }
207209 if err != nil {
208- return nil , res , err
210+ return nil , bd , res , err
209211 }
210- return resp [defaultTargetName ], res , err
212+ return resp [defaultTargetName ], bd , res , err
211213}
212214
213215func wrapBuildError (err error , bake bool ) error {
0 commit comments