Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: require rescue bus and device as pair, remove unsupported local-…
…image-path from update command, fix describe for undefined fields
  • Loading branch information
bahkauv70 committed Jan 17, 2025
commit f158c4575ccd5a21e1738692e0c482687911bf64
1 change: 1 addition & 0 deletions internal/cmd/beta/image/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ func configureFlags(cmd *cobra.Command) {
if err := flags.MarkFlagsRequired(cmd, nameFlag, diskFormatFlag, localFilePathFlag); err != nil {
cobra.CheckErr(err)
}
cmd.MarkFlagsRequiredTogether(rescueBusFlag, rescueDeviceFlag)
}

func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/beta/image/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ func outputResult(p *print.Printer, model *inputModel, resp *iaas.Image) error {
table.AddRow("OPERATING SYSTEM", *os)
table.AddSeparator()
}
if distro := config.OperatingSystemDistro; distro != nil {
if distro := config.OperatingSystemDistro; distro != nil && distro.IsSet() {
table.AddRow("OPERATING SYSTEM DISTRIBUTION", *distro.Get())
table.AddSeparator()
}
if version := config.OperatingSystemVersion; version != nil {
if version := config.OperatingSystemVersion; version != nil && version.IsSet() {
table.AddRow("OPERATING SYSTEM VERSION", *version.Get())
table.AddSeparator()
}
Expand Down
31 changes: 14 additions & 17 deletions internal/cmd/beta/image/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,19 @@ func (ic *imageConfig) isEmpty() bool {
type inputModel struct {
*globalflags.GlobalFlagModel

Id string
Name *string
DiskFormat *string
LocalFilePath *string
Labels *map[string]string
Config *imageConfig
MinDiskSize *int64
MinRam *int64
Protected *bool
Id string
Name *string
DiskFormat *string
Labels *map[string]string
Config *imageConfig
MinDiskSize *int64
MinRam *int64
Protected *bool
}

func (im *inputModel) isEmpty() bool {
return im.Name == nil &&
im.DiskFormat == nil &&
im.LocalFilePath == nil &&
im.Labels == nil &&
(im.Config == nil || im.Config.isEmpty()) &&
im.MinDiskSize == nil &&
Expand All @@ -78,9 +76,8 @@ func (im *inputModel) isEmpty() bool {
const imageIdArg = "IMAGE_ID"

const (
nameFlag = "name"
diskFormatFlag = "disk-format"
localFilePathFlag = "local-file-path"
nameFlag = "name"
diskFormatFlag = "disk-format"

bootMenuFlag = "boot-menu"
cdromBusFlag = "cdrom-bus"
Expand Down Expand Up @@ -167,7 +164,6 @@ func NewCmd(p *print.Printer) *cobra.Command {
func configureFlags(cmd *cobra.Command) {
cmd.Flags().String(nameFlag, "", "The name of the image.")
cmd.Flags().String(diskFormatFlag, "", "The disk format of the image. ")
cmd.Flags().String(localFilePathFlag, "", "The path to the local disk image file.")

cmd.Flags().Bool(bootMenuFlag, false, "Enables the BIOS bootmenu.")
cmd.Flags().String(cdromBusFlag, "", "Sets CDROM bus controller type.")
Expand All @@ -188,6 +184,8 @@ func configureFlags(cmd *cobra.Command) {
cmd.Flags().Int64(minDiskSizeFlag, 0, "Size in Gigabyte.")
cmd.Flags().Int64(minRamFlag, 0, "Size in Megabyte.")
cmd.Flags().Bool(protectedFlag, false, "Protected VM.")

cmd.MarkFlagsRequiredTogether(rescueBusFlag, rescueDeviceFlag)
}

func parseInput(p *print.Printer, cmd *cobra.Command, cliArgs []string) (*inputModel, error) {
Expand All @@ -201,9 +199,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, cliArgs []string) (*inputM
Id: cliArgs[0],
Name: flags.FlagToStringPointer(p, cmd, nameFlag),

DiskFormat: flags.FlagToStringPointer(p, cmd, diskFormatFlag),
LocalFilePath: flags.FlagToStringPointer(p, cmd, localFilePathFlag),
Labels: flags.FlagToStringToStringPointer(p, cmd, labelsFlag),
DiskFormat: flags.FlagToStringPointer(p, cmd, diskFormatFlag),
Labels: flags.FlagToStringToStringPointer(p, cmd, labelsFlag),
Config: &imageConfig{
BootMenu: flags.FlagToBoolPointer(p, cmd, bootMenuFlag),
CdromBus: flags.FlagToStringPointer(p, cmd, cdromBusFlag),
Expand Down
3 changes: 0 additions & 3 deletions internal/cmd/beta/image/update/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ var (
testProjectId = uuid.NewString()

testImageId = []string{uuid.NewString()}
testLocalImagePath = "/does/not/exist"
testDiskFormat = "raw"
testDiskSize int64 = 16 * 1024 * 1024 * 1024
testRamSize int64 = 8 * 1024 * 1024 * 1024
Expand Down Expand Up @@ -54,7 +53,6 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st

nameFlag: testName,
diskFormatFlag: testDiskFormat,
localFilePathFlag: testLocalImagePath,
bootMenuFlag: strconv.FormatBool(testBootmenu),
cdromBusFlag: testCdRomBus,
diskBusFlag: testDiskBus,
Expand Down Expand Up @@ -95,7 +93,6 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
Id: testImageId[0],
Name: &testName,
DiskFormat: &testDiskFormat,
LocalFilePath: &testLocalImagePath,
Labels: utils.Ptr(parseLabels(testLabels)),
Config: &imageConfig{
BootMenu: &testBootmenu,
Expand Down
Loading