Documentation
¶
Overview ¶
Package config resolves Taskronin's configuration and filesystem paths.
Index ¶
- Constants
- func CheckSocketPath(p string) error
- func OtherHumanAccounts(passwdPath string, myUID int) ([]string, error)
- func ScrubJournal(backupDir string) string
- func ValidateClient(c *Client) error
- func ValidateServer(s *Server) error
- func WriteClient(path string, c *Client) error
- func WriteServer(path string, s *Server) error
- type BackupConfig
- type Client
- type ClientOverrides
- type LogConfig
- type Paths
- type Server
- type ServerPaths
- type TokenFileError
- type WebConfig
Constants ¶
const MaxSocketPath = 107
MaxSocketPath leaves one byte for the NUL in Linux's 108-byte sun_path.
Variables ¶
This section is empty.
Functions ¶
func CheckSocketPath ¶
CheckSocketPath checks the encoded byte length, not the number of runes.
func OtherHumanAccounts ¶
OtherHumanAccounts lists other accounts with UID >= 1000 and a login shell. An unreadable or malformed passwd file must not imply a single-user host.
func ScrubJournal ¶
ScrubJournal is the scrub recovery journal within the effective backup dir.
func ValidateClient ¶
ValidateClient checks client paths, time budgets and terminal color mode.
func ValidateServer ¶
ValidateServer checks configuration values. Listener consent is checked separately by WebListenerAllowed when a build starts the web listener.
func WriteClient ¶
WriteClient atomically writes client.toml with mode 0600 and string durations. The parent directory must already exist.
func WriteServer ¶
WriteServer atomically writes server.toml with mode 0600. The parent directory must already exist; init is responsible for creating private directories.
Types ¶
type BackupConfig ¶
BackupConfig gives the backup directory and daily time in the server zone.
type Client ¶
type Client struct {
Socket string `toml:"socket"`
TokenFile string `toml:"token_file"`
Timeout time.Duration `toml:"timeout"`
StatusTimeout time.Duration `toml:"status_timeout"`
Editor string `toml:"editor"`
Color string `toml:"color"`
MCP struct {
TokenFile string `toml:"token_file"`
} `toml:"mcp"`
}
Client is the client.toml schema. Missing keys keep DefaultClient values.
func DefaultClient ¶
DefaultClient supplies paths and time budgets for a missing client.toml.
func LoadClient ¶
LoadClient strictly decodes over defaults, or uses just those defaults if the file is missing. In either case the resulting configuration is validated.
func LoadClientWithOverrides ¶
func LoadClientWithOverrides(path string, p Paths, overrides ClientOverrides) (*Client, error)
LoadClientWithOverrides validates the effective configuration, allowing a caller to replace an unusable configured path without using that path first.
type ClientOverrides ¶
type ClientOverrides struct {
Socket, TokenFile, Color string
}
ClientOverrides contains CLI flags that replace decoded values before validation. Empty strings leave the configured value or default unchanged.
type Paths ¶
type Paths struct {
ConfigDir, DataDir, StateDir, RuntimeDir string
ServerConfig, ClientConfig, Socket, OwnerToken, TokensDir string
DraftsDir, PendingDir, StagingDir, BackupDir, LedgerFile, DB string
}
Paths contains the resolved locations of Taskronin's files and directories.
func DefaultPaths ¶
DefaultPaths resolves XDG paths without accessing the filesystem. Relative XDG values are ignored. An absolute home is required for any home fallback. Callers create and check private directories before using these paths.
func (Paths) SwapJournal ¶
SwapJournal is the recovery journal for a database swap.
func (Paths) WithServerPaths ¶
WithServerPaths returns paths rebased to the effective server configuration. All three arguments must be fully resolved, validated configuration values; empty arguments do not mean "keep the default".
type Server ¶
type Server struct {
Timezone string `toml:"timezone"`
WeekStart string `toml:"week_start"`
DueSoonDays int `toml:"due_soon_days"`
Paths ServerPaths `toml:"paths"`
Web WebConfig `toml:"web"`
Backup BackupConfig `toml:"backup"`
Log LogConfig `toml:"log"`
}
Server is the server.toml schema. Paths are resolved by init; loading a configuration does not create directories or change their permissions.
func DefaultServer ¶
DefaultServer builds init's defaults without granting plain HTTP consent.
func LoadServer ¶
LoadServer strictly decodes and validates an existing server configuration. Before using files, server/offline callers must rebase their Paths with p.WithServerPaths(s.Paths.DataDir, s.Paths.Socket, s.Backup.Dir) (BF01).
func (*Server) BackupMinute ¶
BackupMinute parses the daily backup time, excluding 24:00.
func (*Server) WebAddr ¶
WebAddr parses a numeric loopback address and port without resolving DNS. The one accepted hostname, localhost, always maps to IPv4 loopback.
func (*Server) WebListenerAllowed ¶
WebListenerAllowed requires explicit consent before serving plain HTTP.
func (*Server) WeekStartDay ¶
WeekStartDay returns the weekday selected by the lowercase configuration name.
type ServerPaths ¶
ServerPaths contains the effective server data directory and socket path.
type TokenFileError ¶
TokenFileError identifies token path failures during configuration validation, before the client can check the credential file itself.
func (*TokenFileError) Error ¶
func (e *TokenFileError) Error() string
func (*TokenFileError) Unwrap ¶
func (e *TokenFileError) Unwrap() error
Unwrap preserves the path validation failure.