Skip to content

Commit ce7d5f7

Browse files
committed
Use functional options when constructing direcory locator
Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent 9b64d74 commit ce7d5f7

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

internal/discover/csv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func NewFromCSVFiles(logger logger.Interface, files []string, driverRoot string)
3939
)
4040
locators := map[csv.MountSpecType]lookup.Locator{
4141
csv.MountSpecDev: lookup.NewCharDeviceLocator(lookup.WithLogger(logger), lookup.WithRoot(driverRoot)),
42-
csv.MountSpecDir: lookup.NewDirectoryLocator(logger, driverRoot),
42+
csv.MountSpecDir: lookup.NewDirectoryLocator(lookup.WithLogger(logger), lookup.WithRoot(driverRoot)),
4343
// Libraries and symlinks are handled in the same way
4444
csv.MountSpecLib: symlinkLocator,
4545
csv.MountSpecSym: symlinkLocator,

internal/discover/gds.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func NewGDSDiscoverer(logger logger.Interface, root string) (Discover, error) {
3838

3939
udev := NewMounts(
4040
logger,
41-
lookup.NewDirectoryLocator(logger, root),
41+
lookup.NewDirectoryLocator(lookup.WithLogger(logger), lookup.WithRoot(root)),
4242
root,
4343
[]string{"/run/udev"},
4444
)

internal/lookup/dir.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,15 @@ package lookup
1919
import (
2020
"fmt"
2121
"os"
22-
23-
"github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
2422
)
2523

26-
// NewDirectoryLocator creates a Locator that can be used to find directories at the specified root. A logger
27-
// is also specified.
28-
func NewDirectoryLocator(logger logger.Interface, root string) Locator {
24+
// NewDirectoryLocator creates a Locator that can be used to find directories at the specified root.
25+
func NewDirectoryLocator(opts ...Option) Locator {
2926
return NewFileLocator(
30-
WithLogger(logger),
31-
WithRoot(root),
32-
WithFilter(assertDirectory),
27+
append(
28+
opts,
29+
WithFilter(assertDirectory),
30+
)...,
3331
)
3432
}
3533

0 commit comments

Comments
 (0)