Rename NewGraphicsDiscoverer as NewDRMNodesDiscoverer

This change renames NewGraphicsDiscoverer to NewDRMNodesDiscoverer and
instead calls NewGraphicsMountsDiscoverer explicitly when constructing
a graphics modifier.

This avoids the import of config.Config into the discover package
which leads to a transitive dependency on toml-specifics and
requires that the vendor/github.com/pelletier/ package
be vendored in to consumers.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar
2023-11-20 22:32:46 +01:00
parent e315d7d74b
commit 255181a5ff
2 changed files with 28 additions and 20 deletions

View File

@@ -34,15 +34,34 @@ func NewGraphicsModifier(logger logger.Interface, cfg *config.Config, image imag
return nil, nil
}
d, err := discover.NewGraphicsDiscoverer(
driverRoot := cfg.NVIDIAContainerCLIConfig.Root
nvidiaCTKPath := cfg.NVIDIACTKConfig.Path
mounts, err := discover.NewGraphicsMountsDiscoverer(
logger,
driverRoot,
nvidiaCTKPath,
)
if err != nil {
return nil, fmt.Errorf("failed to create mounts discoverer: %v", err)
}
// In standard usage, the devRoot is the same as the driverRoot.
devRoot := driverRoot
drmNodes, err := discover.NewDRMNodesDiscoverer(
logger,
cfg,
image.DevicesFromEnvvars(visibleDevicesEnvvar),
devRoot,
nvidiaCTKPath,
)
if err != nil {
return nil, fmt.Errorf("failed to construct discoverer: %v", err)
}
d := discover.Merge(
drmNodes,
mounts,
)
return NewModifierFromDiscoverer(logger, d)
}