@@ -23,7 +23,7 @@ func createOutputWithDefaults(kind profile.OutputKind, arch, version string, sec
2323 return out
2424}
2525
26- func createOutputWithOverride (kind profile.OutputKind , bootloader profile.BootloaderKind , arch , version string , secureBoot bool ) profile.Output {
26+ func createOutputWithOverride (kind profile.OutputKind , bootloader profile.BootloaderKind , secureBoot bool ) profile.Output {
2727 out := profile.Output {
2828 Kind : kind ,
2929 }
@@ -34,14 +34,12 @@ func createOutputWithOverride(kind profile.OutputKind, bootloader profile.Bootlo
3434 Bootloader : bootloader ,
3535 }
3636 case profile .OutKindISO :
37- if quirks .New (version ).ISOSupportsSettingBootloader () {
38- out .ISOOptions = & profile.ISOOptions {
39- Bootloader : bootloader ,
40- }
37+ out .ISOOptions = & profile.ISOOptions {
38+ Bootloader : bootloader ,
4139 }
4240 }
4341
44- out .FillDefaults (arch , version , secureBoot )
42+ out .FillDefaults ("amd64" , "v1.12.0" , secureBoot )
4543
4644 return out
4745}
@@ -108,65 +106,37 @@ func TestBootloaderOverride(t *testing.T) {
108106 t .Parallel ()
109107
110108 tests := []struct {
111- arch string
112- version string
113- secureBoot bool
114- override profile.BootloaderKind
115- wantImage profile.BootloaderKind
109+ name string
110+ secureBoot bool
111+ override profile.BootloaderKind
112+ expectedBootloader profile.BootloaderKind
116113 }{
117- // Talos < 1.10: GRUB is forced, overrides are ignored
118- {"amd64" , "1.9.0" , false , profile .BootLoaderKindGrub , profile .BootLoaderKindGrub },
119- {"amd64" , "1.9.0" , false , profile .BootLoaderKindSDBoot , profile .BootLoaderKindGrub }, // forced to GRUB
120- {"amd64" , "1.9.0" , false , profile .BootLoaderKindDualBoot , profile .BootLoaderKindGrub }, // forced to GRUB
121- {"amd64" , "1.9.0" , true , profile .BootLoaderKindGrub , profile .BootLoaderKindSDBoot }, // secureboot forces sd-boot
122- {"arm64" , "1.9.0" , false , profile .BootLoaderKindGrub , profile .BootLoaderKindGrub },
123- {"arm64" , "1.9.0" , false , profile .BootLoaderKindSDBoot , profile .BootLoaderKindGrub }, // forced to GRUB
124- {"arm64" , "1.9.0" , true , profile .BootLoaderKindGrub , profile .BootLoaderKindSDBoot }, // secureboot forces sd-boot
125-
126- // Talos 1.10-1.11: amd64 respects override, arm64 forced to sd-boot
127- {"amd64" , "1.10.0" , false , profile .BootLoaderKindGrub , profile .BootLoaderKindGrub },
128- {"amd64" , "1.10.0" , false , profile .BootLoaderKindSDBoot , profile .BootLoaderKindSDBoot },
129- {"amd64" , "1.10.0" , false , profile .BootLoaderKindDualBoot , profile .BootLoaderKindDualBoot },
130- {"amd64" , "1.10.0" , true , profile .BootLoaderKindGrub , profile .BootLoaderKindSDBoot }, // secureboot forces sd-boot
131- {"arm64" , "1.10.0" , false , profile .BootLoaderKindGrub , profile .BootLoaderKindSDBoot }, // arm64 >= 1.10 forces sd-boot
132- {"arm64" , "1.10.0" , true , profile .BootLoaderKindGrub , profile .BootLoaderKindSDBoot }, // secureboot forces sd-boot
133- {"amd64" , "1.11.0" , false , profile .BootLoaderKindGrub , profile .BootLoaderKindGrub },
134- {"amd64" , "1.11.0" , false , profile .BootLoaderKindDualBoot , profile .BootLoaderKindDualBoot },
135- {"amd64" , "1.11.0" , true , profile .BootLoaderKindGrub , profile .BootLoaderKindSDBoot }, // secureboot forces sd-boot
136- {"arm64" , "1.11.0" , false , profile .BootLoaderKindGrub , profile .BootLoaderKindSDBoot }, // arm64 >= 1.10 forces sd-boot
137- {"arm64" , "1.11.0" , true , profile .BootLoaderKindGrub , profile .BootLoaderKindSDBoot }, // secureboot forces sd-boot
138-
139- // Talos >= 1.12: amd64 respects override, arm64 forced to sd-boot
140- {"amd64" , "1.12.0" , false , profile .BootLoaderKindGrub , profile .BootLoaderKindGrub },
141- {"amd64" , "1.12.0" , false , profile .BootLoaderKindSDBoot , profile .BootLoaderKindSDBoot },
142- {"amd64" , "1.12.0" , false , profile .BootLoaderKindDualBoot , profile .BootLoaderKindDualBoot },
143- {"amd64" , "1.12.0" , true , profile .BootLoaderKindGrub , profile .BootLoaderKindSDBoot }, // secureboot forces sd-boot
144- {"arm64" , "1.12.0" , false , profile .BootLoaderKindGrub , profile .BootLoaderKindSDBoot }, // arm64 >= 1.10 forces sd-boot
145- {"arm64" , "1.12.0" , true , profile .BootLoaderKindGrub , profile .BootLoaderKindSDBoot }, // secureboot forces sd-boot
114+ {
115+ "non-secureboot override to sd-boot" ,
116+ false ,
117+ profile .BootLoaderKindSDBoot ,
118+ profile .BootLoaderKindSDBoot ,
119+ },
120+ {
121+ "secureboot override to grub" ,
122+ true ,
123+ profile .BootLoaderKindGrub ,
124+ profile .BootLoaderKindSDBoot ,
125+ },
146126 }
147127
148128 for _ , tt := range tests {
149- name := tt .arch + "-" + tt .version + "-override-" + tt .override .String ()
150- if tt .secureBoot {
151- name += "-secureboot"
152- }
153-
154- t .Run (name , func (t * testing.T ) {
129+ t .Run (tt .name , func (t * testing.T ) {
155130 t .Parallel ()
156131
157132 // Test Image output with override
158- img := createOutputWithOverride (profile .OutKindImage , tt .override , tt .arch , tt . version , tt . secureBoot )
133+ img := createOutputWithOverride (profile .OutKindImage , tt .override , tt .secureBoot )
159134 require .NotNil (t , img .ImageOptions )
160- require .Equal (t , tt .wantImage , img .ImageOptions .Bootloader )
135+ require .Equal (t , tt .expectedBootloader , img .ImageOptions .Bootloader )
161136
162137 // Test ISO output with override
163- iso := createOutputWithOverride (profile .OutKindISO , tt .override , tt .arch , tt .version , tt .secureBoot )
164- if quirks .New (tt .version ).ISOSupportsSettingBootloader () {
165- require .NotNil (t , iso .ISOOptions )
166- require .Equal (t , tt .wantImage , iso .ISOOptions .Bootloader )
167- } else {
168- require .Nil (t , iso .ISOOptions )
169- }
138+ iso := createOutputWithOverride (profile .OutKindISO , tt .override , tt .secureBoot )
139+ require .Equal (t , tt .expectedBootloader , iso .ISOOptions .Bootloader )
170140 })
171141 }
172142}
0 commit comments