state

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: BSD-3-Clause-Clear Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCheckNoUpdate           = errors.New("selected target is already running")
	ErrNewerVersionIsAvailable = errors.New("can't resume current update, there is a newer version available")
	ErrInvalidOngoingUpdate    = errors.New("invalid ongoing update")
)
View Source
var (
	UpdateModeNewUpdate UpdateMode = "new"
	UpdateModeResume    UpdateMode = "resume"
	UpdateTypeUpdate    UpdateType = "update"
	UpdateTypeSync      UpdateType = "sync"
)
View Source
var (
	ErrStartFailed = errors.New("start failed")
)

Functions

This section is empty.

Types

type ActionName

type ActionName string

ActionName Name of the state action

type ActionState

type ActionState interface {
	Name() ActionName
	Execute(ctx context.Context, updateCtx *UpdateContext) error
}

ActionState interface for all states

type Check

type Check struct {
	UpdateTargets  bool
	AllowNewUpdate bool
	Force          bool
	Action         string
	AllowedStates  []update.State
	ToVersion      int
	SyncCurrent    bool
	MaxAttempts    int
	RequireLatest  bool
	EnableTUF      bool
}

func (*Check) Execute

func (s *Check) Execute(ctx context.Context, updateCtx *UpdateContext) error

func (*Check) Name

func (s *Check) Name() ActionName

type Fetch

type Fetch struct {
	ProgressHandler compose.FetchProgressFunc
}

func (*Fetch) Execute

func (s *Fetch) Execute(ctx context.Context, updateCtx *UpdateContext) error

func (*Fetch) Name

func (s *Fetch) Name() ActionName

type Init

type Init struct {
	CheckState bool
}

func (*Init) Execute

func (s *Init) Execute(ctx context.Context, updateCtx *UpdateContext) error

func (*Init) Name

func (s *Init) Name() ActionName

type Install

type Install struct {
	ProgressHandler compose.InstallProgressFunc
}

func (*Install) Execute

func (s *Install) Execute(ctx context.Context, updateCtx *UpdateContext) error

func (*Install) Name

func (s *Install) Name() ActionName

type Start

type Start struct {
	ProgressHandler compose.AppStartProgress
}

func (*Start) Execute

func (s *Start) Execute(ctx context.Context, updateCtx *UpdateContext) error

func (*Start) Name

func (s *Start) Name() ActionName

type Stop added in v1.0.0

type Stop struct{}

func (*Stop) Execute added in v1.0.0

func (s *Stop) Execute(ctx context.Context, updateCtx *UpdateContext) error

func (*Stop) Name added in v1.0.0

func (s *Stop) Name() ActionName

type UpdateContext

type UpdateContext struct {
	UpdateInfo

	Config      *config.Config
	EventSender *events.EventSender
	Client      *client.GatewayClient
	Targets     target.Targets

	UpdateRunner update.Runner
}

UpdateContext holds the state machine context

func (*UpdateContext) SendEvent

func (u *UpdateContext) SendEvent(event events.EventTypeValue, success ...bool)

type UpdateInfo added in v1.0.0

type UpdateInfo struct {
	TotalStates     int
	CurrentStateNum int
	CurrentState    ActionName
	FromTarget      target.Target
	ToTarget        target.Target
	Mode            UpdateMode
	Type            UpdateType
	Size            struct {
		Bytes int64
		Blobs int
	}
	AppDiff struct {
		Remove target.Apps
		Add    target.Apps
		Sync   target.Apps
		Update target.Apps
	}
	CurrentStatus  *status.CurrentStatus
	InitializedAt  time.Time
	FetchedAt      time.Time
	AlreadyFetched bool
}

type UpdateMode added in v1.0.0

type UpdateMode string

UpdateMode defines the update mode, new or resume

type UpdateType added in v1.0.0

type UpdateType string

UpdateType defines the update type, update to another version or sync the current version

Jump to

Keyboard shortcuts

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