update

package
v0.6.8-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOperationAlreadyInProgress = &UpdateError{
		Code:    OperationInProgressCode,
		Details: "an operation is already in progress",
	}
	ErrNoInternetConnection = &UpdateError{
		Code:    NoInternetConnectionCode,
		Details: "no internet connection available",
	}
)
View Source
var MatchAllPackages = func(p UpgradablePackage) bool {
	return true
}
View Source
var MatchArduinoPackage = func(p UpgradablePackage) bool {
	return strings.HasPrefix(p.Name, "arduino-") ||
		(p.Name == "adbd" && strings.Contains(p.ToVersion, "arduino"))
}

Functions

This section is empty.

Types

type ErrorCode

type ErrorCode string
const (
	NoInternetConnectionCode ErrorCode = "NO_INTERNET_CONNECTION"
	OperationInProgressCode  ErrorCode = "OPERATION_IN_PROGRESS"
	UnknownErrorCode         ErrorCode = "UNKNOWN_ERROR"
)

TODO: add the error to the openAPI spec as an enum

func GetUpdateErrorCode

func GetUpdateErrorCode(err error) ErrorCode

type Event

type Event struct {
	Type EventType
	// contains filtered or unexported fields
}

Event represents a single event in the upgrade process.

func NewDataEvent

func NewDataEvent(t EventType, data string) Event

func NewErrorEvent

func NewErrorEvent(err error) Event

func (Event) GetData

func (e Event) GetData() string

func (Event) GetError

func (e Event) GetError() error

type EventType

type EventType int

EventType defines the type of upgrade event.

const (
	UpgradeLineEvent EventType = iota
	StartEvent
	RestartEvent
	DoneEvent
	ErrorEvent
)

func (EventType) String

func (t EventType) String() string

type Manager

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

func NewManager

func NewManager(debUpdateService ServiceUpdater, arduinoPlatformUpdateService ServiceUpdater) *Manager

func (*Manager) ListUpgradablePackages

func (m *Manager) ListUpgradablePackages(ctx context.Context, matcher func(UpgradablePackage) bool) ([]UpgradablePackage, error)

func (*Manager) Subscribe

func (b *Manager) Subscribe() chan Event

Subscribe creates a new channel for receiving APT events.

func (*Manager) Unsubscribe

func (b *Manager) Unsubscribe(eventCh chan Event)

Unsubscribe removes the channel from the list of subscribers and closes it.

func (*Manager) UpgradePackages

func (m *Manager) UpgradePackages(ctx context.Context, pkgs []UpgradablePackage) error

type PackageType

type PackageType string
const (
	Arduino PackageType = "arduino-platform"
	Debian  PackageType = "debian-package"
)

func (PackageType) AllowedStatuses

func (s PackageType) AllowedStatuses() []PackageType

type ServiceUpdater

type ServiceUpdater interface {
	ListUpgradablePackages(ctx context.Context, matcher func(UpgradablePackage) bool) ([]UpgradablePackage, error)
	UpgradePackages(ctx context.Context, names []string) (<-chan Event, error)
}

type UpdateError

type UpdateError struct {
	Code    ErrorCode `json:"code"`
	Details string    `json:"details"`
	// contains filtered or unexported fields
}

func NewUnkownError

func NewUnkownError(err error) *UpdateError

func (*UpdateError) Error

func (e *UpdateError) Error() string

func (*UpdateError) Unwrap

func (e *UpdateError) Unwrap() error

type UpgradablePackage

type UpgradablePackage struct {
	Type         PackageType `json:"type"` // e.g., "arduino", "deb"
	Name         string      `json:"name"` // Package name without repository information
	Architecture string      `json:"-"`
	FromVersion  string      `json:"from_version"`
	ToVersion    string      `json:"to_version"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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