-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: imager should support different Talos versions
Add some quirks to make images generated with newer Talos compatible with images generated by older Talos. Specifically, reset options were adding in Talos 1.4, so we shouldn't add them for older versions. Signed-off-by: Andrey Smirnov <[email protected]>
- Loading branch information
Showing
12 changed files
with
155 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...l/app/machined/pkg/runtime/v1alpha1/bootloader/grub/testdata/grub_write_no_reset_test.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
set default="A - TestOld v0.0.1" | ||
|
||
set timeout=3 | ||
|
||
insmod all_video | ||
|
||
terminal_input console | ||
terminal_output console | ||
|
||
menuentry "A - TestOld v0.0.1" { | ||
set gfxmode=auto | ||
set gfxpayload=text | ||
linux /A/vmlinuz cmdline A | ||
initrd /A/initramfs.xz | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
// Package quirks contains the quirks for Talos image generation. | ||
package quirks | ||
|
||
import "github.com/blang/semver/v4" | ||
|
||
// Quirks contains the quirks for Talos image generation. | ||
type Quirks struct { | ||
v *semver.Version | ||
} | ||
|
||
// New returns a new Quirks instance based on Talos version for the image. | ||
func New(talosVersion string) Quirks { | ||
v, err := semver.ParseTolerant(talosVersion) // ignore the error | ||
if err != nil { | ||
return Quirks{} | ||
} | ||
|
||
return Quirks{v: &v} | ||
} | ||
|
||
var minVersionResetOption = semver.MustParse("1.4.0") | ||
|
||
// SupportsResetGRUBOption returns true if the Talos version supports the reset option in GRUB menu (image and ISO). | ||
func (q Quirks) SupportsResetGRUBOption() bool { | ||
// if the version doesn't parse, we assume it's latest Talos | ||
if q.v == nil { | ||
return true | ||
} | ||
|
||
return q.v.GTE(minVersionResetOption) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
package quirks_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/siderolabs/talos/pkg/imager/quirks" | ||
) | ||
|
||
func TestSupportsResetOption(t *testing.T) { | ||
for _, test := range []struct { | ||
version string | ||
|
||
expected bool | ||
}{ | ||
{ | ||
version: "1.5.0", | ||
expected: true, | ||
}, | ||
{ | ||
expected: true, | ||
}, | ||
{ | ||
version: "1.3.7", | ||
expected: false, | ||
}, | ||
} { | ||
t.Run(test.version, func(t *testing.T) { | ||
assert.Equal(t, test.expected, quirks.New(test.version).SupportsResetGRUBOption()) | ||
}) | ||
} | ||
} |