installer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: GPL-3.0 Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package installer authenticates, verifies, installs, activates, and recovers independently released bsbctl plugins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activator

type Activator interface {
	DesiredPlugin(context.Context, string) (*config.Plugin, error)
	ActivatePlugin(context.Context, config.Plugin) (localstate.CommitOutcome, error)
}

type Code

type Code string
const (
	CodeCatalogInvalid   Code = "catalog_invalid"
	CodeDownloadFailed   Code = "download_failed"
	CodePackageInvalid   Code = "package_invalid"
	CodeInstallConflict  Code = "install_conflict"
	CodeStateFailed      Code = "state_failed"
	CodeActivationFailed Code = "activation_failed"
	CodeRecoveryRequired Code = "recovery_required"
	CodeNotInstalled     Code = "not_installed"
)

func CodeOf

func CodeOf(err error) Code

type Downloader

type Downloader struct {
	Client  *http.Client
	Timeout time.Duration
}

func (Downloader) Download

func (downloader Downloader) Download(ctx context.Context, directory string, entry catalog.Entry) (result *os.File, resultErr error)

Download returns an authenticated artifact as an open descriptor whose private temporary pathname has been unlinked. The caller owns the descriptor and must close it. The descriptor is initially positioned at the beginning, but consumers may change its offset.

type Error

type Error struct{ Code Code }

func (*Error) Error

func (err *Error) Error() string

type FileRecord

type FileRecord struct {
	SHA256 string `json:"sha256"`
	Size   int64  `json:"size"`
}

type InstallRequest

type InstallRequest struct {
	Catalog  []byte
	Envelope []byte
	PluginID string
	Version  string
	OS       string
	Arch     string
}

type InstallState

type InstallState struct {
	Version         int                           `json:"version"`
	CatalogSequence uint64                        `json:"catalog_sequence"`
	CatalogSHA256   string                        `json:"catalog_sha256,omitempty"`
	Installed       map[string]InstalledRelease   `json:"installed"`
	Plugins         map[string]PluginInstallState `json:"plugins"`
}

type InstalledRelease

type InstalledRelease struct {
	ID             string                  `json:"id"`
	Version        string                  `json:"version"`
	OS             string                  `json:"os"`
	Arch           string                  `json:"arch"`
	Manifest       catalog.PackageManifest `json:"manifest"`
	ManifestSHA256 string                  `json:"manifest_sha256"`
	Files          map[string]FileRecord   `json:"files"`
	Root           string                  `json:"-"`
}

func (InstalledRelease) Ref

func (release InstalledRelease) Ref() ReleaseRef

type Installer

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

func New

func New(options Options) (*Installer, error)

func (*Installer) Install

func (installer *Installer) Install(ctx context.Context, request InstallRequest) (Result, error)

func (*Installer) InstallFirst

func (installer *Installer) InstallFirst(ctx context.Context, request InstallRequest) (Result, error)

InstallFirst is the public first-install operation. An identical active target is idempotent; a different active target is a conflict.

func (*Installer) Rollback

func (installer *Installer) Rollback(ctx context.Context, request RollbackRequest) (Result, error)

func (*Installer) Snapshot

func (installer *Installer) Snapshot(ctx context.Context, pluginID string) (Snapshot, error)

Snapshot returns only installer identities and transaction state; package roots, catalog URLs, and dependency errors never cross this boundary.

func (*Installer) Update

func (installer *Installer) Update(ctx context.Context, request InstallRequest) (Result, error)

Update is the public update operation. It requires an existing active release and treats a repeated completed update as idempotent.

type Intent

type Intent struct {
	Version               int                `json:"version"`
	Kind                  Operation          `json:"kind"`
	PluginID              string             `json:"plugin_id"`
	Target                InstalledRelease   `json:"target"`
	Before                PluginInstallState `json:"before"`
	BeforeCatalogSequence uint64             `json:"before_catalog_sequence"`
	BeforeCatalogSHA256   string             `json:"before_catalog_sha256,omitempty"`
	TargetWasInstalled    bool               `json:"target_was_installed"`
	CatalogSequence       uint64             `json:"catalog_sequence"`
	CatalogSHA256         string             `json:"catalog_sha256,omitempty"`
}

type Operation

type Operation string
const (
	OperationInstall  Operation = "install"
	OperationRollback Operation = "rollback"
)

type Options

type Options struct {
	Root      string
	Keyring   catalog.Keyring
	Client    *http.Client
	Timeout   time.Duration
	Activator Activator
	Now       func() time.Time
	State     stateBackend
}

type PackageStore

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

func NewPackageStore

func NewPackageStore(root string) *PackageStore

func (*PackageStore) Promote

func (store *PackageStore) Promote(verified VerifiedPackage) (InstalledRelease, Promotion, error)

