-
Notifications
You must be signed in to change notification settings - Fork 5
/
factory.go
48 lines (37 loc) · 1018 Bytes
/
factory.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package buildxdriver
import (
"context"
"github.com/depot/cli/pkg/builder"
"github.com/docker/buildx/driver"
dockerclient "github.com/docker/docker/client"
)
const prioritySupported = 30
const priorityUnsupported = 70
func init() {
driver.Register(&factory{})
}
type factory struct {
}
func (*factory) Name() string {
return "depot"
}
func (*factory) Usage() string {
return "depot"
}
func (*factory) Priority(ctx context.Context, endpoint string, api dockerclient.APIClient) int {
if api == nil {
return priorityUnsupported
}
return prioritySupported
}
func (f *factory) New(ctx context.Context, cfg driver.InitConfig) (driver.Driver, error) {
token := cfg.DriverOpts["token"]
platform := cfg.DriverOpts["platform"]
buildID := cfg.DriverOpts["buildID"]
builder := builder.NewBuilder(token, buildID, platform)
d := &Driver{factory: f, InitConfig: cfg, builderInfo: nil, builder: builder, done: make(chan struct{})}
return d, nil
}
func (f *factory) AllowsInstances() bool {
return true
}