diff --git a/pkg/container_config.go b/pkg/container_config.go index c6901974..25861d52 100644 --- a/pkg/container_config.go +++ b/pkg/container_config.go @@ -295,7 +295,8 @@ func getDevices(hookConfig *HookConfig, env map[string]string, mounts []Mount, p return devices } - log.Printf("Ignoring devices specified in NVIDIA_VISIBLE_DEVICES (privileged=%v, config.accept-nvidia-visible-devices-envvar-when-unprivileged=%v) ", privileged, hookConfig.AcceptEnvvarUnprivileged) + configName := hookConfig.getConfigOption("AcceptEnvvarUnprivileged") + log.Printf("Ignoring devices specified in NVIDIA_VISIBLE_DEVICES (privileged=%v, %v=%v) ", privileged, configName, hookConfig.AcceptEnvvarUnprivileged) return nil } diff --git a/pkg/hook_config.go b/pkg/hook_config.go index 0f809c74..8d35cb19 100644 --- a/pkg/hook_config.go +++ b/pkg/hook_config.go @@ -4,6 +4,7 @@ import ( "log" "os" "path" + "reflect" "github.com/BurntSushi/toml" ) @@ -86,3 +87,18 @@ func getHookConfig() (config HookConfig) { return config } + +// getConfigOption returns the toml config option associated with the +// specified struct field. +func (c HookConfig) getConfigOption(fieldName string) string { + t := reflect.TypeOf(c) + f, ok := t.FieldByName(fieldName) + if !ok { + return fieldName + } + v, ok := f.Tag.Lookup("toml") + if !ok { + return fieldName + } + return v +}