Skip to content

Commit

Permalink
fix(config): read all env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
mentos1386 committed Feb 16, 2024
1 parent 9d7c41c commit 3ef1a37
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
13 changes: 5 additions & 8 deletions example.env
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
# PORT
# Zdravko
PORT=8000
ROOT_URL=http://localhost:8000
DATABASE_PATH=zdravko.db
SESSION_SECRET=your_secret

# SQLite
ZDRAVKO_DATABASE_PATH=zdravko.db
# Temporal
TEMPORAL_DATABASE_PATH=temporal.db

# Session
SESSION_SECRET=your_secret

# 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_SECRET=your_client_secret
OAUTH2_SCOPES=openid,profile,email
OAUTH2_ENDPOINT_TOKEN_URL=https://your_oauth2_provider/token
OAUTH2_ENDPOINT_AUTH_URL=https://your_oauth2_provider/auth
OAUTH2_ENDPOINT_USER_INFO_URL=https://your_oauth2_provider/userinfo
Expand Down
3 changes: 1 addition & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,14 @@ func NewConfig() *Config {
viper.SetDefault("port", GetEnvOrDefault("PORT", "8000"))
viper.SetDefault("rooturl", GetEnvOrDefault("ROOT_URL", "http://localhost:8000"))
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("temporal.databasepath", GetEnvOrDefault("TEMPORAL_DATABASE_PATH", "temporal.db"))
viper.SetDefault("temporal.listenaddress", GetEnvOrDefault("TEMPORAL_LISTEN_ADDRESS", "0.0.0.0"))
viper.SetDefault("temporal.uihost", GetEnvOrDefault("TEMPORAL_UI_HOST", "127.0.0.1:8223"))
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.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.endpointauthurl", os.Getenv("OAUTH2_ENDPOINT_AUTH_URL"))
viper.SetDefault("oauth2.endpointuserinfourl", os.Getenv("OAUTH2_ENDPOINT_USER_INFO_URL"))
Expand Down

0 comments on commit 3ef1a37

Please sign in to comment.