/*
* Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
*
* This file is licensed under AGPL-3.0-or-later, see NOTICE and LICENSE for
* more information.
*/
package config
import (
"log"
"tixe/util"
)
var TixeConfig *Config
type Config struct {
// Tixe host, e.g. tixe.liljamo.dev
// Defaults to 127.0.0.1:8080 for local testing
Host string
// Tixe scheme, http or https (default)
Scheme string
PsqlHost string
// Postgres port, defaults to 5432
PsqlPort string
PsqlUser string
PsqlPwd string
PsqlDb string
CookieSecret string
OidcDomain string
OidcIssuerTrailingSlash bool
OidcClientID string
OidcSecret string
// What is written on the login button
OidcLoginVisual string
}
func ParseConfig() {
log.Print("[tixe/config] Parsing config")
TixeConfig = &Config{
Host: util.LoadVar("TIXE_HOST", "127.0.0.1:8080"),
Scheme: util.LoadVar("TIXE_SCHEME", "http"),
PsqlHost: util.LoadVar("TIXE_PSQL_HOST", ""),
PsqlPort: util.LoadVar("TIXE_PSQL_PORT", "5432"),
PsqlUser: util.LoadVar("TIXE_PSQL_USER", ""),
PsqlPwd: util.LoadVar("TIXE_PSQL_PASSWORD", ""),
PsqlDb: util.LoadVar("TIXE_PSQL_DB", ""),
CookieSecret: util.LoadVar("TIXE_COOKIE_SECRET", ""),
OidcDomain: util.LoadVar("TIXE_OIDC_DOMAIN", ""),
OidcIssuerTrailingSlash: util.LoadVarBool("TIXE_OIDC_ISSUER_TRAILING_SLASH", false),
OidcClientID: util.LoadVar("TIXE_OIDC_CLIENTID", ""),
OidcSecret: util.LoadVar("TIXE_OIDC_SECRET", ""),
OidcLoginVisual: util.LoadVar("TIXE_OIDC_LOGIN_VISUAL", "oidc"),
}
}