Documentation
¶
Index ¶
- Constants
- func ApplyUpdate(binaryData []byte, targetPath string) error
- func CompareVersions(v1, v2 string) int
- func ExtractBinary(archiveData []byte, assetName string) ([]byte, error)
- func GetCurrentExecutablePath() (string, error)
- func VerifyChecksum(data []byte, assetName string, checksumsData []byte) error
- type Asset
- type Options
- type Release
- type Semver
- type UpdateResult
- type Updater
Constants ¶
const ( DefaultGitHubRepo = "ErKatta/zbxctl" DefaultTimeout = 30 * time.Second SkillReminderMsg = "To update AI agent skills to match the new version, run:\n zbxctl skill install --all" )
Variables ¶
This section is empty.
Functions ¶
func ApplyUpdate ¶
ApplyUpdate writes the binary atomically in place of the target executable path.
func CompareVersions ¶
CompareVersions compares two version strings. Returns: -1 if v1 < v2
0 if v1 == v2 1 if v1 > v2
func ExtractBinary ¶
ExtractBinary extracts the zbxctl binary from a tar.gz or zip archive.
func GetCurrentExecutablePath ¶
GetCurrentExecutablePath determines the absolute, symlink-resolved path of the running executable.
Types ¶
type Asset ¶
type Asset struct {
Name string `json:"name"`
Size int64 `json:"size"`
BrowserDownloadURL string `json:"browser_download_url"`
ContentType string `json:"content_type"`
}
Asset represents an attached asset to a GitHub release.
func FindChecksumAsset ¶
FindChecksumAsset returns the checksums file asset if available in the release.
type Options ¶
type Options struct {
CurrentVersion string
TargetVersion string // specific release tag (e.g. "v0.2.0") or empty for latest
Repo string // GitHub repository (e.g. "ErKatta/zbxctl")
TargetExecutable string // Target executable path (defaults to current binary)
CheckOnly bool // Only check if update is available without downloading/installing
Force bool // Force update even if already on latest version
BaseAPIURL string // Base GitHub API URL (defaults to https://api.github.com)
HTTPClient *http.Client
Writer io.Writer
}
Options configures the update operation.
type Release ¶
type Release struct {
TagName string `json:"tag_name"`
Name string `json:"name"`
Draft bool `json:"draft"`
Prerelease bool `json:"prerelease"`
PublishedAt time.Time `json:"published_at"`
HTMLURL string `json:"html_url"`
Body string `json:"body"`
Assets []Asset `json:"assets"`
}
Release represents a GitHub release.
type Semver ¶
Semver represents parsed semantic version components.
func ParseSemver ¶
ParseSemver parses a version string into Semver components.
type UpdateResult ¶
type UpdateResult struct {
CurrentVersion string `json:"current_version"`
LatestVersion string `json:"latest_version"`
UpdateAvailable bool `json:"update_available"`
Updated bool `json:"updated"`
BinaryPath string `json:"binary_path,omitempty"`
ReleaseURL string `json:"release_url,omitempty"`
Message string `json:"message"`
SkillReminder string `json:"skill_reminder,omitempty"`
}
UpdateResult represents the output metadata of an update check or execution.
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
Updater handles checking and applying updates.
func NewUpdater ¶
NewUpdater returns a new Updater configured with the given options.
func (*Updater) DownloadAsset ¶
DownloadAsset downloads the bytes of the given asset.
func (*Updater) FetchRelease ¶
FetchRelease retrieves the release metadata from GitHub.