@@ -20,6 +20,7 @@ import (
2020)
2121
2222type imageConfig struct {
23+ Architecture * string
2324 BootMenu * bool
2425 CdromBus * string
2526 DiskBus * string
@@ -80,6 +81,7 @@ const (
8081 nameFlag = "name"
8182 diskFormatFlag = "disk-format"
8283
84+ architectureFlag = "architecture"
8385 bootMenuFlag = "boot-menu"
8486 cdromBusFlag = "cdrom-bus"
8587 diskBusFlag = "disk-bus"
@@ -98,7 +100,6 @@ const (
98100
99101 minDiskSizeFlag = "min-disk-size"
100102 minRamFlag = "min-ram"
101- ownerFlag = "owner"
102103 protectedFlag = "protected"
103104)
104105
@@ -166,6 +167,7 @@ func configureFlags(cmd *cobra.Command) {
166167 cmd .Flags ().String (nameFlag , "" , "The name of the image." )
167168 cmd .Flags ().String (diskFormatFlag , "" , "The disk format of the image. " )
168169
170+ cmd .Flags ().String (architectureFlag , "" , "Sets the CPU architecture." )
169171 cmd .Flags ().Bool (bootMenuFlag , false , "Enables the BIOS bootmenu." )
170172 cmd .Flags ().String (cdromBusFlag , "" , "Sets CDROM bus controller type." )
171173 cmd .Flags ().String (diskBusFlag , "" , "Sets Disk bus controller type." )
@@ -203,6 +205,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, cliArgs []string) (*inputM
203205 DiskFormat : flags .FlagToStringPointer (p , cmd , diskFormatFlag ),
204206 Labels : flags .FlagToStringToStringPointer (p , cmd , labelsFlag ),
205207 Config : & imageConfig {
208+ Architecture : flags .FlagToStringPointer (p , cmd , architectureFlag ),
206209 BootMenu : flags .FlagToBoolPointer (p , cmd , bootMenuFlag ),
207210 CdromBus : flags .FlagToStringPointer (p , cmd , cdromBusFlag ),
208211 DiskBus : flags .FlagToStringPointer (p , cmd , diskBusFlag ),
@@ -226,6 +229,10 @@ func parseInput(p *print.Printer, cmd *cobra.Command, cliArgs []string) (*inputM
226229 return nil , fmt .Errorf ("no flags have been passed" )
227230 }
228231
232+ if model .Config .isEmpty () {
233+ model .Config = nil
234+ }
235+
229236 if p .IsVerbosityDebug () {
230237 modelStr , err := print .BuildDebugStrFromInputModel (model )
231238 if err != nil {
@@ -249,22 +256,48 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
249256 payload .MinRam = model .MinRam
250257 payload .Name = model .Name
251258 payload .Protected = model .Protected
259+ payload .Config = nil
252260
253- if model .Config != nil {
254- payload .Config = & iaas.ImageConfig {
255- BootMenu : model .Config .BootMenu ,
256- CdromBus : iaas .NewNullableString (model .Config .CdromBus ),
257- DiskBus : iaas .NewNullableString (model .Config .DiskBus ),
258- NicModel : iaas .NewNullableString (model .Config .NicModel ),
259- OperatingSystem : model .Config .OperatingSystem ,
260- OperatingSystemDistro : iaas .NewNullableString (model .Config .OperatingSystemDistro ),
261- OperatingSystemVersion : iaas .NewNullableString (model .Config .OperatingSystemVersion ),
262- RescueBus : iaas .NewNullableString (model .Config .RescueBus ),
263- RescueDevice : iaas .NewNullableString (model .Config .RescueDevice ),
264- SecureBoot : model .Config .SecureBoot ,
265- Uefi : model .Config .Uefi ,
266- VideoModel : iaas .NewNullableString (model .Config .VideoModel ),
267- VirtioScsi : model .Config .VirtioScsi ,
261+ if config := model .Config ; config != nil {
262+ payload .Config = & iaas.ImageConfig {}
263+ if model .Config .BootMenu != nil {
264+ payload .Config .BootMenu = model .Config .BootMenu
265+ }
266+ if model .Config .CdromBus != nil {
267+ payload .Config .CdromBus = iaas .NewNullableString (model .Config .CdromBus )
268+ }
269+ if model .Config .DiskBus != nil {
270+ payload .Config .DiskBus = iaas .NewNullableString (model .Config .DiskBus )
271+ }
272+ if model .Config .NicModel != nil {
273+ payload .Config .NicModel = iaas .NewNullableString (model .Config .NicModel )
274+ }
275+ if model .Config .OperatingSystem != nil {
276+ payload .Config .OperatingSystem = model .Config .OperatingSystem
277+ }
278+ if model .Config .OperatingSystemDistro != nil {
279+ payload .Config .OperatingSystemDistro = iaas .NewNullableString (model .Config .OperatingSystemDistro )
280+ }
281+ if model .Config .OperatingSystemVersion != nil {
282+ payload .Config .OperatingSystemVersion = iaas .NewNullableString (model .Config .OperatingSystemVersion )
283+ }
284+ if model .Config .RescueBus != nil {
285+ payload .Config .RescueBus = iaas .NewNullableString (model .Config .RescueBus )
286+ }
287+ if model .Config .RescueDevice != nil {
288+ payload .Config .RescueDevice = iaas .NewNullableString (model .Config .RescueDevice )
289+ }
290+ if model .Config .SecureBoot != nil {
291+ payload .Config .SecureBoot = model .Config .SecureBoot
292+ }
293+ if model .Config .Uefi != nil {
294+ payload .Config .Uefi = model .Config .Uefi
295+ }
296+ if model .Config .VideoModel != nil {
297+ payload .Config .VideoModel = iaas .NewNullableString (model .Config .VideoModel )
298+ }
299+ if model .Config .VirtioScsi != nil {
300+ payload .Config .VirtioScsi = model .Config .VirtioScsi
268301 }
269302 }
270303
0 commit comments