Documentation
¶
Overview ¶
Package config owns the layered configuration loader.
Precedence (lowest → highest):
- Built-in defaults (this file)
- TOML file (path from $SHITHUB_CONFIG, falling back to /etc/shithub/config.toml)
- Environment variables (SHITHUB_<area>_<key>; nested keys joined with "__")
- CLI flag overrides handed in by the caller
The Config struct is the single source of truth for what is configurable. Every consumer reads from this struct rather than from os.Getenv directly.
Index ¶
- func PrintRedacted(c Config) (string, error)
- func Validate(c *Config) error
- type Argon2Config
- type AuthConfig
- type Config
- type DBConfig
- type ErrorReportingConfig
- type LogConfig
- type MetricsConfig
- type NotifConfig
- type PostmarkConfig
- type S3StorageConfig
- type SMTPConfig
- type SessionConfig
- type StorageConfig
- type TracingConfig
- type WebConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintRedacted ¶
PrintRedacted writes the config to w in TOML form with secrets replaced by `***`. The transformation operates on a deep copy so the live Config is never mutated.
Types ¶
type Argon2Config ¶
type Argon2Config struct {
MemoryKiB uint32 `toml:"memory_kib"`
Time uint32 `toml:"time"`
Threads uint8 `toml:"threads"`
}
Argon2Config tunes the password hasher's cost. Defaults match the internal/auth/password Defaults() — operators bump these on faster hardware to keep the per-hash cost in the 100–300 ms band.
type AuthConfig ¶
type AuthConfig struct {
RequireEmailVerification bool `toml:"require_email_verification"`
BaseURL string `toml:"base_url"` // e.g. https://shithub.example
SiteName string `toml:"site_name"`
EmailFrom string `toml:"email_from"`
EmailBackend string `toml:"email_backend"` // stdout | smtp | postmark
SMTP SMTPConfig `toml:"smtp"`
Postmark PostmarkConfig `toml:"postmark"`
Argon2 Argon2Config `toml:"argon2"`
TOTPKeyB64 string `toml:"totp_key_b64"` // base64 32-byte AEAD key for at-rest TOTP secrets
}
AuthConfig configures the email/password auth surface.
type Config ¶
type Config struct {
Env string `toml:"env"` // "dev", "staging", "prod"
Web WebConfig `toml:"web"`
DB DBConfig `toml:"db"`
Log LogConfig `toml:"log"`
Metrics MetricsConfig `toml:"metrics"`
Tracing TracingConfig `toml:"tracing"`
ErrorReporting ErrorReportingConfig `toml:"error_reporting"`
Session SessionConfig `toml:"session"`
Storage StorageConfig `toml:"storage"`
Auth AuthConfig `toml:"auth"`
Notif NotifConfig `toml:"notif"`
}
Config is the typed root.
type DBConfig ¶
type DBConfig struct {
URL string `toml:"url"`
MaxConns int `toml:"max_conns"`
MinConns int `toml:"min_conns"`
ConnectTimeout time.Duration `toml:"connect_timeout"`
}
DBConfig holds Postgres settings.
type ErrorReportingConfig ¶
type ErrorReportingConfig struct {
DSN string `toml:"dsn"`
Environment string `toml:"environment"`
Release string `toml:"release"`
}
ErrorReportingConfig configures the Sentry/GlitchTip-protocol DSN.
type LogConfig ¶
type LogConfig struct {
Level string `toml:"level"` // debug | info | warn | error
Format string `toml:"format"` // text (dev) | json (prod)
}
LogConfig holds slog settings.
type MetricsConfig ¶
type MetricsConfig struct {
Enabled bool `toml:"enabled"`
BasicAuthUser string `toml:"basic_auth_user"`
BasicAuthPass string `toml:"basic_auth_pass"`
}
MetricsConfig configures the /metrics endpoint.
type NotifConfig ¶
type NotifConfig struct {
UnsubscribeKeyB64 string `toml:"unsubscribe_key_b64"`
}
NotifConfig configures the S29 notification surface. UnsubscribeKeyB64 is the base64-encoded HMAC-SHA256 key that signs one-click unsubscribe URLs (RFC 8058). When empty (dev default), the fan-out worker derives a deterministic key from the session key so links are stable across restarts without operator action — this derivation is NOT suitable for prod and the wiring layer logs a warning when it fires.
type PostmarkConfig ¶
type PostmarkConfig struct {
ServerToken string `toml:"server_token"`
}
PostmarkConfig holds Postmark transactional API settings.
type S3StorageConfig ¶
type S3StorageConfig struct {
Endpoint string `toml:"endpoint"` // host[:port], no scheme
Region string `toml:"region"` // e.g. "us-east-1", "nyc3"
AccessKeyID string `toml:"access_key_id"` //
SecretAccessKey string `toml:"secret_access_key"` //
Bucket string `toml:"bucket"` // e.g. "shithub-dev"
UseSSL bool `toml:"use_ssl"` // true for Spaces, false for local MinIO
ForcePathStyle bool `toml:"force_path_style"` // true for MinIO, false for Spaces
}
S3StorageConfig holds the S3-compatible endpoint settings.
type SMTPConfig ¶
type SMTPConfig struct {
Addr string `toml:"addr"` // host:port
Username string `toml:"username"`
Password string `toml:"password"`
}
SMTPConfig holds plain-SMTP backend settings (e.g. MailHog in dev).
type SessionConfig ¶
type SessionConfig struct {
KeyB64 string `toml:"key_b64"`
MaxAge time.Duration `toml:"max_age"`
Secure bool `toml:"secure"`
}
SessionConfig configures the cookie session store.
type StorageConfig ¶
type StorageConfig struct {
ReposRoot string `toml:"repos_root"` // filesystem root for bare repos
S3 S3StorageConfig `toml:"s3"`
}
StorageConfig configures repo filesystem storage and S3-compatible object storage. The S3 block targets MinIO in dev/test and DigitalOcean Spaces in prod (force_path_style true for MinIO, false for Spaces).