updater

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 28 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
	// contains filtered or unexported fields
}

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 resolves the mutable OSS pointer through a signed v2 manifest. GitHub remains a compatibility fallback when OSS is unavailable.

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. A v2 release is bound by its signed v2 manifest; legacy releases are bound by immutable GitHub Release digests.

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