mirror of
https://github.com/Unkn0wnCat/calapi.git
synced 2025-04-28 17:46:19 +02:00
Add configuration via environment
This commit is contained in:
parent
6abea91d7c
commit
37b27ec3e0
1 changed files with 7 additions and 1 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"github.com/Unkn0wnCat/calapi/internal/logger"
|
"github.com/Unkn0wnCat/calapi/internal/logger"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -25,7 +26,10 @@ func Execute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
viper.SetDefault("development", true)
|
viper.SetEnvPrefix("calapi")
|
||||||
|
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "__"))
|
||||||
|
|
||||||
|
viper.SetDefault("development", false)
|
||||||
viper.SetDefault("data_directory", "./data")
|
viper.SetDefault("data_directory", "./data")
|
||||||
viper.SetDefault("auth.type", "GHOST")
|
viper.SetDefault("auth.type", "GHOST")
|
||||||
viper.SetDefault("auth.secret", "hunter2")
|
viper.SetDefault("auth.secret", "hunter2")
|
||||||
|
@ -33,5 +37,7 @@ func init() {
|
||||||
viper.SetDefault("auth.ghost.base_url", "https://content.hhga.1in9.net/ghost")
|
viper.SetDefault("auth.ghost.base_url", "https://content.hhga.1in9.net/ghost")
|
||||||
viper.SetDefault("auth.ghost.limit_to_roles", nil)
|
viper.SetDefault("auth.ghost.limit_to_roles", nil)
|
||||||
|
|
||||||
|
viper.AutomaticEnv()
|
||||||
|
|
||||||
logger.StartLogger()
|
logger.StartLogger()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue