Documentation
¶
Index ¶
- Constants
- func CleanupStaleBinary(targetPath string)
- func CompareSemver(left string, right string) (int, error)
- func Endpoint(repository string) string
- func Format(result Result) string
- func FormatApply(result ApplyResult) string
- func NormalizeVersionTag(version string) (string, error)
- func ResolveEndpoint(endpointOrRepository string, repository string) (string, error)
- type ApplyResult
- type Asset
- type AssetCheck
- type InstallMethod
- type Options
- type Release
- type Result
- type Target
Constants ¶
const ( DefaultRepository = "Gitlawb/zero" DefaultTimeout = 5 * time.Second )
const DefaultDownloadTimeout = 5 * time.Minute
DefaultDownloadTimeout bounds the archive/checksum download phase of a standalone Apply, separately from Options.Timeout (which only covers the small release-metadata check), so a stalled connection can't hang forever.
Variables ¶
This section is empty.
Functions ¶
func CleanupStaleBinary ¶ added in v0.2.0
func CleanupStaleBinary(targetPath string)
CleanupStaleBinary is a no-op outside Windows, which is the only platform that requires renaming a running binary aside instead of replacing it directly.
func CompareSemver ¶
CompareSemver compares two semver-ish release tags.
func FormatApply ¶ added in v0.2.0
func FormatApply(result ApplyResult) string
FormatApply renders an ApplyResult as human-readable text.
func NormalizeVersionTag ¶
NormalizeVersionTag returns a comparable x.y.z version from a release tag.
Types ¶
type ApplyResult ¶ added in v0.2.0
type ApplyResult struct {
Result
Applied bool `json:"applied"`
InstallMethod InstallMethod `json:"installMethod,omitempty"`
BinaryPath string `json:"binaryPath,omitempty"`
Message string `json:"message,omitempty"`
Warnings []string `json:"warnings,omitempty"`
}
ApplyResult reports the outcome of Apply.
func Apply ¶ added in v0.2.0
func Apply(ctx context.Context, options Options) (ApplyResult, error)
Apply checks for an update and, if one is available, installs it: via `npm install -g` for npm-managed installs, or by downloading, verifying, and atomically replacing the binary for standalone installs.
type AssetCheck ¶
type AssetCheck struct {
Platform string `json:"platform"`
Arch string `json:"arch"`
ArchiveName string `json:"archiveName"`
ArchiveURL string `json:"archiveUrl,omitempty"`
ChecksumName string `json:"checksumName"`
ChecksumURL string `json:"checksumUrl,omitempty"`
ArchiveFound bool `json:"archiveFound"`
ChecksumFound bool `json:"checksumFound"`
Verified bool `json:"verified"`
}
type InstallMethod ¶ added in v0.2.0
type InstallMethod string
InstallMethod identifies how the running zero binary was installed.
const ( InstallMethodNpm InstallMethod = "npm" InstallMethodStandalone InstallMethod = "standalone" )
func DetectInstallMethod ¶ added in v0.2.0
func DetectInstallMethod(executablePath string) InstallMethod
DetectInstallMethod inspects the directory containing executablePath for npm-install markers left by scripts/postinstall.mjs.
type Options ¶
type Options struct {
CurrentVersion string
// Endpoint accepts a full release API URL, an owner/repo slug, or a data:
// endpoint for deterministic tests.
Endpoint string
Repository string
Timeout time.Duration
GOOS string
GOARCH string
// Fetch overrides the release fetcher for tests and alternate transports.
Fetch func(context.Context, string) (Release, error)
}
Options configures a release update check.
type Result ¶
type Target ¶
type Target struct {
Name string `json:"name"`
GOOS string `json:"goos"`
GOARCH string `json:"goarch"`
Platform string `json:"platform"`
Arch string `json:"arch"`
}
Target identifies a supported release archive target.
func ResolveTarget ¶
ResolveTarget maps a release target name like windows-x64 to Go build coordinates and release asset naming fields.