mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 08:18:32 +00:00
Add NVCT_CONFIG_FILE_PATH envvar
This change adds support for explicitly specifying the path to the config file through an environment variable. The NVCT_CONFIG_FILE_PATH variable is used for both the nvidia-container-runtime and nvidia-container-runtime-hook. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
1a83552aa6
commit
a1e98539d0
@ -174,6 +174,7 @@ func main() {
|
||||
Name: "config",
|
||||
Destination: &a.configFile,
|
||||
Usage: "The path to the configuration file to use",
|
||||
EnvVars: []string{config.FilePathOverrideEnvVar},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
FilePathOverrideEnvVar = "NVCTK_CONFIG_FILE_PATH"
|
||||
|
||||
configOverride = "XDG_CONFIG_HOME"
|
||||
configFilePath = "nvidia-container-runtime/config.toml"
|
||||
|
||||
@ -71,6 +73,9 @@ type Config struct {
|
||||
|
||||
// GetConfigFilePath returns the path to the config file for the configured system
|
||||
func GetConfigFilePath() string {
|
||||
if configFilePathOverride := os.Getenv(FilePathOverrideEnvVar); configFilePathOverride != "" {
|
||||
return configFilePathOverride
|
||||
}
|
||||
if XDGConfigDir := os.Getenv(configOverride); len(XDGConfigDir) != 0 {
|
||||
return filepath.Join(XDGConfigDir, configFilePath)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user