Documentation
¶
Overview ¶
Package update provides self-update functionality for cern-sso-cli.
Index ¶
- Constants
- func CompareVersions(current, latest string) int
- func DownloadBinary(url string, progress func(downloaded, total int64)) ([]byte, error)
- func FetchChecksums(url string) (map[string]string, error)
- func GetAssetForCurrentPlatform(release *ReleaseInfo) (binaryURL, checksumURL string, err error)
- func GetExecutablePath() (string, error)
- func IsHomebrewInstall() bool
- func ReplaceBinary(newBinary []byte) error
- func VerifyChecksum(data []byte, expectedChecksum string) error
- type ReleaseAsset
- type ReleaseInfo
Constants ¶
const ( // GitHubRepo is the repository path for releases. GitHubRepo = "clelange/cern-sso-cli" // GitHubAPIURL is the base URL for GitHub API. GitHubAPIURL = "https://api.github.com" )
Variables ¶
This section is empty.
Functions ¶
func CompareVersions ¶
CompareVersions compares two version strings. Returns: -1 if current < latest, 0 if equal, 1 if current > latest. Handles "dev" as always older than any release version.
func DownloadBinary ¶
DownloadBinary downloads the binary from the given URL.
func FetchChecksums ¶
FetchChecksums downloads and parses the checksums file.
func GetAssetForCurrentPlatform ¶
func GetAssetForCurrentPlatform(release *ReleaseInfo) (binaryURL, checksumURL string, err error)
GetAssetForCurrentPlatform returns the download URL for the appropriate binary.
func GetExecutablePath ¶
GetExecutablePath returns the resolved path to the current executable.
func IsHomebrewInstall ¶
func IsHomebrewInstall() bool
IsHomebrewInstall checks if the binary appears to be installed via Homebrew.
func ReplaceBinary ¶
ReplaceBinary atomically replaces the current executable with new binary data.
func VerifyChecksum ¶
VerifyChecksum verifies the SHA256 checksum of the binary.
Types ¶
type ReleaseAsset ¶
type ReleaseAsset struct {
Name string `json:"name"`
BrowserDownloadURL string `json:"browser_download_url"`
}
ReleaseAsset represents a downloadable asset from a GitHub release.
type ReleaseInfo ¶
type ReleaseInfo struct {
TagName string `json:"tag_name"`
Assets []ReleaseAsset `json:"assets"`
}
ReleaseInfo contains information about a GitHub release.
func CheckForUpdate ¶
func CheckForUpdate() (*ReleaseInfo, error)
CheckForUpdate queries GitHub for the latest release.