Add ipcMounts type

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2023-02-07 12:07:05 +01:00
parent 3b8c40c3e6
commit 33c7b056ea
2 changed files with 18 additions and 2 deletions

View File

@ -21,9 +21,11 @@ import (
"github.com/sirupsen/logrus"
)
type ipcMounts mounts
// NewIPCDiscoverer creats a discoverer for NVIDIA IPC sockets.
func NewIPCDiscoverer(logger *logrus.Logger, driverRoot string) (Discover, error) {
d := NewMounts(
d := newMounts(
logger,
lookup.NewFileLocator(
lookup.WithLogger(logger),
@ -37,5 +39,14 @@ func NewIPCDiscoverer(logger *logrus.Logger, driverRoot string) (Discover, error
},
)
return d, nil
return (*ipcMounts)(d), nil
}
func (d *ipcMounts) Mounts() ([]Mount, error) {
mounts, err := (*mounts)(d).Mounts()
if err != nil {
return nil, err
}
return mounts, nil
}

View File

@ -43,6 +43,11 @@ var _ Discover = (*mounts)(nil)
// NewMounts creates a discoverer for the required mounts using the specified locator.
func NewMounts(logger *logrus.Logger, lookup lookup.Locator, root string, required []string) Discover {
return newMounts(logger, lookup, root, required)
}
// newMounts creates a discoverer for the required mounts using the specified locator.
func newMounts(logger *logrus.Logger, lookup lookup.Locator, root string, required []string) *mounts {
return &mounts{
logger: logger,
lookup: lookup,