config

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyDefaults

func ApplyDefaults(cfg *Config, paths *Paths) error

ApplyDefaults fills zero-valued fields with defaults and resolves the database path against paths when it is unset.

func ApplyEnv

func ApplyEnv(cfg *Config, getenv func(string) string) error

ApplyEnv overrides cfg fields from environment variables. The getter may be os.Getenv or an injected map for tests.

func Save

func Save(path string, cfg *Config) error

Save writes cfg to path atomically with 0600 permissions.

func Validate

func Validate(cfg *Config) error

Validate checks that cfg is well-formed.

Types

type Config

type Config struct {
	Database    string      `toml:"database,omitempty"`
	TokenSource TokenSource `toml:"token_source,omitempty"`
	Crawl       Crawl       `toml:"crawl,omitempty"`
}

Config is the typed TOML application configuration. It never stores raw GitHub tokens; only a token source descriptor.

func Default

func Default() *Config

Default returns a Config populated with built-in defaults. Database and paths are left empty so that ApplyDefaults can resolve them against Paths.

func Load

func Load(r io.Reader) (*Config, error)

Load reads TOML from r and decodes it into a Config. Unknown fields are rejected.

func LoadFile

func LoadFile(path string) (*Config, error)

LoadFile reads and decodes the TOML file at path.

type Crawl

type Crawl struct {
	Budget      int    `toml:"budget"`
	Concurrency int    `toml:"concurrency"`
	RetryLimit  int    `toml:"retry_limit"`
	Timeout     string `toml:"timeout,omitempty"`
}

Crawl holds crawl budgets and concurrency limits.

type Env

type Env struct {
	Home string
	Vars map[string]string
}

Env provides an injectable environment for tests. A nil Env uses the real process environment and home directory.

type Paths

type Paths struct {
	OS   string
	Name string
	Env  *Env
}

Paths resolves platform-native application directories.

func NewPaths

func NewPaths(env *Env) *Paths

NewPaths returns a Paths resolver for the current platform using env for environment injection. If env is nil, the real process environment is used.

func (*Paths) AcquisitionCacheDir

func (p *Paths) AcquisitionCacheDir() (string, error)

AcquisitionCacheDir returns the managed code-acquisition cache directory.

func (*Paths) CacheDir

func (p *Paths) CacheDir() (string, error)

CacheDir returns the platform-native cache directory for the app.

func (*Paths) ConfigDir

func (p *Paths) ConfigDir() (string, error)

ConfigDir returns the platform-native configuration directory for the app.

func (*Paths) ConfigFile

func (p *Paths) ConfigFile() (string, error)

ConfigFile returns the full path to the configuration file.

func (*Paths) DataDir

func (p *Paths) DataDir() (string, error)

DataDir returns the platform-native data directory for the app.

func (*Paths) DatabasePath

func (p *Paths) DatabasePath() (string, error)

DatabasePath returns the default database path inside DataDir.

func (*Paths) HomeDir

func (p *Paths) HomeDir() string

HomeDir returns the configured user home used for coding-client discovery. It honors the injected environment used by tests.

func (*Paths) LogDir

func (p *Paths) LogDir() (string, error)

LogDir returns the platform-native log directory for the app.

func (*Paths) StateDir

func (p *Paths) StateDir() (string, error)

StateDir returns the platform-native state directory for the app.

type TokenSource

type TokenSource struct {
	Method string `toml:"method"`
	Key    string `toml:"key,omitempty"`
}

TokenSource describes how to obtain a GitHub token. The token itself is never persisted here.

Jump to

Keyboard shortcuts

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