config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 modules, 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

This section is empty.

Types

type Config

type Config struct {
	Port          int      `toml:"port"`
	Host          string   `toml:"host"`
	Data          string   `toml:"data"`
	BaseURL       string   `toml:"base_url"`
	CORSOrigins   []string `toml:"cors_origins"`
	TrustProxy    bool     `toml:"trust_proxy"`
	Tunnel        bool     `toml:"tunnel"`
	LogFormat     string   `toml:"log_format"` // "json" or "text" (default: "text")
	TLSCert       string   `toml:"tls_cert"`
	TLSKey        string   `toml:"tls_key"`
	AdminToken    string   `toml:"admin_token"`
	MaxSecretSize int      `toml:"max_secret_size"` // bytes; 0 = default (512000)
	Metrics       bool     `toml:"metrics"`
}

Config holds all resolved configuration values.

func Defaults

func Defaults() Config

Defaults returns a Config with default values.

func LoadEnv

func LoadEnv() (Config, map[string]bool)

LoadEnv reads ZKETTLE_* environment variables and returns a Config with only the fields that were set via env vars. Returns a Config and a set of field names that were explicitly set.

func LoadFile

func LoadFile() (Config, string, map[string]bool, error)

LoadFile attempts to load a TOML config file from standard locations. Search order: ./zkettle.toml, $HOME/.config/zkettle/zkettle.toml Returns the loaded config, the path that was loaded (empty if none found), a set of field names explicitly defined in the file, and any error. Returns an error only if a file exists but is malformed.

func Merge

func Merge(defaults, file Config, fileSet map[string]bool, env Config, envSet map[string]bool, flags Config, flagSet map[string]bool) Config

Merge combines defaults, file config, env config, and flag overrides. Precedence: flags > env > file > defaults. All set maps use underscore-format keys (e.g. "base_url", "trust_proxy").

func ResolveAll

func ResolveAll(flagCfg Config, flagSet map[string]bool) (Config, string, error)

ResolveAll loads config from file and env, merges with flags and defaults, validates, and checks mutual exclusivity constraints. Returns the resolved config and the config file path (empty if none found).

func (Config) Validate

func (c Config) Validate() error

Validate checks that Config fields contain valid values. Returns an error if any field is invalid.

Jump to

Keyboard shortcuts

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