mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
config: programmatically generate env mapping
This commit is contained in:
parent
c81c1bb04f
commit
bdcff1cc8b
1 changed files with 8 additions and 25 deletions
|
@ -25,6 +25,7 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/zpatrick/go-config"
|
"github.com/zpatrick/go-config"
|
||||||
)
|
)
|
||||||
|
@ -108,31 +109,13 @@ func InitConfig() error {
|
||||||
static["auth.external"] = "false"
|
static["auth.external"] = "false"
|
||||||
}
|
}
|
||||||
|
|
||||||
mappings := map[string]string{
|
mappings := map[string]string{}
|
||||||
"DB_HOST": "db.host",
|
for name, value := range static {
|
||||||
"DB_NAME": "db.name",
|
envName := strings.Replace(name, ".", "_")
|
||||||
"DB_USER": "db.user",
|
envName := strings.Replace(envName, "-", "_")
|
||||||
"DB_PASS": "db.pass",
|
envName := strings.ToUpper(envName)
|
||||||
"DB_SSLMODE": "db.ssl",
|
|
||||||
"AMQP_HOST": "amqp.host",
|
mappings[envName] = name
|
||||||
"AMQP_USER": "amqp.user",
|
|
||||||
"AMQP_PASS": "amqp.pass",
|
|
||||||
"BASE_HOST": "base.host",
|
|
||||||
"BASE_PATH": "base.path",
|
|
||||||
"MODE": "mode",
|
|
||||||
"PORT": "port",
|
|
||||||
"ADMIN_USER": "admin.user",
|
|
||||||
"ADMIN_PASS": "admin.pass",
|
|
||||||
"ADMIN_MAIL": "admin.mail",
|
|
||||||
"S3_BUCKET": "s3.bucket",
|
|
||||||
"S3_ENDPOINT": "s3.endpoint",
|
|
||||||
"S3_REGION": "s3.region",
|
|
||||||
"S3_NOSSL": "s3.nossl",
|
|
||||||
"S3_PATHSTYLE": "s3.pathstyle",
|
|
||||||
"JWT_SECRET": "jwt.secret",
|
|
||||||
"JWT_EXPIRES_AFTER": "jwt.expires-after",
|
|
||||||
"TEST_DATA_PATH": "test.datapath",
|
|
||||||
"AUTH_EXTERNAL": "auth.external",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defaults := config.NewStatic(static)
|
defaults := config.NewStatic(static)
|
||||||
|
|
Loading…
Add table
Reference in a new issue