From bed5a36235a78b53159e35a85b2c55a6bb429271 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Mon, 6 Feb 2023 17:54:06 +0300 Subject: [PATCH] [#44] ir: Support multiple configs Signed-off-by: Denis Kirillov --- cmd/frostfs-ir/defaults.go | 11 +++++++++-- cmd/frostfs-ir/main.go | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cmd/frostfs-ir/defaults.go b/cmd/frostfs-ir/defaults.go index f2f416e00f..1e09c75d84 100644 --- a/cmd/frostfs-ir/defaults.go +++ b/cmd/frostfs-ir/defaults.go @@ -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 diff --git a/cmd/frostfs-ir/main.go b/cmd/frostfs-ir/main.go index f2afd7b8aa..2094265fa3 100644 --- a/cmd/frostfs-ir/main.go +++ b/cmd/frostfs-ir/main.go @@ -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