config

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveConfig

func SaveConfig(cfg *Config, filePath string) error

SaveConfig writes the provided Config struct to a YAML file.

Types

type AdminConfig added in v0.5.0

type AdminConfig struct {
	Username string `mapstructure:"username" yaml:"username"`
	Email    string `mapstructure:"email" yaml:"email"`
	Password string `mapstructure:"password" yaml:"password"`
}

AdminConfig is the administrator created on an empty instance.

type AgentsConfig added in v0.5.0

type AgentsConfig struct {
	// RunsKept is how many runs (with their steps) are kept per agent.
	RunsKept int `mapstructure:"runs_kept" yaml:"runs_kept"`
}

AgentsConfig controls agent run history.

type AuthConfig added in v0.5.0

type AuthConfig struct {
	// Registration is "disabled" (default: accounts are created by admins)
	// or "open" (anyone can create a viewer account at /auth/register).
	Registration string `mapstructure:"registration" yaml:"registration"`
}

AuthConfig controls account creation.

type CORSConfig

type CORSConfig struct {
	AllowedOrigins   []string `mapstructure:"allowed_origins" yaml:"allowed_origins"`
	AllowedMethods   []string `mapstructure:"allowed_methods" yaml:"allowed_methods"`
	AllowedHeaders   []string `mapstructure:"allowed_headers" yaml:"allowed_headers"`
	AllowCredentials bool     `mapstructure:"allow_credentials" yaml:"allow_credentials"`
	MaxAge           int      `mapstructure:"max_age" yaml:"max_age"`
}

type Config

type Config struct {
	LogLevel          string `mapstructure:"log_level"`
	Mode              string `mapstructure:"mode" yaml:"mode"` // Gin mode: development | production | test
	TelemetryEnabled  bool   `mapstructure:"telemetry_enabled"`
	JWTSecret         string `mapstructure:"jwt_secret"`
	DatabaseURL       string `mapstructure:"database_url"`
	ServerPort        string `mapstructure:"server_port"`
	MinPasswordLength int    `json:"min_password_length" yaml:"min_password_length"`

	// Redis settings
	Redis RedisConfig `mapstructure:"redis"`

	// Background job queue
	Queue QueueConfig `mapstructure:"queue" yaml:"queue"`

	// Embedded admin UI
	UI UIConfig `mapstructure:"ui" yaml:"ui"`

	// CORS settings
	CORS CORSConfig `mapstructure:"cors"`

	// LLM settings
	LLM LLMConfig `mapstructure:"llm" yaml:"llm"`

	// Rate limiting for /auth/* (shared across replicas through Redis)
	RateLimit RateLimitConfig `mapstructure:"rate_limit" yaml:"rate_limit"`

	// TrustedProxies lists the proxies (IPs or CIDRs) whose X-Forwarded-For
	// header is trusted to find the client IP. Empty: use the TCP peer.
	TrustedProxies []string `mapstructure:"trusted_proxies" yaml:"trusted_proxies"`

	// Media uploads and storage
	Media MediaConfig `mapstructure:"media" yaml:"media"`

	// Outbound webhooks
	Webhooks WebhooksConfig `mapstructure:"webhooks" yaml:"webhooks"`
	// Connected apps
	Connections ConnectionsConfig `mapstructure:"connections" yaml:"connections"`

	// OpenAPI description and Swagger UI
	OpenAPI OpenAPIConfig `mapstructure:"openapi" yaml:"openapi"`

	// Agents
	Agents AgentsConfig `mapstructure:"agents" yaml:"agents"`

	// Content controls content history.
	Content ContentConfig `mapstructure:"content" yaml:"content"`

	// I18n sets the default content locale.
	I18n I18nConfig `mapstructure:"i18n" yaml:"i18n"`

	// AutoMigrate applies pending database migrations when the API starts.
	// When false, the API refuses to start on an outdated schema: run
	// `gohead migrate` first (the Helm chart does, in an init container).
	AutoMigrate bool `mapstructure:"auto_migrate" yaml:"auto_migrate"`

	// Auth controls self-registration.
	Auth AuthConfig `mapstructure:"auth" yaml:"auth"`

	// Admin is the first administrator, created at startup when the
	// instance has no users.
	Admin AdminConfig `mapstructure:"admin" yaml:"admin"`
}

