mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 00:08:11 +00:00
Use getSearchPrefixes for all locators
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
d1a3de7671
commit
db962c4bf2
@ -19,7 +19,6 @@ package lookup
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -33,7 +32,7 @@ const (
|
||||
func NewCharDeviceLocator(logger *logrus.Logger, root string) Locator {
|
||||
l := file{
|
||||
logger: logger,
|
||||
prefixes: []string{root, filepath.Join(root, devRoot)},
|
||||
prefixes: getSearchPrefixes(root, "", devRoot),
|
||||
filter: assertCharDevice,
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
func NewDirectoryLocator(logger *log.Logger, root string) Locator {
|
||||
l := file{
|
||||
logger: logger,
|
||||
prefixes: []string{root},
|
||||
prefixes: getSearchPrefixes(root),
|
||||
filter: assertDirectory,
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@ package lookup
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -37,14 +36,10 @@ func NewExecutableLocator(logger *log.Logger, root string) Locator {
|
||||
}
|
||||
|
||||
func newExecutableLocator(logger *log.Logger, root string, paths ...string) *executable {
|
||||
var prefixes []string
|
||||
for _, dir := range paths {
|
||||
prefixes = append(prefixes, filepath.Join(root, dir))
|
||||
}
|
||||
l := executable{
|
||||
file: file{
|
||||
logger: logger,
|
||||
prefixes: prefixes,
|
||||
prefixes: getSearchPrefixes(root, paths...),
|
||||
filter: assertExecutable,
|
||||
},
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ func TestExecutableLocator(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
root: "",
|
||||
expectedPrefixes: nil,
|
||||
expectedPrefixes: []string{""},
|
||||
},
|
||||
{
|
||||
root: "",
|
||||
@ -48,7 +48,7 @@ func TestExecutableLocator(t *testing.T) {
|
||||
},
|
||||
{
|
||||
root: "/",
|
||||
expectedPrefixes: nil,
|
||||
expectedPrefixes: []string{"/"},
|
||||
},
|
||||
{
|
||||
root: "/",
|
||||
|
Loading…
Reference in New Issue
Block a user