config

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0, MIT Imports: 16 Imported by: 0

Documentation

Overview

Package config loads runtime settings in layers; later layers win:

defaults → --env-file → system env → overrides

Empty values do not shadow defaults. Unknown keys fail in the env file but are ignored in the system environment.

Index

Constants

This section is empty.

Variables

View Source
var (
	AppName    = "tango"
	AppVersion = "0.0.0"
	BuildHash  = "unknown"
	BuildDate  = "0000-00-00T00:00:00Z"
	Platform   = fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)
)

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Mode         string `koanf:"mode"`
	DataDir      string `koanf:"data_dir"`
	LogLevel     string `koanf:"log_level"`
	LogTransport string `koanf:"log_transport"`
	LogFormat    string `koanf:"log_format"`
	SecretKey    string `koanf:"secret_key"`
}

type AuthConfig

type AuthConfig struct {
	PrivateKey         string `koanf:"private_key"`
	PublicKey          string `koanf:"public_key"`
	SecretKey          string `koanf:"secret_key"`
	AccessTokenExpiry  int    `koanf:"access_token_expiry"`
	RefreshTokenExpiry int    `koanf:"refresh_token_expiry"`
	SessionLifetime    int    `koanf:"session_lifetime"`
	GithubClientID     string `koanf:"github_client_id"`
	GithubClientSecret string `koanf:"github_client_secret"`
	GoogleClientID     string `koanf:"google_client_id"`
	GoogleClientSecret string `koanf:"google_client_secret"`
}

type Config

type Config struct {
	Host     string         `koanf:"host"`
	Port     int            `koanf:"port"`
	App      AppConfig      `koanf:"app"`
	Auth     AuthConfig     `koanf:"auth"`
	Database DatabaseConfig `koanf:"database"`
	Mailer   MailerConfig   `koanf:"mailer"`
	Public   PublicConfig   `koanf:"public"`
	Queue    QueueConfig    `koanf:"queue"`
	Storage  StorageConfig  `koanf:"storage"`
}

Config defines runtime settings and their koanf keys.

func Load

func Load(opts LoadOptions) (*Config, error)

Load assembles layered config and decodes it into Config.

func (*Config) BackupDir

func (c *Config) BackupDir() string

BackupDir returns the backup directory.

func (*Config) DataDir

func (c *Config) DataDir() string

DataDir returns the configured data root.

func (*Config) KeysDir

func (c *Config) KeysDir() string

KeysDir returns the generated key directory.

func (*Config) LogFile

func (c *Config) LogFile() string

LogFile returns the application log path.

func (*Config) PrivateKeyPath

func (c *Config) PrivateKeyPath() string

PrivateKeyPath returns the private key path.

func (*Config) PublicKeyPath

func (c *Config) PublicKeyPath() string

PublicKeyPath returns the public key path.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks values that defaults cannot express, then reports all errors.

type DatabaseConfig

type DatabaseConfig struct {
	URL string `koanf:"url"`
}

type LoadOptions

type LoadOptions struct {
	// EnvFile is an optional dotenv file between defaults and env.
	EnvFile string

	// Overrides win over everything (resolved CLI flags).
	Overrides map[string]any
}

LoadOptions configures Load.

type MailerConfig

type MailerConfig struct {
	FromEmail    string `koanf:"from_email"`
	FromName     string `koanf:"from_name"`
	SMTPHost     string `koanf:"smtp_host"`
	SMTPPort     int    `koanf:"smtp_port"`
	SMTPUsername string `koanf:"smtp_username"`
	SMTPPassword string `koanf:"smtp_password"`
	SMTPSecure   bool   `koanf:"smtp_secure"`
}

type PublicConfig

type PublicConfig struct {
	BaseURL               string   `koanf:"base_url"`
	S3AssetsURL           string   `koanf:"s3_assets_url"`
	VersionCheckURL       string   `koanf:"version_check_url"`
	TrustedOrigins        []string `koanf:"trusted_origins"`
	JwtAccessTokenExpiry  int      `koanf:"jwt_access_token_expiry"`
	JwtRefreshTokenExpiry int      `koanf:"jwt_refresh_token_expiry"`
}

type QueueConfig

type QueueConfig struct {
	Workers         int `koanf:"workers"`
	ReleaseAfter    int `koanf:"release_after"`
	CleanupInterval int `koanf:"cleanup_interval"`
}

type StorageConfig

type StorageConfig struct {
	DataDir            string  `koanf:"data_dir"`
	MaxUploadSize      int64   `koanf:"max_upload_size"`
	S3AccessKeyID      string  `koanf:"s3_access_key_id"`
	S3BucketDefault    string  `koanf:"s3_bucket_default"`
	S3EndpointURL      string  `koanf:"s3_endpoint_url"`
	S3ForcePathStyle   bool    `koanf:"s3_force_path_style"`
	S3PathPrefix       *string `koanf:"s3_path_prefix"`
	S3Region           string  `koanf:"s3_region"`
	S3SecretAccessKey  string  `koanf:"s3_secret_access_key"`
	S3SignedURLExpires int     `koanf:"s3_signed_url_expires"`
}

Jump to

Keyboard shortcuts

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