@ -46,7 +46,7 @@ const defaultTargetName = "default"
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					// NOTE: When an error happens during the build and this function acquires the debuggable *build.ResultContext,
 
 
					 
					 
					 
					// NOTE: When an error happens during the build and this function acquires the debuggable *build.ResultContext,
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					// this function returns it in addition to the error (i.e. it does "return nil, res, err"). The caller can
 
 
					 
					 
					 
					// this function returns it in addition to the error (i.e. it does "return nil, res, err"). The caller can
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					// inspect the result and debug the cause of that error.
 
 
					 
					 
					 
					// inspect the result and debug the cause of that error.
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					func  RunBuild ( ctx  context . Context ,  dockerCli  command . Cli ,  in  controllerapi . BuildOptions ,  inStream  io . Reader ,  progressMode  string ,  statusChan  chan  * client . SolveStatus  ) ( * client . SolveResponse ,  * build . ResultContext ,  error )  { 
 
					 
					 
					 
					func  RunBuild ( ctx  context . Context ,  dockerCli  command . Cli ,  in  controllerapi . BuildOptions ,  inStream  io . Reader ,  progressMode  string ,  statusChan  chan  * client . SolveStatus , generateResult  bool  ) ( * client . SolveResponse ,  * build . ResultContext ,  error )  { 
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
						if  in . NoCache  &&  len ( in . NoCacheFilter )  >  0  { 
 
					 
					 
					 
						if  in . NoCache  &&  len ( in . NoCacheFilter )  >  0  { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							return  nil ,  nil ,  errors . Errorf ( "--no-cache and --no-cache-filter cannot currently be used together" ) 
 
					 
					 
					 
							return  nil ,  nil ,  errors . Errorf ( "--no-cache and --no-cache-filter cannot currently be used together" ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						} 
 
					 
					 
					 
						} 
 
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					 
					@ -179,7 +179,7 @@ func RunBuild(ctx context.Context, dockerCli command.Cli, in controllerapi.Build
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							return  nil ,  nil ,  err 
 
					 
					 
					 
							return  nil ,  nil ,  err 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						} 
 
					 
					 
					 
						} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						resp ,  res ,  err  :=  buildTargets ( ctx ,  dockerCli ,  b . NodeGroup ,  nodes ,  map [ string ] build . Options { defaultTargetName :  opts } ,  progressMode ,  in . MetadataFile ,  statusChan  )
 
					 
					 
					 
						resp ,  res ,  err  :=  buildTargets ( ctx ,  dockerCli ,  b . NodeGroup ,  nodes ,  map [ string ] build . Options { defaultTargetName :  opts } ,  progressMode ,  in . MetadataFile ,  statusChan , generateResult  )
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
						err  =  wrapBuildError ( err ,  false ) 
 
					 
					 
					 
						err  =  wrapBuildError ( err ,  false ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						if  err  !=  nil  { 
 
					 
					 
					 
						if  err  !=  nil  { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							// NOTE: buildTargets can return *build.ResultContext even on error.
 
 
					 
					 
					 
							// NOTE: buildTargets can return *build.ResultContext even on error.
 
 
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -193,7 +193,7 @@ func RunBuild(ctx context.Context, dockerCli command.Cli, in controllerapi.Build
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					// NOTE: When an error happens during the build and this function acquires the debuggable *build.ResultContext,
 
 
					 
					 
					 
					// NOTE: When an error happens during the build and this function acquires the debuggable *build.ResultContext,
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					// this function returns it in addition to the error (i.e. it does "return nil, res, err"). The caller can
 
 
					 
					 
					 
					// this function returns it in addition to the error (i.e. it does "return nil, res, err"). The caller can
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					// inspect the result and debug the cause of that error.
 
 
					 
					 
					 
					// inspect the result and debug the cause of that error.
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					func  buildTargets ( ctx  context . Context ,  dockerCli  command . Cli ,  ng  * store . NodeGroup ,  nodes  [ ] builder . Node ,  opts  map [ string ] build . Options ,  progressMode  string ,  metadataFile  string ,  statusChan  chan  * client . SolveStatus  ) ( * client . SolveResponse ,  * build . ResultContext ,  error )  { 
 
					 
					 
					 
					func  buildTargets ( ctx  context . Context ,  dockerCli  command . Cli ,  ng  * store . NodeGroup ,  nodes  [ ] builder . Node ,  opts  map [ string ] build . Options ,  progressMode  string ,  metadataFile  string ,  statusChan  chan  * client . SolveStatus , generateResult  bool  ) ( * client . SolveResponse ,  * build . ResultContext ,  error )  { 
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
						ctx2 ,  cancel  :=  context . WithCancel ( context . TODO ( ) ) 
 
					 
					 
					 
						ctx2 ,  cancel  :=  context . WithCancel ( context . TODO ( ) ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						defer  cancel ( ) 
 
					 
					 
					 
						defer  cancel ( ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -206,15 +206,20 @@ func buildTargets(ctx context.Context, dockerCli command.Cli, ng *store.NodeGrou
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						} 
 
					 
					 
					 
						} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						var  res  * build . ResultContext 
 
					 
					 
					 
						var  res  * build . ResultContext 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						var  mu  sync . Mutex 
 
					 
					 
					 
						var  resp  map [ string ] * client . SolveResponse 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
						var  idx  int 
 
					 
					 
					 
						if  generateResult  { 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
						resp ,  err  :=  build . BuildWithResultHandler ( ctx ,  nodes ,  opts ,  dockerutil . NewClient ( dockerCli ) ,  confutil . ConfigDir ( dockerCli ) ,  progress . Tee ( printer ,  statusChan ) ,  func ( driverIndex  int ,  gotRes  * build . ResultContext )  { 
 
					 
					 
					 
							var  mu  sync . Mutex 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
							mu . Lock ( ) 
 
					 
					 
					 
							var  idx  int 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
							defer  mu . Unlock ( ) 
 
					 
					 
					 
							resp ,  err  =  build . BuildWithResultHandler ( ctx ,  nodes ,  opts ,  dockerutil . NewClient ( dockerCli ) ,  confutil . ConfigDir ( dockerCli ) ,  progress . Tee ( printer ,  statusChan ) ,  func ( driverIndex  int ,  gotRes  * build . ResultContext )  { 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
							if  res  ==  nil  ||  driverIndex  <  idx  { 
 
					 
					 
					 
								mu . Lock ( ) 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
								idx ,  res  =  driverIndex ,  gotRes 
 
					 
					 
					 
								defer  mu . Unlock ( ) 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
							} 
 
					 
					 
					 
								if  res  ==  nil  ||  driverIndex  <  idx  { 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
						} ) 
 
					 
					 
					 
									idx ,  res  =  driverIndex ,  gotRes 
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
								} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							} ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						}  else  { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							resp ,  err  =  build . Build ( ctx ,  nodes ,  opts ,  dockerutil . NewClient ( dockerCli ) ,  confutil . ConfigDir ( dockerCli ) ,  progress . Tee ( printer ,  statusChan ) ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						err1  :=  printer . Wait ( ) 
 
					 
					 
					 
						err1  :=  printer . Wait ( ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						if  err  ==  nil  { 
 
					 
					 
					 
						if  err  ==  nil  { 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
							err  =  err1 
 
					 
					 
					 
							err  =  err1