Skip to content

Commit

Permalink
Expand source error (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
Itxaka authored Apr 15, 2024
1 parent 28e5622 commit d24489e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ const (
PassiveBootSuffix = " (fallback)"
RecoveryBootSuffix = " recovery"
StateResetBootSuffix = " state reset (auto)"

// Error
UpgradeNoSourceError = "Could not find a proper source for the upgrade.\nThis can be configured in the cloud config files under the 'upgrade.system.uri' key or via cmdline using the '--source' flag."
)

func UkiDefaultMenuEntries() []string {
Expand Down
4 changes: 2 additions & 2 deletions pkg/types/v1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ type UpgradeSpec struct {
func (u *UpgradeSpec) Sanitize() error {
if u.RecoveryUpgrade {
if u.Recovery.Source.IsEmpty() {
return fmt.Errorf("undefined upgrade source")
return fmt.Errorf(constants.UpgradeNoSourceError)
}
if u.Partitions.Recovery == nil || u.Partitions.Recovery.MountPoint == "" {
return fmt.Errorf("undefined recovery partition")
}
} else {
if u.Active.Source.IsEmpty() {
return fmt.Errorf("undefined upgrade source")
return fmt.Errorf(constants.UpgradeNoSourceError)
}
if u.Partitions.State == nil || u.Partitions.State.MountPoint == "" {
return fmt.Errorf("undefined state partition")
Expand Down
4 changes: 2 additions & 2 deletions pkg/types/v1/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ var _ = Describe("Types", Label("types", "config"), func() {
It("fails with empty source", func() {
err := spec.Sanitize()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("undefined upgrade source"))
Expect(err.Error()).To(ContainSubstring(constants.UpgradeNoSourceError))
})
It("fails with missing state partition", func() {
spec.Active.Source = v1.NewFileSrc("/tmp")
Expand All @@ -449,7 +449,7 @@ var _ = Describe("Types", Label("types", "config"), func() {
It("fails with empty source", func() {
err := spec.Sanitize()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("undefined upgrade source"))
Expect(err.Error()).To(ContainSubstring(constants.UpgradeNoSourceError))
})
It("fails with missing recovery partition", func() {
spec.Recovery.Source = v1.NewFileSrc("/tmp")
Expand Down

0 comments on commit d24489e

Please sign in to comment.