package docker import ( "context" "github.com/pkg/errors" "github.com/tonistiigi/buildx/driver" ) const prioritySupported = 30 const priorityUnsupported = 70 func init() { driver.Register(&factory{}) } type factory struct { } func (*factory) Name() string { return "docker-container" } func (*factory) Usage() string { return "docker-container" } func (*factory) Priority(cfg driver.InitConfig) int { if cfg.DockerAPI == nil { return priorityUnsupported } return prioritySupported } func (f *factory) New(ctx context.Context, cfg driver.InitConfig) (driver.Driver, error) { if cfg.DockerAPI == nil { return nil, errors.Errorf("%s driver requires docker API access", f.Name()) } v, err := cfg.DockerAPI.ServerVersion(ctx) if err != nil { return nil, errors.Wrapf(driver.ErrNotConnecting, err.Error()) } return &Driver{InitConfig: cfg, version: v}, nil }