From cdd4bcdc6536394f6de4a83fa7dff30d85e5c4da Mon Sep 17 00:00:00 2001 From: Marvin Weck Date: Wed, 8 Aug 2018 14:04:51 +0200 Subject: [PATCH] feat: allow configuration through envvars (#504) --- cmd/filebrowser/main.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/cmd/filebrowser/main.go b/cmd/filebrowser/main.go index e2bb787e..968d0fd7 100644 --- a/cmd/filebrowser/main.go +++ b/cmd/filebrowser/main.go @@ -2,6 +2,14 @@ package main import ( "fmt" + "io/ioutil" + "log" + "net" + "net/http" + "os" + "path/filepath" + "strings" + "github.com/asdine/storm" "github.com/filebrowser/filebrowser" "github.com/filebrowser/filebrowser/bolt" @@ -10,14 +18,7 @@ import ( "github.com/hacdias/fileutils" flag "github.com/spf13/pflag" "github.com/spf13/viper" - "gopkg.in/natefinch/lumberjack.v2" - "io/ioutil" - "log" - "net" - "net/http" - "os" - "path/filepath" - "strings") +) var ( addr string @@ -117,6 +118,10 @@ func setupViper() { viper.BindPFlag("AlternativeRecaptcha", flag.Lookup("alternative-recaptcha")) viper.BindPFlag("ReCaptchaKey", flag.Lookup("recaptcha-key")) viper.BindPFlag("ReCaptchaSecret", flag.Lookup("recaptcha-secret")) + + viper.SetEnvPrefix("FB") + viper.AutomaticEnv() + } func printVersion() { @@ -155,7 +160,7 @@ func main() { printVersion() } - initConfig(); + initConfig() // Set up process log before anything bad happens. switch viper.GetString("Logger") {