[#44] ir: Support multiple configs
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
f25521aeb9
commit
891f884af1
2 changed files with 11 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue