mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
commands: add implementations for create, use, rm, stop
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
@ -40,7 +40,27 @@ type Inputs struct {
|
||||
InStream io.Reader
|
||||
}
|
||||
|
||||
func Build(ctx context.Context, drivers []driver.Driver, opt map[string]Options, pw progress.Writer) (map[string]*client.SolveResponse, error) {
|
||||
type DriverInfo struct {
|
||||
Driver driver.Driver
|
||||
Name string
|
||||
Platform []string // TODO: specs.Platform
|
||||
Err error
|
||||
}
|
||||
|
||||
func getFirstDriver(drivers []DriverInfo) (driver.Driver, error) {
|
||||
err := errors.Errorf("no drivers found")
|
||||
for _, di := range drivers {
|
||||
if di.Driver != nil {
|
||||
return di.Driver, nil
|
||||
}
|
||||
if di.Err != nil {
|
||||
err = di.Err
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func Build(ctx context.Context, drivers []DriverInfo, opt map[string]Options, pw progress.Writer) (map[string]*client.SolveResponse, error) {
|
||||
if len(drivers) == 0 {
|
||||
return nil, errors.Errorf("driver required for build")
|
||||
}
|
||||
@ -50,7 +70,10 @@ func Build(ctx context.Context, drivers []driver.Driver, opt map[string]Options,
|
||||
}
|
||||
|
||||
pwOld := pw
|
||||
d := drivers[0]
|
||||
d, err := getFirstDriver(drivers)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, isDefaultMobyDriver := d.(interface {
|
||||
IsDefaultMobyDriver()
|
||||
})
|
||||
|
Reference in New Issue
Block a user