Documentation
¶
Index ¶
- Constants
- Variables
- func AddPackage(path, host, name, version string) error
- func AddRepo(path string, repo Repo) error
- func CurrentHost() string
- func FindGaleConfig(dir string) (string, error)
- func FindToolVersions(dir string) string
- func HostKeyMatches(sectionKey, host string) bool
- func HostSectionExists(path, host string) bool
- func ParseToolVersions(data string) (map[string]string, error)
- func PinPackage(path, host, name string) error
- func RemovePackage(path, host, name string) error
- func RemoveRepo(path string, name string) error
- func ResolveParallelism(cfg *AppConfig) int
- func UnpinPackage(path, host, name string) error
- func UpsertPackage(path, host, name, version string) error
- func WriteAppConfig(path string, cfg *AppConfig) error
- func WriteGaleConfig(path string, cfg *GaleConfig) error
- type AIConfig
- type AppConfig
- type BuildConfig
- type GaleConfig
- type GenerationConfig
- type HostConfig
- type RegistryConfig
- type Repo
- type SyncConfig
Constants ¶
const DefaultGenerationKeep = 10
DefaultGenerationKeep is the number of generations preserved when config.toml has no [generation] section. Sized to cover a typical week of installs while keeping inode usage bounded: at ~28K inodes per gen, 10 gens ≈ 280K inodes total, two orders of magnitude under typical ext4 default budgets.
const DefaultParallelism = 8
DefaultParallelism is the fallback download parallelism when nothing is configured via GALE_JOBS or sync parallelism.
Variables ¶
var ErrGaleConfigNotFound = errors.New(
"gale.toml not found",
)
ErrGaleConfigNotFound is returned when gale.toml cannot be found in the directory tree.
var ErrPackageNotFound = errors.New("package not found")
ErrPackageNotFound is returned when a package to remove does not exist in the config.
var ErrRepoNotFound = errors.New("repo not found")
ErrRepoNotFound is returned when a repo to remove does not exist in the config.
Functions ¶
func AddPackage ¶
AddPackage adds or updates a package in the gale.toml at path. When host is empty, the package is written to the shared [packages] section. When non-empty, it is written under [hosts.<host>.packages]. If the file does not exist, it is bootstrapped.
func AddRepo ¶ added in v0.9.0
AddRepo adds a repository to the config.toml at path. Creates the file if it does not exist.
func CurrentHost ¶ added in v0.16.0
func CurrentHost() string
CurrentHost returns the active host identifier. Reads $GALE_HOST first; falls back to os.Hostname(). Returns "" if both fail.
func FindGaleConfig ¶
FindGaleConfig walks up from dir to find gale.toml. Returns the path to the found file.
func FindToolVersions ¶ added in v0.4.0
FindToolVersions walks up from dir looking for a .tool-versions file. Returns the path if found, empty string if not.
func HostKeyMatches ¶ added in v0.16.3
HostKeyMatches reports whether sectionKey applies to the given host. The key is a comma-separated list of glob patterns; any matching pattern returns true.
func HostSectionExists ¶ added in v0.17.0
HostSectionExists reports whether the gale.toml at path already contains a [hosts.<key>] section that applies to host. A key applies when it equals host literally (covers comma-list keys, which HostKeyMatches splits and never compares whole) or when HostKeyMatches in either direction: an exact key, a glob key covering host, or a glob host value covering an exact key all count. Legacy unquoted dotted headers ([hosts.travis-mb.local.packages], pre-#59) parse as nested tables and never reach the typed Hosts map, but the section exists on disk and the mutators normalize and reuse it, so they count too. Errors (unreadable or unparseable file) report true so callers stay quiet and let the subsequent write surface the real problem.
func ParseToolVersions ¶ added in v0.4.0
ParseToolVersions parses a .tool-versions file into a package map. Each line is "<name> <version> [version...]". Comments start with #. When multiple versions are listed, only the first is used. Names are mapped to gale recipe names where known (e.g., "golang" → "go").
func PinPackage ¶ added in v0.6.0
PinPackage marks a package as pinned in the gale.toml at path. When host is empty, the pin is recorded in shared [pinned] and the package must exist in shared [packages]. Otherwise the pin is recorded under [hosts.<host>.pinned] and the package must exist in that host's package list. Returns ErrPackageNotFound when the package is not in the targeted section.
TODO(0012-0014): PinPackage uses struct round-trip (WriteGaleConfig) which strips comments and drops unknown sections. Convert to text-based edit when setTOMLBoolKey is added.
func RemovePackage ¶
RemovePackage removes a package from the gale.toml at path. When host is empty, removes from shared [packages]; otherwise from [hosts.<host>.packages]. Returns ErrPackageNotFound if the package is not present in the targeted section.
func RemoveRepo ¶ added in v0.9.0
RemoveRepo removes a repository by name from config.toml.
func ResolveParallelism ¶ added in v0.16.4
ResolveParallelism returns the effective download parallelism. Precedence: GALE_JOBS env var, then sync parallelism, then DefaultParallelism. The result is always >= 1.
func UnpinPackage ¶ added in v0.6.0
UnpinPackage removes a pin from the gale.toml at path. When host is empty, removes from shared [pinned]; otherwise from [hosts.<host>.pinned]. Missing pins are a no-op.
TODO(0012-0014): UnpinPackage uses struct round-trip (WriteGaleConfig) which strips comments and drops unknown sections. Convert to text-based edit when setTOMLBoolKey is added.
func UpsertPackage ¶ added in v0.16.0
UpsertPackage updates a package in gale.toml, preserving its existing location. If the package is present in the current host's section, it is updated there; otherwise it is written to the shared [packages] section. Used by install/update flows that should not move a host-scoped package to the shared section. host may be empty (no preservation; equivalent to AddPackage(path, "", ...)).
func WriteAppConfig ¶ added in v0.9.0
WriteAppConfig writes an AppConfig to the given path atomically.
func WriteGaleConfig ¶
func WriteGaleConfig(path string, cfg *GaleConfig) error
WriteGaleConfig writes a GaleConfig to the given path atomically.
Types ¶
type AppConfig ¶
type AppConfig struct {
Repos []Repo `toml:"repos"`
Build BuildConfig `toml:"build"`
Anthropic AIConfig `toml:"anthropic"`
Registry RegistryConfig `toml:"registry"`
Generation GenerationConfig `toml:"generation"`
Sync SyncConfig `toml:"sync"`
}
AppConfig represents ~/.gale/config.toml (app-level settings).
func ParseAppConfig ¶
ParseAppConfig parses a config.toml string.
type BuildConfig ¶ added in v0.7.0
type BuildConfig struct {
Debug bool `toml:"debug,omitempty"`
}
BuildConfig holds build-related settings.
type GaleConfig ¶
type GaleConfig struct {
Packages map[string]string `toml:"packages"`
Vars map[string]string `toml:"vars,omitempty"`
Pinned map[string]bool `toml:"pinned,omitempty"`
Hosts map[string]HostConfig `toml:"hosts,omitempty"`
}
GaleConfig represents a gale.toml file (global or project).
func ParseGaleConfig ¶
func ParseGaleConfig(data string) (*GaleConfig, error)
ParseGaleConfig parses a gale.toml string.
func (*GaleConfig) ApplyHost ¶ added in v0.16.0
func (c *GaleConfig) ApplyHost(host string)
ApplyHost replaces Packages and Pinned with the effective merged maps for the given host. Mutates the receiver. Callers that need the raw on-disk view (e.g. mutators) must not call this.
func (*GaleConfig) EffectivePackages ¶ added in v0.16.0
func (c *GaleConfig) EffectivePackages(host string) map[string]string
EffectivePackages returns the shared [packages] merged with every [hosts.<key>.packages] section whose key matches host. Host section keys may list multiple comma-separated patterns and use glob wildcards (*, ?). Wildcard-bearing sections are applied first; exact-name sections last, so exact entries override globs. Does not mutate the receiver.
func (*GaleConfig) EffectivePinned ¶ added in v0.16.0
func (c *GaleConfig) EffectivePinned(host string) map[string]bool
EffectivePinned merges shared [pinned] with every matching [hosts.<key>.pinned] overlay, using the same multi-pattern matching and override order as EffectivePackages. Does not mutate the receiver.
type GenerationConfig ¶ added in v0.16.3
type GenerationConfig struct {
Keep int `toml:"keep,omitempty"`
}
GenerationConfig holds gen-retention settings. Keep is the number of recent generations (including the current one) preserved after each rebuild's auto-gc pass. Default 10 when unset or non-positive; set to a negative value to disable auto-gc entirely.
func (GenerationConfig) EffectiveGenerationKeep ¶ added in v0.16.3
func (g GenerationConfig) EffectiveGenerationKeep() int
EffectiveGenerationKeep returns the configured Keep value when positive, otherwise DefaultGenerationKeep. A negative value (the "disabled" sentinel) is returned as-is so the caller can short-circuit auto-gc.
type HostConfig ¶ added in v0.16.0
type HostConfig struct {
Packages map[string]string `toml:"packages,omitempty"`
Pinned map[string]bool `toml:"pinned,omitempty"`
}
HostConfig represents a per-host packages/pinned overlay stored under [hosts.<name>] in gale.toml.
type RegistryConfig ¶
type RegistryConfig struct {
URL string `toml:"url"`
}
RegistryConfig holds registry settings.
type Repo ¶
type Repo struct {
Name string `toml:"name"`
URL string `toml:"url"`
Priority int `toml:"priority"`
}
Repo represents a recipe repository entry in config.toml.
type SyncConfig ¶ added in v0.16.4
type SyncConfig struct {
Parallelism int `toml:"parallelism,omitempty"`
}
SyncConfig controls sync/download behavior. Parallelism is the number of concurrent downloads; default DefaultParallelism when unset or non-positive.