Documentation ¶
Overview ¶
Package snapstate implements the manager and state aspects responsible for the installation and removal of snaps.
Package snapstate implements the manager and state aspects responsible for the installation and removal of snaps.
Index ¶
- Constants
- Variables
- func ActiveInfos(s *state.State) ([]*snap.Info, error)
- func All(s *state.State) (map[string]*SnapState, error)
- func CurrentInfo(s *state.State, name string) (*snap.Info, error)
- func Disable(s *state.State, name string) (*state.TaskSet, error)
- func Enable(s *state.State, name string) (*state.TaskSet, error)
- func GadgetInfo(s *state.State) (*snap.Info, error)
- func Get(s *state.State, name string, snapst *SnapState) error
- func Info(s *state.State, name string, revision snap.Revision) (*snap.Info, error)
- func Install(s *state.State, name, channel string, userID int, flags Flags) (*state.TaskSet, error)
- func InstallPath(s *state.State, name, path, channel string, flags Flags) (*state.TaskSet, error)
- func Remove(s *state.State, name string) (*state.TaskSet, error)
- func ReplaceStore(state *state.State, store StoreService)
- func Revert(s *state.State, name string) (*state.TaskSet, error)
- func RevertToRevision(s *state.State, name string, rev snap.Revision) (*state.TaskSet, error)
- func Set(s *state.State, name string, snapst *SnapState)
- func TryPath(s *state.State, name, path string, flags Flags) (*state.TaskSet, error)
- func Update(s *state.State, name, channel string, userID int, flags Flags) (*state.TaskSet, error)
- type Flags
- type SnapManager
- type SnapSetup
- type SnapSetupFlags
- type SnapState
- func (snapst *SnapState) Block() []snap.Revision
- func (snapst *SnapState) CurrentInfo() (*snap.Info, error)
- func (snapst *SnapState) CurrentSideInfo() *snap.SideInfo
- func (snapst *SnapState) DevMode() bool
- func (snapst *SnapState) DevModeAllowed() bool
- func (snapst *SnapState) HasCurrent() bool
- func (snapst *SnapState) JailMode() bool
- func (snapst *SnapState) LocalRevision() snap.Revision
- func (snapst *SnapState) SetDevMode(active bool)
- func (snapst *SnapState) SetJailMode(active bool)
- func (snapst *SnapState) SetTryMode(active bool)
- func (snapst *SnapState) SetType(typ snap.Type)
- func (snapst *SnapState) TryMode() bool
- func (snapst *SnapState) Type() (snap.Type, error)
- type SnapStateFlags
- type StoreService
- type TaskProgressAdapter
- func (t *TaskProgressAdapter) Finished()
- func (t *TaskProgressAdapter) Notify(msg string)
- func (t *TaskProgressAdapter) Set(current float64)
- func (t *TaskProgressAdapter) SetTotal(total float64)
- func (t *TaskProgressAdapter) Spin(msg string)
- func (t *TaskProgressAdapter) Start(pkg string, total float64)
- func (t *TaskProgressAdapter) Write(p []byte) (n int, err error)
Constants ¶
const ( // DevMode switches confinement to non-enforcing mode. DevMode = 1 << iota // TryMode is set for snaps installed to try directly from a local directory. TryMode // JailMode is set when the user has requested confinement // always be enforcing, even if the snap requests otherwise. JailMode )
Variables ¶
var ErrNoCurrent = errors.New("snap has no current revision")
Functions ¶
func ActiveInfos ¶
ActiveInfos returns information about all active snaps.
func All ¶
All retrieves return a map from name to SnapState for all current snaps in the system state.
func CurrentInfo ¶
CurrentInfo returns the information about the current revision of a snap with the given name.
func GadgetInfo ¶
GadgetInfo finds the current gadget snap's info.
func Info ¶
Info returns the information about the snap with given name and revision. Works also for a mounted candidate snap in the process of being installed.
func Install ¶
Install returns a set of tasks for installing snap. Note that the state must be locked by the caller.
func InstallPath ¶
InstallPath returns a set of tasks for installing snap from a file path. Note that the state must be locked by the caller.
func Remove ¶
Remove returns a set of tasks for removing snap. Note that the state must be locked by the caller.
func ReplaceStore ¶
func ReplaceStore(state *state.State, store StoreService)
ReplaceStore replaces the store used by the manager.
func Revert ¶
Revert returns a set of tasks for reverting to the pervious version of the snap. Note that the state must be locked by the caller.
func RevertToRevision ¶
Types ¶
type Flags ¶
type Flags int
Flags are used to pass additional flags to operations and to keep track of snap modes.
func (Flags) DevModeAllowed ¶
type SnapManager ¶
type SnapManager struct {
// contains filtered or unexported fields
}
SnapManager is responsible for the installation and removal of snaps.
func Manager ¶
func Manager(s *state.State) (*SnapManager, error)
Manager returns a new snap manager.
func (*SnapManager) Ensure ¶
func (m *SnapManager) Ensure() error
Ensure implements StateManager.Ensure.
type SnapSetup ¶
type SnapSetup struct { // FIXME: rename to RequestedChannel to convey the meaning better Channel string `json:"channel,omitempty"` UserID int `json:"user-id,omitempty"` Flags SnapSetupFlags `json:"flags,omitempty"` SnapPath string `json:"snap-path,omitempty"` DownloadInfo *snap.DownloadInfo `json:"download-info,omitempty"` SideInfo *snap.SideInfo `json:"side-info,omitempty"` }
SnapSetup holds the necessary snap details to perform most snap manager tasks.
func TaskSnapSetup ¶
TaskSnapSetup returns the SnapSetup with task params hold by or referred to by the the task.
func (*SnapSetup) DevModeAllowed ¶
type SnapSetupFlags ¶
type SnapSetupFlags Flags
SnapSetupFlags are flags stored in SnapSetup to control snap manager tasks.
type SnapState ¶
type SnapState struct { SnapType string `json:"type"` // Use Type and SetType Sequence []*snap.SideInfo `json:"sequence"` Active bool `json:"active,omitempty"` // Current indicates the current active revision if Active is // true or the last active revision if Active is false // (usually while a snap is being operated on or disabled) Current snap.Revision `json:"current"` Channel string `json:"channel,omitempty"` Flags SnapStateFlags `json:"flags,omitempty"` }
SnapState holds the state for a snap installed in the system.
func (*SnapState) Block ¶
Block returns revisions that should be blocked on refreshes, computed from Sequence[currentRevisionIndex+1:].
func (*SnapState) CurrentInfo ¶
CurrentInfo returns the information about the current active revision or the last active revision (if the snap is inactive). It returns the ErrNoCurrent error if snapst.Current is unset.
func (*SnapState) CurrentSideInfo ¶
CurrentSideInfo returns the side info for the revision indicated by snapst.Current in the snap revision sequence if there is one.
func (*SnapState) DevModeAllowed ¶
func (*SnapState) HasCurrent ¶
HasCurrent returns whether snapst.Current is set.
func (*SnapState) LocalRevision ¶
LocalRevision returns the "latest" local revision. Local revisions start at -1 and are counted down.
func (*SnapState) SetDevMode ¶
SetDevMode sets/clears the DevMode flag in the SnapState.
func (*SnapState) SetJailMode ¶
SetJailMode sets/clears the JailMode flag in the SnapState.
func (*SnapState) SetTryMode ¶
SetTryMode sets/clears the TryMode flag in the SnapState.
type StoreService ¶
type StoreService interface { Snap(name, channel string, devmode bool, user *auth.UserState) (*snap.Info, error) Find(query, channel string, user *auth.UserState) ([]*snap.Info, error) ListRefresh([]*store.RefreshCandidate, *auth.UserState) ([]*snap.Info, error) SuggestedCurrency() string Download(string, *snap.DownloadInfo, progress.Meter, *auth.UserState) (string, error) Buy(options *store.BuyOptions) (*store.BuyResult, error) PaymentMethods(*auth.UserState) (*store.PaymentInformation, error) }
A StoreService can find, list available updates and download snaps.
func Store ¶
func Store(s *state.State) StoreService
Store returns the store service used by the snapstate package.
type TaskProgressAdapter ¶
type TaskProgressAdapter struct {
// contains filtered or unexported fields
}
TaskProgressAdapter adapts the progress.Meter to the task progress until we have native install/update/remove.
func (*TaskProgressAdapter) Finished ¶
func (t *TaskProgressAdapter) Finished()
Finished set the progress to 100%
func (*TaskProgressAdapter) Notify ¶
func (t *TaskProgressAdapter) Notify(msg string)
Notify notifies
func (*TaskProgressAdapter) Set ¶
func (t *TaskProgressAdapter) Set(current float64)
Set sets the current progress
func (*TaskProgressAdapter) SetTotal ¶
func (t *TaskProgressAdapter) SetTotal(total float64)
SetTotal sets tht maximum progress
func (*TaskProgressAdapter) Start ¶
func (t *TaskProgressAdapter) Start(pkg string, total float64)
Start sets total