Documentation ¶
Overview ¶
Package snapstate implements the manager and state aspects responsible for the installation and removal of snaps.
Index ¶
- Constants
- Variables
- func ActiveInfos(st *state.State) ([]*snap.Info, error)
- func AddCheckSnapCallback(check CheckSnapCallback)
- func AddGadgetAssetsTasks(st *state.State, ts *state.TaskSet) (*state.TaskSet, error)
- func AddLinkNewBaseOrKernel(st *state.State, ts *state.TaskSet) (*state.TaskSet, error)
- func AddLinkSnapParticipant(p LinkSnapParticipant)
- func AffectedByRefreshCandidates(st *state.State) (map[string]*AffectedSnapInfo, error)
- func AffectingSnapsForAffectedByRefreshCandidates(st *state.State, affectedSnap string) ([]string, error)
- func Alias(st *state.State, instanceName, app, alias string) (*state.TaskSet, error)
- func All(st *state.State) (map[string]*SnapState, error)
- func AutoRefresh(ctx context.Context, st *state.State) ([]string, []*state.TaskSet, error)
- func AutoRefreshForGatingSnap(st *state.State, gatingSnap string) error
- func BootBaseInfo(st *state.State, deviceCtx DeviceContext) (*snap.Info, error)
- func CheckChangeConflict(st *state.State, instanceName string, snapst *SnapState) error
- func CheckChangeConflictMany(st *state.State, instanceNames []string, ignoreChangeID string) error
- func CheckChangeConflictRunExclusively(st *state.State, newChangeKind string) error
- func ConfigDefaults(st *state.State, deviceCtx DeviceContext, snapName string) (map[string]interface{}, error)
- func ConfigureSnap(st *state.State, snapName string, confFlags int) *state.TaskSet
- func CurrentInfo(st *state.State, name string) (*snap.Info, error)
- func Disable(st *state.State, name string) (*state.TaskSet, error)
- func DisableAllAliases(st *state.State, instanceName string) (*state.TaskSet, error)
- func Enable(st *state.State, name string) (*state.TaskSet, error)
- func FinishRestart(task *state.Task, snapsup *SnapSetup) (err error)
- func FinishTaskWithRestart(task *state.Task, status state.Status, rt restart.RestartType, ...) error
- func GadgetConnections(st *state.State, deviceCtx DeviceContext) ([]gadget.Connection, error)
- func GadgetInfo(st *state.State, deviceCtx DeviceContext) (*snap.Info, error)
- func Get(st *state.State, name string, snapst *SnapState) error
- func HardNothingRunningRefreshCheck(info *snap.Info) error
- func HasSnapOfType(st *state.State, snapType snap.Type) (bool, error)
- func HeldSnaps(st *state.State, level HoldLevel) (map[string]bool, error)
- func HoldRefresh(st *state.State, level HoldLevel, gatingSnap string, ...) (time.Duration, error)
- func HoldRefreshesBySystem(st *state.State, level HoldLevel, holdTime string, holdSnaps []string) error
- func Info(st *state.State, name string, revision snap.Revision) (*snap.Info, error)
- func InjectAutoConnect(mainTask *state.Task, snapsup *SnapSetup)
- func InjectTasks(mainTask *state.Task, extraTasks *state.TaskSet)
- func Install(ctx context.Context, st *state.State, name string, opts *RevisionOptions, ...) (*state.TaskSet, error)
- func InstallMany(st *state.State, names []string, revOpts []*RevisionOptions, userID int, ...) ([]string, []*state.TaskSet, error)
- func InstallPath(st *state.State, si *snap.SideInfo, path, instanceName, channel string, ...) (*state.TaskSet, *snap.Info, error)
- func InstallPathMany(ctx context.Context, st *state.State, sideInfos []*snap.SideInfo, ...) ([]*state.TaskSet, error)
- func InstallWithDeviceContext(ctx context.Context, st *state.State, name string, opts *RevisionOptions, ...) (*state.TaskSet, error)
- func InstalledSnaps(st *state.State) (snaps []*snapasserts.InstalledSnap, ignoreValidation map[string]bool, ...)
- func Installing(st *state.State) bool
- func KernelInfo(st *state.State, deviceCtx DeviceContext) (*snap.Info, error)
- func LinkNewBaseOrKernel(st *state.State, name string) (*state.TaskSet, error)
- func MigrateHome(st *state.State, snaps []string) ([]*state.TaskSet, error)
- func MockCheckSnapCallbacks(checks []CheckSnapCallback) (restore func())
- func MockEnforceSingleRebootForBaseKernelGadget(val bool) (restore func())
- func MockLinkSnapParticipants(ps []LinkSnapParticipant) (restore func())
- func MockOsutilCheckFreeSpace(mock func(path string, minSize uint64) error) (restore func())
- func MockRefreshCandidate(snapSetup *SnapSetup, version string) interface{}
- func ModelFromTask(task *state.Task) (*asserts.Model, error)
- func NewTaskProgressAdapterLocked(t *state.Task) progress.Meter
- func NewTaskProgressAdapterUnlocked(t *state.Task) progress.Meter
- func NumSnaps(st *state.State) (int, error)
- func Prefer(st *state.State, name string) (*state.TaskSet, error)
- func ProceedWithRefresh(st *state.State, gatingSnap string, unholdSnaps []string) error
- func RefreshCandidates(st *state.State, user *auth.UserState) ([]*snap.Info, error)
- func RegisterAffectedSnapsByAttr(attr string, f AffectedSnapsFunc)
- func RegisterAffectedSnapsByKind(kind string, f AffectedSnapsFunc)
- func Remove(st *state.State, name string, revision snap.Revision, flags *RemoveFlags) (*state.TaskSet, error)
- func RemoveManualAlias(st *state.State, alias string) (ts *state.TaskSet, instanceName string, err error)
- func RemoveMany(st *state.State, names []string, flags *RemoveFlags) ([]string, []*state.TaskSet, error)
- func ReplaceStore(state *state.State, store StoreService)
- func ResolveValidationSetsEnforcementError(ctx context.Context, st *state.State, ...) ([]*state.TaskSet, []string, error)
- func Revert(st *state.State, name string, flags Flags, fromChange string) (*state.TaskSet, error)
- func RevertToRevision(st *state.State, name string, rev snap.Revision, flags Flags, ...) (*state.TaskSet, error)
- func Set(st *state.State, name string, snapst *SnapState)
- func SetTaskSnapSetup(t *state.Task, snapsup *SnapSetup) error
- func SoftNothingRunningRefreshCheck(info *snap.Info) error
- func Switch(st *state.State, name string, opts *RevisionOptions) (*state.TaskSet, error)
- func SwitchToNewGadget(st *state.State, name string) (*state.TaskSet, error)
- func TransitionCore(st *state.State, oldName, newName string) ([]*state.TaskSet, error)
- func TryPath(st *state.State, name, path string, flags Flags) (*state.TaskSet, error)
- func Update(st *state.State, name string, opts *RevisionOptions, userID int, flags Flags) (*state.TaskSet, error)
- func UpdateBootRevisions(st *state.State) error
- func UpdateMany(ctx context.Context, st *state.State, names []string, ...) ([]string, []*state.TaskSet, error)
- func UpdateWithDeviceContext(st *state.State, name string, opts *RevisionOptions, userID int, flags Flags, ...) (*state.TaskSet, error)
- type AffectedSnapInfo
- type AffectedSnapsFunc
- type AliasConflictError
- type AliasTarget
- type BusySnapError
- type ChangeConflictError
- type CheckSnapCallback
- type DeviceContext
- type Flags
- type GateAutoRefreshAction
- type HoldDurationError
- type HoldError
- type HoldLevel
- type InsufficientSpaceError
- type LinkSnapParticipant
- type LinkSnapParticipantFunc
- type PendingSecurityState
- type Policy
- type RemoveFlags
- type RevertStatus
- type RevisionOptions
- type SnapManager
- func (m *SnapManager) CanStandby() bool
- func (m *SnapManager) EffectiveRefreshHold() (time.Time, error)
- func (m *SnapManager) Ensure() error
- func (m *SnapManager) EnsureAutoRefreshesAreDelayed(delay time.Duration) ([]*state.Change, error)
- func (m *SnapManager) LastRefresh() (time.Time, error)
- func (m *SnapManager) NextRefresh() time.Time
- func (m *SnapManager) RefreshSchedule() (string, bool, error)
- func (m *SnapManager) StartUp() error
- func (m *SnapManager) SyncCookies(st *state.State) error
- type SnapNeedsClassicError
- type SnapNeedsClassicSystemError
- type SnapNeedsDevModeError
- type SnapNotClassicError
- type SnapSetup
- type SnapState
- func (snapst *SnapState) Block() []snap.Revision
- func (snapst *SnapState) CurrentInfo() (*snap.Info, error)
- func (snapst *SnapState) CurrentSideInfo() *snap.SideInfo
- func (snapst *SnapState) InstanceName() string
- func (snapst *SnapState) IsInstalled() bool
- func (snapst *SnapState) LastIndex(revision snap.Revision) int
- func (snapst *SnapState) LocalRevision() snap.Revision
- func (snapst *SnapState) SetTrackingChannel(s string) error
- func (snapst *SnapState) SetType(typ snap.Type)
- func (snapst *SnapState) Type() (snap.Type, error)
- type StoreService
Constants ¶
const ( IgnoreHookError = 1 << iota TrackHookError UseConfigDefaults )
control flags for "Configure()"
const ( BeginEdge = state.TaskSetEdge("begin") BeforeHooksEdge = state.TaskSetEdge("before-hooks") HooksEdge = state.TaskSetEdge("hooks") BeforeMaybeRebootEdge = state.TaskSetEdge("before-maybe-reboot") MaybeRebootEdge = state.TaskSetEdge("maybe-reboot") MaybeRebootWaitEdge = state.TaskSetEdge("maybe-reboot-wait") AfterMaybeRebootWaitEdge = state.TaskSetEdge("after-maybe-reboot-wait") LastBeforeLocalModificationsEdge = state.TaskSetEdge("last-before-local-modifications") )
Variables ¶
var ( CanAutoRefresh func(st *state.State) (bool, error) CanManageRefreshes func(st *state.State) bool IsOnMeteredConnection func() (bool, error) )
hooks setup by devicestate
var AddCurrentTrackingToValidationSetsStack func(st *state.State) error
var AddSnapToQuotaGroup = func(st *state.State, snapName string, quotaGroup string) (*state.Task, error) { panic("internal error: snapstate.AddSnapToQuotaGroup is unset") }
AutoAliases allows to hook support for retrieving the automatic aliases of a snap.
var AutoRefreshAssertions func(st *state.State, userID int) error
AutoRefreshAssertions allows to hook fetching of important assertions into the Autorefresh function.
var AutomaticSnapshot func(st *state.State, instanceName string) (ts *state.TaskSet, err error)
AutomaticSnapshot allows to hook snapshot manager's AutomaticSnapshot.
var CheckHealthHook = func(st *state.State, snapName string, rev snap.Revision) *state.Task { panic("internal error: snapstate.CheckHealthHook is unset") }
var Configure = func(st *state.State, snapName string, patch map[string]interface{}, flags int) *state.TaskSet { panic("internal error: snapstate.Configure is unset") }
var (
DeviceCtx func(st *state.State, task *state.Task, providedDeviceCtx DeviceContext) (DeviceContext, error)
)
Hook setup by devicestate to pick a device context from state, optional task or an optionally pre-provided one. It's expected to return ErrNoState if a model assertion is not yet known.
var EnforceValidationSets func(*state.State, map[string]*asserts.ValidationSet, map[string]int, []*snapasserts.InstalledSnap, map[string]bool, int) error
EnforceValidationSets allows to hook enforcing validation sets without fetching them. It's hooked from assertstate.
var EnforcedValidationSets func(st *state.State, extraVss ...*asserts.ValidationSet) (*snapasserts.ValidationSets, error)
EnforcedValidationSets allows to hook getting of validation sets in enforce mode into installation/refresh/removal of snaps. It gets hooked from assertstate.
var EnsureSnapAbsentFromQuotaGroup = func(st *state.State, snap string) error { panic("internal error: snapstate.EnsureSnapAbsentFromQuotaGroup is unset") }
var ErrKernelGadgetUpdateTaskMissing = errors.New("cannot refresh kernel with change created by old snapd that is missing gadget update task")
var ErrMissingExpectedResult = fmt.Errorf("unexpectedly empty response from the server (try again later)")
var ErrNoCurrent = errors.New("snap has no current revision")
var ErrNothingToDo = errors.New("nothing to do")
var EstimateSnapshotSize func(st *state.State, instanceName string, users []string) (uint64, error)
var FinalTasks = []string{"mark-seeded", "set-model"}
FinalTasks are task kinds for final tasks in a change which means no further change work should be performed afterward, usually these are tasks that commit a full system transition.
var GetSnapDirOpts = func(st *state.State, name string) (*dirs.SnapDirOptions, error) { var snapst SnapState if err := Get(st, name, &snapst); err != nil && !errors.Is(err, state.ErrNoState) { return nil, err } hiddenOpts, err := getDirMigrationOpts(st, &snapst, nil) if err != nil { return nil, err } return hiddenOpts.getSnapDirOpts(), nil }
GetSnapDirOpts returns the options required to get the correct snap dir.
var (
RemodelingChange func(st *state.State) *state.Change
)
Hook setup by devicestate to know whether a remodeling is in progress.
var RestoreValidationSetsTracking func(st *state.State) error
var SecurityProfilesRemoveLate = func(snapName string, rev snap.Revision, typ snap.Type) error { panic("internal error: snapstate.SecurityProfilesRemoveLate is unset") }
var SetupGateAutoRefreshHook = func(st *state.State, snapName string) *state.Task { panic("internal error: snapstate.SetupAutoRefreshGatingHook is unset") }
var SetupInstallHook = func(st *state.State, snapName string) *state.Task { panic("internal error: snapstate.SetupInstallHook is unset") }
var SetupPostRefreshHook = func(st *state.State, snapName string) *state.Task { panic("internal error: snapstate.SetupPostRefreshHook is unset") }
var SetupPreRefreshHook = func(st *state.State, snapName string) *state.Task { panic("internal error: snapstate.SetupPreRefreshHook is unset") }
var SetupRemoveHook = func(st *state.State, snapName string) *state.Task { panic("internal error: snapstate.SetupRemoveHook is unset") }
var SnapServiceOptions = func(st *state.State, instanceName string, grps map[string]*quota.Group) (opts *wrappers.SnapServiceOptions, err error) { panic("internal error: snapstate.SnapServiceOptions is unset") }
SnapServiceOptions is a hook set by servicestate.
var TestingLeaveOutKernelUpdateGadgetAssets bool = false
TestingLeaveOutKernelUpdateGadgetAssets can be used to simulate an upgrade from a broken snapd that does not generate a "update-gadget-assets" task. See LP:#1940553
var ValidateRefreshes func(st *state.State, refreshes []*snap.Info, ignoreValidation map[string]bool, userID int, deviceCtx DeviceContext) (validated []*snap.Info, err error)
ValidateRefreshes allows to hook validation into the handling of refresh candidates.
Functions ¶
func ActiveInfos ¶
ActiveInfos returns information about all active snaps.
func AddCheckSnapCallback ¶
func AddCheckSnapCallback(check CheckSnapCallback)
AddCheckSnapCallback installs a callback to check a snap for installation or refresh.
func AddGadgetAssetsTasks ¶
AddGadgetAssetsTasks creates the same tasks as SwitchToNewGadget but adds them to the provided task set.
func AddLinkNewBaseOrKernel ¶
AddLinkNewBaseOrKernel creates the same tasks as LinkNewBaseOrKernel but adds them to the provided task set.
func AddLinkSnapParticipant ¶
func AddLinkSnapParticipant(p LinkSnapParticipant)
AddLinkSnapParticipant adds a participant in the link/unlink operations.
func AffectedByRefreshCandidates ¶
func AffectedByRefreshCandidates(st *state.State) (map[string]*AffectedSnapInfo, error)
AffectedByRefreshCandidates returns information about all snaps affected by current refresh-candidates in the state.
func AffectingSnapsForAffectedByRefreshCandidates ¶
func AffectingSnapsForAffectedByRefreshCandidates(st *state.State, affectedSnap string) ([]string, error)
AffectingSnapsForAffectedByRefreshCandidates returns the list of all snaps affecting affectedSnap (i.e. a gating snap), based on upcoming updates from refresh-candidates.
func All ¶
All retrieves return a map from name to SnapState for all current snaps in the system state.
func AutoRefresh ¶
AutoRefresh is the wrapper that will do a refresh of all the installed snaps on the system. In addition to that it will also refresh important assertions.
func AutoRefreshForGatingSnap ¶
AutoRefreshForGatingSnap triggers an auto-refresh change for all snaps held by the given gating snap. This should only be called if the gate-auto-refresh-hook feature is enabled. TODO: this should be restricted as it doesn't take refresh timer/refresh hold into account.
func BootBaseInfo ¶
BootBaseInfo finds the boot base snap's info for the given device context.
func CheckChangeConflict ¶
CheckChangeConflict ensures that for the given instanceName no other changes that alters the snap (like remove, install, refresh) are in progress. It also ensures that snapst (if not nil) did not get modified. If a conflict is detected an error is returned.
func CheckChangeConflictMany ¶
CheckChangeConflictMany ensures that for the given instanceNames no other changes that alters the snaps (like remove, install, refresh) are in progress. If a conflict is detected an error is returned.
It's like CheckChangeConflict, but for multiple snaps, and does not check snapst.
func CheckChangeConflictRunExclusively ¶
CheckChangeConflictRunExclusively checks for conflicts with a new change which must be run when no other changes are running.
func ConfigDefaults ¶
func ConfigDefaults(st *state.State, deviceCtx DeviceContext, snapName string) (map[string]interface{}, error)
ConfigDefaults returns the configuration defaults for the snap as specified in the gadget for the given device context. If gadget is absent or the snap has no snap-id it returns ErrNoState.
func ConfigureSnap ¶
ConfigureSnap returns a set of tasks to configure snapName as done during installation/refresh.
func CurrentInfo ¶
CurrentInfo returns the information about the current revision of a snap with the given name.
func DisableAllAliases ¶
DisableAllAliases disables all aliases of a snap, removing all manual ones.
func FinishRestart ¶
FinishRestart will return a Retry error if there is a pending restart and a real error if anything went wrong (like a rollback across restarts). For snapd snap updates this will also rerun wrappers generation to fully catch up with any change.
func FinishTaskWithRestart ¶
func FinishTaskWithRestart(task *state.Task, status state.Status, rt restart.RestartType, rebootInfo *boot.RebootInfo) error
FinishTaskWithRestart will finish a task that needs a restart, by setting its status and requesting a restart. It should usually be invoked returning its result immediately from the caller. TODO not implemented yet: we will return an error in the future if we want to hold the restart. We will also add post hold status and boot id information in the task in that case.
func GadgetConnections ¶
func GadgetConnections(st *state.State, deviceCtx DeviceContext) ([]gadget.Connection, error)
GadgetConnections returns the interface connection instructions specified in the gadget for the given device context. If gadget is absent it returns ErrNoState.
func GadgetInfo ¶
GadgetInfo finds the gadget snap's info for the given device context.
func HardNothingRunningRefreshCheck ¶
HardNothingRunningRefreshCheck looks if there are any undesired processes alive.
The check is designed to run late in the refresh pipeline, after stopping snap services. At this point non-enduring services should be stopped, hooks should no longer run, and applications should be barred from running externally (e.g. by using a new inhibition mechanism for snap run).
The check fails if any process belonging to the snap, apart from services and snaps that explicitly allow refreshes, is still alive. If a snap is busy it cannot be refreshed and the refresh process is aborted.
Apart from ignoring services, the check allows apps that want not to block refresh to continue executing.
func HeldSnaps ¶
HeldSnaps returns all snaps that are held at the given level or at more restricting ones and shouldn't be refreshed.
func HoldRefresh ¶
func HoldRefresh(st *state.State, level HoldLevel, gatingSnap string, holdDuration time.Duration, affectingSnaps ...string) (time.Duration, error)
HoldRefresh marks affectingSnaps as held for refresh for up to holdTime. HoldTime of zero denotes maximum allowed hold time. Holding fails if not all snaps can be held, in that case HoldError is returned and it contains the details of snaps that prevented holding. On success the function returns the remaining hold time. The remaining hold time is the minimum of the remaining hold time for all affecting snaps. A hold level can be specified indicating which operations are affected by the hold.
func HoldRefreshesBySystem ¶
func HoldRefreshesBySystem(st *state.State, level HoldLevel, holdTime string, holdSnaps []string) error
HoldRefreshesBySystem is used to hold snaps by the sys admin (denoted by the "system" holding snap). HoldTime can be "forever" to denote an indefinite hold or any RFC3339 timestamp. A hold level can be specified indicating which operations are affected by the hold.
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 InjectAutoConnect ¶
func InjectTasks ¶
InjectTasks makes all the halt tasks of the mainTask wait for extraTasks; extraTasks join the same lane and change as the mainTask.
func Install ¶
func Install(ctx context.Context, st *state.State, name string, opts *RevisionOptions, userID int, flags Flags) (*state.TaskSet, error)
Install returns a set of tasks for installing a snap. Note that the state must be locked by the caller.
The returned TaskSet will contain a LastBeforeLocalModificationsEdge identifying the last task before the first task that introduces system modifications.
func InstallMany ¶
func InstallMany(st *state.State, names []string, revOpts []*RevisionOptions, userID int, flags *Flags) ([]string, []*state.TaskSet, error)
InstallMany installs everything from the given list of names. When specifying revisions, the checks against enforced validation sets are bypassed. Note that the state must be locked by the caller.
func InstallPath ¶
func InstallPath(st *state.State, si *snap.SideInfo, path, instanceName, channel string, flags Flags) (*state.TaskSet, *snap.Info, error)
InstallPath returns a set of tasks for installing a snap from a file path and the snap.Info for the given snap.
Note that the state must be locked by the caller. The provided SideInfo can contain just a name which results in a local revision and sideloading, or full metadata in which case it the snap will appear as installed from the store.
func InstallPathMany ¶
func InstallPathMany(ctx context.Context, st *state.State, sideInfos []*snap.SideInfo, paths []string, userID int, flags *Flags) ([]*state.TaskSet, error)
InstallPathMany returns a set of tasks for installing snaps from a file paths and snap.Infos.
The state must be locked by the caller. The provided SideInfos can contain just a name which results in a local revision and sideloading, or full metadata in which case the snaps will appear as installed from the store.
func InstallWithDeviceContext ¶
func InstallWithDeviceContext(ctx context.Context, st *state.State, name string, opts *RevisionOptions, userID int, flags Flags, deviceCtx DeviceContext, fromChange string) (*state.TaskSet, error)
InstallWithDeviceContext returns a set of tasks for installing a snap. It will query for the snap with the given deviceCtx. Note that the state must be locked by the caller.
The returned TaskSet will contain a LastBeforeLocalModificationsEdge identifying the last task before the first task that introduces system modifications.
func InstalledSnaps ¶
func InstalledSnaps(st *state.State) (snaps []*snapasserts.InstalledSnap, ignoreValidation map[string]bool, err error)
InstalledSnaps returns the list of all installed snaps suitable for ValidationSets checks.
func Installing ¶
Installing returns whether there's an in-progress installation.
func KernelInfo ¶
KernelInfo finds the kernel snap's info for the given device context.
func LinkNewBaseOrKernel ¶
LinkNewBaseOrKernel creates a new task set with prepare/link-snap, and additionally update-gadget-assets for the kernel snap, tasks for a remodel.
func MigrateHome ¶
MigrateHome migrates a set of snaps to use a ~/Snap sub-directory as HOME. The state must be locked by the caller.
func MockCheckSnapCallbacks ¶
func MockCheckSnapCallbacks(checks []CheckSnapCallback) (restore func())
func MockEnforceSingleRebootForBaseKernelGadget ¶
func MockEnforceSingleRebootForBaseKernelGadget(val bool) (restore func())
func MockLinkSnapParticipants ¶
func MockLinkSnapParticipants(ps []LinkSnapParticipant) (restore func())
MockLinkSnapParticipants replaces the list of link snap participants for testing.
func MockRefreshCandidate ¶
for testing outside of snapstate
func ModelFromTask ¶
ModelFromTask returns a model assertion through the device context for the task.
func NewTaskProgressAdapterLocked ¶
NewTaskProgressAdapterUnlocked creates an adapter of the task into a progress.Meter to use while the state is locked
func NewTaskProgressAdapterUnlocked ¶
NewTaskProgressAdapterUnlocked creates an adapter of the task into a progress.Meter to use while the state is unlocked
func Prefer ¶
Prefer enables all aliases of a snap in preference to conflicting aliases of other snaps whose aliases will be disabled (removed for manual ones).
func ProceedWithRefresh ¶
ProceedWithRefresh unblocks a set of snaps held by gatingSnap for refresh. If no snaps are specified, all snaps held by gatingSnap are unblocked. This should be called for --proceed on the gatingSnap.
func RefreshCandidates ¶
RefreshCandidates gets a list of candidates for update Note that the state must be locked by the caller.
func RegisterAffectedSnapsByAttr ¶
func RegisterAffectedSnapsByAttr(attr string, f AffectedSnapsFunc)
RegisterAffectedSnapsByAttr registers an AffectedSnapsFunc for returning the affected snaps for tasks sporting the given identifying attribute, to use in conflicts detection.
func RegisterAffectedSnapsByKind ¶
func RegisterAffectedSnapsByKind(kind string, f AffectedSnapsFunc)
RegisterAffectedSnapsByKind registers an AffectedSnapsFunc for returning the affected snaps for tasks of the given kind, to use in conflicts detection. Whenever possible using RegisterAffectedSnapsByAttr should be preferred.
func Remove ¶
func Remove(st *state.State, name string, revision snap.Revision, flags *RemoveFlags) (*state.TaskSet, error)
Remove returns a set of tasks for removing snap. Note that the state must be locked by the caller.
func RemoveManualAlias ¶
func RemoveManualAlias(st *state.State, alias string) (ts *state.TaskSet, instanceName string, err error)
RemoveManualAlias removes a manual alias.
func RemoveMany ¶
func RemoveMany(st *state.State, names []string, flags *RemoveFlags) ([]string, []*state.TaskSet, error)
RemoveMany removes everything from the given list of names. 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 ResolveValidationSetsEnforcementError ¶
func ResolveValidationSetsEnforcementError(ctx context.Context, st *state.State, valErr *snapasserts.ValidationSetsValidationError, pinnedSeqs map[string]int, userID int) ([]*state.TaskSet, []string, error)
ResolveValidationSetsEnforcementError installs and updates snaps in order to meet the validation set constraints reported in the ValidationSetsValidationError..
func Revert ¶
Revert returns a set of tasks for reverting to the previous version of the snap. Note that the state must be locked by the caller.
func RevertToRevision ¶
func Set ¶
Set sets the SnapState of the given snap, overwriting any earlier state. Note that a SnapState with an empty Sequence will be treated as if snapst was nil and name will be deleted from the state.
func SetTaskSnapSetup ¶
SetTaskSnapSetup writes the given SnapSetup to the provided task's snap-setup-task Task, or to the task itself if the task does not have a snap-setup-task (i.e. it _is_ the snap-setup-task)
func SoftNothingRunningRefreshCheck ¶
SoftNothingRunningRefreshCheck looks if there are at most only service processes alive.
The check is designed to run early in the refresh pipeline. Before downloading or stopping services for the update, we can check that only services or snaps that explicitly allow refreshes are running, that is, that no non-service apps or hooks are currently running.
Since services are stopped during the update this provides a good early precondition check. The check is also deliberately racy as existing snap commands can fork new processes or existing processes can die. After the soft check passes the user is free to start snap applications and block the hard check.
Apart from ignoring services, the check allows apps that want not to block refresh to continue executing.
func SwitchToNewGadget ¶
LinkNewBaseOrKernel creates a new task set with prepare/update-gadget-assets/update-gadget-cmdline tasks for the gadget snap, for remodel.
func TransitionCore ¶
TransitionCore transitions from an old core snap name to a new core snap name. It is used for the ubuntu-core -> core transition (that is not just a rename because the two snaps have different snapIDs)
Note that this function makes some assumptions like: - no aliases setup for both snaps - no data needs to be copied - all interfaces are absolutely identical on both new and old Do not use this as a general way to transition from snap A to snap B.
func TryPath ¶
TryPath returns a set of tasks for trying a snap from a file path. Note that the state must be locked by the caller.
func Update ¶
func Update(st *state.State, name string, opts *RevisionOptions, userID int, flags Flags) (*state.TaskSet, error)
Update initiates a change updating a snap. Note that the state must be locked by the caller.
The returned TaskSet can contain a LastBeforeLocalModificationsEdge identifying the last task before the first task that introduces system modifications. If no such edge is set, then none of the tasks introduce system modifications.
func UpdateBootRevisions ¶
UpdateBootRevisions synchronizes the active kernel and OS snap versions with the versions that actually booted. This is needed because a system may install "os=v2" but that fails to boot. The bootloader fallback logic will revert to "os=v1" but on the filesystem snappy still has the "active" version set to "v2" which is misleading. This code will check what kernel/os booted and set those versions active. To do this it creates a Change and kicks start it directly.
func UpdateMany ¶
func UpdateMany(ctx context.Context, st *state.State, names []string, revOpts []*RevisionOptions, userID int, flags *Flags) ([]string, []*state.TaskSet, error)
UpdateMany updates everything from the given list of names that the store says is updateable. If the list is empty, update everything. Note that the state must be locked by the caller.
func UpdateWithDeviceContext ¶
func UpdateWithDeviceContext(st *state.State, name string, opts *RevisionOptions, userID int, flags Flags, deviceCtx DeviceContext, fromChange string) (*state.TaskSet, error)
UpdateWithDeviceContext initiates a change updating a snap. It will query for the snap with the given deviceCtx. Note that the state must be locked by the caller.
The returned TaskSet can contain a LastBeforeLocalModificationsEdge identifying the last task before the first task that introduces system modifications. If no such edge is set, then none of the tasks introduce system modifications.
Types ¶
type AffectedSnapInfo ¶
type AffectedSnapsFunc ¶
An AffectedSnapsFunc returns a list of affected snap names for the given supported task.
type AliasConflictError ¶
type AliasConflictError struct { Snap string Alias string Reason string Conflicts map[string][]string }
func (*AliasConflictError) Error ¶
func (e *AliasConflictError) Error() string
type AliasTarget ¶
type AliasTarget struct { Manual string `json:"manual,omitempty"` Auto string `json:"auto,omitempty"` }
AliasTarget carries the targets of an alias in the context of snap. If Manual is set it is the target of an enabled manual alias. Auto is set to the target for an automatic alias, enabled or disabled depending on the automatic aliases flag state.
func (*AliasTarget) Effective ¶
func (at *AliasTarget) Effective(autoDisabled bool) string
Effective returns the target to use considering whether automatic aliases are disabled for the whole snap (autoDisabled), returns "" if the alias is disabled.
type BusySnapError ¶
BusySnapError indicates that snap has apps or hooks running and cannot refresh.
func (*BusySnapError) Error ¶
func (err *BusySnapError) Error() string
Error formats an error string describing what is running.
func (*BusySnapError) PendingSnapRefreshInfo ¶
func (err *BusySnapError) PendingSnapRefreshInfo() *userclient.PendingSnapRefreshInfo
PendingSnapRefreshInfo computes information necessary to perform user notification of postponed refresh of a snap, based on the information about snap "business".
The returned value contains the instance name of the snap as well as, if possible, information relevant for desktop notification services, such as application name and the snapd-generated desktop file name.
func (BusySnapError) Pids ¶
func (err BusySnapError) Pids() []int
Pids returns the set of process identifiers that are running.
Since this list is a snapshot it should be only acted upon if there is an external synchronization system applied (e.g. all processes are frozen) at the time the snapshot was taken.
The list is intended for snapd to forcefully kill all processes for a forced refresh scenario.
type ChangeConflictError ¶
type ChangeConflictError struct { Snap string ChangeKind string // a Message is optional, otherwise one is composed from the other information Message string // ChangeID can optionally be set to the ID of the change with which the operation conflicts ChangeID string }
ChangeConflictError represents an error because of snap conflicts between changes.
func (*ChangeConflictError) Error ¶
func (e *ChangeConflictError) Error() string
func (*ChangeConflictError) Is ¶
func (e *ChangeConflictError) Is(err error) bool
type CheckSnapCallback ¶
type CheckSnapCallback func(st *state.State, snap, curSnap *snap.Info, snapf snap.Container, flags Flags, deviceCtx DeviceContext) error
CheckSnapCallback defines callbacks for checking a snap for installation or refresh.
type DeviceContext ¶
type DeviceContext interface { // GroundContext returns a context corresponding to the // original model of the device for a remodel, or a context // equivalent to this one otherwise, except in both cases // Store cannot be used and must panic. GroundContext() DeviceContext // Store returns the store service to use under this context or nil if the snapstate store is appropriate. Store() StoreService // ForRemodeling returns whether this context is for use over a remodeling. ForRemodeling() bool // SystemMode returns the system mode (run,install,recover,...). SystemMode() string // DeviceContext should be usable as snap.Device snap.Device }
A DeviceContext provides for operating as a given device and with its brand store either for normal operation or over a remodeling.
func DeviceCtxFromState ¶
func DeviceCtxFromState(st *state.State, providedDeviceCtx DeviceContext) (DeviceContext, error)
DeviceCtxFromState returns a device context if a model assertion is available. Otherwise it returns a ChangeConflictError about being too early unless an pre-provided DeviceContext is passed in.
func DevicePastSeeding ¶
func DevicePastSeeding(st *state.State, providedDeviceCtx DeviceContext) (DeviceContext, error)
DevicePastSeeding returns a device context if a model assertion is available and the device is seeded, at that point the device store is known and seeding done. Otherwise it returns a ChangeConflictError about being too early unless a pre-provided DeviceContext is passed in. It will again return a conflict error during remodeling unless the providedDeviceCtx is for it.
type Flags ¶
type Flags struct { // DevMode switches confinement to non-enforcing mode. DevMode bool `json:"devmode,omitempty"` // JailMode is set when the user has requested confinement // always be enforcing, even if the snap requests otherwise. JailMode bool `json:"jailmode,omitempty"` // Classic is set when the user has consented to install a snap with // classic confinement and the snap declares that confinement. Classic bool `json:"classic,omitempty"` // TryMode is set for snaps installed to try directly from a local directory. TryMode bool `json:"trymode,omitempty"` // Revert flags the SnapSetup as coming from a revert Revert bool `json:"revert,omitempty"` // If reverting, set this status for the reverted revision. RevertStatus RevertStatus `json:"revert-status,omitempty"` // RemoveSnapPath is used via InstallPath to flag that the file passed in is // temporary and should be removed RemoveSnapPath bool `json:"remove-snap-path,omitempty"` // IgnoreValidation is set when the user requested as one-off // to ignore refresh control validation. IgnoreValidation bool `json:"ignore-validation,omitempty"` // IgnoreRunning is set to indicate that running apps or hooks should be // ignored. IgnoreRunning bool `json:"ignore-running,omitempty"` // Required is set to mark that a snap is required // and cannot be removed Required bool `json:"required,omitempty"` // SkipConfigure is used with InstallPath to flag that creating a task // running the configure hook should be skipped. SkipConfigure bool `json:"skip-configure,omitempty"` // SkipKernelExtraction is used with InstallPath to flag that the // kernel extraction should be skipped. This is useful during seeding. SkipKernelExtraction bool `json:"skip-kernel-extraction,omitempty"` // Unaliased is set to request that no automatic aliases are created // installing the snap. Unaliased bool `json:"unaliased,omitempty"` // Amend allows refreshing out of a snap unknown to the store // and into one that is known. Amend bool `json:"amend,omitempty"` // IsAutoRefresh is true if the snap is currently auto-refreshed IsAutoRefresh bool `json:"is-auto-refresh,omitempty"` // NoReRefresh prevents refresh from adding epoch-hopping // re-refresh tasks. This allows refresh to work offline, as // long as refresh assets are cached. NoReRefresh bool `json:"no-rerefresh,omitempty"` // RequireTypeBase is set to mark that a snap needs to be of type: base, // otherwise installation fails. RequireTypeBase bool `json:"require-base-type,omitempty"` // ApplySnapDevMode overrides allowing a snap to be installed if it is in // devmode confinement. This is set to true for currently only UC20 model // grades dangerous for all snaps during first boot, where we always allow // devmode snaps to be installed, and installed with devmode confinement // turned on. // This may eventually be set for specific snaps mentioned in the model // assertion for non-dangerous grade models too. ApplySnapDevMode bool `json:"apply-snap-devmode,omitempty"` // Transaction is set to "all-snaps" to request that the set of // snaps is transactionally installed/updated jointly, or to // "per-snap" in case each snap is treated in a different // transaction. Transaction client.TransactionType `json:"transaction,omitempty"` // QuotaGroupName represents the quota group a snap should be assigned // to during installation. QuotaGroupName string `json:"quota-group,omitempty"` // Lane is the lane that tasks should join if Transaction is set to "all-snaps". Lane int `json:"lane,omitempty"` }
Flags are used to pass additional flags to operations and to keep track of snap modes.
func (Flags) DevModeAllowed ¶
DevModeAllowed returns whether a snap can be installed with devmode confinement (either set or overridden).
func (Flags) ForSnapSetup ¶
ForSnapSetup returns a copy of the Flags with the flags that we don't need in SnapSetup set to false (so they're not serialized).
type GateAutoRefreshAction ¶
type GateAutoRefreshAction int
gateAutoRefreshAction represents the action executed by snapctl refresh --hold or --proceed and stored in the context of gate-auto-refresh hook.
const ( GateAutoRefreshProceed GateAutoRefreshAction = iota GateAutoRefreshHold )
type HoldDurationError ¶
HoldDurationError contains the that error prevents requested hold, along with hold time that's left (if any).
func (*HoldDurationError) Error ¶
func (h *HoldDurationError) Error() string
type HoldError ¶
type HoldError struct {
SnapsInError map[string]HoldDurationError
}
HoldError contains the details of snaps that cannot to be held.
type HoldLevel ¶
type HoldLevel int
HoldLevel determines which refresh operations are controlled by the hold. Levels are ordered and higher levels imply lower ones.
type InsufficientSpaceError ¶
type InsufficientSpaceError struct { // Path is the filesystem path checked for available disk space Path string // Snaps affected by the failing operation Snaps []string // Kind of the change that failed ChangeKind string // Message is optional, otherwise one is composed from the other information Message string }
InsufficientSpaceError represents an error where there is not enough disk space to perform an operation.
func (*InsufficientSpaceError) Error ¶
func (e *InsufficientSpaceError) Error() string
type LinkSnapParticipant ¶
type LinkSnapParticipant interface { // SnapLinkageChanged is called when a snap is linked or unlinked. // The error is only logged and does not stop the task it is used from. SnapLinkageChanged(st *state.State, instanceName string) error }
LinkSnapParticipant is an interface for interacting with snap link/unlink operations.
Unlike the interface for a task handler, only one notification method is used. The method notifies a participant that linkage of a snap has changed. This method is invoked in link-snap, unlink-snap, the undo path of those methods and the undo handler for link-snap.
In all cases it is invoked after all other operations are completed but before the task completes.
type LinkSnapParticipantFunc ¶
LinkSnapParticipantFunc is an adapter from function to LinkSnapParticipant.
func (LinkSnapParticipantFunc) SnapLinkageChanged ¶
func (f LinkSnapParticipantFunc) SnapLinkageChanged(st *state.State, instanceName string) error
type PendingSecurityState ¶
type PendingSecurityState struct { // SideInfo of the revision for which security profiles are or // should be set up if any. SideInfo *snap.SideInfo `json:"side-info,omitempty"` }
PendingSecurityState holds information about snaps that have their security profiles set up but are not active.
type Policy ¶
type Policy interface { // CanRemove verifies that a snap can be removed. // If rev is not unset, check for removing only that revision. CanRemove(st *state.State, snapst *SnapState, rev snap.Revision, dev snap.Device) error }
Policy encapsulates behaviour that varies with the details of a snap installation, like the model assertion or the type of snap involved in an operation. Rather than have a forest of `if`s looking at type, model, etc, we move it to Policy and look it up.
type RemoveFlags ¶
type RemoveFlags struct { // Remove the snap without creating snapshot data Purge bool }
RemoveFlags are used to pass additional flags to the Remove operation.
type RevertStatus ¶
type RevertStatus int
RevertStatus is a status of a snap revert; anything other than DefaultStatus denotes a reverted snap revision that needs special handling in terms of refresh blocking.
const ( DefaultStatus RevertStatus = iota NotBlocked )
type RevisionOptions ¶
type RevisionOptions struct { Channel string Revision snap.Revision ValidationSets []snapasserts.ValidationSetKey CohortKey string LeaveCohort bool }
RevisionOptions control the selection of a snap revision.
type SnapManager ¶
type SnapManager struct {
// contains filtered or unexported fields
}
SnapManager is responsible for the installation and removal of snaps.
func Manager ¶
func Manager(st *state.State, runner *state.TaskRunner) (*SnapManager, error)
Manager returns a new snap manager.
func (*SnapManager) CanStandby ¶
func (m *SnapManager) CanStandby() bool
func (*SnapManager) EffectiveRefreshHold ¶
func (m *SnapManager) EffectiveRefreshHold() (time.Time, error)
EffectiveRefreshHold returns the time until to which refreshes are held if refresh.hold configuration is set. The caller should be holding the state lock.
func (*SnapManager) Ensure ¶
func (m *SnapManager) Ensure() error
Ensure implements StateManager.Ensure.
func (*SnapManager) EnsureAutoRefreshesAreDelayed ¶
EnsureAutoRefreshesAreDelayed will delay refreshes for the specified amount of time, as well as return any active auto-refresh changes that are currently not ready so that the client can wait for those.
func (*SnapManager) LastRefresh ¶
func (m *SnapManager) LastRefresh() (time.Time, error)
LastRefresh returns the time the last snap update. The caller should be holding the state lock.
func (*SnapManager) NextRefresh ¶
func (m *SnapManager) NextRefresh() time.Time
NextRefresh returns the time the next update of the system's snaps will be attempted. The caller should be holding the state lock.
func (*SnapManager) RefreshSchedule ¶
func (m *SnapManager) RefreshSchedule() (string, bool, error)
RefreshSchedule returns the current refresh schedule as a string suitable for display to a user and a flag indicating whether the schedule is a legacy one. The caller should be holding the state lock.
func (*SnapManager) StartUp ¶
func (m *SnapManager) StartUp() error
StartUp implements StateStarterUp.Startup.
func (*SnapManager) SyncCookies ¶
func (m *SnapManager) SyncCookies(st *state.State) error
SyncCookies creates snap cookies for snaps that are missing them (may be the case for snaps installed before the feature of running snapctl outside of hooks was introduced, leading to a warning from snap-confine). It is the caller's responsibility to lock state before calling this function.
type SnapNeedsClassicError ¶
type SnapNeedsClassicError struct {
Snap string
}
func (*SnapNeedsClassicError) Error ¶
func (e *SnapNeedsClassicError) Error() string
type SnapNeedsClassicSystemError ¶
type SnapNeedsClassicSystemError struct {
Snap string
}
func (*SnapNeedsClassicSystemError) Error ¶
func (e *SnapNeedsClassicSystemError) Error() string
type SnapNeedsDevModeError ¶
type SnapNeedsDevModeError struct {
Snap string
}
func (*SnapNeedsDevModeError) Error ¶
func (e *SnapNeedsDevModeError) Error() string
type SnapNotClassicError ¶
type SnapNotClassicError struct {
Snap string
}
func (*SnapNotClassicError) Error ¶
func (e *SnapNotClassicError) Error() string
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"` Base string `json:"base,omitempty"` Type snap.Type `json:"type,omitempty"` // PlugsOnly indicates whether the relevant revisions for the // operation have only plugs (#plugs >= 0), and absolutely no // slots (#slots == 0). PlugsOnly bool `json:"plugs-only,omitempty"` CohortKey string `json:"cohort-key,omitempty"` // FIXME: implement rename of this as suggested in // https://gitee.com/mysnapcore/mysnapd/pull/4103#discussion_r169569717 // // Prereq is a list of snap-names that need to get installed // together with this snap. Typically used when installing // content-snaps with default-providers. Should be set along // with PrereqContentAttrs (and match its keys) for forward-compatibility. Prereq []string `json:"prereq,omitempty"` // PrereqContentAttrs maps default providers snap names to the content they provide. PrereqContentAttrs map[string][]string `json:"prereq-content-attrs,omitempty"` Flags SnapPath string `json:"snap-path,omitempty"` ExpectedProvenance string `json:"provenance,omitempty"` DownloadInfo *snap.DownloadInfo `json:"download-info,omitempty"` SideInfo *snap.SideInfo `json:"side-info,omitempty"` // InstanceKey is set by the user during installation and differs for // each instance of given snap InstanceKey string `json:"instance-key,omitempty"` // MigratedHidden is set if the user's snap dir has been migrated to // ~/.snap/data in the current change. So a 'false' value doesn't mean the // dir isn't hidden. This prevents us from always having to set it. MigratedHidden bool `json:"migrated-hidden,omitempty"` // UndidHiddenMigration is set if the migration to a hidden snap dir was undone in // the current change. A 'false' value doesn't mean the dir is hidden, just // that it wasn't exposed in this change. UndidHiddenMigration bool `json:"migrated-exposed,omitempty"` // MigratedToExposedHome is set if the ~/Snap dir was created and initialized in the // current change. A 'false' value doesn't that ~/Snap doesn't exist, just // that it wasn't create in the current change. MigratedToExposedHome bool `json:"migrated-exposed-home,omitempty"` // RemovedExposedHome is set if the ~/Snap sub directory was removed. This // should only happen when undoing the creation of that directory in the same // (failed) change. To disable usage of the exposed home in a change after it // was created, SnapSetup.DisableExposedHome should be used. RemovedExposedHome bool `json:"removed-exposed-home,omitempty"` // EnableExposedHome is set if the ~/Snap sub directory already exists and // should be used. EnableExposedHome bool `json:"enable-exposed-home,omitempty"` // DisabledExposedHome is set if ~/Snap should not be used as $HOME. DisableExposedHome bool `json:"disable-exposed-home,omitempty"` // contains filtered or unexported fields }
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 task.
func (*SnapSetup) InstanceName ¶
type SnapState ¶
type SnapState struct { SnapType string `json:"type"` // Use Type and SetType Sequence []*snap.SideInfo `json:"sequence"` // RevertStatus maps revisions to RevertStatus for revisions that // need special handling in Block(). RevertStatus map[int]RevertStatus `json:"revert-status,omitempty"` Active bool `json:"active,omitempty"` // LastActiveDisabledServices is a list of services that were disabled in // this snap when it was last active - i.e. when it was disabled, before // it was reverted, or before a refresh happens. // It is set during unlink-snap and unlink-current-snap and reset during // link-snap since it is only meant to be saved when snapd needs to remove // systemd units. // Note that to handle potential service renames, only services that exist // in the snap are removed from this list on link-snap, so that we can // remember services that were disabled in another revision and then renamed // or otherwise removed from the snap in a future refresh. LastActiveDisabledServices []string `json:"last-active-disabled-services,omitempty"` // tracking services enabled and disabled by hooks ServicesEnabledByHooks []string `json:"services-enabled-by-hooks,omitempty"` ServicesDisabledByHooks []string `json:"services-disabled-by-hooks,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"` TrackingChannel string `json:"channel,omitempty"` Flags // aliases, see aliasesv2.go Aliases map[string]*AliasTarget `json:"aliases,omitempty"` AutoAliasesDisabled bool `json:"auto-aliases-disabled,omitempty"` AliasesPending bool `json:"aliases-pending,omitempty"` // UserID of the user requesting the install UserID int `json:"user-id,omitempty"` // InstanceKey is set by the user during installation and differs for // each instance of given snap InstanceKey string `json:"instance-key,omitempty"` CohortKey string `json:"cohort-key,omitempty"` // RefreshInhibitedime records the time when the refresh was first // attempted but inhibited because the snap was busy. This value is // reset on each successful refresh. RefreshInhibitedTime *time.Time `json:"refresh-inhibited-time,omitempty"` // LastRefreshTime records the time when the snap was last refreshed. LastRefreshTime *time.Time `json:"last-refresh-time,omitempty"` // MigratedHidden is set if the user's snap dir has been migrated // to ~/.snap/data. MigratedHidden bool `json:"migrated-hidden,omitempty"` // MigratedToExposedHome is set if ~/Snap was created and initialized. If set, ~/Snap // should be used as the snap's HOME. MigratedToExposedHome bool `json:"migrated-exposed-home,omitempty"` // PendingSecurity tracks information about snaps that have // their security profiles set up but are not active. // It is managed by ifacestate. PendingSecurity *PendingSecurityState `json:"pending-security,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:] and considering special casing resulting from snapst.RevertStatus map.
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) InstanceName ¶
func (*SnapState) IsInstalled ¶
IsInstalled returns whether the snap is installed, i.e. snapst represents an installed snap with Current revision set.
func (*SnapState) LastIndex ¶
LastIndex returns the last index of the given revision in the snapst.Sequence
func (*SnapState) LocalRevision ¶
LocalRevision returns the "latest" local revision. Local revisions start at -1 and are counted down.
func (*SnapState) SetTrackingChannel ¶
type StoreService ¶
type StoreService interface { EnsureDeviceSession() error SnapInfo(ctx context.Context, spec store.SnapSpec, user *auth.UserState) (*snap.Info, error) SnapExists(ctx context.Context, spec store.SnapSpec, user *auth.UserState) (naming.SnapRef, *channel.Channel, error) Find(ctx context.Context, search *store.Search, user *auth.UserState) ([]*snap.Info, error) SnapAction(ctx context.Context, currentSnaps []*store.CurrentSnap, actions []*store.SnapAction, assertQuery store.AssertionQuery, user *auth.UserState, opts *store.RefreshOptions) ([]store.SnapActionResult, []store.AssertionResult, error) Sections(ctx context.Context, user *auth.UserState) ([]string, error) WriteCatalogs(ctx context.Context, names io.Writer, adder store.SnapAdder) error Download(context.Context, string, string, *snap.DownloadInfo, progress.Meter, *auth.UserState, *store.DownloadOptions) error DownloadStream(context.Context, string, *snap.DownloadInfo, int64, *auth.UserState) (r io.ReadCloser, status int, err error) Assertion(assertType *asserts.AssertionType, primaryKey []string, user *auth.UserState) (asserts.Assertion, error) SeqFormingAssertion(assertType *asserts.AssertionType, sequenceKey []string, sequence int, user *auth.UserState) (asserts.Assertion, error) DownloadAssertions([]string, *asserts.Batch, *auth.UserState) error SuggestedCurrency() string Buy(options *client.BuyOptions, user *auth.UserState) (*client.BuyResult, error) ReadyToBuy(*auth.UserState) error ConnectivityCheck() (map[string]bool, error) CreateCohorts(context.Context, []string) (map[string]string, error) LoginUser(username, password, otp string) (string, string, error) UserInfo(email string) (userinfo *store.User, err error) }
A StoreService can find, list available updates and download snaps.
func Store ¶
func Store(st *state.State, deviceCtx DeviceContext) StoreService
Store returns the store service provided by the optional device context or the one used by the snapstate package if the former has no override.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package backend implements the low-level primitives to manage the snaps and their installation on disk.
|
Package backend implements the low-level primitives to manage the snaps and their installation on disk. |
Package policy implements fine grained decision-making for snapstate
|
Package policy implements fine grained decision-making for snapstate |