mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
driver: add context to Features interface
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@ -387,9 +387,8 @@ func (d *Driver) Factory() driver.Factory {
|
||||
return d.factory
|
||||
}
|
||||
|
||||
func (d *Driver) Features() map[driver.Feature]bool {
|
||||
func (d *Driver) Features(ctx context.Context) map[driver.Feature]bool {
|
||||
var historyAPI bool
|
||||
ctx := context.Background()
|
||||
c, err := d.Client(ctx)
|
||||
if err == nil {
|
||||
historyAPI = driver.HistoryAPISupported(ctx, c)
|
||||
|
@ -58,10 +58,9 @@ func (d *Driver) Client(ctx context.Context) (*client.Client, error) {
|
||||
}))
|
||||
}
|
||||
|
||||
func (d *Driver) Features() map[driver.Feature]bool {
|
||||
func (d *Driver) Features(ctx context.Context) map[driver.Feature]bool {
|
||||
var useContainerdSnapshotter bool
|
||||
var historyAPI bool
|
||||
ctx := context.Background()
|
||||
c, err := d.Client(ctx)
|
||||
if err == nil {
|
||||
workers, _ := c.ListWorkers(ctx)
|
||||
|
@ -60,7 +60,7 @@ type Driver interface {
|
||||
Stop(ctx context.Context, force bool) error
|
||||
Rm(ctx context.Context, force, rmVolume, rmDaemon bool) error
|
||||
Client(ctx context.Context) (*client.Client, error)
|
||||
Features() map[Feature]bool
|
||||
Features(ctx context.Context) map[Feature]bool
|
||||
IsMobyDriver() bool
|
||||
Config() InitConfig
|
||||
}
|
||||
|
@ -228,9 +228,8 @@ func (d *Driver) Factory() driver.Factory {
|
||||
return d.factory
|
||||
}
|
||||
|
||||
func (d *Driver) Features() map[driver.Feature]bool {
|
||||
func (d *Driver) Features(ctx context.Context) map[driver.Feature]bool {
|
||||
var historyAPI bool
|
||||
ctx := context.Background()
|
||||
c, err := d.Client(ctx)
|
||||
if err == nil {
|
||||
historyAPI = driver.HistoryAPISupported(ctx, c)
|
||||
|
@ -161,9 +161,9 @@ func (d *cachedDriver) Client(ctx context.Context) (*client.Client, error) {
|
||||
return d.client, d.err
|
||||
}
|
||||
|
||||
func (d *cachedDriver) Features() map[Feature]bool {
|
||||
func (d *cachedDriver) Features(ctx context.Context) map[Feature]bool {
|
||||
d.featuresOnce.Do(func() {
|
||||
d.features = d.Driver.Features()
|
||||
d.features = d.Driver.Features(ctx)
|
||||
})
|
||||
return d.features
|
||||
}
|
||||
|
@ -87,9 +87,8 @@ func (d *Driver) Client(ctx context.Context) (*client.Client, error) {
|
||||
return client.New(ctx, d.InitConfig.EndpointAddr, opts...)
|
||||
}
|
||||
|
||||
func (d *Driver) Features() map[driver.Feature]bool {
|
||||
func (d *Driver) Features(ctx context.Context) map[driver.Feature]bool {
|
||||
var historyAPI bool
|
||||
ctx := context.Background()
|
||||
c, err := d.Client(ctx)
|
||||
if err == nil {
|
||||
historyAPI = driver.HistoryAPISupported(ctx, c)
|
||||
|
Reference in New Issue
Block a user