@@ -85,22 +85,21 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
85
85
return fmt .Errorf ("get SKE clusters: %w" , err )
86
86
}
87
87
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
- }
97
88
98
89
// Truncate output
99
90
if model .Limit != nil && len (clusters ) > int (* model .Limit ) {
100
91
clusters = clusters [:* model .Limit ]
101
92
}
102
93
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 )
104
103
},
105
104
}
106
105
@@ -148,7 +147,7 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *ske.APIClie
148
147
return req
149
148
}
150
149
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 {
152
151
switch outputFormat {
153
152
case print .JSONOutputFormat :
154
153
details , err := json .MarshalIndent (clusters , "" , " " )
@@ -167,6 +166,11 @@ func outputResult(p *print.Printer, outputFormat string, clusters []ske.Cluster)
167
166
168
167
return nil
169
168
default :
169
+ if len (clusters ) == 0 {
170
+ p .Outputf ("No clusters found for project %q\n " , projectLabel )
171
+ return nil
172
+ }
173
+
170
174
table := tables .NewTable ()
171
175
table .SetHeader ("NAME" , "STATE" , "VERSION" , "POOLS" , "MONITORING" )
172
176
for i := range clusters {
0 commit comments