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{
|
locators := map[csv.MountSpecType]lookup.Locator{
|
||||||
csv.MountSpecDev: lookup.NewCharDeviceLocator(lookup.WithLogger(logger), lookup.WithRoot(driverRoot)),
|
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
|
// Libraries and symlinks are handled in the same way
|
||||||
csv.MountSpecLib: symlinkLocator,
|
csv.MountSpecLib: symlinkLocator,
|
||||||
csv.MountSpecSym: symlinkLocator,
|
csv.MountSpecSym: symlinkLocator,
|
||||||
|
@ -38,7 +38,7 @@ func NewGDSDiscoverer(logger logger.Interface, root string) (Discover, error) {
|
|||||||
|
|
||||||
udev := NewMounts(
|
udev := NewMounts(
|
||||||
logger,
|
logger,
|
||||||
lookup.NewDirectoryLocator(logger, root),
|
lookup.NewDirectoryLocator(lookup.WithLogger(logger), lookup.WithRoot(root)),
|
||||||
root,
|
root,
|
||||||
[]string{"/run/udev"},
|
[]string{"/run/udev"},
|
||||||
)
|
)
|
||||||
|
@ -19,17 +19,15 @@ package lookup
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"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
|
// NewDirectoryLocator creates a Locator that can be used to find directories at the specified root.
|
||||||
// is also specified.
|
func NewDirectoryLocator(opts ...Option) Locator {
|
||||||
func NewDirectoryLocator(logger logger.Interface, root string) Locator {
|
|
||||||
return NewFileLocator(
|
return NewFileLocator(
|
||||||
WithLogger(logger),
|
append(
|
||||||
WithRoot(root),
|
opts,
|
||||||
WithFilter(assertDirectory),
|
WithFilter(assertDirectory),
|
||||||
|
)...,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user