mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 13:37:08 +08:00
controller: move controllers out of commands into separate package
Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
27
controller/controller.go
Normal file
27
controller/controller.go
Normal file
@ -0,0 +1,27 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/buildx/controller/control"
|
||||
"github.com/docker/buildx/controller/local"
|
||||
"github.com/docker/buildx/controller/remote"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func NewController(ctx context.Context, opts control.ControlOptions, dockerCli command.Cli) (c control.BuildxController, err error) {
|
||||
if !opts.Detach {
|
||||
logrus.Infof("launching local buildx controller")
|
||||
c = local.NewLocalBuildxController(ctx, dockerCli)
|
||||
return c, nil
|
||||
}
|
||||
|
||||
logrus.Infof("connecting to buildx server")
|
||||
c, err = remote.NewRemoteBuildxController(ctx, dockerCli, opts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to use buildx server; use --detach=false: %w", err)
|
||||
}
|
||||
return c, nil
|
||||
}
|
Reference in New Issue
Block a user