@@ -80,31 +80,30 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
8080 return fmt .Errorf ("list network areas: %w" , err )
8181 }
8282
83- if resp .Items == nil || len (* resp .Items ) == 0 {
84- var orgLabel string
85- rmApiClient , err := rmClient .ConfigureClient (params .Printer , params .CliVersion )
86- if err == nil {
87- orgLabel , err = rmUtils .GetOrganizationName (ctx , rmApiClient , * model .OrganizationId )
88- if err != nil {
89- params .Printer .Debug (print .ErrorLevel , "get organization name: %v" , err )
90- orgLabel = * model .OrganizationId
91- } else if orgLabel == "" {
92- orgLabel = * model .OrganizationId
93- }
94- } else {
95- params .Printer .Debug (print .ErrorLevel , "configure resource manager client: %v" , err )
83+ items := resp .GetItems ()
84+
85+ var orgLabel string
86+ rmApiClient , err := rmClient .ConfigureClient (params .Printer , params .CliVersion )
87+ if err == nil {
88+ orgLabel , err = rmUtils .GetOrganizationName (ctx , rmApiClient , * model .OrganizationId )
89+ if err != nil {
90+ params .Printer .Debug (print .ErrorLevel , "get organization name: %v" , err )
91+ orgLabel = * model .OrganizationId
9692 }
97- params .Printer .Info ("No STACKIT Network Areas found for organization %q\n " , orgLabel )
98- return nil
93+ } else {
94+ params .Printer .Debug (print .ErrorLevel , "configure resource manager client: %v" , err )
95+ }
96+
97+ if orgLabel == "" {
98+ orgLabel = * model .OrganizationId
9999 }
100100
101101 // Truncate output
102- items := * resp .Items
103102 if model .Limit != nil && len (items ) > int (* model .Limit ) {
104103 items = items [:* model .Limit ]
105104 }
106105
107- return outputResult (params .Printer , model .OutputFormat , items )
106+ return outputResult (params .Printer , orgLabel , model .OutputFormat , items )
108107 },
109108 }
110109 configureFlags (cmd )
@@ -149,8 +148,13 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
149148 return req
150149}
151150
152- func outputResult (p * print.Printer , outputFormat string , networkAreas []iaas.NetworkArea ) error {
151+ func outputResult (p * print.Printer , orgLabel , outputFormat string , networkAreas []iaas.NetworkArea ) error {
153152 return p .OutputResult (outputFormat , networkAreas , func () error {
153+ if len (networkAreas ) == 0 {
154+ p .Outputf ("No STACKIT Network Areas found for organization %q\n " , orgLabel )
155+ return nil
156+ }
157+
154158 table := tables .NewTable ()
155159 table .SetHeader ("ID" , "Name" , "# Attached Projects" )
156160
0 commit comments