mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 16:29:18 +00:00
Export config.GetDefault function
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
e4722e9642
commit
8bf52e1dec
@ -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{
|
||||||
|
@ -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)
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user