Documentation
¶
Overview ¶
Package config parses the 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, envHTTPAddr, envHTTPPort, envReportingURL, envAPIToken, envAPIToken + envsecret.Suffix, envCAFile, envEngineDBURL, envEngineDBURL + envsecret.Suffix, envHtpasswd, envHtpasswd + envsecret.Suffix, envOpsPort, envMetricsEnabled, envReportingInsecure, }
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"`
// HTTPAddr is the IP address the console binds. The default keeps the
// console on the machine it runs on. A deployment behind a Gateway sets
// 0.0.0.0.
HTTPAddr string `env:"TALLY_CONSOLE_HTTP_ADDR" envDefault:"127.0.0.1"`
// HTTPPort is the port the console listens on. The default is 8095 because
// 8090 and 8091 are taken by the simulator compose stack.
HTTPPort int `env:"TALLY_CONSOLE_HTTP_PORT" envDefault:"8095"`
// OpsPort is the port the probes and the metrics are served on, at the
// address the console binds. It differs from the page port so that a route
// publishing the pages cannot reach them.
OpsPort int `env:"TALLY_CONSOLE_OPS_PORT" envDefault:"8096"`
// MetricsEnabled set to false makes GET /metrics answer 404. The variable has
// no CONSOLE infix because roadmap section 8 lists it among the common
// variables.
MetricsEnabled bool `env:"TALLY_METRICS_ENABLED" envDefault:"true"`
// 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 or ReportingInsecure allows a plaintext one, because the API token
// rides on every call.
ReportingURL string `env:"TALLY_CONSOLE_REPORTING_URL"`
// ReportingInsecure allows an http Reporting API on a host that is not
// loopback. It exists for a console and an API in the same namespace.
// Anywhere else it puts the API token on the wire in cleartext.
ReportingInsecure bool `env:"TALLY_CONSOLE_REPORTING_INSECURE" envDefault:"false"`
// APIToken is the bearer token the console reads the Reporting API with. It
// has to carry read_all, the lowest role every route the console reads
// accepts. 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. Its role is meant to be tally_console, the member
// of tally_console_reader that tally-engine ensure-console-role provisions.
// It has to be set. Supports the *_FILE convention.
EngineDBURL string `env:"TALLY_CONSOLE_ENGINE_DB_URL"`
// Htpasswd is the one operator allowed to sign in, as one user:bcrypt-hash
// line in htpasswd format. It has to be set. Supports the *_FILE convention.
Htpasswd string `env:"TALLY_CONSOLE_HTPASSWD"`
}
Config is the 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.