Skip to content

Commit 91bd0bb

Browse files
authored
fix(image): Uefi flag cannot be set to false (#698)
Signed-off-by: Alexander Dahmen <[email protected]>
1 parent 39c1fe0 commit 91bd0bb

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

docs/stackit_image_create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ stackit image create [flags]
4242
--rescue-bus string Sets the device bus when the image is used as a rescue image.
4343
--rescue-device string Sets the device when the image is used as a rescue image.
4444
--secure-boot Enables Secure Boot.
45-
--uefi Enables UEFI boot.
45+
--uefi Enables UEFI boot. (default true)
4646
--video-model string Sets Graphic device model.
4747
--virtio-scsi Enables the use of VirtIO SCSI to provide block device access. By default instances use VirtIO Block.
4848
```

internal/cmd/image/create/create.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type imageConfig struct {
6262
RescueBus *string
6363
RescueDevice *string
6464
SecureBoot *bool
65-
Uefi *bool
65+
Uefi bool
6666
VideoModel *string
6767
VirtioScsi *bool
6868
}
@@ -270,7 +270,7 @@ func configureFlags(cmd *cobra.Command) {
270270
cmd.Flags().String(rescueBusFlag, "", "Sets the device bus when the image is used as a rescue image.")
271271
cmd.Flags().String(rescueDeviceFlag, "", "Sets the device when the image is used as a rescue image.")
272272
cmd.Flags().Bool(secureBootFlag, false, "Enables Secure Boot.")
273-
cmd.Flags().Bool(uefiFlag, false, "Enables UEFI boot.")
273+
cmd.Flags().Bool(uefiFlag, true, "Enables UEFI boot.")
274274
cmd.Flags().String(videoModelFlag, "", "Sets Graphic device model.")
275275
cmd.Flags().Bool(virtioScsiFlag, false, "Enables the use of VirtIO SCSI to provide block device access. By default instances use VirtIO Block.")
276276

@@ -311,7 +311,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
311311
RescueBus: flags.FlagToStringPointer(p, cmd, rescueBusFlag),
312312
RescueDevice: flags.FlagToStringPointer(p, cmd, rescueDeviceFlag),
313313
SecureBoot: flags.FlagToBoolPointer(p, cmd, secureBootFlag),
314-
Uefi: flags.FlagToBoolPointer(p, cmd, uefiFlag),
314+
Uefi: flags.FlagToBoolValue(p, cmd, uefiFlag),
315315
VideoModel: flags.FlagToStringPointer(p, cmd, videoModelFlag),
316316
VirtioScsi: flags.FlagToBoolPointer(p, cmd, virtioScsiFlag),
317317
},
@@ -367,7 +367,7 @@ func createPayload(_ context.Context, model *inputModel) iaas.CreateImagePayload
367367
RescueBus: iaas.NewNullableString(model.Config.RescueBus),
368368
RescueDevice: iaas.NewNullableString(model.Config.RescueDevice),
369369
SecureBoot: model.Config.SecureBoot,
370-
Uefi: model.Config.Uefi,
370+
Uefi: utils.Ptr(model.Config.Uefi),
371371
VideoModel: iaas.NewNullableString(model.Config.VideoModel),
372372
VirtioScsi: model.Config.VirtioScsi,
373373
}

internal/cmd/image/create/create_test.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
105105
RescueBus: &testRescueBus,
106106
RescueDevice: &testRescueDevice,
107107
SecureBoot: &testSecureBoot,
108-
Uefi: &testUefi,
108+
Uefi: testUefi,
109109
VideoModel: &testVideoModel,
110110
VirtioScsi: &testVirtioScsi,
111111
},
@@ -246,6 +246,16 @@ func TestParseInput(t *testing.T) {
246246
}),
247247
isValid: false,
248248
},
249+
{
250+
description: "uefi flag is set to false",
251+
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
252+
flagValues[uefiFlag] = strconv.FormatBool(false)
253+
}),
254+
isValid: true,
255+
expectedModel: fixtureInputModel(func(model *inputModel) {
256+
model.Config.Uefi = false
257+
}),
258+
},
249259
{
250260
description: "no rescue device and no bus is valid",
251261
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
@@ -347,7 +357,7 @@ func TestBuildRequest(t *testing.T) {
347357
{
348358
description: "uefi flag",
349359
model: fixtureInputModel(func(model *inputModel) {
350-
model.Config.Uefi = utils.Ptr(false)
360+
model.Config.Uefi = false
351361
}),
352362
expectedRequest: fixtureRequest(func(request *iaas.ApiCreateImageRequest) {
353363
*request = request.CreateImagePayload(fixtureCreatePayload(func(payload *iaas.CreateImagePayload) {

0 commit comments

Comments
 (0)