Skip to content

Commit

Permalink
fix: a couple of imager panics/crashes
Browse files Browse the repository at this point in the history
Fixes #8987

Signed-off-by: Andrey Smirnov <[email protected]>
  • Loading branch information
smira committed Jan 13, 2025
1 parent 5bc3e34 commit 8de1975
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions pkg/imager/profile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ func (p *Profile) Validate() error {
// cmdline supports all kinds of customization
case OutKindImage:
// Image supports all kinds of customization
if p.Output.ImageOptions == nil {
return errors.New("image options are required for image output")
}

if p.Output.ImageOptions.DiskSize == 0 {
return errors.New("disk size is required for image output")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/machinery/extensions/extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestLoadValidate(t *testing.T) {
assert.NoError(t, ext.Validate(
extensions.WithValidateConstraints(),
extensions.WithValidateContents(),
extensions.WithTalosVersion(version),
extensions.WithTalosVersion(&version),
))
}

Expand Down Expand Up @@ -70,7 +70,7 @@ func TestValidateFailures(t *testing.T) {
err = ext.Validate(
extensions.WithValidateConstraints(),
extensions.WithValidateContents(),
extensions.WithTalosVersion(version),
extensions.WithTalosVersion(&version),
)

assert.EqualError(t, err, tt.validateError)
Expand Down
4 changes: 2 additions & 2 deletions pkg/machinery/extensions/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ func WithValidateContents() ValidationOption {
}

// WithTalosVersion sets the Talos version to validate against.
func WithTalosVersion(version semver.Version) ValidationOption {
func WithTalosVersion(version *semver.Version) ValidationOption {
return func(o *ValidationOptions) error {
o.TalosVersion = &version
o.TalosVersion = version

return nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/machinery/imager/quirks/quirks.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func New(talosVersion string) Quirks {
var minVersionResetOption = semver.MustParse("1.4.0")

// Version returns the Talos version.
func (q Quirks) Version() semver.Version {
return *q.v
func (q Quirks) Version() *semver.Version {
return q.v
}

// SupportsResetGRUBOption returns true if the Talos version supports the reset option in GRUB menu (image and ISO).
Expand Down

0 comments on commit 8de1975

Please sign in to comment.