Skip to content

Commit 0831fef

Browse files
committed
driver: add context to Features interface
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
1 parent fef0c67 commit 0831fef

File tree

7 files changed

+11
-15
lines changed

7 files changed

+11
-15
lines changed

build/build.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
389389
}
390390

391391
for _, e := range opt.CacheTo {
392-
if e.Type != "inline" && !nodeDriver.Features()[driver.CacheExport] {
392+
if e.Type != "inline" && !nodeDriver.Features(ctx)[driver.CacheExport] {
393393
return nil, nil, notSupported(nodeDriver, driver.CacheExport)
394394
}
395395
}
@@ -527,7 +527,7 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
527527

528528
// set up exporters
529529
for i, e := range opt.Exports {
530-
if e.Type == "oci" && !nodeDriver.Features()[driver.OCIExporter] {
530+
if e.Type == "oci" && !nodeDriver.Features(ctx)[driver.OCIExporter] {
531531
return nil, nil, notSupported(nodeDriver, driver.OCIExporter)
532532
}
533533
if e.Type == "docker" {
@@ -545,7 +545,7 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
545545
defers = append(defers, cancel)
546546
opt.Exports[i].Output = wrapWriteCloser(w)
547547
}
548-
} else if !nodeDriver.Features()[driver.DockerExporter] {
548+
} else if !nodeDriver.Features(ctx)[driver.DockerExporter] {
549549
return nil, nil, notSupported(nodeDriver, driver.DockerExporter)
550550
}
551551
}
@@ -614,7 +614,7 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
614614
for i, p := range opt.Platforms {
615615
pp[i] = platforms.Format(p)
616616
}
617-
if len(pp) > 1 && !nodeDriver.Features()[driver.MultiPlatform] {
617+
if len(pp) > 1 && !nodeDriver.Features(ctx)[driver.MultiPlatform] {
618618
return nil, nil, notSupported(nodeDriver, driver.MultiPlatform)
619619
}
620620
so.FrontendAttrs["platform"] = strings.Join(pp, ",")

driver/docker-container/driver.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,8 @@ func (d *Driver) Factory() driver.Factory {
387387
return d.factory
388388
}
389389

390-
func (d *Driver) Features() map[driver.Feature]bool {
390+
func (d *Driver) Features(ctx context.Context) map[driver.Feature]bool {
391391
var historyAPI bool
392-
ctx := context.Background()
393392
c, err := d.Client(ctx)
394393
if err == nil {
395394
historyAPI = driver.HistoryAPISupported(ctx, c)

driver/docker/driver.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ func (d *Driver) Client(ctx context.Context) (*client.Client, error) {
5858
}))
5959
}
6060

61-
func (d *Driver) Features() map[driver.Feature]bool {
61+
func (d *Driver) Features(ctx context.Context) map[driver.Feature]bool {
6262
var useContainerdSnapshotter bool
6363
var historyAPI bool
64-
ctx := context.Background()
6564
c, err := d.Client(ctx)
6665
if err == nil {
6766
workers, _ := c.ListWorkers(ctx)

driver/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ type Driver interface {
6060
Stop(ctx context.Context, force bool) error
6161
Rm(ctx context.Context, force, rmVolume, rmDaemon bool) error
6262
Client(ctx context.Context) (*client.Client, error)
63-
Features() map[Feature]bool
63+
Features(ctx context.Context) map[Feature]bool
6464
IsMobyDriver() bool
6565
Config() InitConfig
6666
}

driver/kubernetes/driver.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,8 @@ func (d *Driver) Factory() driver.Factory {
228228
return d.factory
229229
}
230230

231-
func (d *Driver) Features() map[driver.Feature]bool {
231+
func (d *Driver) Features(ctx context.Context) map[driver.Feature]bool {
232232
var historyAPI bool
233-
ctx := context.Background()
234233
c, err := d.Client(ctx)
235234
if err == nil {
236235
historyAPI = driver.HistoryAPISupported(ctx, c)

driver/manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ func (d *cachedDriver) Client(ctx context.Context) (*client.Client, error) {
161161
return d.client, d.err
162162
}
163163

164-
func (d *cachedDriver) Features() map[Feature]bool {
164+
func (d *cachedDriver) Features(ctx context.Context) map[Feature]bool {
165165
d.featuresOnce.Do(func() {
166-
d.features = d.Driver.Features()
166+
d.features = d.Driver.Features(ctx)
167167
})
168168
return d.features
169169
}

driver/remote/driver.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,8 @@ func (d *Driver) Client(ctx context.Context) (*client.Client, error) {
8787
return client.New(ctx, d.InitConfig.EndpointAddr, opts...)
8888
}
8989

90-
func (d *Driver) Features() map[driver.Feature]bool {
90+
func (d *Driver) Features(ctx context.Context) map[driver.Feature]bool {
9191
var historyAPI bool
92-
ctx := context.Background()
9392
c, err := d.Client(ctx)
9493
if err == nil {
9594
historyAPI = driver.HistoryAPISupported(ctx, c)

0 commit comments

Comments
 (0)