[#44] ir: Support multiple configs

Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
Denis Kirillov 2023-02-06 17:54:06 +03:00 committed by fyrchik
parent 87e69b9349
commit bed5a36235
2 changed files with 11 additions and 3 deletions

View file

@ -4,10 +4,11 @@ import (
"strings"
"time"
"github.com/TrueCloudLab/frostfs-node/pkg/util/config"
"github.com/spf13/viper"
)
func newConfig(path string) (*viper.Viper, error) {
func newConfig(path, directory string) (*viper.Viper, error) {
const envPrefix = "FROSTFS_IR"
var (
@ -28,7 +29,13 @@ func newConfig(path string) (*viper.Viper, error) {
} else {
v.SetConfigType("yml")
}
err = v.ReadInConfig()
if err = v.ReadInConfig(); err != nil {
return v, err
}
}
if directory != "" {
err = config.ReadConfigDir(v, directory)
}
return v, err

View file

@ -35,6 +35,7 @@ func exitErr(err error) {
func main() {
configFile := flag.String("config", "", "path to config")
configDir := flag.String("config-dir", "", "path to config directory")
versionFlag := flag.Bool("version", false, "frostfs-ir node version")
flag.Parse()
@ -44,7 +45,7 @@ func main() {
os.Exit(SuccessReturnCode)
}
cfg, err := newConfig(*configFile)
cfg, err := newConfig(*configFile, *configDir)
exitErr(err)
var logPrm logger.Prm