Skip to content

Commit a1e9853

Browse files
committed
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>
1 parent 1a83552 commit a1e9853

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

cmd/nvidia-container-runtime-hook/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ func main() {
174174
Name: "config",
175175
Destination: &a.configFile,
176176
Usage: "The path to the configuration file to use",
177+
EnvVars: []string{config.FilePathOverrideEnvVar},
177178
},
178179
}
179180

internal/config/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import (
3030
)
3131

3232
const (
33+
FilePathOverrideEnvVar = "NVCTK_CONFIG_FILE_PATH"
34+
3335
configOverride = "XDG_CONFIG_HOME"
3436
configFilePath = "nvidia-container-runtime/config.toml"
3537

@@ -71,6 +73,9 @@ type Config struct {
7173

7274
// GetConfigFilePath returns the path to the config file for the configured system
7375
func GetConfigFilePath() string {
76+
if configFilePathOverride := os.Getenv(FilePathOverrideEnvVar); configFilePathOverride != "" {
77+
return configFilePathOverride
78+
}
7479
if XDGConfigDir := os.Getenv(configOverride); len(XDGConfigDir) != 0 {
7580
return filepath.Join(XDGConfigDir, configFilePath)
7681
}

0 commit comments

Comments
 (0)