Export config.GetDefault function

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2023-08-10 12:20:07 +02:00
parent e4722e9642
commit 8bf52e1dec
4 changed files with 8 additions and 8 deletions

View File

@ -81,12 +81,12 @@ func GetConfig() (*Config, error) {
// Load loads the config from the specified file path. // Load loads the config from the specified file path.
func Load(configFilePath string) (*Config, error) { func Load(configFilePath string) (*Config, error) {
if configFilePath == "" { if configFilePath == "" {
return getDefault() return GetDefault()
} }
tomlFile, err := os.Open(configFilePath) tomlFile, err := os.Open(configFilePath)
if err != nil { if err != nil {
return getDefault() return GetDefault()
} }
defer tomlFile.Close() defer tomlFile.Close()
@ -114,7 +114,7 @@ func LoadFrom(reader io.Reader) (*Config, error) {
// getFromTree reads the nvidia container runtime config from the specified toml Tree. // getFromTree reads the nvidia container runtime config from the specified toml Tree.
func getFromTree(toml *toml.Tree) (*Config, error) { func getFromTree(toml *toml.Tree) (*Config, error) {
cfg, err := getDefault() cfg, err := GetDefault()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -129,8 +129,8 @@ func getFromTree(toml *toml.Tree) (*Config, error) {
return cfg, nil return cfg, nil
} }
// getDefault defines the default values for the config // GetDefault defines the default values for the config
func getDefault() (*Config, error) { func GetDefault() (*Config, error) {
d := Config{ d := Config{
AcceptEnvvarUnprivileged: true, AcceptEnvvarUnprivileged: true,
NVIDIAContainerCLIConfig: ContainerCLIConfig{ NVIDIAContainerCLIConfig: ContainerCLIConfig{

View File

@ -237,7 +237,7 @@ func TestGetConfig(t *testing.T) {
} }
func TestConfigDefault(t *testing.T) { func TestConfigDefault(t *testing.T) {
config, err := getDefault() config, err := GetDefault()
require.NoError(t, err) require.NoError(t, err)
buffer := new(bytes.Buffer) buffer := new(bytes.Buffer)

View File

@ -27,7 +27,7 @@ type RuntimeHookConfig struct {
// GetDefaultRuntimeHookConfig defines the default values for the config // GetDefaultRuntimeHookConfig defines the default values for the config
func GetDefaultRuntimeHookConfig() (*RuntimeHookConfig, error) { func GetDefaultRuntimeHookConfig() (*RuntimeHookConfig, error) {
cfg, err := getDefault() cfg, err := GetDefault()
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -48,7 +48,7 @@ type csvModeConfig struct {
// GetDefaultRuntimeConfig defines the default values for the config // GetDefaultRuntimeConfig defines the default values for the config
func GetDefaultRuntimeConfig() (*RuntimeConfig, error) { func GetDefaultRuntimeConfig() (*RuntimeConfig, error) {
cfg, err := getDefault() cfg, err := GetDefault()
if err != nil { if err != nil {
return nil, err return nil, err
} }