fix(config): read all env variables

This commit is contained in:
Tine 2024-02-16 14:23:07 +01:00
parent 9d7c41c44d
commit 3ef1a37046
Signed by: mentos1386
SSH key fingerprint: SHA256:MNtTsLbihYaWF8j1fkOHfkKNlnN1JQfxEU/rBU8nCGw
2 changed files with 7 additions and 11 deletions

View file

@ -1,19 +1,16 @@
# PORT # Zdravko
PORT=8000 PORT=8000
ROOT_URL=http://localhost:8000 ROOT_URL=http://localhost:8000
DATABASE_PATH=zdravko.db
# SQLite
ZDRAVKO_DATABASE_PATH=zdravko.db
TEMPORAL_DATABASE_PATH=temporal.db
# Session
SESSION_SECRET=your_secret SESSION_SECRET=your_secret
# Temporal
TEMPORAL_DATABASE_PATH=temporal.db
# OAUTH2 # OAUTH2
# The redirect/callback url is ${ROOT_URL}/auth/callback # The redirect/callback url is ${ROOT_URL}/oauth2/callback
OAUTH2_CLIENT_ID=your_client_id OAUTH2_CLIENT_ID=your_client_id
OAUTH2_CLIENT_SECRET=your_client_secret OAUTH2_CLIENT_SECRET=your_client_secret
OAUTH2_SCOPES=openid,profile,email
OAUTH2_ENDPOINT_TOKEN_URL=https://your_oauth2_provider/token OAUTH2_ENDPOINT_TOKEN_URL=https://your_oauth2_provider/token
OAUTH2_ENDPOINT_AUTH_URL=https://your_oauth2_provider/auth OAUTH2_ENDPOINT_AUTH_URL=https://your_oauth2_provider/auth
OAUTH2_ENDPOINT_USER_INFO_URL=https://your_oauth2_provider/userinfo OAUTH2_ENDPOINT_USER_INFO_URL=https://your_oauth2_provider/userinfo

View file

@ -88,7 +88,6 @@ func NewConfig() *Config {
viper.SetDefault("port", GetEnvOrDefault("PORT", "8000")) viper.SetDefault("port", GetEnvOrDefault("PORT", "8000"))
viper.SetDefault("rooturl", GetEnvOrDefault("ROOT_URL", "http://localhost:8000")) viper.SetDefault("rooturl", GetEnvOrDefault("ROOT_URL", "http://localhost:8000"))
viper.SetDefault("databasepath", GetEnvOrDefault("DATABASE_PATH", "zdravko.db")) viper.SetDefault("databasepath", GetEnvOrDefault("DATABASE_PATH", "zdravko.db"))
viper.SetDefault("oauth2.scopes", GetEnvOrDefault("OAUTH2_ENDPOINT_SCOPE", "openid profile email"))
viper.SetDefault("sessionsecret", os.Getenv("SESSION_SECRET")) viper.SetDefault("sessionsecret", os.Getenv("SESSION_SECRET"))
viper.SetDefault("temporal.databasepath", GetEnvOrDefault("TEMPORAL_DATABASE_PATH", "temporal.db")) viper.SetDefault("temporal.databasepath", GetEnvOrDefault("TEMPORAL_DATABASE_PATH", "temporal.db"))
viper.SetDefault("temporal.listenaddress", GetEnvOrDefault("TEMPORAL_LISTEN_ADDRESS", "0.0.0.0")) viper.SetDefault("temporal.listenaddress", GetEnvOrDefault("TEMPORAL_LISTEN_ADDRESS", "0.0.0.0"))
@ -96,7 +95,7 @@ func NewConfig() *Config {
viper.SetDefault("temporal.serverhost", GetEnvOrDefault("TEMPORAL_SERVER_HOST", "127.0.0.1:7233")) viper.SetDefault("temporal.serverhost", GetEnvOrDefault("TEMPORAL_SERVER_HOST", "127.0.0.1:7233"))
viper.SetDefault("oauth2.clientid", os.Getenv("OAUTH2_CLIENT_ID")) viper.SetDefault("oauth2.clientid", os.Getenv("OAUTH2_CLIENT_ID"))
viper.SetDefault("oauth2.clientsecret", os.Getenv("OAUTH2_CLIENT_SECRET")) viper.SetDefault("oauth2.clientsecret", os.Getenv("OAUTH2_CLIENT_SECRET"))
viper.SetDefault("oauth2.scope", os.Getenv("OAUTH2_ENDPOINT_SCOPE")) viper.SetDefault("oauth2.scopes", GetEnvOrDefault("OAUTH2_ENDPOINT_SCOPES", "openid profile email"))
viper.SetDefault("oauth2.endpointtokenurl", os.Getenv("OAUTH2_ENDPOINT_TOKEN_URL")) viper.SetDefault("oauth2.endpointtokenurl", os.Getenv("OAUTH2_ENDPOINT_TOKEN_URL"))
viper.SetDefault("oauth2.endpointauthurl", os.Getenv("OAUTH2_ENDPOINT_AUTH_URL")) viper.SetDefault("oauth2.endpointauthurl", os.Getenv("OAUTH2_ENDPOINT_AUTH_URL"))
viper.SetDefault("oauth2.endpointuserinfourl", os.Getenv("OAUTH2_ENDPOINT_USER_INFO_URL")) viper.SetDefault("oauth2.endpointuserinfourl", os.Getenv("OAUTH2_ENDPOINT_USER_INFO_URL"))