Mercurial > gemma
view config/config.go @ 196:b67208d82543
Make test output more comprehensive
Running all tests in one transaction ensures the final output tells
about any failing test, not just in the last transaction (i.e.
test script).
The price is that no traces of the tests are left in the database
because we have to rollback in order to have no left-over test roles
in the cluster.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 20 Jul 2018 18:31:45 +0200 |
parents | 3457a60fb12d |
children | 11d1a488b08f |
line wrap: on
line source
package config import ( "log" "os" "strconv" ) var Config = NewConfiguration() type Configuration struct { DBHost string DBPort uint DBName string DBSSLMode string SessionStore string } func NewConfiguration() *Configuration { // TODO: Load from file. return &Configuration{ DBHost: envString("GEMMA_DB_HOST", "localhost"), DBPort: envUint("GEMMA_DB_PORT", 5432), DBName: envString("GEMMA_DB_NAME", "gemma"), DBSSLMode: envString("GEMMA_DB_SSL_MODE", "require"), SessionStore: envString("GEMMA_SESSION_STORE", ""), } } func envString(key, def string) string { if v, ok := os.LookupEnv(key); ok { return v } return def } func envUint(key string, def uint) uint { if v, ok := os.LookupEnv(key); ok { x, err := strconv.ParseUint(v, 10, 64) if err != nil { log.Printf("warn: invalid uint env %s: %v\n", key, err) return def } return uint(x) } return def }