Files
snapd/daemon/export_api_model_test.go
Andrew Phelps 8a7f3f2c63 o/devicestate, overlord, daemon: add flag to devicestate.Remodel to force an offline remodel (#13494)
This flag will enable offline remodeling, even when all snaps required for the remodel are not provided locally. The remodel will fall back to using already installed snaps in situations that it can. This includes simple channel switches, and when the required revision of a snap is already installed. If a snap is required for the remodel, and the snap is neither provided locally or already installed, then the remodel will fail.

* snap: add support for errors.Is for NotInstalledError

* o/snapstate: add Type to SnapSetup created in snapstate.Switch

* o/devicestate, overlord, daemon: add flag to devicestate.Remodel to force an offline remodel

This flag will enable offline remodeling, even when all snaps required
for the remodel are not provided locally. The remodel will fall back to
using already installed snaps in situations that it can. This includes
simple channel switches, and when the required revision of a snap is
already installed.

* o/devicestate: re-word comment on RemodelOptions.Offline

* o/devicestate: convert sideInfoAndPathFromID to a method on remodelVariant

* o/devicestate: make comment in UpdateWithDeviceContext more clear

* o/devicestate: add TODO about looking for other revisions

* o/devicestate: add comment explaining that case in UpdateWithDeviceContext is unexpected

* o/devicestate: prefix unexpected state error with "internal error"

* o/devicestate: use var for default initialization

* o/devicestate: invert if in UpdateWithDeviceContext to reduce some nesting

* o/devicestate: rename sideInfoAndPathFromID and add some clarifying comments

* o/devicestate: remove unused parameter from remodelEssentialSnapTasks

* o/devicestate: correct copy-pasted comment
2024-01-30 15:17:38 +01:00

48 lines
1.5 KiB
Go

// -*- Mode: Go; indent-tabs-mode: t -*-
/*
* Copyright (C) 2021 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package daemon
import (
"github.com/snapcore/snapd/asserts"
"github.com/snapcore/snapd/overlord/devicestate"
"github.com/snapcore/snapd/overlord/state"
"github.com/snapcore/snapd/snap"
)
func MockDevicestateRemodel(mock func(*state.State, *asserts.Model, []*snap.SideInfo, []string, devicestate.RemodelOptions) (*state.Change, error)) (restore func()) {
oldDevicestateRemodel := devicestateRemodel
devicestateRemodel = mock
return func() {
devicestateRemodel = oldDevicestateRemodel
}
}
func MockDevicestateDeviceManagerUnregister(mock func(*devicestate.DeviceManager, *devicestate.UnregisterOptions) error) (restore func()) {
oldDevicestateDeviceManagerUnregister := devicestateDeviceManagerUnregister
devicestateDeviceManagerUnregister = mock
return func() {
devicestateDeviceManagerUnregister = oldDevicestateDeviceManagerUnregister
}
}
type (
PostModelData = postModelData
)