config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AIConfig added in v0.2.2

type AIConfig struct {
	// OpenAI API key
	APIKey string `koanf:"api_key"`
	// Model to use for AI SQL generation (default: gpt-4o)
	Model string `koanf:"model"`
	// MaxTokens is the maximum number of tokens to generate (default: 1024)
	MaxTokens int `koanf:"max_tokens"`
	// Temperature controls randomness in generation (0.0-1.0, default: 0.1)
	Temperature float32 `koanf:"temperature"`
	// Enabled indicates whether AI features are enabled
	Enabled bool `koanf:"enabled"`
	// BaseURL for OpenAI API (default: "", which uses the standard OpenAI API endpoint)
	BaseURL string `koanf:"base_url"`
}

AIConfig contains AI service (OpenAI) settings

type AlertsConfig added in v0.6.0

type AlertsConfig struct {
	Enabled            bool          `koanf:"enabled"`
	EvaluationInterval time.Duration `koanf:"evaluation_interval"`
	DefaultLookback    time.Duration `koanf:"default_lookback"`
	HistoryLimit       int           `koanf:"history_limit"`
}

AlertsConfig controls scheduling behaviour for alert rules. SMTP and other delivery settings are stored in the database and managed via Admin UI.

type AuthConfig

type AuthConfig struct {
	AdminEmails           []string      `koanf:"admin_emails"`
	SessionDuration       time.Duration `koanf:"session_duration"`
	MaxConcurrentSessions int           `koanf:"max_concurrent_sessions"`
	APITokenSecret        string        `koanf:"api_token_secret"`
	DefaultTokenExpiry    time.Duration `koanf:"default_token_expiry"`
}

AuthConfig contains authentication settings

type ClickhouseConfig

type ClickhouseConfig struct {
	Host     string `koanf:"host"`
	Port     int    `koanf:"port"`
	Database string `koanf:"database"`
	Username string `koanf:"username"`
	Password string `koanf:"password"`
}

ClickhouseConfig contains Clickhouse database settings

type Config

type Config struct {
	Server     ServerConfig     `koanf:"server"`
	SQLite     SQLiteConfig     `koanf:"sqlite"`
	Clickhouse ClickhouseConfig `koanf:"clickhouse"`
	OIDC       OIDCConfig       `koanf:"oidc"`
	Auth       AuthConfig       `koanf:"auth"`
	Logging    LoggingConfig    `koanf:"logging"`
	AI         AIConfig         `koanf:"ai"`
	Alerts     AlertsConfig     `koanf:"alerts"`
}

Config represents the application configuration

func Load

func Load(path string) (*Config, error)

Load loads the configuration from a file and environment variables. Environment variables with the prefix LOGCHEF_ can override file values. E.g., LOGCHEF_SERVER__PORT will override server.port

func LoadRuntimeConfig added in v0.6.0

func LoadRuntimeConfig(ctx context.Context, staticConfig *Config, store SettingsStore) *Config

LoadRuntimeConfig loads configuration from both static config and database. Database values override static config values for non-essential settings.

type LoggingConfig

type LoggingConfig struct {
	// Level sets the minimum log level (debug, info, warn, error)
	Level string `koanf:"level"`
}

LoggingConfig contains logging settings

type OIDCConfig

type OIDCConfig struct {
	// Provider URL for OIDC discovery
	ProviderURL string `koanf:"provider_url"` // Base URL for OIDC provider discovery
	// Different endpoints for OIDC flow
	AuthURL  string `koanf:"auth_url"`  // URL for browser auth redirects
	TokenURL string `koanf:"token_url"` // URL for token exchange (server-to-server)

	ClientID     string   `koanf:"client_id"`
	ClientSecret string   `koanf:"client_secret"`
	RedirectURL  string   `koanf:"redirect_url"`
	Scopes       []string `koanf:"scopes"`

	CLIClientID string `koanf:"cli_client_id"`
}

OIDCConfig contains OpenID Connect settings

type SQLiteConfig

type SQLiteConfig struct {
	Path string `koanf:"path"`
}

SQLiteConfig contains SQLite database settings

type ServerConfig

type ServerConfig struct {
	Port              int           `koanf:"port"`
	Host              string        `koanf:"host"`
	FrontendURL       string        `koanf:"frontend_url"`
	HTTPServerTimeout time.Duration `koanf:"http_server_timeout"`
}

ServerConfig contains HTTP server settings

type SettingsStore added in v0.6.0

type SettingsStore interface {
	GetSettingWithDefault(ctx context.Context, key, defaultValue string) string
	GetBoolSetting(ctx context.Context, key string, defaultValue bool) bool
	GetIntSetting(ctx context.Context, key string, defaultValue int) int
	GetFloat64Setting(ctx context.Context, key string, defaultValue float64) float64
	GetDurationSetting(ctx context.Context, key string, defaultValue time.Duration) time.Duration
}

SettingsStore defines the interface for retrieving settings from the database.

Jump to

Keyboard shortcuts

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