mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 00:08:11 +00:00
Use functional options when constructing direcory locator
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
9b64d74f6a
commit
ce7d5f7a51
@ -39,7 +39,7 @@ func NewFromCSVFiles(logger logger.Interface, files []string, driverRoot string)
|
||||
)
|
||||
locators := map[csv.MountSpecType]lookup.Locator{
|
||||
csv.MountSpecDev: lookup.NewCharDeviceLocator(lookup.WithLogger(logger), lookup.WithRoot(driverRoot)),
|
||||
csv.MountSpecDir: lookup.NewDirectoryLocator(logger, driverRoot),
|
||||
csv.MountSpecDir: lookup.NewDirectoryLocator(lookup.WithLogger(logger), lookup.WithRoot(driverRoot)),
|
||||
// Libraries and symlinks are handled in the same way
|
||||
csv.MountSpecLib: symlinkLocator,
|
||||
csv.MountSpecSym: symlinkLocator,
|
||||
|
@ -38,7 +38,7 @@ func NewGDSDiscoverer(logger logger.Interface, root string) (Discover, error) {
|
||||
|
||||
udev := NewMounts(
|
||||
logger,
|
||||
lookup.NewDirectoryLocator(logger, root),
|
||||
lookup.NewDirectoryLocator(lookup.WithLogger(logger), lookup.WithRoot(root)),
|
||||
root,
|
||||
[]string{"/run/udev"},
|
||||
)
|
||||
|
@ -19,17 +19,15 @@ package lookup
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
|
||||
)
|
||||
|
||||
// NewDirectoryLocator creates a Locator that can be used to find directories at the specified root. A logger
|
||||
// is also specified.
|
||||
func NewDirectoryLocator(logger logger.Interface, root string) Locator {
|
||||
// NewDirectoryLocator creates a Locator that can be used to find directories at the specified root.
|
||||
func NewDirectoryLocator(opts ...Option) Locator {
|
||||
return NewFileLocator(
|
||||
WithLogger(logger),
|
||||
WithRoot(root),
|
||||
append(
|
||||
opts,
|
||||
WithFilter(assertDirectory),
|
||||
)...,
|
||||
)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user