Documentation
¶
Overview ¶
Package config loads the server's startup settings, *arr-style: from environment variables and command-line flags. Only what the server needs before it can reach its database lives here. Everything else is managed in the app and stored in the database.
Index ¶
Constants ¶
const ( EnvListen = "PANELARR_LISTEN" EnvDatabaseURL = "PANELARR_DB" EnvConfigDir = "PANELARR_CONFIG" EnvDataDir = "PANELARR_DATA" EnvBaseURL = "PANELARR_BASE_URL" EnvLogFormat = "PANELARR_LOG_FORMAT" EnvLogLevel = "PANELARR_LOG_LEVEL" EnvMetricsEnabled = "PANELARR_METRICS_ENABLED" EnvMetricsListen = "PANELARR_METRICS_LISTEN" EnvSecretKey = "PANELARR_SECRET_KEY" EnvTrustedProxies = "PANELARR_TRUSTED_PROXIES" EnvMetaURL = "PANELARR_META_URL" EnvMetaAPIKey = "PANELARR_META_KEY" //nolint:gosec // a variable name, not a credential EnvWebDir = "PANELARR_WEB_DIR" )
Env names. Each setting can also be given as a flag.
const DefaultListen = ":8900"
DefaultListen is the server's port by convention.
const DefaultTrustedProxies = "127.0.0.0/8,::1/128,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7"
DefaultTrustedProxies are loopback and private networks.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Listen is the address of the HTTP server. Default ":8900".
Listen string
// DatabaseURL is the PostgreSQL URL (or key=value DSN). Required.
DatabaseURL string
// ConfigDir holds the server's own files: the encryption key for stored
// secrets, caches and logs. The image uses /config.
ConfigDir string
// DataDir is the default library location for downloads. The image
// uses /data.
DataDir string
// BaseURL is the public URL the server is reached at, e.g.
// "https://panelarr.example.com". Optional. It decides whether cookies
// are marked Secure and how absolute links are built.
BaseURL string
// SecretKey encrypts stored secrets (service and plugin keys, storage
// credentials): base64 of 32 bytes. Empty: a key file in ConfigDir,
// generated on first use.
SecretKey string
// TrustedProxies are the networks whose X-Forwarded-For header is
// believed when finding a client's address (for login limits and the
// session list). Default: loopback and private networks, where reverse
// proxies usually run.
TrustedProxies []netip.Prefix
// Meta, when its URL is set, is the metadata service connection; it
// then can't be changed in the app. Empty: an admin connects it in the
// first-run wizard.
MetaURL string
MetaAPIKey string
// WebDir serves the web app from a directory (a local build) instead of
// the one embedded in the binary. For development.
WebDir string
// Log configures logging.
Log Log
// Metrics configures the Prometheus endpoint.
Metrics Metrics
}
Config is the server's startup configuration.
func (Config) RequireDatabase ¶
RequireDatabase reports a clear error when no database URL is set.
func (Config) SecureCookies ¶
SecureCookies reports whether the public URL is https.
type Flags ¶
type Flags struct {
// contains filtered or unexported fields
}
Flags binds the settings to fs. Call Load after fs.Parse.
type Log ¶
type Log struct {
// Format is "json" (the default) or "text".
Format string
// Level is "debug", "info" (the default), "warn" or "error".
Level string
}
Log configures structured logging.
type Metrics ¶
type Metrics struct {
Enabled bool
// Listen is the metrics address, e.g. "127.0.0.1:9464". Empty: /metrics
// on the API port, behind a metrics:read key.
Listen string
}
Metrics configures Prometheus metrics. They are off by default. When on, they are served on their own address, or on the API port to callers whose API key has the metrics:read scope.