From d196ac347e5b3ef45086a42f96e3ed0f55d3ec51 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Fri, 26 May 2023 10:30:49 +0200 Subject: [PATCH] driver: cache features Signed-off-by: CrazyMax --- driver/manager.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/driver/manager.go b/driver/manager.go index 37436a22..13826cc8 100644 --- a/driver/manager.go +++ b/driver/manager.go @@ -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 +}