Skip to content

Commit f158c45

Browse files
committed
fix: require rescue bus and device as pair, remove unsupported local-image-path from update command, fix describe for undefined fields
1 parent 8c62bf2 commit f158c45

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

internal/cmd/beta/image/create/create.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ func configureFlags(cmd *cobra.Command) {
283283
if err := flags.MarkFlagsRequired(cmd, nameFlag, diskFormatFlag, localFilePathFlag); err != nil {
284284
cobra.CheckErr(err)
285285
}
286+
cmd.MarkFlagsRequiredTogether(rescueBusFlag, rescueDeviceFlag)
286287
}
287288

288289
func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {

internal/cmd/beta/image/describe/describe.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ func outputResult(p *print.Printer, model *inputModel, resp *iaas.Image) error {
141141
table.AddRow("OPERATING SYSTEM", *os)
142142
table.AddSeparator()
143143
}
144-
if distro := config.OperatingSystemDistro; distro != nil {
144+
if distro := config.OperatingSystemDistro; distro != nil && distro.IsSet() {
145145
table.AddRow("OPERATING SYSTEM DISTRIBUTION", *distro.Get())
146146
table.AddSeparator()
147147
}
148-
if version := config.OperatingSystemVersion; version != nil {
148+
if version := config.OperatingSystemVersion; version != nil && version.IsSet() {
149149
table.AddRow("OPERATING SYSTEM VERSION", *version.Get())
150150
table.AddSeparator()
151151
}

internal/cmd/beta/image/update/update.go

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,19 @@ func (ic *imageConfig) isEmpty() bool {
5353
type inputModel struct {
5454
*globalflags.GlobalFlagModel
5555

56-
Id string
57-
Name *string
58-
DiskFormat *string
59-
LocalFilePath *string
60-
Labels *map[string]string
61-
Config *imageConfig
62-
MinDiskSize *int64
63-
MinRam *int64
64-
Protected *bool
56+
Id string
57+
Name *string
58+
DiskFormat *string
59+
Labels *map[string]string
60+
Config *imageConfig
61+
MinDiskSize *int64
62+
MinRam *int64
63+
Protected *bool
6564
}
6665

6766
func (im *inputModel) isEmpty() bool {
6867
return im.Name == nil &&
6968
im.DiskFormat == nil &&
70-
im.LocalFilePath == nil &&
7169
im.Labels == nil &&
7270
(im.Config == nil || im.Config.isEmpty()) &&
7371
im.MinDiskSize == nil &&
@@ -78,9 +76,8 @@ func (im *inputModel) isEmpty() bool {
7876
const imageIdArg = "IMAGE_ID"
7977

8078
const (
81-
nameFlag = "name"
82-
diskFormatFlag = "disk-format"
83-
localFilePathFlag = "local-file-path"
79+
nameFlag = "name"
80+
diskFormatFlag = "disk-format"
8481

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

172168
cmd.Flags().Bool(bootMenuFlag, false, "Enables the BIOS bootmenu.")
173169
cmd.Flags().String(cdromBusFlag, "", "Sets CDROM bus controller type.")
@@ -188,6 +184,8 @@ func configureFlags(cmd *cobra.Command) {
188184
cmd.Flags().Int64(minDiskSizeFlag, 0, "Size in Gigabyte.")
189185
cmd.Flags().Int64(minRamFlag, 0, "Size in Megabyte.")
190186
cmd.Flags().Bool(protectedFlag, false, "Protected VM.")
187+
188+
cmd.MarkFlagsRequiredTogether(rescueBusFlag, rescueDeviceFlag)
191189
}
192190

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

204-
DiskFormat: flags.FlagToStringPointer(p, cmd, diskFormatFlag),
205-
LocalFilePath: flags.FlagToStringPointer(p, cmd, localFilePathFlag),
206-
Labels: flags.FlagToStringToStringPointer(p, cmd, labelsFlag),
202+
DiskFormat: flags.FlagToStringPointer(p, cmd, diskFormatFlag),
203+
Labels: flags.FlagToStringToStringPointer(p, cmd, labelsFlag),
207204
Config: &imageConfig{
208205
BootMenu: flags.FlagToBoolPointer(p, cmd, bootMenuFlag),
209206
CdromBus: flags.FlagToStringPointer(p, cmd, cdromBusFlag),

internal/cmd/beta/image/update/update_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ var (
2626
testProjectId = uuid.NewString()
2727

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

5554
nameFlag: testName,
5655
diskFormatFlag: testDiskFormat,
57-
localFilePathFlag: testLocalImagePath,
5856
bootMenuFlag: strconv.FormatBool(testBootmenu),
5957
cdromBusFlag: testCdRomBus,
6058
diskBusFlag: testDiskBus,
@@ -95,7 +93,6 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
9593
Id: testImageId[0],
9694
Name: &testName,
9795
DiskFormat: &testDiskFormat,
98-
LocalFilePath: &testLocalImagePath,
9996
Labels: utils.Ptr(parseLabels(testLabels)),
10097
Config: &imageConfig{
10198
BootMenu: &testBootmenu,

0 commit comments

Comments
 (0)