From 639f1e80f05999a4ee33a5f2763ac6c9a65ae691 Mon Sep 17 00:00:00 2001 From: HuKeping Date: Tue, 8 Dec 2015 14:08:05 +0800 Subject: [PATCH] Use the function to parse viper on server side Signed-off-by: Hu Keping --- cmd/notary-server/main.go | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/cmd/notary-server/main.go b/cmd/notary-server/main.go index 0577dadec4..044da76108 100644 --- a/cmd/notary-server/main.go +++ b/cmd/notary-server/main.go @@ -8,8 +8,6 @@ import ( "net/http" _ "net/http/pprof" "os" - "path/filepath" - "strings" "time" "github.com/Sirupsen/logrus" @@ -186,19 +184,9 @@ func main() { ctx := context.Background() - filename := filepath.Base(configFile) - ext := filepath.Ext(configFile) - configPath := filepath.Dir(configFile) - - mainViper.SetConfigType(strings.TrimPrefix(ext, ".")) - mainViper.SetConfigName(strings.TrimSuffix(filename, ext)) - mainViper.AddConfigPath(configPath) - - err := mainViper.ReadInConfig() - if err != nil { - logrus.Error("Viper Error: ", err.Error()) - logrus.Error("Could not read config at ", configFile) - os.Exit(1) + // parse viper config + if err := utils.ParseViper(mainViper, configFile); err != nil { + logrus.Fatal(err.Error()) } // default is error level