Skip to content

Commit

Permalink
Fix leftovers after rebase
Browse files Browse the repository at this point in the history
Signed-off-by: David Cassany <dcassany@suse.com>
  • Loading branch information
davidcassany committed Mar 5, 2024
1 parent 8cf5cd0 commit f6171e8
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion cmd/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ var _ = Describe("Config", Label("config"), func() {
defer ghwTest.Clean()

err := os.Setenv("ELEMENTAL_UPGRADE_RECOVERY", "true")
spec, err := ReadUpgradeSpec(cfg, nil)
spec, err := ReadUpgradeSpec(cfg, nil, false)
Expect(err).ShouldNot(HaveOccurred())
// Overwrites recovery-system image, flags have priority over files and env vars
Expect(spec.RecoverySystem.Source.Value() == "image/from:flag")
Expand Down
2 changes: 1 addition & 1 deletion cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/rancher/elemental-toolkit/v2/cmd/config"
"github.com/rancher/elemental-toolkit/v2/pkg/action"
"github.com/rancher/elemental-toolkit/v2/pkg/constants"
"github.com/rancher/elemental-toolkit/v2/pkg/constants"
elementalError "github.com/rancher/elemental-toolkit/v2/pkg/error"
"github.com/rancher/elemental-toolkit/v2/pkg/types"
"github.com/rancher/elemental-toolkit/v2/pkg/utils"
Expand Down
10 changes: 5 additions & 5 deletions cmd/upgrade-recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/rancher/elemental-toolkit/cmd/config"
"github.com/rancher/elemental-toolkit/pkg/action"
elementalError "github.com/rancher/elemental-toolkit/pkg/error"
v1 "github.com/rancher/elemental-toolkit/pkg/types/v1"
"github.com/rancher/elemental-toolkit/v2/cmd/config"
"github.com/rancher/elemental-toolkit/v2/pkg/action"
elementalError "github.com/rancher/elemental-toolkit/v2/pkg/error"
"github.com/rancher/elemental-toolkit/v2/pkg/types"
)

// NewUpgradeCmd returns a new instance of the upgrade subcommand and appends it to
Expand All @@ -48,7 +48,7 @@ func NewUpgradeRecoveryCmd(root *cobra.Command, addCheckRoot bool) *cobra.Comman
if err != nil {
return err
}
mounter := v1.NewMounter(path)
mounter := types.NewMounter(path)

cfg, err := config.ReadConfigRun(viper.GetString("config-dir"), cmd.Flags(), mounter)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/build-disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ func (b *BuildDiskAction) createStatePartitionImage() (*types.Image, error) {
system := b.spec.System
if b.spec.RecoverySystem.Source.String() == b.spec.System.String() {
// Reuse already deployed root-tree from recovery image
system = v1.NewFileSrc(b.spec.RecoverySystem.File)
system = types.NewFileSrc(b.spec.RecoverySystem.File)
b.spec.System.SetDigest(b.spec.RecoverySystem.Source.GetDigest())
}

Expand Down
20 changes: 10 additions & 10 deletions pkg/action/upgrade-recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ import (
"path/filepath"
"time"

"github.com/rancher/elemental-toolkit/pkg/constants"
"github.com/rancher/elemental-toolkit/pkg/elemental"
elementalError "github.com/rancher/elemental-toolkit/pkg/error"
v1 "github.com/rancher/elemental-toolkit/pkg/types/v1"
"github.com/rancher/elemental-toolkit/pkg/utils"
"github.com/rancher/elemental-toolkit/v2/pkg/constants"
"github.com/rancher/elemental-toolkit/v2/pkg/elemental"
elementalError "github.com/rancher/elemental-toolkit/v2/pkg/error"
"github.com/rancher/elemental-toolkit/v2/pkg/types"
"github.com/rancher/elemental-toolkit/v2/pkg/utils"
)

var ErrUpgradeRecoveryFromRecovery = errors.New("Can not upgrade recovery from recovery partition")

// UpgradeRecoveryAction represents the struct that will run the recovery upgrade from start to finish
type UpgradeRecoveryAction struct {
cfg *v1.RunConfig
spec *v1.UpgradeSpec
cfg *types.RunConfig
spec *types.UpgradeSpec
updateInstallState bool
}

Expand All @@ -47,7 +47,7 @@ func WithUpdateInstallState(updateInstallState bool) func(u *UpgradeRecoveryActi
}
}

func NewUpgradeRecoveryAction(config *v1.RunConfig, spec *v1.UpgradeSpec, opts ...UpgradeRecoveryActionOption) (*UpgradeRecoveryAction, error) {
func NewUpgradeRecoveryAction(config *types.RunConfig, spec *types.UpgradeSpec, opts ...UpgradeRecoveryActionOption) (*UpgradeRecoveryAction, error) {
var err error

u := &UpgradeRecoveryAction{cfg: config, spec: spec}
Expand Down Expand Up @@ -111,9 +111,9 @@ func (u *UpgradeRecoveryAction) upgradeInstallStateYaml() error {

recoveryPart := u.spec.State.Partitions[constants.RecoveryPartName]
if recoveryPart == nil {
recoveryPart = &v1.PartitionState{
recoveryPart = &types.PartitionState{
FSLabel: u.spec.Partitions.Recovery.FilesystemLabel,
RecoveryImage: &v1.SystemState{
RecoveryImage: &types.SystemState{
FS: u.spec.RecoverySystem.FS,
Label: u.spec.RecoverySystem.Label,
Source: u.spec.RecoverySystem.Source,
Expand Down
66 changes: 33 additions & 33 deletions pkg/action/upgrade-recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,41 @@ import (
"github.com/twpayne/go-vfs/v4"
"github.com/twpayne/go-vfs/v4/vfst"

"github.com/rancher/elemental-toolkit/pkg/action"
conf "github.com/rancher/elemental-toolkit/pkg/config"
"github.com/rancher/elemental-toolkit/pkg/constants"
v1mock "github.com/rancher/elemental-toolkit/pkg/mocks"
v1 "github.com/rancher/elemental-toolkit/pkg/types/v1"
"github.com/rancher/elemental-toolkit/pkg/utils"
"github.com/rancher/elemental-toolkit/v2/pkg/action"
conf "github.com/rancher/elemental-toolkit/v2/pkg/config"
"github.com/rancher/elemental-toolkit/v2/pkg/constants"
"github.com/rancher/elemental-toolkit/v2/pkg/mocks"
"github.com/rancher/elemental-toolkit/v2/pkg/types"
"github.com/rancher/elemental-toolkit/v2/pkg/utils"
)

var _ = Describe("Upgrade Recovery Actions", func() {
var config *v1.RunConfig
var runner *v1mock.FakeRunner
var config *types.RunConfig
var runner *mocks.FakeRunner
var fs vfs.FS
var logger v1.Logger
var mounter *v1mock.FakeMounter
var syscall *v1mock.FakeSyscall
var client *v1mock.FakeHTTPClient
var cloudInit *v1mock.FakeCloudInitRunner
var extractor *v1mock.FakeImageExtractor
var logger types.Logger
var mounter *mocks.FakeMounter
var syscall *mocks.FakeSyscall
var client *mocks.FakeHTTPClient
var cloudInit *mocks.FakeCloudInitRunner
var extractor *mocks.FakeImageExtractor
var cleanup func()
var memLog *bytes.Buffer
var ghwTest v1mock.GhwMock
var ghwTest mocks.GhwMock

BeforeEach(func() {
runner = v1mock.NewFakeRunner()
syscall = &v1mock.FakeSyscall{}
mounter = v1mock.NewFakeMounter()
client = &v1mock.FakeHTTPClient{}
runner = mocks.NewFakeRunner()
syscall = &mocks.FakeSyscall{}
mounter = mocks.NewFakeMounter()
client = &mocks.FakeHTTPClient{}
memLog = &bytes.Buffer{}
logger = v1.NewBufferLogger(memLog)
extractor = v1mock.NewFakeImageExtractor(logger)
logger = types.NewBufferLogger(memLog)
extractor = mocks.NewFakeImageExtractor(logger)
var err error
fs, cleanup, err = vfst.NewTestFS(map[string]interface{}{})
Expect(err).Should(BeNil())

cloudInit = &v1mock.FakeCloudInitRunner{}
cloudInit = &mocks.FakeCloudInitRunner{}
config = conf.NewRunConfig(
conf.WithFs(fs),
conf.WithRunner(runner),
Expand All @@ -79,13 +79,13 @@ var _ = Describe("Upgrade Recovery Actions", func() {
AfterEach(func() { cleanup() })

Describe("UpgradeRecovery Action", Label("upgrade-recovery"), func() {
var spec *v1.UpgradeSpec
var spec *types.UpgradeSpec
var upgradeRecovery *action.UpgradeRecoveryAction
var memLog *bytes.Buffer

BeforeEach(func() {
memLog = &bytes.Buffer{}
logger = v1.NewBufferLogger(memLog)
logger = types.NewBufferLogger(memLog)
config.Logger = logger
logger.SetLevel(logrus.DebugLevel)

Expand Down Expand Up @@ -122,7 +122,7 @@ var _ = Describe("Upgrade Recovery Actions", func() {
},
},
}
ghwTest = v1mock.GhwMock{}
ghwTest = mocks.GhwMock{}
ghwTest.AddDisk(mainDisk)
ghwTest.CreateDevices()
})
Expand All @@ -137,8 +137,8 @@ var _ = Describe("Upgrade Recovery Actions", func() {
spec, err = conf.NewUpgradeSpec(config.Config)
Expect(err).ShouldNot(HaveOccurred())

spec.System = v1.NewDockerSrc("alpine")
loopCfg, ok := config.Snapshotter.Config.(*v1.LoopDeviceConfig)
spec.System = types.NewDockerSrc("alpine")
loopCfg, ok := config.Snapshotter.Config.(*types.LoopDeviceConfig)
Expect(ok).To(BeTrue())
loopCfg.Size = 16

Expand Down Expand Up @@ -252,18 +252,18 @@ var _ = Describe("Upgrade Recovery Actions", func() {
})
})

func PrepareTestRecoveryImage(config *v1.RunConfig, recoveryImgPath string, fs vfs.FS, runner *v1mock.FakeRunner) *v1.UpgradeSpec {
func PrepareTestRecoveryImage(config *types.RunConfig, recoveryImgPath string, fs vfs.FS, runner *mocks.FakeRunner) *types.UpgradeSpec {
GinkgoHelper()
// Create installState with squashed recovery
statePath := filepath.Join(constants.RunningStateDir, constants.InstallStateFile)
installState := &v1.InstallState{
Partitions: map[string]*v1.PartitionState{
installState := &types.InstallState{
Partitions: map[string]*types.PartitionState{
constants.RecoveryPartName: {
FSLabel: constants.RecoveryLabel,
RecoveryImage: &v1.SystemState{
RecoveryImage: &types.SystemState{
Label: constants.SystemLabel,
FS: constants.SquashFs,
Source: v1.NewDirSrc("/some/dir"),
Source: types.NewDirSrc("/some/dir"),
},
},
},
Expand All @@ -275,7 +275,7 @@ func PrepareTestRecoveryImage(config *v1.RunConfig, recoveryImgPath string, fs v
spec, err := conf.NewUpgradeSpec(config.Config)
Expect(err).ShouldNot(HaveOccurred())

spec.System = v1.NewDockerSrc("alpine")
spec.System = types.NewDockerSrc("alpine")
spec.RecoveryUpgrade = true
spec.RecoverySystem.Source = spec.System
spec.RecoverySystem.Size = 16
Expand Down
2 changes: 1 addition & 1 deletion pkg/snapshotter/btrfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func newBtrfsSnapshotter(cfg types.Config, snapCfg types.SnapshotterConfig, boot
}, nil
}

func (b *Btrfs) InitSnapshotter(state *v1.Partition, efiDir string) error {
func (b *Btrfs) InitSnapshotter(state *types.Partition, efiDir string) error {
var err error
var ok bool

Expand Down
2 changes: 1 addition & 1 deletion pkg/snapshotter/btrfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ var _ = Describe("Btrfs", Label("snapshotter", " btrfs"), func() {
It("fails to umount default subvolume", func() {
failCmd = "nofail"
mounter.ErrorOnUnmount = true
err = b.InitSnapshotter(rootDir)
err = b.InitSnapshotter(statePart, rootDir)
Expect(err.Error()).To(ContainSubstring("unmount"))
})
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/snapshotter/loopdevice.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func newLoopDeviceSnapshotter(cfg types.Config, snapCfg types.SnapshotterConfig,

// InitSnapshotter initiates the snapshotter to the given root directory. More over this method includes logic to migrate
// from older elemental-toolkit versions.
func (l *LoopDevice) InitSnapshotter(state *v1.Partition, efiDir string) error {
func (l *LoopDevice) InitSnapshotter(state *types.Partition, efiDir string) error {
var err error

l.cfg.Logger.Infof("Initiating a LoopDevice snapshotter at %s", state.MountPoint)
Expand Down

0 comments on commit f6171e8

Please sign in to comment.