config

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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

View Source
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.

func Load

func Load() (Config, error)

Load reads the environment, resolves the file-backed secrets, and checks every value the console needs. The console serves one thing and reads from two places, so what it requires does not depend on the caller: a configuration Load accepts is one the server can start on.

func (Config) SlogLevel

func (c Config) SlogLevel() slog.Level

SlogLevel is the slog level that LogLevel names. A Config that never went through Load, and so carries an unchecked level, logs at info.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL