@@ -72,25 +72,22 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
7272 return fmt .Errorf ("list attached network interfaces: %w" , err )
7373 }
7474
75- if resp .Items == nil || len (* resp .Items ) == 0 {
76- serverLabel , err := iaasUtils .GetServerName (ctx , apiClient , model .ProjectId , model .Region , model .ServerId )
77- if err != nil {
78- params .Printer .Debug (print .ErrorLevel , "get server name: %v" , err )
79- serverLabel = model .ServerId
80- } else if serverLabel == "" {
81- serverLabel = model .ServerId
82- }
83- params .Printer .Info ("No attached network interfaces found for server %q\n " , serverLabel )
84- return nil
75+ items := resp .GetItems ()
76+
77+ serverLabel , err := iaasUtils .GetServerName (ctx , apiClient , model .ProjectId , model .Region , model .ServerId )
78+ if err != nil {
79+ params .Printer .Debug (print .ErrorLevel , "get server name: %v" , err )
80+ serverLabel = model .ServerId
81+ } else if serverLabel == "" {
82+ serverLabel = model .ServerId
8583 }
8684
8785 // Truncate output
88- items := * resp .Items
8986 if model .Limit != nil && len (items ) > int (* model .Limit ) {
9087 items = items [:* model .Limit ]
9188 }
9289
93- return outputResult (params .Printer , model .OutputFormat , model .ServerId , items )
90+ return outputResult (params .Printer , model .OutputFormat , model .ServerId , serverLabel , items )
9491 },
9592 }
9693 configureFlags (cmd )
@@ -133,8 +130,12 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
133130 return apiClient .ListServerNICs (ctx , model .ProjectId , model .Region , model .ServerId )
134131}
135132
136- func outputResult (p * print.Printer , outputFormat , serverId string , serverNics []iaas.NIC ) error {
133+ func outputResult (p * print.Printer , outputFormat , serverId , serverLabel string , serverNics []iaas.NIC ) error {
137134 return p .OutputResult (outputFormat , serverNics , func () error {
135+ if len (serverNics ) == 0 {
136+ p .Outputf ("No attached network interfaces found for server %q\n " , serverLabel )
137+ return nil
138+ }
138139 table := tables .NewTable ()
139140 table .SetHeader ("NIC ID" , "SERVER ID" )
140141
0 commit comments