update

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const Repository = "kaaanata/jetkvm-cli"

Variables

This section is empty.

Functions

func ReceiptPath

func ReceiptPath(executable string) string

Types

type Backend

type Backend interface {
	Resolve(context.Context, ReleaseQuery) (Release, error)
	Apply(context.Context, Release, string, string) error
	ReplaceFromFile(context.Context, string, string, string) error
}

func NewGitHubBackend

func NewGitHubBackend(config GitHubBackendConfig) (Backend, error)

type Channel

type Channel string
const (
	ChannelStable     Channel = "stable"
	ChannelPrerelease Channel = "prerelease"
)

type CheckResult

type CheckResult struct {
	Installation Installation `json:"installation"`
	Request      Request      `json:"request"`
	Release      Release      `json:"release"`
	Available    bool         `json:"available"`
	Downgrade    bool         `json:"downgrade,omitzero"`
}

type Error

type Error struct {
	Kind    ErrorKind `json:"kind"`
	Message string    `json:"message"`
	Owner   Owner     `json:"owner,omitempty"`
	Command []string  `json:"action_required,omitempty"`
	Cause   error     `json:"-"`
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorKind

type ErrorKind string
const (
	ErrInvalidRequest        ErrorKind = "invalid_request"
	ErrInvalidReceipt        ErrorKind = "invalid_install_receipt"
	ErrReceiptMismatch       ErrorKind = "install_receipt_mismatch"
	ErrUnsupportedOwner      ErrorKind = "unsupported_install_owner"
	ErrReleaseNotFound       ErrorKind = "release_not_found"
	ErrReleaseResolution     ErrorKind = "release_resolution_failed"
	ErrUpdateInProgress      ErrorKind = "update_in_progress"
	ErrChecksumMismatch      ErrorKind = "checksum_mismatch"
	ErrSignatureVerification ErrorKind = "signature_verification_failed"
	ErrApplyFailed           ErrorKind = "update_apply_failed"
	ErrRollbackUnavailable   ErrorKind = "rollback_unavailable"
	ErrRollbackFailed        ErrorKind = "rollback_failed"
)

func (ErrorKind) Error

func (k ErrorKind) Error() string

type FileLocker

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

func NewFileLocker

func NewFileLocker(executable string) *FileLocker

func (*FileLocker) Lock

func (l *FileLocker) Lock(ctx context.Context) (func() error, error)

type FileReceiptStore

type FileReceiptStore struct{}

func (FileReceiptStore) Load

func (FileReceiptStore) Load(executable string) (InstallReceipt, error)

func (FileReceiptStore) LoadPrevious

func (FileReceiptStore) LoadPrevious(executable string) (InstallReceipt, error)

func (FileReceiptStore) RemovePrevious

func (FileReceiptStore) RemovePrevious(executable string) error

func (FileReceiptStore) Save

func (FileReceiptStore) Save(receipt InstallReceipt) error

func (FileReceiptStore) SavePrevious

func (FileReceiptStore) SavePrevious(receipt InstallReceipt) error

type GitHubBackendConfig

type GitHubBackendConfig struct {
	Token             string
	SignatureVerifier SignatureVerifier
	HTTPClient        *http.Client
	APIBaseURL        string
	OS                string
	Arch              string
}

type InstallReceipt

type InstallReceipt struct {
	SchemaVersion int       `json:"schema_version"`
	InstallID     string    `json:"install_id"`
	Owner         Owner     `json:"owner"`
	Executable    string    `json:"executable"`
	Version       string    `json:"version"`
	Repository    string    `json:"repository"`
	Channel       Channel   `json:"channel"`
	InstalledAt   time.Time `json:"installed_at"`
}

func NewStandaloneReceipt

func NewStandaloneReceipt(executable, version string, channel Channel, installedAt time.Time) (InstallReceipt, error)

func (InstallReceipt) Installation

func (r InstallReceipt) Installation() Installation

func (InstallReceipt) Validate

func (r InstallReceipt) Validate(currentExecutable string) error

type Installation

type Installation struct {
	InstallID   string    `json:"install_id,omitempty"`
	Owner       Owner     `json:"owner"`
	Executable  string    `json:"executable"`
	Version     string    `json:"version"`
	Repository  string    `json:"repository"`
	Channel     Channel   `json:"channel"`
	InstalledAt time.Time `json:"installed_at,omitzero"`
}

type InstallationResolver

type InstallationResolver interface {
	ResolveInstallation(context.Context) (Installation, error)
}

type Locker

type Locker interface {
	Lock(context.Context) (func() error, error)
}

type Owner

type Owner string
const (
	OwnerStandalone Owner = "standalone"
	OwnerHomebrew   Owner = "homebrew"
	OwnerWinget     Owner = "winget"
	OwnerScoop      Owner = "scoop"
	OwnerDeb        Owner = "deb"
	OwnerRPM        Owner = "rpm"
	OwnerSource     Owner = "source"
	OwnerUnmanaged  Owner = "unmanaged"
	OwnerUnknown    Owner = "unknown"
)

func (Owner) Valid

func (o Owner) Valid() bool

type Plan

type Plan struct {
	Action         PlanAction `json:"action"`
	Owner          Owner      `json:"owner"`
	CurrentVersion string     `json:"current_version"`
	TargetVersion  string     `json:"target_version"`
	Executable     string     `json:"executable"`
	Channel        Channel    `json:"channel"`
	Command        []string   `json:"command,omitempty"`
	Release        Release    `json:"release"`
	InstallID      string     `json:"install_id,omitempty"`
}

type PlanAction

type PlanAction string
const (
	ActionNone        PlanAction = "none"
	ActionSelfReplace PlanAction = "self_replace"
	ActionRequired    PlanAction = "action_required"
)

type PortableInstallationResolver

type PortableInstallationResolver struct {
	Executable   string
	Receipts     ReceiptStore
	MissingOwner Owner
	Version      string
	Channel      Channel
}

func (PortableInstallationResolver) ResolveInstallation

type ReceiptStore

type ReceiptStore interface {
	Load(executable string) (InstallReceipt, error)
	Save(InstallReceipt) error
	LoadPrevious(executable string) (InstallReceipt, error)
	SavePrevious(InstallReceipt) error
	RemovePrevious(executable string) error
}

type Release

type Release struct {
	Version     string    `json:"version"`
	Prerelease  bool      `json:"prerelease,omitzero"`
	AssetName   string    `json:"asset_name"`
	AssetURL    string    `json:"asset_url"`
	PublishedAt time.Time `json:"published_at,omitzero"`
	// contains filtered or unexported fields
}

type ReleaseQuery

type ReleaseQuery struct {
	Version    string
	Prerelease bool
}

type Request

type Request struct {
	Version        string  `json:"version,omitempty"`
	Channel        Channel `json:"channel"`
	AllowDowngrade bool    `json:"allow_downgrade,omitzero"`
}

type Resolution

type Resolution struct {
	Installation Installation `json:"installation"`
	Request      Request      `json:"request"`
}

type Result

type Result struct {
	Status            ResultStatus `json:"status"`
	Owner             Owner        `json:"owner"`
	PreviousVersion   string       `json:"previous_version,omitempty"`
	CurrentVersion    string       `json:"current_version"`
	Verified          bool         `json:"verified,omitzero"`
	RollbackAvailable bool         `json:"rollback_available,omitzero"`
	ActionRequired    []string     `json:"action_required,omitempty"`
}

type ResultStatus

type ResultStatus string
const (
	StatusUpToDate       ResultStatus = "up_to_date"
	StatusActionRequired ResultStatus = "action_required"
	StatusApplied        ResultStatus = "applied"
	StatusRolledBack     ResultStatus = "rolled_back"
)

type Service

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

func NewService

func NewService(installations InstallationResolver, backend Backend, receipts ReceiptStore, locker Locker) (*Service, error)

func (*Service) Apply

func (s *Service) Apply(ctx context.Context, plan Plan) (Result, error)

func (*Service) Check

func (s *Service) Check(ctx context.Context, resolution Resolution) (CheckResult, error)

func (*Service) Plan

func (s *Service) Plan(check CheckResult) (Plan, error)

func (*Service) Resolve

func (s *Service) Resolve(ctx context.Context, request Request) (Resolution, error)

func (*Service) Rollback

func (s *Service) Rollback(ctx context.Context) (Result, error)

type SignatureVerifier

type SignatureVerifier interface {
	Verify(payload, bundle []byte) error
}

func NewSigstoreVerifier

func NewSigstoreVerifier() SignatureVerifier

NewSigstoreVerifier returns the production verifier for JetKVM release checksums. Trust material is loaded from Sigstore's public-good TUF repository for every verification operation so key rotations are honored.

Jump to

Keyboard shortcuts

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