Skip to content

fix(image): Uefi flag cannot be set to false #698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/stackit_image_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ stackit image create [flags]
--rescue-bus string Sets the device bus when the image is used as a rescue image.
--rescue-device string Sets the device when the image is used as a rescue image.
--secure-boot Enables Secure Boot.
--uefi Enables UEFI boot.
--uefi Enables UEFI boot. (default true)
--video-model string Sets Graphic device model.
--virtio-scsi Enables the use of VirtIO SCSI to provide block device access. By default instances use VirtIO Block.
```
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/image/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type imageConfig struct {
RescueBus *string
RescueDevice *string
SecureBoot *bool
Uefi *bool
Uefi bool
VideoModel *string
VirtioScsi *bool
}
Expand Down Expand Up @@ -270,7 +270,7 @@ func configureFlags(cmd *cobra.Command) {
cmd.Flags().String(rescueBusFlag, "", "Sets the device bus when the image is used as a rescue image.")
cmd.Flags().String(rescueDeviceFlag, "", "Sets the device when the image is used as a rescue image.")
cmd.Flags().Bool(secureBootFlag, false, "Enables Secure Boot.")
cmd.Flags().Bool(uefiFlag, false, "Enables UEFI boot.")
cmd.Flags().Bool(uefiFlag, true, "Enables UEFI boot.")
cmd.Flags().String(videoModelFlag, "", "Sets Graphic device model.")
cmd.Flags().Bool(virtioScsiFlag, false, "Enables the use of VirtIO SCSI to provide block device access. By default instances use VirtIO Block.")

Expand Down Expand Up @@ -311,7 +311,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
RescueBus: flags.FlagToStringPointer(p, cmd, rescueBusFlag),
RescueDevice: flags.FlagToStringPointer(p, cmd, rescueDeviceFlag),
SecureBoot: flags.FlagToBoolPointer(p, cmd, secureBootFlag),
Uefi: flags.FlagToBoolPointer(p, cmd, uefiFlag),
Uefi: flags.FlagToBoolValue(p, cmd, uefiFlag),
VideoModel: flags.FlagToStringPointer(p, cmd, videoModelFlag),
VirtioScsi: flags.FlagToBoolPointer(p, cmd, virtioScsiFlag),
},
Expand Down Expand Up @@ -367,7 +367,7 @@ func createPayload(_ context.Context, model *inputModel) iaas.CreateImagePayload
RescueBus: iaas.NewNullableString(model.Config.RescueBus),
RescueDevice: iaas.NewNullableString(model.Config.RescueDevice),
SecureBoot: model.Config.SecureBoot,
Uefi: model.Config.Uefi,
Uefi: utils.Ptr(model.Config.Uefi),
VideoModel: iaas.NewNullableString(model.Config.VideoModel),
VirtioScsi: model.Config.VirtioScsi,
}
Expand Down
14 changes: 12 additions & 2 deletions internal/cmd/image/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
RescueBus: &testRescueBus,
RescueDevice: &testRescueDevice,
SecureBoot: &testSecureBoot,
Uefi: &testUefi,
Uefi: testUefi,
VideoModel: &testVideoModel,
VirtioScsi: &testVirtioScsi,
},
Expand Down Expand Up @@ -246,6 +246,16 @@ func TestParseInput(t *testing.T) {
}),
isValid: false,
},
{
description: "uefi flag is set to false",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues[uefiFlag] = strconv.FormatBool(false)
}),
isValid: true,
expectedModel: fixtureInputModel(func(model *inputModel) {
model.Config.Uefi = false
}),
},
{
description: "no rescue device and no bus is valid",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
Expand Down Expand Up @@ -347,7 +357,7 @@ func TestBuildRequest(t *testing.T) {
{
description: "uefi flag",
model: fixtureInputModel(func(model *inputModel) {
model.Config.Uefi = utils.Ptr(false)
model.Config.Uefi = false
}),
expectedRequest: fixtureRequest(func(request *iaas.ApiCreateImageRequest) {
*request = request.CreateImagePayload(fixtureCreatePayload(func(payload *iaas.CreateImagePayload) {
Expand Down