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:
Kevin Klues 2020-07-23 14:18:11 +00:00
parent aec9a28bc3
commit 889ebae1fe
2 changed files with 6 additions and 2 deletions

View File

@ -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

View File

@ -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