func (*PackageStore) StagingDir

func (store *PackageStore) StagingDir() (string, error)

func (*PackageStore) VerifyInstalled

func (store *PackageStore) VerifyInstalled(release InstalledRelease) error

type PluginInstallState

type PluginInstallState struct {
	Active   *ReleaseRef `json:"active,omitempty"`
	Previous *ReleaseRef `json:"previous,omitempty"`
}

type PluginSnapshot

type PluginSnapshot struct {
	PluginID          string      `json:"plugin_id"`
	Configured        bool        `json:"configured"`
	ConfiguredSource  string      `json:"configured_source,omitempty"`
	ConfiguredVersion string      `json:"configured_version,omitempty"`
	AppCount          int         `json:"app_count"`
	Active            *ReleaseRef `json:"active,omitempty"`
	Previous          *ReleaseRef `json:"previous,omitempty"`
}

type Promotion

type Promotion string
const (
	PromotionInstalled                    Promotion = "installed"
	PromotionAlreadyInstalled             Promotion = "already_installed"
	PromotionInstalledDurabilityUncertain Promotion = "installed_durability_uncertain"
)

type RecoveryOptions

type RecoveryOptions struct {
	Root      string
	Activator Activator
	State     stateBackend
}

RecoveryOptions contains only the dependencies needed to reconcile an interrupted installer transaction before the live runtime exists.

type ReleaseRef

type ReleaseRef struct {
	ID      string `json:"id"`
	Version string `json:"version"`
	OS      string `json:"os"`
	Arch    string `json:"arch"`
}

func (ReleaseRef) Key

func (ref ReleaseRef) Key() string

type Result

type Result struct {
	Status            Status                   `json:"status"`
	Release           ReleaseRef               `json:"release"`
	Promotion         Promotion                `json:"promotion,omitempty"`
	IntentOutcome     localstate.CommitOutcome `json:"intent_outcome,omitempty"`
	ActivationOutcome localstate.CommitOutcome `json:"activation_outcome,omitempty"`
	StateOutcome      localstate.CommitOutcome `json:"state_outcome,omitempty"`
	CleanupOutcome    localstate.CommitOutcome `json:"cleanup_outcome,omitempty"`
}

func Recover

func Recover(ctx context.Context, options RecoveryOptions) (Result, error)

Recover reconciles one interrupted transaction using a short-lived recovery object. The returned object cannot be reused for live package operations.

type RollbackRequest

type RollbackRequest struct {
	PluginID string
	Version  string
	OS       string
	Arch     string
}

type Snapshot

type Snapshot struct {
	CatalogSequence  uint64           `json:"catalog_sequence"`
	RecoveryRequired bool             `json:"recovery_required"`
	Plugins          []PluginSnapshot `json:"plugins"`
}

type StateStore

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

func NewStateStore

func NewStateStore(root string) *StateStore

func (*StateStore) ClearIntent

func (store *StateStore) ClearIntent() (localstate.CommitOutcome, error)

func (*StateStore) LoadIntent

func (store *StateStore) LoadIntent() (*Intent, error)

func (*StateStore) LoadState

func (store *StateStore) LoadState() (InstallState, error)

func (*StateStore) WriteIntent

func (store *StateStore) WriteIntent(intent Intent) (localstate.CommitOutcome, error)

func (*StateStore) WriteState

func (store *StateStore) WriteState(state InstallState) (localstate.CommitOutcome, error)

type Status

type Status string
const (
	StatusInstalled       Status = "installed"
	StatusUpdated         Status = "updated"
	StatusRolledBack      Status = "rolled_back"
	StatusRecoveredTarget Status = "recovered_target"
	StatusRecoveredPrior  Status = "recovered_prior"
	StatusNoRecovery      Status = "no_recovery"
)

type VerifiedPackage

type VerifiedPackage struct {
	Root           string
	Entry          catalog.Entry
	Manifest       catalog.PackageManifest
	ManifestSHA256 string
	Files          map[string]FileRecord
	// contains filtered or unexported fields
}

func ExtractAndVerifyFile

func ExtractAndVerifyFile(artifact *os.File, stagingParent string, entry catalog.Entry) (VerifiedPackage, error)

ExtractAndVerifyFile authenticates and extracts from artifact without taking ownership of it. The caller must close artifact; the function seeks it and may leave its offset changed. On success, the returned VerifiedPackage owns staging directory handles and must be closed unless passed to Promote, which closes it before returning.

func (VerifiedPackage) Close

func (verified VerifiedPackage) Close() error

Close releases the verified package's owned directory handles. It is safe to call more than once. A package promoted into the immutable store remains installed; an unpromoted package's staging directory is removed when its original pathname still identifies the owned directory.

Jump to

Keyboard shortcuts

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