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 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 CheckExpectedRestart(st *state.State) error
- func CheckUpdateKernelCommandLineConflict(st *state.State, ignoreChangeID string) error
- func ComponentInfoFromComponentSetup(compsup *ComponentSetup, info *snap.Info) (*snap.ComponentInfo, 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 Download(ctx context.Context, st *state.State, name string, blobDirectory string, ...) (*state.TaskSet, *snap.Info, 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 HasSnapOfType(st *state.State, snapType snap.Type) (bool, error)
- func HeldSnaps(st *state.State, level HoldLevel) (map[string][]string, 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 InstallComponentPath(st *state.State, csi *snap.ComponentSideInfo, info *snap.Info, path string, ...) (*state.TaskSet, error)
- func InstallComponents(ctx context.Context, st *state.State, names []string, info *snap.Info, ...) ([]*state.TaskSet, error)
- func InstallMany(st *state.State, names []string, revOpts []*RevisionOptions, userID int, ...) ([]string, []*state.TaskSet, error)
- func InstallOne(ctx context.Context, st *state.State, goal InstallGoal, opts Options) (*snap.Info, *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 InstallPathWithDeviceContext(st *state.State, si *snap.SideInfo, path, name string, opts *RevisionOptions, ...) (*state.TaskSet, error)
- func InstallWithDeviceContext(ctx context.Context, st *state.State, name string, opts *RevisionOptions, ...) (*state.TaskSet, error)
- func InstallWithGoal(ctx context.Context, st *state.State, goal InstallGoal, opts Options) ([]*snap.Info, []*state.TaskSet, error)
- func InstalledSnaps(st *state.State) (snaps []*snapasserts.InstalledSnap, ignoreValidation map[string]bool, ...)
- func Installing(st *state.State) bool
- func IsErrAndNotWait(err error) bool
- func IsSnapMonitored(st *state.State, snapName string) bool
- func KernelInfo(st *state.State, deviceCtx DeviceContext) (*snap.Info, error)
- func LinkNewBaseOrKernel(st *state.State, name string, fromChange string) (*state.TaskSet, error)
- func LongestGatingHold(st *state.State, snap string) (time.Time, error)
- func MigrateHome(st *state.State, snaps []string) ([]*state.TaskSet, error)
- func MockCheckSnapCallbacks(checks []CheckSnapCallback) (restore func())
- func MockEnforceSingleRebootForBaseKernelGadget(val bool) (restore func())
- func MockEnsuredMountsUpdated(m *SnapManager, ensured bool) (restore func())
- func MockLinkSnapParticipants(ps []LinkSnapParticipant) (restore func())
- func MockOsutilCheckFreeSpace(mock func(path string, minSize uint64) error) (restore func())
- func MockRefreshCandidate(snapSetup *SnapSetup) interface{}
- func ModelFromTask(task *state.Task) (*asserts.Model, error)
- func NeedsKernelSetup(model *asserts.Model) bool
- 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 ReadComponentInfo(snapInfo *snap.Info, csi *snap.ComponentSideInfo) (*snap.ComponentInfo, 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 RemoveComponents(st *state.State, snapName string, compName []string, opts RemoveComponentsOpts) ([]*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 SetEssentialSnapsRestartBoundaries(st *state.State, providedDeviceCtx DeviceContext, tss []*state.TaskSet) error
- func SetTaskSnapSetup(t *state.Task, snapsup *SnapSetup) error
- func ShouldSendNotificationsToTheUser(st *state.State) (bool, error)
- func SnapHolds(st *state.State, snaps []string) (map[string][]string, error)
- func SnapsAffectedByTask(t *state.Task) ([]string, error)
- func Switch(st *state.State, name string, opts *RevisionOptions) (*state.TaskSet, error)
- func SwitchToNewGadget(st *state.State, name string, fromChange string) (*state.TaskSet, error)
- func SystemHold(st *state.State, snap string) (time.Time, error)
- func TaskComponentSetup(t *state.Task) (*ComponentSetup, *SnapSetup, 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 UnmountAllSnaps(st *state.State) 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 UpdateOne(ctx context.Context, st *state.State, goal UpdateGoal, filter updateFilter, ...) (*state.TaskSet, error)
- func UpdatePathWithDeviceContext(st *state.State, si *snap.SideInfo, path, name string, opts *RevisionOptions, ...) (*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 AutoRefreshOptions
- type BusySnapError
- type ChangeConflictError
- type CheckSnapCallback
- type ComponentInstallFlags
- type ComponentSetup
- type DeviceContext
- type Flags
- type GateAutoRefreshAction
- type HoldDurationError
- type HoldError
- type HoldLevel
- type InstallGoal
- type InsufficientSpaceError
- type LinkSnapParticipant
- type LinkSnapParticipantFunc
- type Options
- type PathSnap
- type PendingSecurityState
- type Policy
- type PrereqTracker
- type RegistryID
- type RemoveComponentsOpts
- 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) Stop()
- 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) ComponentInfosForRevision(rev snap.Revision) ([]*snap.ComponentInfo, error)
- func (snapst *SnapState) CurrentComponentInfo(cref naming.ComponentRef) (*snap.ComponentInfo, error)
- func (snapst *SnapState) CurrentComponentInfos() ([]*snap.ComponentInfo, error)
- func (snapst *SnapState) CurrentComponentSideInfo(cref naming.ComponentRef) *snap.ComponentSideInfo
- func (snapst *SnapState) CurrentComponentSideInfos() []*snap.ComponentSideInfo
- func (snapst *SnapState) CurrentComponentState(cref naming.ComponentRef) *sequence.ComponentState
- func (snapst *SnapState) CurrentInfo() (*snap.Info, error)
- func (snapst *SnapState) CurrentSideInfo() *snap.SideInfo
- func (snapst *SnapState) HasActiveComponents() bool
- func (snapst *SnapState) InstanceName() string
- func (snapst *SnapState) IsComponentInCurrentSeq(cref naming.ComponentRef) bool
- func (snapst *SnapState) IsComponentRevPresent(compSi *snap.ComponentSideInfo) bool
- func (snapst *SnapState) IsCurrentComponentRevInAnyNonCurrentSeq(cref naming.ComponentRef) bool
- func (snapst *SnapState) IsInstalled() bool
- func (snapst *SnapState) LastIndex(revision snap.Revision) int
- func (snapst *SnapState) LocalComponentRevision(compName string) snap.Revision
- func (snapst *SnapState) LocalRevision() snap.Revision
- func (snapst *SnapState) RefreshInhibitProceedTime(st *state.State) time.Time
- func (snapst *SnapState) SetTrackingChannel(s string) error
- func (snapst *SnapState) SetType(typ snap.Type)
- func (snapst *SnapState) Type() (snap.Type, error)
- type StoreService
- type StoreSnap
- type StoreUpdate
- type UpdateGoal
- type UpdateTaskSets
Constants ¶
const ( IgnoreHookError = 1 << iota 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") EndEdge = state.TaskSetEdge("end") )
Variables ¶
var ( CanAutoRefresh func(st *state.State) (bool, error) 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 DefaultConfigure = func(st *state.State, snapName string) *state.TaskSet { panic("internal error: snapstate.DefaultConfigure 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 EnforceLocalValidationSets func(*state.State, map[string][]string, map[string]int, []*snapasserts.InstalledSnap, map[string]bool) error
EnforceLocalValidationSets allows to hook enforcing validation sets without fetching them or their dependencies. It's hooked from assertstate.
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 ErrExpectedOneSnap = errors.New("expected exactly one snap to install/update")
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 ErrUnexpectedRuntimeRestart = errors.New("unexpected restart at runtime")
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 HasActiveConnection = func(st *state.State, iface string) (bool, error) { panic("internal error: snapstate.HasActiveConnection is unset") }
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 SetupInstallComponentHook = func(st *state.State, snap, component string) *state.Task { panic("internal error: snapstate.SetupInstallComponentHook is unset") }
var SetupInstallHook = func(st *state.State, snapName string) *state.Task { panic("internal error: snapstate.SetupInstallHook is unset") }
var SetupPostRefreshComponentHook = func(st *state.State, snap, component string) *state.Task { panic("internal error: snapstate.SetupPostRefreshComponentHook is unset") }
var SetupPostRefreshHook = func(st *state.State, snapName string) *state.Task { panic("internal error: snapstate.SetupPostRefreshHook is unset") }
var SetupPreRefreshComponentHook = func(st *state.State, snap, component string) *state.Task { panic("internal error: snapstate.SetupPreRefreshComponentHook is unset") }
var SetupPreRefreshHook = func(st *state.State, snapName string) *state.Task { panic("internal error: snapstate.SetupPreRefreshHook is unset") }
var SetupRemoveComponentHook = func(st *state.State, snap, component string) *state.Task { panic("internal error: snapstate.SetupRemoveComponentHook 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, snapInfo *snap.Info, 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 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 CheckExpectedRestart ¶
CheckExpectedRestart check whether the current process state indicates that it may have been started as a response to an unexpected restart at runtime (most likely by snap-failure), and depending on the current changes state either returns ErrRecoveryFromUnexpectedRuntimeFailure to indicate that no failure handling is needed, or nil indicating that snapd should proceed with execution.
func CheckUpdateKernelCommandLineConflict ¶
CheckUpdateKernelCommandLineConflict checks that no active change other than ignoreChangeID has a task that touches the kernel command line.
func ComponentInfoFromComponentSetup ¶
func ComponentInfoFromComponentSetup(compsup *ComponentSetup, info *snap.Info) (*snap.ComponentInfo, error)
ComponentInfoFromComponentSetup returns a snap.ComponentInfo for the given ComponentSetup and snap.Info. It is assumed that the component represented by compsup has already been mounted.
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 Download ¶
func Download(ctx context.Context, st *state.State, name string, blobDirectory string, opts *RevisionOptions, userID int, flags Flags, deviceCtx DeviceContext) (*state.TaskSet, *snap.Info, error)
Download returns a set of tasks for downloading a snap into the given blobDirectory. If blobDirectory is empty, then dirs.SnapBlobDir is used. The snap.Info for the snap that is downloaded is also returned. The tasks that are returned will also download and validate the snap's assertion. Prerequisites for the snap are not downloaded.
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. It delegates the work to restart.FinishTaskWithRestart which decides on how the restart will be scheduled.
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 HeldSnaps ¶
HeldSnaps returns all snaps that are held at the given level or at more restricting ones and shouldn't be refreshed. The snaps are mapped to a list of snaps with currently effective holds on them.
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 InstallComponentPath ¶
func InstallComponentPath(st *state.State, csi *snap.ComponentSideInfo, info *snap.Info, path string, opts Options) (*state.TaskSet, error)
InstallComponentPath returns a set of tasks for installing a snap component from a file path.
Note that the state must be locked by the caller. The provided SideInfo can contain just a name which results in local sideloading of the component, or full metadata in which case the component will appear as installed from the store.
func InstallComponents ¶
func InstallComponents(ctx context.Context, st *state.State, names []string, info *snap.Info, opts Options) ([]*state.TaskSet, error)
InstallComponents installs all of the components in the given names list. The snap represented by info must already be installed, and all of the components in names should not be installed prior to calling this function.
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 InstallOne ¶
func InstallOne(ctx context.Context, st *state.State, goal InstallGoal, opts Options) (*snap.Info, *state.TaskSet, error)
InstallOne is a convenience wrapper for InstallWithGoal that ensures that a single snap is being installed and unwraps the results to return a single snap.Info and state.TaskSet. If the InstallGoal does not request to install exactly one snap, an error is returned.
func InstallPath ¶
func InstallPath(st *state.State, si *snap.SideInfo, path, instanceName, channel string, flags Flags, prqt PrereqTracker) (*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 InstallPathWithDeviceContext ¶
func InstallPathWithDeviceContext(st *state.State, si *snap.SideInfo, path, name string, opts *RevisionOptions, userID int, flags Flags, prqt PrereqTracker, deviceCtx DeviceContext, fromChange string) (*state.TaskSet, error)
InstallPathWithDeviceContext returns a set of tasks for installing a local 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 InstallWithDeviceContext ¶
func InstallWithDeviceContext(ctx context.Context, st *state.State, name string, opts *RevisionOptions, userID int, flags Flags, prqt PrereqTracker, deviceCtx DeviceContext, fromChange string) (*state.TaskSet, error)
InstallWithDeviceContext returns a set of tasks for installing a snap. It will query the store 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 InstallWithGoal ¶
func InstallWithGoal(ctx context.Context, st *state.State, goal InstallGoal, opts Options) ([]*snap.Info, []*state.TaskSet, error)
InstallWithGoal installs the snap/set of snaps specified by the given InstallGoal.
The InstallGoal controls what snaps should be installed and where to source the snaps from. The Options struct contains optional parameters that apply to the installation operation.
A slice of snap.Info structs is returned for each snap that is being installed along with a slice of state.TaskSet structs that represent the tasks that are part of the installation operation for each snap.
TODO: rename this to Install once the API is settled, and we can rename or remove the old Install function.
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 IsErrAndNotWait ¶
IsErrAndNotWait returns true if err is not nil and neither state.Wait, it is useful for code using FinishTaskWithRestart to not undo work in the presence of a state.Wait return.
func IsSnapMonitored ¶
IsSnapMonitored checks if there's already a goroutine waiting for this snap to close.
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 LongestGatingHold ¶
LongestGatingHold returns the time until which the snap's refreshes have been held by a gating snap. If no such hold exists, returns a zero time.Time value.
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 MockEnsuredMountsUpdated ¶
func MockEnsuredMountsUpdated(m *SnapManager, ensured bool) (restore func())
func MockLinkSnapParticipants ¶
func MockLinkSnapParticipants(ps []LinkSnapParticipant) (restore func())
MockLinkSnapParticipants replaces the list of link snap participants for testing.
func MockRefreshCandidate ¶
func MockRefreshCandidate(snapSetup *SnapSetup) interface{}
for testing outside of snapstate
func ModelFromTask ¶
ModelFromTask returns a model assertion through the device context for the task.
func NeedsKernelSetup ¶
func NewTaskProgressAdapterLocked ¶
NewTaskProgressAdapterLocked 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 ReadComponentInfo ¶
func ReadComponentInfo(snapInfo *snap.Info, csi *snap.ComponentSideInfo) (*snap.ComponentInfo, error)
ReadComponentInfo reads the snap's component and returns a ComponentInfo.
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 RemoveComponents ¶
func RemoveComponents(st *state.State, snapName string, compName []string, opts RemoveComponentsOpts) ([]*state.TaskSet, error)
RemoveComponents returns a taskset that removes the components in compName that belog to snapName.
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 SetEssentialSnapsRestartBoundaries ¶
func SetEssentialSnapsRestartBoundaries(st *state.State, providedDeviceCtx DeviceContext, tss []*state.TaskSet) error
SetEssentialSnapsRestartBoundaries sets up default restart boundaries for a list of task-sets. If the list of task-sets contain any updates/installs of essential snaps (base,gadget,kernel), then proper restart boundaries will be set up for them.
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 ShouldSendNotificationsToTheUser ¶
Allows to know if snapd should send desktop notifications to the user. If there is a snap connected to the snap-refresh-observe slot, then no notification should be sent, delegating all the job to that snap.
func SnapHolds ¶
SnapHolds returns a map of held snaps to lists of holding snaps (including "system" for user holds).
func SnapsAffectedByTask ¶
SnapsAffectedByTask returns a list of names of snaps affected by the given task.
func SwitchToNewGadget ¶
SwitchToNewGadget creates a new task set with prepare/update-gadget-assets/update-gadget-cmdline tasks for the gadget snap, for remodel.
func SystemHold ¶
SystemHold returns the time until which the snap's refreshes have been held by the sysadmin. If no such hold exists, returns a zero time.Time value.
func TaskComponentSetup ¶
func TaskComponentSetup(t *state.Task) (*ComponentSetup, *SnapSetup, error)
TaskComponentSetup returns the ComponentSetup and SnapSetup with task params hold by or referred to by the task.
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 UnmountAllSnaps ¶
UnmountAllSnaps unmounts all of the snaps and components in the system state. The primary use case for this is to unmount all snaps that were installed in the chroot environment that is used when creating a preseeded image.
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 updatable. If the list is empty, update everything. Note that the state must be locked by the caller.
func UpdateOne ¶
func UpdateOne(ctx context.Context, st *state.State, goal UpdateGoal, filter updateFilter, opts Options) (*state.TaskSet, error)
UpdateOne is a convenience wrapper for UpdateWithGoal that ensures that a single snap is being updated and unwraps the results to return a single state.TaskSet. If the UpdateGoal does not request to update exactly one snap, an error is returned.
func UpdatePathWithDeviceContext ¶
func UpdatePathWithDeviceContext(st *state.State, si *snap.SideInfo, path, name string, opts *RevisionOptions, userID int, flags Flags, prqt PrereqTracker, deviceCtx DeviceContext, fromChange string) (*state.TaskSet, error)
UpdatePathWithDeviceContext initiates a change updating a snap from a local file. 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 UpdateWithDeviceContext ¶
func UpdateWithDeviceContext(st *state.State, name string, opts *RevisionOptions, userID int, flags Flags, prqt PrereqTracker, deviceCtx DeviceContext, fromChange string) (*state.TaskSet, error)
UpdateWithDeviceContext initiates a change updating a snap. It will query the store 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 AutoRefreshOptions ¶
type AutoRefreshOptions struct {
IsContinuedAutoRefresh bool
}
AutoRefreshOptions are the options that can be passed to AutoRefresh
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) Is ¶
func (*BusySnapError) Is(err error) bool
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 ComponentInstallFlags ¶
type ComponentSetup ¶
type ComponentSetup struct { // CompSideInfo for metadata not coming from the component CompSideInfo *snap.ComponentSideInfo `json:"comp-side-info,omitempty"` // CompType is needed as some types need special handling CompType snap.ComponentType `json:"comp-type,omitempty"` // CompPath is the path to the component that will be mounted on the system. // It may be empty if the component is not yet present on the system (i.e., // needs to be downloaded). CompPath string `json:"comp-path,omitempty"` // DownloadInfo contains information about how to download this component. // Will be nil if the component should be sourced from a local file. DownloadInfo *snap.DownloadInfo `json:"download-info,omitempty"` // ComponentInstallFlags is a set of flags that control the behavior of the // component's installation/update. ComponentInstallFlags }
ComponentSetup holds the necessary component details to perform most component related tasks.
func ComponentSetupsForTask ¶
func ComponentSetupsForTask(t *state.Task) ([]*ComponentSetup, error)
ComponentSetupFromSnapSetup returns a list of ComponentSetup structs for the given task. Since the task could originate from one of a few different scenarios, we inspect the task for various keys to determine how to find the component setups.
The task could originate from: * Installing a singular component for an already installed snap * Installing multiple components for an already installed snap * Installing/refreshing a snap with components * Installing/refreshing a snap without any components
func NewComponentSetup ¶
func NewComponentSetup(csi *snap.ComponentSideInfo, compType snap.ComponentType, compPath string) *ComponentSetup
func TaskComponentSetups ¶
func TaskComponentSetups(t *state.Task) ([]*ComponentSetup, error)
func (*ComponentSetup) ComponentName ¶
func (compsu *ComponentSetup) ComponentName() string
ComponentName returns the component name for compsu.
func (*ComponentSetup) Revision ¶
func (compsu *ComponentSetup) Revision() snap.Revision
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"` // Prefer enables all aliases of the given snap in preference to // conflicting aliases of other snaps whose automatic aliases will // be disabled and manual aliases will be removed. Prefer bool `json:"prefer,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"` // IsContinuedAutoRefresh is true if this is a continued refresh IsContinuedAutoRefresh bool `json:"is-continued-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 InstallGoal ¶
type InstallGoal interface {
// contains filtered or unexported methods
}
InstallGoal represents a single snap or a group of snaps to be installed.
func PathInstallGoal ¶
func PathInstallGoal(instanceName, path string, si *snap.SideInfo, components map[*snap.ComponentSideInfo]string, opts RevisionOptions) InstallGoal
PathInstallGoal creates a new InstallGoal to install a snap from a given from a path on disk. If instanceName is not provided, si.RealName will be used.
func StoreInstallGoal ¶
func StoreInstallGoal(snaps ...StoreSnap) InstallGoal
StoreInstallGoal creates a new InstallGoal to install snaps from the store. If a snap is provided more than once in the list, the first instance of it will be used to provide the installation options.
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, snapsup *SnapSetup) 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, snapsup *SnapSetup) error
type Options ¶
type Options struct { // Flags contains flags that apply to the entire operation. Flags Flags // UserID is the ID of the user that is performing the operation. UserID int // DeviceCtx is an optional device context that will be used during the // operation. DeviceCtx DeviceContext // PrereqTracker is an optional prereq tracker that will be used to keep // track of all snaps (explicitly requested and implicitly required snaps) // that might need to be installed during the operation. PrereqTracker PrereqTracker // FromChange is the change that triggered the operation. FromChange string // Seed should be true while seeding the device. This indicates that we // shouldn't require that the device is seeded before installing/updating // snaps. Seed bool // ExpectOneSnap is a boolean flag indicating that this operation is expected // to only operate on one snap (excluding any prerequisite snaps that may be // required). If this is true, then the operation will fail if more than one // snap is being operated on. This flag primarily exists to support the // pre-existing behavior of calling InstallMany with one snap vs calling // Install. ExpectOneSnap bool }
Options contains optional parameters for the snapstate operations. All of these fields are optional and can be left unset. The options in this struct apply to all snaps that are part of an operation. Options that apply to individual snaps can be found in RevisionOptions.
type PathSnap ¶
type PathSnap struct { // Path is the path to the snap on disk. Path string // InstanceName is the name of the snap. InstanceName string // RevOpts contains options that apply to the installation or update of this // snap. RevOpts RevisionOptions // SideInfo contains extra information about the snap. SideInfo *snap.SideInfo // Components is a mapping of component side infos to paths that should be // installed alongside this snap. Components map[*snap.ComponentSideInfo]string }
PathSnap represents a single snap to be installed or updated from a path on disk.
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"` Components []*snap.ComponentSideInfo `json:"components,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 set, check // for removing only that revision. A revision which is unset means that // the snap will be completely gone after the operation, i.e. all // installed revisions will be removed, which is equally true when // removing the last remaining revision of the snap, even if said // revision was explicitly passed by the user. 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 PrereqTracker ¶
type PrereqTracker interface { // Add adds a snap for tracking. Add(*snap.Info) // MissingProviderContentTags returns a map keyed by the names of all // missing default-providers for the content plugs that the given // snap.Info needs. The map values are the corresponding content tags. // Different prerequisites trackers might decide in different // ways which providers are missing. Either making assumptions about // the snap operations that are being set up or considering // just the snap info and repo. // In the latter case if repo is not nil, any content tag provided by // an existing slot in it should be considered already available and // filtered out from the result. info might or might have not been // passed already to Add. snapstate uses the result to decide to // install providers automatically. MissingProviderContentTags(info *snap.Info, repo snap.InterfaceRepo) map[string][]string }
A PrereqTracker helps tracking snap prerequisites for one or across multiple snap operations. Depending of usage context implementations can be stateful or stateless. Functions taking a PrereqTracker accept nil and promise to call Add once for any target snap.
type RegistryID ¶
type RegistryID struct { // Account is the name of the account that publishes the registry. Account string // Registry is the name of the registry within the account namespace. Registry string }
RegistryID identifies a registry.
type RemoveComponentsOpts ¶
type RemoveFlags ¶
type RemoveFlags struct { // Remove the snap without creating snapshot data Purge bool // Kill running snap apps and services Terminate 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) Stop ¶
func (m *SnapManager) Stop()
Stop implements StateStopper. It will unregister the change callback handler from state.
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"` // Version being installed/refreshed to. Version string `json:"version,omitempty"` CohortKey string `json:"cohort-key,omitempty"` // FIXME: implement rename of this as suggested in // https://github.com/snapcore/snapd/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"` // DownloadBlobDir is the directory where the snap blob is downloaded to. If // empty, dir.SnapBlobDir is used. DownloadBlobDir string `json:"download-blob-dir,omitempty"` // AlwaysUpdate is set if the snap should be put through the entire update // process, even if the snap is already at the correct revision. Has an // effect on which tasks get created to update the snap. AlwaysUpdate bool `json:"-"` // Registries is the set of registries that the snap plugs, identified by // account and registry name pairs. Registries []RegistryID `json:"registries,omitempty"` // PreUpdateKernelModuleComponents is set if the kernel-modules component // that are set up, prior to any changes to the state. This is used in the // case of an undo. Note that this cannot be tagged as omitempty, since we // need to distinguish between empty and nil. PreUpdateKernelModuleComponents []*snap.ComponentSideInfo `json:"pre-update-kernel-module-components"` // 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 ¶
func (*SnapSetup) MountDir ¶
MountDir returns the path to the directory where this snap would be mounted.
type SnapState ¶
type SnapState struct { SnapType string `json:"type"` // Use Type and SetType // Sequence contains installation side state for a snap revision and // related components. Sequence sequence.SnapSequence `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"` // LastActiveDisabledUserServices, like LastActiveDisabledServices is a map of user-services // that were disabled in the snap when it was last active. The same rules apply. LastActiveDisabledUserServices map[int][]string `json:"last-active-disabled-user-services,omitempty"` // tracking services enabled and disabled by hooks ServicesEnabledByHooks []string `json:"services-enabled-by-hooks,omitempty"` UserServicesEnabledByHooks map[int][]string `json:"user-services-enabled-by-hooks,omitempty"` ServicesDisabledByHooks []string `json:"services-disabled-by-hooks,omitempty"` UserServicesDisabledByHooks map[int][]string `json:"user-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 when true indicates that aliases in internal state // and on disk might not match. 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"` // RefreshInhibitedTime 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"` // LastCompRefreshTime is a map of component names to times that records the // time when a component was last refreshed. LastCompRefreshTime map[string]time.Time `json:"last-component-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"` // RefreshFailures tracks information about snap failed refreshes. RefreshFailures *snap.RefreshFailuresInfo `json:"refresh-failures,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) ComponentInfosForRevision ¶
func (snapst *SnapState) ComponentInfosForRevision(rev snap.Revision) ([]*snap.ComponentInfo, error)
CurrentComponentInfos return a snap.ComponentInfo slice that contains all of the components for the last appearance of the specified revision. Returns an error if the revision is not found in the sequence of snaps.
func (*SnapState) CurrentComponentInfo ¶
func (snapst *SnapState) CurrentComponentInfo(cref naming.ComponentRef) (*snap.ComponentInfo, error)
CurrentComponentInfo returns the information about the current active revision or the last active revision (if the component is inactive). It returns the ErrNoCurrent error if the component is not found.
func (*SnapState) CurrentComponentInfos ¶
func (snapst *SnapState) CurrentComponentInfos() ([]*snap.ComponentInfo, error)
CurrentComponentInfos return a snap.ComponentInfo slice that contains all of the components for the current active revision or the last active revision. It returns the ErrNoCurrent error if snapst.Current is unset.
func (*SnapState) CurrentComponentSideInfo ¶
func (snapst *SnapState) CurrentComponentSideInfo(cref naming.ComponentRef) *snap.ComponentSideInfo
CurrentComponentSideInfo returns the component side info for the revision indicated by snapst.Current in the snap revision sequence if there is one.
func (*SnapState) CurrentComponentSideInfos ¶
func (snapst *SnapState) CurrentComponentSideInfos() []*snap.ComponentSideInfo
CurrentComponentSideInfos returns the component side infos for the revision indicated by snapst.Current in the snap revision sequence, if there is one.
func (*SnapState) CurrentComponentState ¶
func (snapst *SnapState) CurrentComponentState(cref naming.ComponentRef) *sequence.ComponentState
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) HasActiveComponents ¶
HasActiveComponents returns true if the current revision of this snap has any components installed with it. Otherwise, false is returned if either the snap isn't installed or the snap has no components installed with it.
func (*SnapState) InstanceName ¶
func (*SnapState) IsComponentInCurrentSeq ¶
func (snapst *SnapState) IsComponentInCurrentSeq(cref naming.ComponentRef) bool
IsComponentInCurrentSeq returns whether a given component is present for the snap represented by snapst in the active or last active revision.
func (*SnapState) IsComponentRevPresent ¶
func (snapst *SnapState) IsComponentRevPresent(compSi *snap.ComponentSideInfo) bool
IsComponentRevPresent tells us if a given component revision is present in the system for this snap.
func (*SnapState) IsCurrentComponentRevInAnyNonCurrentSeq ¶
func (snapst *SnapState) IsCurrentComponentRevInAnyNonCurrentSeq(cref naming.ComponentRef) bool
IsCurrentComponentRevInAnyNonCurrentSeq tells us if the component cref in the revision for the current snap is used in another sequence point too.
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.Revisions
func (*SnapState) LocalComponentRevision ¶
LocalComponentRevision returns the "latest" local revision for the compName component. Local revisions start at -1 and are counted down. 0 will be returned if no local revision for the component is found.
func (*SnapState) LocalRevision ¶
LocalRevision returns the "latest" local revision. Local revisions start at -1 and are counted down.
func (*SnapState) RefreshInhibitProceedTime ¶
RefreshInhibitProceedTime is the time after which a pending refresh is forced for a running snap in the next auto-refresh. Zero time indicates that there are no pending refreshes. st must be locked.
The provided state must be locked by the caller.
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) Categories(ctx context.Context, user *auth.UserState) ([]store.CategoryDetails, 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.
type StoreSnap ¶
type StoreSnap struct { // InstanceName is the name of snap to install. InstanceName string // Components is the list of components to install with this snap. Components []string // RevOpts contains options that apply to the installation of this snap. RevOpts RevisionOptions // SkipIfPresent indicates that the snap should not be installed if it is already present. SkipIfPresent bool }
StoreSnap represents a snap that is to be installed from the store.
type StoreUpdate ¶
type StoreUpdate struct { // InstanceName is the instance name of the snap to update. InstanceName string // RevOpts contains options that apply to the update of this snap. RevOpts RevisionOptions // AdditionalComponents is a list of additional components to install during // the refresh. AdditionalComponents []string }
StoreUpdate represents a snap that is to be updated from the store.
type UpdateGoal ¶
type UpdateGoal interface {
// contains filtered or unexported methods
}
UpdateGoal represents a single snap or a group of snaps to be updated.
func PathUpdateGoal ¶
func PathUpdateGoal(snaps ...PathSnap) UpdateGoal
PathUpdateGoal creates a new UpdateGoal to update snaps from paths on disk.
func StoreUpdateGoal ¶
func StoreUpdateGoal(snaps ...StoreUpdate) UpdateGoal
StoreUpdateGoal creates a new UpdateGoal to update snaps from the store.
type UpdateTaskSets ¶
type UpdateTaskSets struct { // PreDownload holds the pre-downloads tasksets created when there are busy // snaps that can't be refreshed during an auto-refresh. PreDownload []*state.TaskSet // Refresh holds the refresh tasksets. Refresh []*state.TaskSet }
UpdateTaskSets distinguishes tasksets for refreshes and pre-downloads since an auto-refresh can return both (even simultaneously).
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 UpdateWithGoal ¶
func UpdateWithGoal(ctx context.Context, st *state.State, goal UpdateGoal, filter updateFilter, opts Options) ([]string, *UpdateTaskSets, error)
UpdateWithGoal updates the snap/set of snaps specified by the given UpdateGoal.
Source Files ¶
- aliasesv2.go
- autorefresh.go
- autorefresh_gating.go
- aux_store_info.go
- backend.go
- booted.go
- catalogrefresh.go
- check_snap.go
- component.go
- conflict.go
- cookies.go
- dbus.go
- devicectx.go
- flags.go
- handlers.go
- handlers_components.go
- policy.go
- progress.go
- readme.go
- reboot.go
- refresh.go
- refreshhints.go
- snapmgr.go
- snapstate.go
- storehelpers.go
- target.go
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 |
Package sequence contains types representing a sequence of snap revisions (with components) that describe current and past states of the snap in the system.
|
Package sequence contains types representing a sequence of snap revisions (with components) that describe current and past states of the snap in the system. |