Config holds all application settings.

func LoadConfig

func LoadConfig(configPath string) (Config, error)

LoadConfig loads the configuration from file and environment variables.

func LoadTestConfig

func LoadTestConfig() (Config, error)

LoadTestConfig loads a test configuration file.

func (Config) RedisClientOpt

func (c Config) RedisClientOpt() asynq.RedisClientOpt

RedisClientOpt returns the asynq connection options for the configured Redis, including password and database index.

func (Config) RedisOptions

func (c Config) RedisOptions() *redis.Options

RedisOptions returns go-redis options for the configured Redis.

type ConnectionsConfig added in v0.7.0

type ConnectionsConfig struct {
	// AllowPrivateNetworks lets connections reach private and loopback
	// addresses. Link-local (cloud metadata) addresses are always refused.
	AllowPrivateNetworks bool          `mapstructure:"allow_private_networks" yaml:"allow_private_networks"`
	Timeout              time.Duration `mapstructure:"timeout" yaml:"timeout"`
}

ConnectionsConfig controls connections to other services (connected apps: remote MCP servers agents use).

type ContentConfig added in v0.5.0

type ContentConfig struct {
	// RevisionsKept is how many revisions are kept per entry (0: all).
	RevisionsKept int `mapstructure:"revisions_kept" yaml:"revisions_kept"`
}

ContentConfig controls content history.

type I18nConfig added in v0.5.0

type I18nConfig struct {
	// DefaultLocale is the locale of existing and new content when the
	// database has no locale yet (first start, or upgrade). Later changes
	// go through the locales API.
	DefaultLocale string `mapstructure:"default_locale" yaml:"default_locale"`
}

I18nConfig sets up content locales.

type LLMConfig

type LLMConfig struct {
	Provider  string `mapstructure:"provider" yaml:"provider"`
	Model     string `mapstructure:"model" yaml:"model"`
	APIKey    string `mapstructure:"api_key" yaml:"api_key"`
	APISecret string `mapstructure:"api_secret" yaml:"api_secret"`
	BaseURL   string `mapstructure:"base_url" yaml:"base_url"` // optional API endpoint override
	// Prices in USD per million tokens, used to estimate run costs and
	// enforce cost limits. Zero: cost is not tracked.
	InputCostPerMillion  float64 `mapstructure:"input_cost_per_million" yaml:"input_cost_per_million" json:"input_cost_per_million,omitempty"`
	OutputCostPerMillion float64 `mapstructure:"output_cost_per_million" yaml:"output_cost_per_million" json:"output_cost_per_million,omitempty"`
}

LLMConfig holds settings for Large Language Model providers.

type MediaConfig added in v0.4.0

type MediaConfig struct {
	Enabled      bool     `mapstructure:"enabled" yaml:"enabled"`
	Driver       string   `mapstructure:"driver" yaml:"driver"` // local | s3
	MaxSizeMB    int      `mapstructure:"max_size_mb" yaml:"max_size_mb"`
	AllowedTypes []string `mapstructure:"allowed_types" yaml:"allowed_types"` // MIME patterns; empty = built-in list
	// PublicURL is the base URL files are downloaded from (CDN, public
	// bucket, or the API's /uploads). Empty: /uploads on the API for local
	// files, presigned URLs for S3.
	PublicURL string           `mapstructure:"public_url" yaml:"public_url"`
	Local     MediaLocalConfig `mapstructure:"local" yaml:"local"`
	S3        MediaS3Config    `mapstructure:"s3" yaml:"s3"`
}

MediaConfig configures uploads (POST /api/media) and where files are stored.

type MediaLocalConfig added in v0.4.0

type MediaLocalConfig struct {
	Path string `mapstructure:"path" yaml:"path"`
}

MediaLocalConfig configures the filesystem media driver.

type MediaS3Config added in v0.4.0

