Documentation
¶
Index ¶
- Variables
- func FetchChangelog(currentVersion, latestVersion string) (string, error)
- func FetchLatestPrerelease() (string, error)
- func FetchLatestVersion() (string, error)
- func FollowsBetas(currentVersion string) bool
- func ForgetCachedLatest()
- func IsPrerelease(v string) bool
- func LatestFor(currentVersion string) (string, error)
- func StripGitDescribe(v string) string
- func StripV(v string) string
- func SummarizeChangelog(sections string) string
- func ValidTag(tag string) bool
- func VersionGreaterThan(a, b string) bool
- func WriteUpdateCache(version string)
- type GithubReleaseForTest
- type UpdateInfo
Constants ¶
This section is empty.
Variables ¶
var APIBaseURLs = origin.ReleaseAPIBaseURLs
APIBaseURLs returns the GitHub API bases in priority order. Overridable in tests.
var BetaChannel = func() bool { cfg, err := config.LoadGlobal() if err != nil { return false } return cfg.IsBetaChannel() }
BetaChannel reports whether this install asked to be offered prereleases from a stable version. Overridable in tests.
var ReleaseBaseURLs = origin.ReleaseBaseURLs
ReleaseBaseURLs returns the GitHub releases bases in priority order, read live so a NoteFetched flip reorders them. Overridable in tests.
Functions ¶
func FetchChangelog ¶ added in v0.9.0
FetchChangelog downloads docs/changelog.md from GitHub at the latestVersion tag and returns the sections for versions strictly greater than currentVersion and <= latestVersion. Returns an empty string and a non-nil error when the fetch fails.
func FetchLatestPrerelease ¶ added in v1.5.0
FetchLatestPrerelease returns the latest pre-release tag from GitHub. Unlike FetchLatestVersion, this calls the GitHub API because the /releases/latest redirect only returns stable releases.
func FetchLatestVersion ¶
FetchLatestVersion returns the latest published release tag, trying each release base in order until one answers.
func FollowsBetas ¶ added in v1.35.0
FollowsBetas reports whether currentVersion should be offered prereleases: either it is one already, or the user opted the install into the beta line.
func ForgetCachedLatest ¶ added in v1.36.0
func ForgetCachedLatest()
ForgetCachedLatest drops the cached latest release, which belongs to the update line the install followed when it was written. Switching lines calls it so the next check asks again instead of answering for the old line.
func IsPrerelease ¶ added in v1.20.0
IsPrerelease reports whether v carries a semver prerelease suffix (any "-" trailer). The input should be StripV-cleaned; git-describe artifacts like "1.20.0-3-gabc1234" must be StripGitDescribe'd first to avoid false positives.
func LatestFor ¶ added in v1.35.0
LatestFor returns the release tag a user on currentVersion should be offered. A stable install only ever sees stable releases unless it opted into betas. An install already on a beta keeps following the beta line, so the second beta of a cycle arrives the same way the first one did instead of waiting for the user to remember --beta; a stable release outranks the betas it supersedes, which is what ends the run. A prerelease lookup that fails falls back to the stable answer rather than costing the user an update that would have worked.
func StripGitDescribe ¶ added in v1.14.0
StripGitDescribe removes git-describe suffixes like "-dirty" or "-5-gabcdef" while preserving semver pre-release tags like "-beta.1" or "-rc.1". Git-describe suffixes contain a commit hash segment starting with "g".
func SummarizeChangelog ¶ added in v1.34.0
SummarizeChangelog condenses full changelog sections into a short list of entry headlines with their issue numbers, keeping the version and section headers. Long prose paragraphs are dropped.
func ValidTag ¶ added in v1.32.0
ValidTag reports whether tag is safe to interpolate into a download URL and an archive path.
func VersionGreaterThan ¶ added in v1.0.0
VersionGreaterThan returns true if a > b, comparing "X.Y.Z[-pre]" version strings (without a leading "v") component-by-component as integers. Pre-release suffixes (e.g. "-beta.1", "-rc.1") are handled per semver: a release without a pre-release suffix is greater than one with the same core version, and pre-release suffixes are compared lexicographically.
func WriteUpdateCache ¶ added in v0.9.1
func WriteUpdateCache(version string)
WriteUpdateCache records version as the known latest in the on-disk cache, resetting the 24-hour TTL. Call this after a successful update so that lerd status / doctor stop showing a stale "update available" notice.
Types ¶
type GithubReleaseForTest ¶ added in v1.5.0
type GithubReleaseForTest = githubRelease
GithubReleaseForTest is exported only so tests in other packages can build JSON fixtures. It is not part of the public API.
type UpdateInfo ¶ added in v0.9.0
type UpdateInfo struct {
LatestVersion string // e.g. "v0.8.5"
Changelog string // relevant CHANGELOG.md sections (trimmed markdown)
}
UpdateInfo holds the result of a successful update check when a newer version exists.
func CachedUpdateCheck ¶ added in v0.9.0
func CachedUpdateCheck(currentVersion string) (*UpdateInfo, error)
CachedUpdateCheck returns update info when a newer version is available. Returns nil, nil if already on the latest version, or if the check fails silently (no network, GitHub unreachable, etc.). Network fetches are rate-limited to once per 24 hours via a cache file at config.UpdateCheckFile().
func ForceUpdateCheck ¶ added in v1.28.0
func ForceUpdateCheck(currentVersion string) (*UpdateInfo, error)
ForceUpdateCheck queries GitHub for the latest release right away, ignoring the 24-hour cache, and refreshes the cache with the result. Use it when the user explicitly asks to check for updates and expects a live answer. Returns nil, nil when already current or when the network fetch fails silently.