Documentation
¶
Index ¶
- Constants
- func CanonicalVersion(s string) (string, bool)
- func DefaultHTTPClient() *http.Client
- func ExpectedAssetName(goos, goarch string) (string, error)
- func IsUpToDate(currentVersion, releaseTag string) bool
- func PeriodicCheckStatePath() string
- func ReplaceExecutable(ctx context.Context, client *http.Client, targetPath, downloadURL string) error
- func ResolveExecutablePath() (string, error)
- func RunPeriodicVersionCheck(ctx context.Context, currentVersion string, w io.Writer)
- type Latest
Constants ¶
const DefaultReleasesLatestURL = "https://api.github.com/repos/Barestack-io/vaultenv/releases/latest"
DefaultReleasesLatestURL is the GitHub API URL for the latest release.
const PeriodicCheckInterval = 24 * time.Hour
PeriodicCheckInterval is the minimum time between background update checks.
Variables ¶
This section is empty.
Functions ¶
func CanonicalVersion ¶
CanonicalVersion returns semver canonical form with v prefix, or false if not a valid release version.
func DefaultHTTPClient ¶
DefaultHTTPClient returns an HTTP client with timeouts suitable for update checks.
func ExpectedAssetName ¶
ExpectedAssetName returns the release filename for goos/goarch (same as install.sh).
func IsUpToDate ¶
IsUpToDate reports whether currentVersion is the same or newer than releaseTag (both semver). If currentVersion is not valid semver (e.g. dev), returns false so callers may still offer an update.
func PeriodicCheckStatePath ¶
func PeriodicCheckStatePath() string
PeriodicCheckStatePath returns the path to the JSON file recording the last check time.
func ReplaceExecutable ¶
func ReplaceExecutable(ctx context.Context, client *http.Client, targetPath, downloadURL string) error
ReplaceExecutable downloads the release binary and replaces targetPath.
func ResolveExecutablePath ¶
ResolveExecutablePath returns the absolute path to the current binary (symlinks resolved).
func RunPeriodicVersionCheck ¶
RunPeriodicVersionCheck contacts GitHub at most once per PeriodicCheckInterval, and writes a notice to w when a newer semver release exists than currentVersion. Failures are silent. Always updates the last-check timestamp after a fetch attempt (success or failure) so offline runs do not retry every invocation.
Types ¶
type Latest ¶
type Latest struct {
Tag string // e.g. v0.2.0
AssetURL string
Asset string // e.g. vaultenv-darwin-arm64
}
Latest describes the newest published release asset for this platform.