You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
874 B
Go
47 lines
874 B
Go
package docker
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/docker/buildx/driver"
|
|
dockerclient "github.com/docker/docker/client"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
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(ctx context.Context, api dockerclient.APIClient) int {
|
|
if api == 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())
|
|
}
|
|
|
|
return &Driver{factory: f, InitConfig: cfg}, nil
|
|
}
|
|
|
|
func (f *factory) AllowsInstances() bool {
|
|
return true
|
|
}
|