@@ -85,22 +85,21 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
8585 return fmt .Errorf ("get SKE clusters: %w" , err )
8686 }
8787 clusters := * resp .Items
88- if len (clusters ) == 0 {
89- projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
90- if err != nil {
91- params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
92- projectLabel = model .ProjectId
93- }
94- params .Printer .Info ("No clusters found for project %q\n " , projectLabel )
95- return nil
96- }
9788
9889 // Truncate output
9990 if model .Limit != nil && len (clusters ) > int (* model .Limit ) {
10091 clusters = clusters [:* model .Limit ]
10192 }
10293
103- return outputResult (params .Printer , model .OutputFormat , clusters )
94+ projectLabel := model .ProjectId
95+ if len (clusters ) == 0 {
96+ projectLabel , err = projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
97+ if err != nil {
98+ params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
99+ }
100+ }
101+
102+ return outputResult (params .Printer , model .OutputFormat , projectLabel , clusters )
104103 },
105104 }
106105
@@ -148,7 +147,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *ske.APIClie
148147 return req
149148}
150149
151- func outputResult (p * print.Printer , outputFormat string , clusters []ske.Cluster ) error {
150+ func outputResult (p * print.Printer , outputFormat , projectLabel string , clusters []ske.Cluster ) error {
152151 switch outputFormat {
153152 case print .JSONOutputFormat :
154153 details , err := json .MarshalIndent (clusters , "" , " " )
@@ -167,6 +166,11 @@ func outputResult(p *print.Printer, outputFormat string, clusters []ske.Cluster)
167166
168167 return nil
169168 default :
169+ if len (clusters ) == 0 {
170+ p .Outputf ("No clusters found for project %q\n " , projectLabel )
171+ return nil
172+ }
173+
170174 table := tables .NewTable ()
171175 table .SetHeader ("NAME" , "STATE" , "VERSION" , "POOLS" , "MONITORING" )
172176 for i := range clusters {
0 commit comments