version

package
v1.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: EPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version is set at build time via ldflags
	Version = "dev"
	// BuildTime is set at build time via ldflags
	BuildTime = "unknown"
	// GitCommit is set at build time via ldflags
	GitCommit = "unknown"
)

Functions

func GetBuildInfo

func GetBuildInfo() map[string]string

GetBuildInfo returns build information

func GetVersion

func GetVersion() string

GetVersion returns the agent version

func ParseVersion

func ParseVersion(version string) (major, minor, patch int, suffix string)

ParseVersion parses a version string and returns components

func SetBuildInfo

func SetBuildInfo(version, buildTime, gitCommit string)

SetBuildInfo overrides build metadata (used in tests).

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler orchestrates controller-driven OTA via install.sh.

func GetInstance

func GetInstance() *Handler

GetInstance returns the singleton version handler.

func NewHandler

func NewHandler(manager *ReleaseManager) *Handler

NewHandler constructs a Handler with the given ReleaseManager.

func (*Handler) ChangeVersion

func (h *Handler) ChangeVersion(actionData map[string]any) error

ChangeVersion performs a controller-initiated upgrade or rollback.

func (*Handler) IsReadyToRollback

func (h *Handler) IsReadyToRollback() bool

IsReadyToRollback reports rollback readiness from previous-release and cache/url.

func (*Handler) IsReadyToUpgrade

func (h *Handler) IsReadyToUpgrade() bool

IsReadyToUpgrade reports upgrade readiness using GitHub latest as target.

func (*Handler) IsReadyToUpgradeWithAction

func (h *Handler) IsReadyToUpgradeWithAction(actionData map[string]any) bool

IsReadyToUpgradeWithAction reports upgrade readiness for an optional controller target.

type InstallReceipt

type InstallReceipt struct {
	InstalledVersion string
	OS               string
	Arch             string
	ContainerEngine  string
	SourceURL        string
	InstalledAt      string
	InstallMethod    string
	BinarySHA256     string
}

InstallReceipt holds parsed install-receipt v1 fields.

type PreviousRelease

type PreviousRelease struct {
	PreviousVersion         string
	PreviousOS              string
	PreviousArch            string
	PreviousContainerEngine string
	PreviousDownloadURL     string
	PreviousBinarySHA256    string
	ConfigBackupPath        string
}

PreviousRelease holds parsed previous-release fields.

type ReleaseManager

type ReleaseManager struct {
	// contains filtered or unexported fields
}

ReleaseManager reads OTA state from install.sh receipt files and GitHub releases.

func NewReleaseManager

func NewReleaseManager(opts ...ReleaseManagerOption) *ReleaseManager

NewReleaseManager constructs a ReleaseManager with optional overrides.

func (*ReleaseManager) GetCandidateVersion

func (rm *ReleaseManager) GetCandidateVersion(actionData map[string]any) (string, error)

GetCandidateVersion resolves the controller target from action data or GitHub latest.

func (*ReleaseManager) GetInstalledVersion

func (rm *ReleaseManager) GetInstalledVersion() string

GetInstalledVersion returns receipt installed_version or the running build version.

func (*ReleaseManager) HasCachedBinary

func (rm *ReleaseManager) HasCachedBinary(version, osName, arch string) bool

HasCachedBinary reports whether rollback cache contains the previous binary.

func (*ReleaseManager) InstallScriptExists

func (rm *ReleaseManager) InstallScriptExists() bool

InstallScriptExists reports whether the bundled install script is present.

func (*ReleaseManager) InstallScriptPath

func (rm *ReleaseManager) InstallScriptPath() string

InstallScriptPath returns the bundled install script path.

func (*ReleaseManager) IsPreviousDownloadReachable

func (rm *ReleaseManager) IsPreviousDownloadReachable(url string) bool

IsPreviousDownloadReachable checks whether previous_download_url responds.

func (*ReleaseManager) PreviousReleaseExists

func (rm *ReleaseManager) PreviousReleaseExists() bool

PreviousReleaseExists reports whether a previous-release record is on disk.

func (*ReleaseManager) ReadInstallReceipt

func (rm *ReleaseManager) ReadInstallReceipt() (*InstallReceipt, error)

ReadInstallReceipt parses install-receipt v1 if present.

func (*ReleaseManager) ReadPreviousRelease

func (rm *ReleaseManager) ReadPreviousRelease() (*PreviousRelease, error)

ReadPreviousRelease parses previous-release if present.

type ReleaseManagerOption

type ReleaseManagerOption func(*ReleaseManager)

ReleaseManagerOption configures a ReleaseManager.

func WithHTTPClient

func WithHTTPClient(client *http.Client) ReleaseManagerOption

WithHTTPClient overrides the HTTP client (tests).

func WithPaths

func WithPaths(installScript, receiptFile, previousFile, cacheDir string) ReleaseManagerOption

WithPaths overrides default on-disk OTA paths (tests).

func WithRunningVersion

func WithRunningVersion(fn func() string) ReleaseManagerOption

WithRunningVersion overrides the running agent version source (tests).

type VersionCommand

type VersionCommand string //nolint:revive // exported API

VersionCommand represents a version change command.

const (
	VersionCommandUpgrade  VersionCommand = "UPGRADE"
	VersionCommandRollback VersionCommand = "ROLLBACK"
)

func ParseVersionCommand

func ParseVersionCommand(actionData map[string]any) (VersionCommand, error)

ParseVersionCommand parses version command from JSON.

Jump to

Keyboard shortcuts

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