Documentation
¶
Index ¶
- Variables
- func GetBuildInfo() map[string]string
- func GetVersion() string
- func ParseVersion(version string) (major, minor, patch int, suffix string)
- func SetBuildInfo(version, buildTime, gitCommit string)
- type Handler
- type InstallReceipt
- type PreviousRelease
- type ReleaseManager
- func (rm *ReleaseManager) GetCandidateVersion(actionData map[string]any) (string, error)
- func (rm *ReleaseManager) GetInstalledVersion() string
- func (rm *ReleaseManager) HasCachedBinary(version, osName, arch string) bool
- func (rm *ReleaseManager) InstallScriptExists() bool
- func (rm *ReleaseManager) InstallScriptPath() string
- func (rm *ReleaseManager) IsPreviousDownloadReachable(url string) bool
- func (rm *ReleaseManager) PreviousReleaseExists() bool
- func (rm *ReleaseManager) ReadInstallReceipt() (*InstallReceipt, error)
- func (rm *ReleaseManager) ReadPreviousRelease() (*PreviousRelease, error)
- type ReleaseManagerOption
- type VersionCommand
Constants ¶
This section is empty.
Variables ¶
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 ParseVersion ¶
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 NewHandler ¶
func NewHandler(manager *ReleaseManager) *Handler
NewHandler constructs a Handler with the given ReleaseManager.
func (*Handler) ChangeVersion ¶
ChangeVersion performs a controller-initiated upgrade or rollback.
func (*Handler) IsReadyToRollback ¶
IsReadyToRollback reports rollback readiness from previous-release and cache/url.
func (*Handler) IsReadyToUpgrade ¶
IsReadyToUpgrade reports upgrade readiness using GitHub latest as 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.