mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 00:08:11 +00:00
Pull logic to get the device list from ENVVARs out to its own function
Signed-off-by: Kevin Klues <kklues@nvidia.com>
This commit is contained in:
parent
aec9a28bc3
commit
889ebae1fe
@ -197,7 +197,7 @@ func isLegacyCUDAImage(env map[string]string) bool {
|
|||||||
return len(legacyCudaVersion) > 0 && len(cudaRequire) == 0
|
return len(legacyCudaVersion) > 0 && len(cudaRequire) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDevices(hookConfig *HookConfig, env map[string]string, mounts []Mount, privileged bool, legacyImage bool) *string {
|
func getDevicesFromEnvvar(env map[string]string, legacyImage bool) *string {
|
||||||
// Build a list of envvars to consider.
|
// Build a list of envvars to consider.
|
||||||
envVars := []string{envNVVisibleDevices}
|
envVars := []string{envNVVisibleDevices}
|
||||||
if envSwarmGPU != nil {
|
if envSwarmGPU != nil {
|
||||||
@ -235,6 +235,10 @@ func getDevices(hookConfig *HookConfig, env map[string]string, mounts []Mount, p
|
|||||||
return devices
|
return devices
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getDevices(hookConfig *HookConfig, env map[string]string, mounts []Mount, privileged bool, legacyImage bool) *string {
|
||||||
|
return getDevicesFromEnvvar(env, legacyImage)
|
||||||
|
}
|
||||||
|
|
||||||
func getMigConfigDevices(env map[string]string) *string {
|
func getMigConfigDevices(env map[string]string) *string {
|
||||||
if devices, ok := env[envNVMigConfigDevices]; ok {
|
if devices, ok := env[envNVMigConfigDevices]; ok {
|
||||||
return &devices
|
return &devices
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetNvidiaConfigEnvvar(t *testing.T) {
|
func TestGetNvidiaConfig(t *testing.T) {
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
description string
|
description string
|
||||||
env map[string]string
|
env map[string]string
|
||||||
|
Loading…
Reference in New Issue
Block a user