updater

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultOSSBaseURL = "https://ros-public-tools.oss-cn-beijing.aliyuncs.com/github-releases/aliyun/elastic-compute-control-cli"
)

Variables

This section is empty.

Functions

func CompareVersions

func CompareVersions(left, right string) (int, error)

func DefaultCachePath

func DefaultCachePath() (string, error)

func ErrorRetryable

func ErrorRetryable(kind ErrorKind) bool

func NormalizeVersion

func NormalizeVersion(raw string) (string, error)

func RunInternalUpdate

func RunInternalUpdate([]string) error

func WrapError

func WrapError(kind ErrorKind, err error) error

Types

type Artifact

type Artifact struct {
	Archive  []byte
	Filename string
	SHA256   string
	Source   string
}

type AutoCheckOptions

type AutoCheckOptions struct {
	CurrentVersion   string
	CachePath        string
	Client           *Client
	Now              func() time.Time
	MarkNotification bool
}

type AutoCheckResult

type AutoCheckResult struct {
	LatestVersion string
	Available     bool
	Notify        bool
}

func AutoCheck

func AutoCheck(ctx context.Context, options AutoCheckOptions) (AutoCheckResult, error)

type Client

type Client struct {
	HTTP          *http.Client
	OSSBase       string
	GitHubAPIBase string
}

func NewClient

func NewClient(timeout time.Duration) *Client

func (*Client) DownloadArtifact

func (client *Client) DownloadArtifact(ctx context.Context, version, goos, goarch string) (Artifact, error)

func (*Client) LatestVersion

func (client *Client) LatestVersion(ctx context.Context) (string, error)

func (*Client) ResolveLatestVersion

func (client *Client) ResolveLatestVersion(ctx context.Context) (string, error)

ResolveLatestVersion verifies the mutable OSS pointer against GitHub's immutable latest stable Release.

func (*Client) ValidateArtifact

func (client *Client) ValidateArtifact(ctx context.Context, version, goos, goarch string) (string, error)

ValidateArtifact verifies that a platform artifact is published and returns the source an update would use without downloading the archive itself. OSS remains preferred, but its mutable checksum must agree with the immutable GitHub Release checksum before it is trusted.

type CommandRunner

type CommandRunner func(ctx context.Context, env []string, name string, args ...string) ([]byte, error)

type ErrorKind

type ErrorKind string
const (
	ErrorUnavailable   ErrorKind = "unavailable"
	ErrorIntegrity     ErrorKind = "integrity"
	ErrorInvalidTarget ErrorKind = "invalid_target"
	ErrorPermission    ErrorKind = "permission"
	ErrorBusy          ErrorKind = "busy"
	ErrorTimeout       ErrorKind = "timeout"
	ErrorCanceled      ErrorKind = "canceled"
	ErrorInstallation  ErrorKind = "installation"
)

func ErrorKindOf

func ErrorKindOf(err error) ErrorKind

type Options

type Options struct {
	CurrentVersion string
	TargetVersion  string
	Force          bool
	Executable     string
	GOOS           string
	GOARCH         string
	Client         *Client
	RunCommand     CommandRunner
	LookPath       func(string) (string, error)
}

type Result

type Result struct {
	CurrentVersion  string `json:"current_version"`
	TargetVersion   string `json:"target_version"`
	UpdateAvailable bool   `json:"update_available"`
	Source          string `json:"source"`
	Installer       string `json:"installer"`
	Updated         bool   `json:"updated"`
	UpdatePending   bool   `json:"update_pending"`
}

func Check

func Check(ctx context.Context, options Options) (Result, error)

func Update

func Update(ctx context.Context, options Options) (Result, error)

Jump to

Keyboard shortcuts

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