Skip to content

Commit

Permalink
Merge pull request #103 from isaqueveras/config-prod
Browse files Browse the repository at this point in the history
Changing environment using environment variable
  • Loading branch information
isaqueveras committed Feb 7, 2023
2 parents aba3201 + 0a84c54 commit d968b94
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
File renamed without changes.
65 changes: 65 additions & 0 deletions config/config-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
meta:
ProjectName: "PowerSSO"
ProjectURL: "http://localhost:3000"

server:
Version: 1.0.0
Port: :5000
PprofPort: :5555
Mode: production
JwtSecretKey: 234wdasfsgfsd34rewsfg5tergergdf
CookieName: jwt-power-sso
SSL: true
CtxDefaultTimeout: 12
ReadTimeout: 5
WriteTimeout: 5
CSRF: true
Debug: false
StartHTTP: true
StartGRPC: false
AccessLogDirectory: /var/log/power-sso/access.log
ErrorLogDirectory: /var/log/power-sso/error.log
PermissionBase: github.com/isaqueveras/power-sso

postgres:
Host: localhost
Port: 5432
User: postgres
Password: postgres
Dbname: power-sso
Sslmode: true
Driver: pgx
MaxOpenConns: 60
MaxIdleConns: 30
ConnMaxLifetime: 120
ConnMaxIdleTime: 20
Timeout: 2

redis:
RedisAddr: localhost:6379
RedisPassword:
RedisDb: 0
RedisDefaultdb: 0
MinIdleConns: 200
PoolSize: 12000
PoolTimeout: 240
Password: ""
DB: 0

logger:
Development: true
DisableCaller: false
DisableStacktrace: false
Encoding: json
Level: info

mailer:
Host: localhost
Port: 1025
Email: [email protected]
Password: password
TLS: true

UserAuthToken:
SecretKey: kjnfdjksdbfsdhfbdskjfnamkndkn
Duration: 2592000
11 changes: 10 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package config

import (
"log"
"os"

"github.com/spf13/viper"
)
Expand All @@ -20,7 +21,7 @@ func LoadConfig(path ...string) {
path[0] = "."
}

v.SetConfigName("./config/config-local")
v.SetConfigName(getConfigPath(os.Getenv("CONFIG_POWER_SSO")))
v.AddConfigPath(path[0])
v.AutomaticEnv()

Expand All @@ -44,3 +45,11 @@ func Get() *Config {
}
return config
}

// Get config path for dev or production
func getConfigPath(configPath string) string {
if configPath == modeProduction {
return "./config/config-prod"
}
return "./config/config-dev"
}

1 comment on commit d968b94

@vercel
Copy link

@vercel vercel bot commented on d968b94 Feb 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

power-sso – ./

power-sso-git-main-isaqueveras.vercel.app
power-sso-isaqueveras.vercel.app
power-sso.vercel.app

Please sign in to comment.