Documentation
¶
Overview ¶
Package settings reads backd's runtime configuration from environment variables.
Index ¶
Constants ¶
const DefaultImageMaxPixels = 40_000_000
DefaultImageMaxPixels is the pixel limit for image versions when none is set.
Variables ¶
This section is empty.
Functions ¶
func ImageMaxPixels ¶ added in v0.8.1
ImageMaxPixels reads BACKD_IMAGE_MAX_PIXELS: a positive number of pixels.
func LoadKeyMaterial ¶
LoadKeyMaterial reads secret key material from the environment variable name, or from the file named by name+"_FILE" (trimmed of surrounding whitespace); the two are mutually exclusive. Returns "" if neither is set. Exported for `backd secret rotate-key`, which reads BACKD_SECRETS_NEW_KEY the same way outside of Load.
func LoadMetrics ¶ added in v0.4.0
LoadMetrics reads METRICS_ADDR and METRICS_TOKEN, shared by every backd command that can serve /metrics. reserved are the addresses the process serves other things on: metrics must have a listener of their own.
Types ¶
type ProvisionMode ¶
type ProvisionMode string
ProvisionMode controls what startup provisioning does to MongoDB.
const ( // ProvisionApply creates missing collections, validators and indexes. ProvisionApply ProvisionMode = "apply" // ProvisionVerify only compares MongoDB against the config and fails on differences. ProvisionVerify ProvisionMode = "verify" )
type Settings ¶
type Settings struct {
ConfigDir string
MongoURI string
HTTPAddr string
ProvisionMode ProvisionMode
LogLevel slog.Level
MaxBodyBytes int64
// MaxUploadBytes caps one file of a proxy upload (BACKD_MAX_UPLOAD_BYTES), apart from
// MaxBodyBytes, which is for JSON.
MaxUploadBytes int64
// ImageMaxPixels is the most pixels (width × height) an image may have to get
// versions (BACKD_IMAGE_MAX_PIXELS); a file field may only lower it.
ImageMaxPixels int64
// ImageTimeout bounds the making of one image's versions (BACKD_IMAGE_TIMEOUT).
ImageTimeout time.Duration
// ImageConcurrency is how many images one worker process makes versions of at once
// (BACKD_IMAGE_CONCURRENCY); 0 derives it from the container's CPU and memory limits.
ImageConcurrency int
MongoOpTimeout time.Duration
ShutdownTimeout time.Duration
// PasswordHashConcurrency caps concurrent password hashes; 0 means
// auth.DefaultHashConcurrency (CPU and memory limits).
PasswordHashConcurrency int
// TrustedProxies are networks whose X-Forwarded-For header is believed.
TrustedProxies []netip.Prefix
// Functions: the executor (BACKD_EXECUTOR_URL, BACKD_EXECUTOR_TOKEN),
// the internal listener it and the functions reach backd on
// (BACKD_INTERNAL_ADDR, as BACKD_CALLBACK_URL from their side), and the
// key callback tokens are signed with (BACKD_CALLBACK_KEY).
ExecutorURL string
ExecutorToken string
InternalAddr string
CallbackURL string
CallbackKey string
// BackdURL is backd's public address (BACKD_URL), the base of the links
// in emails; a realm's email.public_url overrides it. No trailing slash.
BackdURL string
// SecretsKey is the master key functions' secrets (roadmap F5) are
// encrypted under (BACKD_SECRETS_KEY, or BACKD_SECRETS_KEY_FILE for a
// file holding it). Empty when neither is set: functions that declare
// secrets are refused at startup (checked against the config, so it
// isn't here).
SecretsKey []byte
// Dev enables BACKD_DEV: functions rebuild automatically when their
// sources change. Local development only; serve refuses it unless
// HTTPAddr is bound to localhost.
Dev bool
// DisableAdminAPI is BACKD_ADMIN_API=false: this instance serves no
// /_admin route at all (they answer 404 like any unknown route), for public
// instances when an internal one has the admin API.
DisableAdminAPI bool
// AdminUI is BACKD_ADMIN_UI=true: this instance serves the admin web
// interface. It needs the admin API on the same instance.
AdminUI bool
// AdminUIIdle is BACKD_ADMIN_UI_IDLE: how long the admin UI may sit
// untouched before it signs out and revokes its session (default 30m).
AdminUIIdle time.Duration
// DevAnyAddr (BACKD_DEV_ANY_ADDR) lets dev mode run on an address that
// isn't localhost, for a container whose ports are published on the
// host's localhost only.
DevAnyAddr bool
// Deno is the deno binary dev mode bundles with; "" means "deno" on
// the PATH (BACKD_DEV only; `functions build` reads DENO itself).
Deno string
// WorkerConcurrency caps how many async jobs one worker process runs
// at once (WORKER_CONCURRENCY, roadmap F11); default 10.
WorkerConcurrency int
// MetricsAddr (METRICS_ADDR) is where a process serves /metrics; empty
// means it doesn't. MetricsToken (METRICS_TOKEN) makes it ask for that
// bearer token. The port must be private (design/metrics.md).
MetricsAddr string
MetricsToken string
}
Settings is the complete runtime configuration.