Add config.Toml type to handle config files

This change introduced a config.Toml type that is used as the base for
config file processing and manipulation. This ensures that configs --
including commented values -- can be handled consistently.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar
2023-08-04 17:56:15 +02:00
parent c2d4de54b0
commit a69657dde7
7 changed files with 465 additions and 358 deletions

View File

@@ -43,13 +43,15 @@ func loadConfig() (*config.Config, error) {
}
for _, p := range configPaths {
cfg, err := config.Load(p)
cfg, err := config.New(
config.WithConfigFile(p),
)
if err == nil {
return cfg, nil
return cfg.Config()
} else if os.IsNotExist(err) && !required {
continue
}
return nil, fmt.Errorf("couldn't open configuration file: %v", err)
return nil, fmt.Errorf("couldn't open required configuration file: %v", err)
}
return config.GetDefault()