update

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

func ApplyUpdate(binaryData []byte, targetPath string) error

ApplyUpdate writes the binary atomically in place of the target executable path.

func CompareVersions

func CompareVersions(v1, v2 string) int

CompareVersions compares two version strings. Returns: -1 if v1 < v2

0 if v1 == v2
1 if v1 > v2

func ExtractBinary

func ExtractBinary(archiveData []byte, assetName string) ([]byte, error)

ExtractBinary extracts the zbxctl binary from a tar.gz or zip archive.

func GetCurrentExecutablePath

func GetCurrentExecutablePath() (string, error)

GetCurrentExecutablePath determines the absolute, symlink-resolved path of the running executable.

func VerifyChecksum

func VerifyChecksum(data []byte, assetName string, checksumsData []byte) error

VerifyChecksum verifies the SHA256 checksum of data against the checksums file.

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

func FindChecksumAsset(assets []Asset) *Asset

FindChecksumAsset returns the checksums file asset if available in the release.

func FindMatchingAsset

func FindMatchingAsset(assets []Asset, goos, goarch string) (*Asset, error)

FindMatchingAsset finds the binary archive asset matching the target OS and architecture.

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

type Semver struct {
	Major      int
	Minor      int
	Patch      int
	Prerelease string
	Raw        string
}

Semver represents parsed semantic version components.

func ParseSemver

func ParseSemver(v string) Semver

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

func NewUpdater(opts Options) *Updater

NewUpdater returns a new Updater configured with the given options.

func (*Updater) DownloadAsset

func (u *Updater) DownloadAsset(ctx context.Context, asset *Asset) ([]byte, error)

DownloadAsset downloads the bytes of the given asset.

func (*Updater) FetchRelease

func (u *Updater) FetchRelease(ctx context.Context) (*Release, error)

FetchRelease retrieves the release metadata from GitHub.

func (*Updater) Run

func (u *Updater) Run(ctx context.Context) (*UpdateResult, error)

Run executes the complete update check and installation flow.

Jump to

Keyboard shortcuts

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