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.
81 lines
1.6 KiB
Go
81 lines
1.6 KiB
Go
3 years ago
|
package remote
|
||
3 years ago
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/docker/buildx/driver"
|
||
|
"github.com/docker/buildx/util/progress"
|
||
|
"github.com/moby/buildkit/client"
|
||
|
"github.com/pkg/errors"
|
||
|
)
|
||
|
|
||
|
type Driver struct {
|
||
|
factory driver.Factory
|
||
|
driver.InitConfig
|
||
3 years ago
|
*tlsOpts
|
||
|
}
|
||
|
|
||
|
type tlsOpts struct {
|
||
|
serverName string
|
||
|
caCert string
|
||
|
cert string
|
||
|
key string
|
||
3 years ago
|
}
|
||
|
|
||
|
func (d *Driver) Bootstrap(ctx context.Context, l progress.Logger) error {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (d *Driver) Info(ctx context.Context) (*driver.Info, error) {
|
||
3 years ago
|
c, err := d.Client(ctx)
|
||
3 years ago
|
if err != nil {
|
||
|
return nil, errors.Wrapf(driver.ErrNotConnecting, err.Error())
|
||
|
}
|
||
|
|
||
|
if _, err := c.ListWorkers(ctx); err != nil {
|
||
|
return nil, errors.Wrapf(driver.ErrNotConnecting, err.Error())
|
||
|
}
|
||
|
|
||
|
return &driver.Info{
|
||
|
Status: driver.Running,
|
||
|
}, nil
|
||
|
}
|
||
|
|
||
|
func (d *Driver) Stop(ctx context.Context, force bool) error {
|
||
3 years ago
|
return nil
|
||
3 years ago
|
}
|
||
|
|
||
|
func (d *Driver) Rm(ctx context.Context, force, rmVolume, rmDaemon bool) error {
|
||
3 years ago
|
return nil
|
||
3 years ago
|
}
|
||
|
|
||
|
func (d *Driver) Client(ctx context.Context) (*client.Client, error) {
|
||
3 years ago
|
opts := []client.ClientOpt{}
|
||
|
if d.tlsOpts != nil {
|
||
|
opts = append(opts, client.WithCredentials(d.tlsOpts.serverName, d.tlsOpts.caCert, d.tlsOpts.cert, d.tlsOpts.key))
|
||
|
}
|
||
|
|
||
|
return client.New(ctx, d.InitConfig.EndpointAddr, opts...)
|
||
3 years ago
|
}
|
||
|
|
||
|
func (d *Driver) Features() map[driver.Feature]bool {
|
||
3 years ago
|
return map[driver.Feature]bool{
|
||
|
driver.OCIExporter: true,
|
||
|
driver.DockerExporter: false,
|
||
|
driver.CacheExport: true,
|
||
|
driver.MultiPlatform: true,
|
||
|
}
|
||
3 years ago
|
}
|
||
|
|
||
|
func (d *Driver) Factory() driver.Factory {
|
||
|
return d.factory
|
||
|
}
|
||
|
|
||
|
func (d *Driver) IsMobyDriver() bool {
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
func (d *Driver) Config() driver.InitConfig {
|
||
|
return d.InitConfig
|
||
|
}
|