Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultConfigTemplate() string
- func DefaultPath() string
- func EnsureConfigFile(path string) (bool, error)
- func NormalizeSort(s string) (string, error)
- func ParseDuration(s string) (time.Duration, error)
- func WriteConfigFile(path string) error
- type Config
- type DetectionConfig
- type FilterConfig
- type Options
- type RetentionConfig
- type TrackerConfig
- type UIConfig
Constants ¶
const (
// ConfigEnv is the environment variable for overriding the config file path.
ConfigEnv = "AHT_CONFIG"
)
Variables ¶
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 ¶
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 0o600 permissions, returning created=true, nil. Publication is atomic and never overwrites a file created by another process.
func NormalizeSort ¶
NormalizeSort validates and normalizes sort key names.
func ParseDuration ¶
ParseDuration parses duration strings including day suffixes (e.g. "7d", "24h", "10s").
func WriteConfigFile ¶
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" toml:"ui"`
Retention RetentionConfig `json:"retention" toml:"retention"`
Filter FilterConfig `json:"filter" toml:"filter"`
Tracker TrackerConfig `json:"tracker" toml:"tracker"`
Detection DetectionConfig `json:"detection" toml:"detection"`
}
func Defaults ¶ added in v1.4.0
func Defaults() Config
Defaults returns a complete typed configuration with all base defaults populated.
func Load ¶
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 LoadWithOptions ¶ added in v1.4.0
LoadWithOptions resolves configuration across all tiers per the given options.
type DetectionConfig ¶
type DetectionConfig struct {
ManifestsDir string `json:"manifests_dir,omitempty" toml:"manifests_dir"`
ScreenInspection *bool `json:"screen_inspection,omitempty" toml:"screen_inspection"`
}
DetectionConfig controls agent and screen inspection defaults.
type FilterConfig ¶
type FilterConfig struct {
IgnoreHarnesses []string `json:"ignore_harnesses,omitempty" toml:"ignore_harnesses"`
IgnorePaths []string `json:"ignore_paths,omitempty" toml:"ignore_paths"`
}
FilterConfig controls default session visibility exclusions.
type Options ¶ added in v1.4.0
type Options struct {
Path string
Explicit bool
NoConfig bool
Stdin io.Reader
CWD string
UserConfigDir string
SystemDirs []string
}
Options controls layered configuration resolution.
type RetentionConfig ¶
type RetentionConfig struct {
AutoClean *bool `json:"auto_clean,omitempty" toml:"auto_clean"`
MaxGoneAge string `json:"max_gone_age,omitempty" toml:"max_gone_age"`
}
RetentionConfig controls state retention and tombstone cleanup defaults.
type TrackerConfig ¶
type TrackerConfig struct {
Interval string `json:"interval,omitempty" toml:"interval"`
GracePeriod string `json:"grace_period,omitempty" toml:"grace_period"`
Quiet *bool `json:"quiet,omitempty" toml:"quiet"`
}
TrackerConfig controls background observer behavior.
type UIConfig ¶
type UIConfig struct {
DefaultPresence string `json:"default_presence,omitempty" toml:"default_presence"`
Sort string `json:"sort,omitempty" toml:"sort"`
SortDesc *bool `json:"sort_desc,omitempty" toml:"sort_desc"`
AbsoluteTime *bool `json:"absolute_time,omitempty" toml:"absolute_time"`
TimeFormat string `json:"time_format,omitempty" toml:"time_format"`
}
UIConfig controls terminal and table display defaults.