mirror of https://github.com/docker/docs.git
Use the function to parse viper on server side
Signed-off-by: Hu Keping <hukeping@huawei.com>
This commit is contained in:
parent
bfe7316de9
commit
639f1e80f0
|
|
@ -8,8 +8,6 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
|
|
@ -186,19 +184,9 @@ func main() {
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
filename := filepath.Base(configFile)
|
// parse viper config
|
||||||
ext := filepath.Ext(configFile)
|
if err := utils.ParseViper(mainViper, configFile); err != nil {
|
||||||
configPath := filepath.Dir(configFile)
|
logrus.Fatal(err.Error())
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// default is error level
|
// default is error level
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue