Documentation
¶
Overview ¶
Package config parses the demo console's environment configuration. The console reads the Reporting API over HTTP and the engine database directly, so it needs an address and a credential for each.
Configuration comes from the environment alone, prefixed TALLY_. Secrets also accept the *_FILE convention, which is how a Kubernetes Secret volume reaches the process without the value appearing in a pod spec.
The normative specification is roadmap/00-conventions.md section 8.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var EnvNames = []string{ envLogLevel, envHTTPPort, envReportingURL, envAPIToken, envAPIToken + envsecret.Suffix, envCAFile, envEngineDBURL, envEngineDBURL + envsecret.Suffix, }
EnvNames is every variable this package reads, including the *_FILE companions of the secrets. Tests blank all of them, so a value in the developer's shell never reaches the code under test.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// LogLevel is the slog threshold, one of DEBUG, INFO, WARN, or ERROR.
LogLevel string `env:"TALLY_LOG_LEVEL" envDefault:"INFO"`
// HTTPPort is the port the console listens on, bound to the loopback
// address only. The default is 8095 because 8090 and 8091 are taken by the
// simulator compose stack.
HTTPPort int `env:"TALLY_CONSOLE_HTTP_PORT" envDefault:"8095"`
// ReportingURL is the base URL of the Reporting API without the /api/v1
// suffix. It has to be set, and it has to be https unless its host is
// loopback, because the API token rides on every call.
ReportingURL string `env:"TALLY_CONSOLE_REPORTING_URL"`
// APIToken is the bearer token the console reads the Reporting API with. It
// has to carry the admin role, because the dead-letter list the overview
// reads is admin-only. It has to be set. Supports the *_FILE convention.
APIToken string `env:"TALLY_CONSOLE_API_TOKEN"`
// CAFile is a PEM file holding the CA that signed the Reporting API's
// certificate. Empty trusts the system store.
CAFile string `env:"TALLY_CONSOLE_CA_FILE"`
// EngineDBURL is the PostgreSQL connection string of the engine database,
// opened for reads only. It has to be set. Supports the *_FILE convention.
EngineDBURL string `env:"TALLY_CONSOLE_ENGINE_DB_URL"`
}
Config is the demo console's resolved configuration. Every field is final by the time Load returns: file-backed secrets hold their content, and the values the console cannot run without are present.