@@ -104,12 +104,10 @@ type buildOptions struct {
104104 exportPush bool
105105 exportLoad bool
106106
107- control.ControlOptions
108-
109107 invokeConfig * invokeConfig
110108}
111109
112- func (o * buildOptions ) toControllerOptions () (* controllerapi. BuildOptions , error ) {
110+ func (o * buildOptions ) toControllerOptions () (* cbuild. Options , error ) {
113111 var err error
114112
115113 buildArgs , err := listToMap (o .buildArgs , true )
@@ -122,7 +120,7 @@ func (o *buildOptions) toControllerOptions() (*controllerapi.BuildOptions, error
122120 return nil , err
123121 }
124122
125- opts := controllerapi. BuildOptions {
123+ opts := cbuild. Options {
126124 Allow : o .allow ,
127125 Annotations : o .annotations ,
128126 BuildArgs : buildArgs ,
@@ -420,23 +418,20 @@ func getImageID(resp map[string]string) string {
420418 return dgst
421419}
422420
423- func runBasicBuild (ctx context.Context , dockerCli command.Cli , opts * controllerapi. BuildOptions , printer * progress.Printer ) (* client.SolveResponse , * build.Inputs , error ) {
421+ func runBasicBuild (ctx context.Context , dockerCli command.Cli , opts * cbuild. Options , printer * progress.Printer ) (* client.SolveResponse , * build.Inputs , error ) {
424422 resp , res , dfmap , err := cbuild .RunBuild (ctx , dockerCli , opts , dockerCli .In (), printer , false )
425423 if res != nil {
426424 res .Done ()
427425 }
428426 return resp , dfmap , err
429427}
430428
431- func runControllerBuild (ctx context.Context , dockerCli command.Cli , opts * controllerapi. BuildOptions , options buildOptions , printer * progress.Printer ) (* client.SolveResponse , * build.Inputs , error ) {
429+ func runControllerBuild (ctx context.Context , dockerCli command.Cli , opts * cbuild. Options , options buildOptions , printer * progress.Printer ) (* client.SolveResponse , * build.Inputs , error ) {
432430 if options .invokeConfig != nil && (options .dockerfileName == "-" || options .contextPath == "-" ) {
433431 // stdin must be usable for monitor
434432 return nil , nil , errors .Errorf ("Dockerfile or context from stdin is not supported with invoke" )
435433 }
436- c , err := controller .NewController (ctx , options .ControlOptions , dockerCli , printer )
437- if err != nil {
438- return nil , nil , err
439- }
434+ c := controller .NewController (ctx , dockerCli )
440435 defer func () {
441436 if err := c .Close (); err != nil {
442437 logrus .Warnf ("failed to close server connection %v" , err )
@@ -445,7 +440,7 @@ func runControllerBuild(ctx context.Context, dockerCli command.Cli, opts *contro
445440
446441 // NOTE: buildx server has the current working directory different from the client
447442 // so we need to resolve paths to abosolute ones in the client.
448- opts , err = controllerapi .ResolveOptionPaths (opts )
443+ opts , err := cbuild .ResolveOptionPaths (opts )
449444 if err != nil {
450445 return nil , nil , err
451446 }
@@ -471,7 +466,7 @@ func runControllerBuild(ctx context.Context, dockerCli command.Cli, opts *contro
471466 })
472467 }
473468
474- ref , resp , inputs , err = c .Build (ctx , opts , pr , printer )
469+ resp , inputs , err = c .Build (ctx , opts , pr , printer )
475470 if err != nil {
476471 var be * controllererrors.BuildError
477472 if errors .As (err , & be ) {
@@ -515,8 +510,8 @@ func runControllerBuild(ctx context.Context, dockerCli command.Cli, opts *contro
515510 resp , retErr = monitorBuildResult .Resp , monitorBuildResult .Err
516511 }
517512 } else {
518- if err := c .Disconnect ( ctx , ref ); err != nil {
519- logrus .Warnf ("disconnect error: %v" , err )
513+ if err := c .Close ( ); err != nil {
514+ logrus .Warnf ("close error: %v" , err )
520515 }
521516 }
522517
@@ -653,14 +648,6 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions, debugConfig *debug.D
653648 flags .StringVar (& options .sbom , "sbom" , "" , `Shorthand for "--attest=type=sbom"` )
654649 flags .StringVar (& options .provenance , "provenance" , "" , `Shorthand for "--attest=type=provenance"` )
655650
656- if confutil .IsExperimental () {
657- // TODO: move this to debug command if needed
658- flags .StringVar (& options .Root , "root" , "" , "Specify root directory of server to connect" )
659- flags .BoolVar (& options .Detach , "detach" , false , "Detach buildx server (supported only on linux)" )
660- flags .StringVar (& options .ServerConfig , "server-config" , "" , "Specify buildx server config file (used only when launching new server)" )
661- cobrautil .MarkFlagsExperimental (flags , "root" , "detach" , "server-config" )
662- }
663-
664651 flags .StringVar (& options .callFunc , "call" , "build" , `Set method for evaluating build ("check", "outline", "targets")` )
665652 flags .VarPF (callAlias (& options .callFunc , "check" ), "check" , "" , `Shorthand for "--call=check"` )
666653 flags .Lookup ("check" ).NoOptDefVal = "true"
@@ -1017,12 +1004,12 @@ func (cfg *invokeConfig) needsDebug(retErr error) bool {
10171004 }
10181005}
10191006
1020- func (cfg * invokeConfig ) runDebug (ctx context.Context , ref string , options * controllerapi. BuildOptions , c control.BuildxController , stdin io.ReadCloser , stdout io.WriteCloser , stderr console.File , progress * progress.Printer ) (* monitor.MonitorBuildResult , error ) {
1007+ func (cfg * invokeConfig ) runDebug (ctx context.Context , ref string , options * cbuild. Options , c control.BuildxController , stdin io.ReadCloser , stdout io.WriteCloser , stderr console.File , progress * progress.Printer ) (* monitor.MonitorBuildResult , error ) {
10211008 con := console .Current ()
10221009 if err := con .SetRaw (); err != nil {
10231010 // TODO: run disconnect in build command (on error case)
1024- if err := c .Disconnect ( ctx , ref ); err != nil {
1025- logrus .Warnf ("disconnect error: %v" , err )
1011+ if err := c .Close ( ); err != nil {
1012+ logrus .Warnf ("close error: %v" , err )
10261013 }
10271014 return nil , errors .Errorf ("failed to configure terminal: %v" , err )
10281015 }
0 commit comments