mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00
driver: cache features
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
9b723ece46
commit
d196ac347e
@ -147,9 +147,11 @@ func GetFactories(instanceRequired bool) []Factory {
|
||||
|
||||
type cachedDriver struct {
|
||||
Driver
|
||||
client *client.Client
|
||||
err error
|
||||
once sync.Once
|
||||
client *client.Client
|
||||
err error
|
||||
once sync.Once
|
||||
featuresOnce sync.Once
|
||||
features map[Feature]bool
|
||||
}
|
||||
|
||||
func (d *cachedDriver) Client(ctx context.Context) (*client.Client, error) {
|
||||
@ -158,3 +160,10 @@ func (d *cachedDriver) Client(ctx context.Context) (*client.Client, error) {
|
||||
})
|
||||
return d.client, d.err
|
||||
}
|
||||
|
||||
func (d *cachedDriver) Features() map[Feature]bool {
|
||||
d.featuresOnce.Do(func() {
|
||||
d.features = d.Driver.Features()
|
||||
})
|
||||
return d.features
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user