update

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: Unlicense Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultReleasesLatestURL = "https://api.github.com/repos/Barestack-io/vaultenv/releases/latest"

DefaultReleasesLatestURL is the GitHub API URL for the latest release.

View Source
const PeriodicCheckInterval = 24 * time.Hour

PeriodicCheckInterval is the minimum time between background update checks.

Variables

This section is empty.

Functions

func CanonicalVersion

func CanonicalVersion(s string) (string, bool)

CanonicalVersion returns semver canonical form with v prefix, or false if not a valid release version.

func DefaultHTTPClient

func DefaultHTTPClient() *http.Client

DefaultHTTPClient returns an HTTP client with timeouts suitable for update checks.

func ExpectedAssetName

func ExpectedAssetName(goos, goarch string) (string, error)

ExpectedAssetName returns the release filename for goos/goarch (same as install.sh).

func IsUpToDate

func IsUpToDate(currentVersion, releaseTag string) bool

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

func ResolveExecutablePath() (string, error)

ResolveExecutablePath returns the absolute path to the current binary (symlinks resolved).

func RunPeriodicVersionCheck

func RunPeriodicVersionCheck(ctx context.Context, currentVersion string, w io.Writer)

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.

func FetchLatest

func FetchLatest(ctx context.Context, client *http.Client, releasesLatestURL string) (*Latest, error)

FetchLatest returns the latest release tag and download URL for this OS/arch.

func LatestFromReleaseJSON

func LatestFromReleaseJSON(data []byte, goos, goarch string) (*Latest, error)

LatestFromReleaseJSON parses a GitHub release API payload and finds the asset for goos/goarch.

Jump to

Keyboard shortcuts

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