Documentation
¶
Overview ¶
Package config loads GoRun configuration.
Precedence (highest first): flags > environment > <DataDir>/gorun.toml > defaults. The data dir itself is resolved from --data / GORUN_DATA / default only.
Index ¶
Constants ¶
const MinSetupTokenLen = 16
MinSetupTokenLen is the shortest GORUN_SETUP_TOKEN accepted.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Addons map[string]string // Optional addon modes: enabled, disabled or auto.
TrustedProxies []string // GORUN_TRUSTED_PROXIES; empty trusts no forwarded headers
CSPScriptSrc []string // GORUN_CSP_SCRIPT_SRC: extra public-page script sources (see PublicScriptSources)
Env string // "dev" | "prod"
DataDir string // GORUN_DATA, default ./data
BaseURL string // GORUN_BASE_URL
Addr string // GORUN_ADDR default 127.0.0.1:8080 (dev), :8080 (prod)
SecretKey []byte // GORUN_SECRET_KEY (32 bytes after base64 decode) — required in prod, generated+persisted in dev
AllowPrivateNet bool // GORUN_ALLOW_PRIVATE_NET
// MCPSameOwnerApproval (GORUN_MCP_SAME_OWNER_APPROVAL) lets an API key
// approve MCP calls requested by another key of the same owner. Off by
// default: approvals by key need a different person.
MCPSameOwnerApproval bool
// HSTSIncludeSubdomains (GORUN_HSTS_INCLUDE_SUBDOMAINS) and HSTSPreload
// (GORUN_HSTS_PRELOAD) extend the HSTS header sent on https requests.
// Off by default; preload requires includeSubDomains.
HSTSIncludeSubdomains, HSTSPreload bool
// Metrics (GORUN_METRICS) serves GET /metrics in Prometheus text format.
// Off by default. MetricsToken (GORUN_METRICS_TOKEN) optional Bearer for scrapers.
Metrics bool
MetricsToken string
Stripe struct{ SecretKey, WebhookSecret string } // STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET
Theme string // GORUN_THEME default "default"
SetupToken string // GORUN_SETUP_TOKEN: honored in every environment; required for prod setup (≥ 16 chars)
S3 S3 // [s3] / GORUN_S3_*: media in an S3-compatible bucket
}
Config is the resolved runtime configuration.
func Load ¶
Load resolves the configuration from args (flags, without the program or subcommand name), the environment, the TOML file and defaults.
func LoadReadOnly ¶
LoadReadOnly validates existing configuration without generating a dev secret.
func (Config) PublicScriptSources ¶
PublicScriptSources validates the operator's extra script-src entries for public pages (never the admin). The bundled themes need none; a custom theme that still loads a CDN or a self-hosted standard Alpine build lists what it needs, e.g. "https://cdn.jsdelivr.net 'unsafe-eval'". Entries are https origins or URL prefixes, or the keyword 'unsafe-eval'; anything broader (https:, *, 'unsafe-inline', data:) is refused.