Documentation
¶
Index ¶
Constants ¶
const UpgradeURL = "https://alloyproject.org/docs/upgrade/"
UpgradeURL is the stable documentation URL shown in update notifications. This URL must not change across releases — the CLI hardcodes it.
Variables ¶
This section is empty.
Functions ¶
func CacheDir ¶
func CacheDir() string
CacheDir returns the alloy config directory path, respecting XDG_CONFIG_HOME. Falls back to ~/.config/alloy.
func CheckLatestVersion ¶
CheckLatestVersion queries the GitHub Releases API for the latest release tag. Returns the tag name (e.g., "v0.5.0") or an error. Uses a 10-second HTTP timeout. Unauthenticated.
func CheckLatestVersionFrom ¶
CheckLatestVersionFrom queries the given base URL (which must serve the GitHub Releases API format) for the latest release tag. Tests use this with httptest servers; production calls CheckLatestVersion.
func IsNewer ¶
IsNewer returns true if latest is a higher semantic version than current. Both strings may have a leading "v" prefix (stripped before comparison). Returns false if either string is not valid semver.
func SaveCache ¶
func SaveCache(result CacheResult) error
SaveCache writes the check result to the XDG config directory. Creates the directory if needed. Uses write-then-rename for atomicity so concurrent goroutines cannot corrupt the file.
func ShouldCheck ¶
func ShouldCheck(cached CacheResult) bool
ShouldCheck returns true if the cache is missing, expired (>24h), or has an empty LatestVersion.
Types ¶
type CacheResult ¶
type CacheResult struct {
LatestVersion string `json:"latestVersion"`
CheckedAt time.Time `json:"checkedAt"`
}
CacheResult represents a cached version check result.
func LoadCache ¶
func LoadCache() (CacheResult, error)
LoadCache reads the cached check result from the XDG config directory. Returns zero CacheResult and nil error if the file doesn't exist or is corrupt. Returns error only for unexpected I/O failures.