@@ -80,22 +80,18 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
8080 return fmt .Errorf ("read machine-types: %w" , err )
8181 }
8282
83- if resp .Items == nil || len (* resp .Items ) == 0 {
84- projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
85- if err != nil {
86- params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
87- projectLabel = model .ProjectId
88- }
89- params .Printer .Info ("No machine-types found for project %q\n " , projectLabel )
90- return nil
83+ projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
84+ if err != nil {
85+ params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
86+ projectLabel = model .ProjectId
9187 }
9288
9389 // limit output
9490 if model .Limit != nil && len (* resp .Items ) > int (* model .Limit ) {
9591 * resp .Items = (* resp .Items )[:* model .Limit ]
9692 }
9793
98- return outputResult (params .Printer , model .OutputFormat , * resp )
94+ return outputResult (params .Printer , model .OutputFormat , projectLabel , * resp )
9995 },
10096 }
10197
@@ -140,8 +136,12 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
140136 return req
141137}
142138
143- func outputResult (p * print.Printer , outputFormat string , machineTypes iaas.MachineTypeListResponse ) error {
139+ func outputResult (p * print.Printer , outputFormat , projectLabel string , machineTypes iaas.MachineTypeListResponse ) error {
144140 return p .OutputResult (outputFormat , machineTypes , func () error {
141+ if machineTypes .Items == nil || len (* machineTypes .Items ) == 0 {
142+ p .Outputf ("No machine-types found for project %q\n " , projectLabel )
143+ return nil
144+ }
145145 table := tables .NewTable ()
146146 table .SetTitle ("Machine-Types" )
147147 table .SetHeader ("NAME" , "VCPUS" , "RAM (GB)" , "DESCRIPTION" , "EXTRA SPECS" )
0 commit comments