@@ -77,25 +77,22 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
7777 return fmt .Errorf ("list public IPs: %w" , err )
7878 }
7979
80- if resp .Items == nil || len (* resp .Items ) == 0 {
81- projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
82- if err != nil {
83- params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
84- projectLabel = model .ProjectId
85- } else if projectLabel == "" {
86- projectLabel = model .ProjectId
87- }
88- params .Printer .Info ("No public IPs found for project %q\n " , projectLabel )
89- return nil
80+ items := resp .GetItems ()
81+
82+ projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
83+ if err != nil {
84+ params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
85+ projectLabel = model .ProjectId
86+ } else if projectLabel == "" {
87+ projectLabel = model .ProjectId
9088 }
9189
9290 // Truncate output
93- items := * resp .Items
9491 if model .Limit != nil && len (items ) > int (* model .Limit ) {
9592 items = items [:* model .Limit ]
9693 }
9794
98- return outputResult (params .Printer , model .OutputFormat , items )
95+ return outputResult (params .Printer , model .OutputFormat , projectLabel , items )
9996 },
10097 }
10198 configureFlags (cmd )
@@ -140,8 +137,12 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
140137 return req
141138}
142139
143- func outputResult (p * print.Printer , outputFormat string , publicIps []iaas.PublicIp ) error {
140+ func outputResult (p * print.Printer , outputFormat , projectLabel string , publicIps []iaas.PublicIp ) error {
144141 return p .OutputResult (outputFormat , publicIps , func () error {
142+ if len (publicIps ) == 0 {
143+ p .Outputf ("No public IPs found for project %q\n " , projectLabel )
144+ return nil
145+ }
145146 table := tables .NewTable ()
146147 table .SetHeader ("ID" , "IP ADDRESS" , "USED BY" )
147148
0 commit comments