type MediaS3Config struct {
	Endpoint      string        `mapstructure:"endpoint" yaml:"endpoint"`
	Region        string        `mapstructure:"region" yaml:"region"`
	Bucket        string        `mapstructure:"bucket" yaml:"bucket"`
	AccessKey     string        `mapstructure:"access_key" yaml:"access_key"`
	SecretKey     string        `mapstructure:"secret_key" yaml:"secret_key"`
	UseSSL        bool          `mapstructure:"use_ssl" yaml:"use_ssl"`
	PathStyle     bool          `mapstructure:"path_style" yaml:"path_style"`
	Prefix        string        `mapstructure:"prefix" yaml:"prefix"`
	PresignExpiry time.Duration `mapstructure:"presign_expiry" yaml:"presign_expiry"`
}

MediaS3Config configures the S3-compatible media driver.

type OpenAPIConfig added in v0.5.0

type OpenAPIConfig struct {
	Enabled bool `mapstructure:"enabled" yaml:"enabled"`
	// Public serves /api/openapi.json without a token. Off by default: the
	// spec describes your content model.
	Public bool `mapstructure:"public" yaml:"public"`
}

OpenAPIConfig controls the generated API description.

type QueueConfig added in v0.6.0

type QueueConfig struct {
	// Driver: "redis" (asynq on Redis; several processes and replicas) or
	// "database" (a jobs table in GoHead's database; no Redis). Empty:
	// "database" for gohead standalone, "redis" otherwise.
	Driver string `mapstructure:"driver" yaml:"driver"`
	// Concurrency is the number of jobs a process runs at once (standalone;
	// worker and dispatcher keep their own defaults when 0).
	Concurrency int `mapstructure:"concurrency" yaml:"concurrency"`
	// PollInterval: how often the database driver looks for jobs queued by
	// other processes, and for retries that became due.
	PollInterval time.Duration `mapstructure:"poll_interval" yaml:"poll_interval"`
}

QueueConfig selects how background jobs (collection events, agent runs, webhook deliveries) are queued.

type RateLimitConfig

type RateLimitConfig struct {
	Enabled bool `mapstructure:"enabled" yaml:"enabled"`
	// AuthPerMinute is the number of /auth/* requests allowed per client IP
	// per minute (0 disables it).
	AuthPerMinute int `mapstructure:"auth_per_minute" yaml:"auth_per_minute"`
	// LoginFailures is the number of failed logins allowed per username and
	// client IP within LoginWindow before further attempts get 429.
	LoginFailures int           `mapstructure:"login_failures" yaml:"login_failures"`
	LoginWindow   time.Duration `mapstructure:"login_window" yaml:"login_window"`
	// PublicPerMinute is the number of anonymous /api requests allowed per
	// client IP per minute when the public role grants access (0 disables
	// it).
	PublicPerMinute int `mapstructure:"public_per_minute" yaml:"public_per_minute"`
}

RateLimitConfig protects the authentication endpoints.

type RedisConfig

type RedisConfig struct {
	Address  string `mapstructure:"address" yaml:"address"`
	Password string `mapstructure:"password" yaml:"password"`
	DB       int    `mapstructure:"db" yaml:"db"`
}

RedisConfig holds settings for the Redis connection.

type UIConfig added in v0.6.0

type UIConfig struct {
	// Enabled serves the admin UI at / when the binary includes it.
	Enabled bool `mapstructure:"enabled" yaml:"enabled"`
}

UIConfig controls the admin UI embedded in the binary.

type WebhooksConfig added in v0.5.0

type WebhooksConfig struct {
	// AllowPrivateNetworks lets webhooks reach private and loopback
	// addresses. Link-local (cloud metadata) addresses are always refused.
	AllowPrivateNetworks bool          `mapstructure:"allow_private_networks" yaml:"allow_private_networks"`
	Timeout              time.Duration `mapstructure:"timeout" yaml:"timeout"`
	MaxRetries           int           `mapstructure:"max_retries" yaml:"max_retries"`
}

WebhooksConfig controls outbound webhook deliveries.

Jump to

Keyboard shortcuts

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