config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package config loads bootstrap settings (needed before the database opens) from a YAML file overlaid by SHELLCN_* environment variables. Settings an admin edits at runtime live in the store, not here.

Package config provides typed application configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AIConfig

type AIConfig struct {
	Kind    string `mapstructure:"kind"`
	Name    string `mapstructure:"name"`
	BaseURL string `mapstructure:"base_url"`
	APIKey  string `mapstructure:"api_key"`
	Model   string `mapstructure:"model"`
}

AIConfig is the optional operator-provided shared AI configuration. It is loaded from config.yaml + SHELLCN_AI_* env and exposed to clients only as a non-secret status projection.

func (AIConfig) Configured

func (c AIConfig) Configured() bool

Configured reports whether a usable shared AI provider is present.

func (AIConfig) DisplayName

func (c AIConfig) DisplayName() string

DisplayName is the name shown to users, falling back to the kind.

type AuditConfig

type AuditConfig struct {
	Enabled         bool   `mapstructure:"enabled"`
	RetentionDays   int    `mapstructure:"retention_days"`   // 0 = disabled (keep forever)
	CleanupInterval string `mapstructure:"cleanup_interval"` // how often to sweep expired audit rows
}

AuditConfig controls audit writes and optional retention cleanup. Audit is enabled by default; retention is OFF by default (RetentionDays == 0 keeps audit entries forever).

func (AuditConfig) CleanupEvery

func (c AuditConfig) CleanupEvery() time.Duration

CleanupEvery parses CleanupInterval, falling back to a sane default.

func (AuditConfig) RetentionEnabled

func (c AuditConfig) RetentionEnabled() bool

RetentionEnabled reports whether audit expiry/cleanup is active.

type AuthConfig

type AuthConfig struct {
	SessionTTL string `mapstructure:"session_ttl"`
	JWTSecret  string `mapstructure:"jwt_secret"`
}

func (AuthConfig) JWTSigningKey

func (c AuthConfig) JWTSigningKey(masterKey []byte) []byte

JWTSigningKey returns a stable HMAC key. An explicit jwt_secret takes precedence; otherwise the key is derived from the already-required master key.

func (AuthConfig) SessionTTLDuration

func (c AuthConfig) SessionTTLDuration() time.Duration

SessionTTLDuration parses SessionTTL, falling back to 24 hours.

type BootstrapConfig

type BootstrapConfig struct {
	AdminUsername string `mapstructure:"admin_username"`
	AdminPassword string `mapstructure:"admin_password"`
}

type Config

type Config struct {
	Server     ServerConfig     `mapstructure:"server"`
	Auth       AuthConfig       `mapstructure:"auth"`
	Bootstrap  BootstrapConfig  `mapstructure:"bootstrap"`
	Database   DatabaseConfig   `mapstructure:"database"`
	Secrets    SecretsConfig    `mapstructure:"secrets"`
	Email      EmailConfig      `mapstructure:"email"`
	Audit      AuditConfig      `mapstructure:"audit"`
	Recordings RecordingsConfig `mapstructure:"recordings"`
	AI         AIConfig         `mapstructure:"ai"`
}

func Load

func Load(paths ...string) (*Config, error)

Load reads config.yaml from the current directory, ./config, or any extra paths, then overlays SHELLCN_* environment variables. A missing file is fine.

func (*Config) SlogLevel

func (c *Config) SlogLevel() slog.Level

type DatabaseConfig

type DatabaseConfig struct {
	Driver string `mapstructure:"driver"` // sqlite | postgres | mysql
	DSN    string `mapstructure:"dsn"`    // sqlite: file path; others: connection string
}

type EmailConfig

type EmailConfig struct {
	Enabled  bool   `mapstructure:"enabled"`
	Host     string `mapstructure:"host"`
	Port     int    `mapstructure:"port"`
	From     string `mapstructure:"from"`
	Username string `mapstructure:"username"`
	Password string `mapstructure:"password"`
	UseTLS   bool   `mapstructure:"use_tls"` // implicit TLS (e.g. port 465); else STARTTLS
}

EmailConfig is the outbound SMTP configuration used for account invitations. Disabled by default; when off, invites are shared via their copyable link.

type RecordingsConfig

type RecordingsConfig struct {
	Dir             string `mapstructure:"dir"`              // blob storage root directory
	RetentionDays   int    `mapstructure:"retention_days"`   // 0 = disabled (keep forever)
	CleanupInterval string `mapstructure:"cleanup_interval"` // how often to sweep expired recordings
	MaxChunkBytes   int64  `mapstructure:"max_chunk_bytes"`  // per-chunk cap for desktop uploads
}

RecordingsConfig controls session-recording storage and retention. Retention is OFF by default (RetentionDays == 0 keeps recordings forever); an admin opts in by setting a positive retention here. The cleanup job only runs when retention is enabled.

func (RecordingsConfig) CleanupEvery

func (c RecordingsConfig) CleanupEvery() time.Duration

CleanupEvery parses CleanupInterval, falling back to a sane default.

func (RecordingsConfig) RetentionEnabled

func (c RecordingsConfig) RetentionEnabled() bool

RetentionEnabled reports whether expiry/cleanup is active.

type SecretsConfig

type SecretsConfig struct {
	MasterKey     string `mapstructure:"master_key"`
	MasterKeyFile string `mapstructure:"master_key_file"`
}

type ServerConfig

type ServerConfig struct {
	Addr     string `mapstructure:"addr"`
	LogLevel string `mapstructure:"log_level"`
}

Jump to

Keyboard shortcuts

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