Feature/44 multiple configs #45

Merged
KirillovDenis merged 5 commits from feature/44-multiple_configs into master 2023-02-21 07:00:29 +00:00
2 changed files with 11 additions and 3 deletions
Showing only changes of commit 891f884af1 - Show all commits

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