config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConfigEnv is the environment variable for overriding the config file path.
	ConfigEnv = "AHT_CONFIG"
)

Variables

View Source
var (
	ErrMissingUnitSuffix   = errors.New("missing unit suffix")
	ErrInvalidSort         = errors.New("invalid ui.sort")
	ErrInvalidPresence     = errors.New("invalid ui.default_presence")
	ErrInvalidTimeFormat   = errors.New("invalid ui.time_format")
	ErrNegativeAge         = errors.New("retention.max_gone_age must be non-negative")
	ErrNonPositiveInterval = errors.New("tracker.interval must be positive")
	ErrNegativeGracePeriod = errors.New("tracker.grace_period must be non-negative")
	ErrConfigIsDirectory   = errors.New("config path is a directory")
	ErrConfigFileTooLarge  = errors.New("config file exceeds 1 MiB limit")
	ErrConfigNotFound      = errors.New("config file not found")
	ErrParseConfig         = errors.New("failed to parse config file")
	ErrLoadDefaults        = errors.New("failed to load base defaults")
	ErrLoadEnv             = errors.New("failed to load environment overrides")
	ErrUnmarshalConfig     = errors.New("failed to unmarshal configuration")
	ErrAccessConfig        = errors.New("failed to access config file")
	ErrInvalidDuration     = errors.New("invalid duration")
)

Sentinel configuration errors.

Functions

func DefaultConfigTemplate

func DefaultConfigTemplate() string

DefaultConfigTemplate returns a formatted TOML string containing every default option with descriptive comments.

func DefaultPath

func DefaultPath() string

DefaultPath returns the default path to the user's config file.

func EnsureConfigFile

func EnsureConfigFile(path string) (bool, error)

EnsureConfigFile ensures that a configuration file exists at path. If path is empty, DefaultPath() is used. If the file already exists, it returns created=false, nil. If the file does not exist, it creates the parent directories and writes DefaultConfigTemplate() with 0o644 permissions, returning created=true, nil.

func NormalizeSort

func NormalizeSort(s string) (string, error)

NormalizeSort validates and normalizes sort key names.

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses duration strings including day suffixes (e.g. "7d", "24h", "10s").

func WriteConfigFile

func WriteConfigFile(path string) error

WriteConfigFile writes the default configuration template to path, creating parent directories if needed. It overwrites any existing file at path.

Types

type Config

type Config struct {
	UI        UIConfig        `json:"ui"        koanf:"ui"        toml:"ui"`
	Retention RetentionConfig `json:"retention" koanf:"retention" toml:"retention"`
	Filter    FilterConfig    `json:"filter"    koanf:"filter"    toml:"filter"`
	Tracker   TrackerConfig   `json:"tracker"   koanf:"tracker"   toml:"tracker"`
	Detection DetectionConfig `json:"detection" koanf:"detection" toml:"detection"`
}

func Load

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

Load loads, parses, and validates the configuration file from path. If path is empty, DefaultPath() is used. A missing default config file is silently skipped; a missing explicitly specified path is an error.

func (Config) Validate

func (c Config) Validate() error

Validate checks configuration invariants.

type DetectionConfig

type DetectionConfig struct {
	ManifestsDir     string `json:"manifests_dir,omitempty"     koanf:"manifests_dir"     toml:"manifests_dir"`
	ScreenInspection *bool  `json:"screen_inspection,omitempty" koanf:"screen_inspection" toml:"screen_inspection"`
}

DetectionConfig controls agent and screen inspection defaults.

type FilterConfig

type FilterConfig struct {
	IgnoreHarnesses []string `json:"ignore_harnesses,omitempty" koanf:"ignore_harnesses" toml:"ignore_harnesses"`
	IgnorePaths     []string `json:"ignore_paths,omitempty"     koanf:"ignore_paths"     toml:"ignore_paths"`
}

FilterConfig controls default session visibility exclusions.

type RetentionConfig

type RetentionConfig struct {
	AutoClean  *bool  `json:"auto_clean,omitempty"   koanf:"auto_clean"   toml:"auto_clean"`
	MaxGoneAge string `json:"max_gone_age,omitempty" koanf:"max_gone_age" toml:"max_gone_age"`
}

RetentionConfig controls state retention and tombstone cleanup defaults.

type TrackerConfig

type TrackerConfig struct {
	Interval    string `json:"interval,omitempty"     koanf:"interval"     toml:"interval"`
	GracePeriod string `json:"grace_period,omitempty" koanf:"grace_period" toml:"grace_period"`
	Quiet       *bool  `json:"quiet,omitempty"        koanf:"quiet"        toml:"quiet"`
}

TrackerConfig controls background observer behavior.

type UIConfig

type UIConfig struct {
	DefaultPresence string `json:"default_presence,omitempty" koanf:"default_presence" toml:"default_presence"`
	Sort            string `json:"sort,omitempty"             koanf:"sort"             toml:"sort"`
	SortDesc        *bool  `json:"sort_desc,omitempty"        koanf:"sort_desc"        toml:"sort_desc"`
	AbsoluteTime    *bool  `json:"absolute_time,omitempty"    koanf:"absolute_time"    toml:"absolute_time"`
	TimeFormat      string `json:"time_format,omitempty"      koanf:"time_format"      toml:"time_format"`
}

UIConfig controls terminal and table display defaults.

Jump to

Keyboard shortcuts

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