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.
41 lines
721 B
Go
41 lines
721 B
Go
6 years ago
|
package docker
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/pkg/errors"
|
||
|
"github.com/tonistiigi/buildx/driver"
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
driver.Register(&factory{})
|
||
|
}
|
||
|
|
||
|
type factory struct {
|
||
|
}
|
||
|
|
||
|
func (*factory) Name() string {
|
||
6 years ago
|
return "docker-container"
|
||
6 years ago
|
}
|
||
|
|
||
|
func (*factory) Usage() string {
|
||
6 years ago
|
return "docker-container"
|
||
6 years ago
|
}
|
||
|
|
||
|
func (*factory) Priority() int {
|
||
|
return 30
|
||
|
}
|
||
|
|
||
|
func (*factory) New(ctx context.Context, cfg driver.InitConfig) (driver.Driver, error) {
|
||
|
if cfg.DockerAPI == nil {
|
||
|
return nil, errors.Errorf("docker driver requires docker API access")
|
||
|
}
|
||
|
|
||
|
v, err := cfg.DockerAPI.ServerVersion(ctx)
|
||
|
if err != nil {
|
||
|
return nil, errors.Wrapf(driver.ErrNotConnecting, err.Error())
|
||
|
}
|
||
|
|
||
6 years ago
|
return &Driver{InitConfig: cfg, version: v}, nil
|
||
6 years ago
|
}
|