@@ -74,24 +74,21 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
7474 return fmt .Errorf ("list static routes: %w" , err )
7575 }
7676
77- if resp .Items == nil || len (* resp .Items ) == 0 {
78- var networkAreaLabel string
79- networkAreaLabel , err = iaasUtils .GetNetworkAreaName (ctx , apiClient , * model .OrganizationId , * model .NetworkAreaId )
80- if err != nil {
81- params .Printer .Debug (print .ErrorLevel , "get network area name: %v" , err )
82- networkAreaLabel = * model .NetworkAreaId
83- }
84- params .Printer .Info ("No static routes found for STACKIT Network Area %q\n " , networkAreaLabel )
85- return nil
77+ items := resp .GetItems ()
78+
79+ var networkAreaLabel string
80+ networkAreaLabel , err = iaasUtils .GetNetworkAreaName (ctx , apiClient , * model .OrganizationId , * model .NetworkAreaId )
81+ if err != nil {
82+ params .Printer .Debug (print .ErrorLevel , "get network area name: %v" , err )
83+ networkAreaLabel = * model .NetworkAreaId
8684 }
8785
8886 // Truncate output
89- items := * resp .Items
9087 if model .Limit != nil && len (items ) > int (* model .Limit ) {
9188 items = items [:* model .Limit ]
9289 }
9390
94- return outputResult (params .Printer , model .OutputFormat , items )
91+ return outputResult (params .Printer , model .OutputFormat , networkAreaLabel , items )
9592 },
9693 }
9794 configureFlags (cmd )
@@ -132,8 +129,12 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
132129 return apiClient .ListNetworkAreaRoutes (ctx , * model .OrganizationId , * model .NetworkAreaId , model .Region )
133130}
134131
135- func outputResult (p * print.Printer , outputFormat string , routes []iaas.Route ) error {
132+ func outputResult (p * print.Printer , outputFormat , networkAreaLabel string , routes []iaas.Route ) error {
136133 return p .OutputResult (outputFormat , routes , func () error {
134+ if len (routes ) == 0 {
135+ p .Outputf ("No static routes found for STACKIT Network Area %q\n " , networkAreaLabel )
136+ return nil
137+ }
137138 table := tables .NewTable ()
138139 table .SetHeader ("Static Route ID" , "Next Hop" , "Next Hop Type" , "Destination" )
139140
0 commit comments