From 40899d170527744981e1eb6e494792b263fcf1c8 Mon Sep 17 00:00:00 2001 From: RaviAnand Mohabir Date: Mon, 30 Oct 2023 12:33:16 +0100 Subject: [PATCH] feat: :sparkles: bind all applicable env vars to config values --- main.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 987d736..31d33a3 100644 --- a/main.go +++ b/main.go @@ -9,17 +9,22 @@ import ( ) func main() { - viper.SetConfigName("config") // name of config file (without extension) - viper.SetConfigType("yaml") // REQUIRED if the config file does not have the extension in the name + viper.SetConfigName("config") // name of config file (without extension) + viper.SetConfigType("yaml") // REQUIRED if the config file does not have the extension in the name viper.AddConfigPath("/etc/listy/") // path to look for the config file in viper.AddConfigPath("$HOME/.listy") // call multiple times to add many search paths - viper.AddConfigPath(".") // optionally look for config in the working directory - viper.ReadInConfig() // Find and read the config file + viper.AddConfigPath(".") // optionally look for config in the working directory + viper.ReadInConfig() // Find and read the config file viper.SetDefault("server.scheme", "http") viper.SetDefault("server.host", "localhost:5001") + viper.BindEnv("spotify.clientid", "SPOTIFY_CLIENT_ID") + viper.BindEnv("spotify.clientsecret", "SPOTIFY_CLIENT_SECRET") viper.BindEnv("mongodb.uri", "MONGODB_URI") + viper.BindEnv("server.sessionkey", "SERVER_SESSION_KEY") + viper.BindEnv("server.scheme", "SERVER_SCHEME") + viper.BindEnv("server.host", "SERVER_HOST") cmd.Execute() }