@@ -143,7 +143,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
143
143
s .Stop ()
144
144
}
145
145
146
- return outputResult (p , model , projectLabel , resp )
146
+ return outputResult (p , model . OutputFormat , model . Async , projectLabel , resp )
147
147
},
148
148
}
149
149
configureFlags (cmd )
@@ -197,18 +197,22 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *ske.APIClie
197
197
return req
198
198
}
199
199
200
- func outputResult (p * print.Printer , model * inputModel , projectLabel string , resp * ske.Cluster ) error {
201
- switch model .OutputFormat {
200
+ func outputResult (p * print.Printer , outputFormat string , async bool , projectLabel string , cluster * ske.Cluster ) error {
201
+ if cluster == nil {
202
+ return fmt .Errorf ("cluster is nil" )
203
+ }
204
+
205
+ switch outputFormat {
202
206
case print .JSONOutputFormat :
203
- details , err := json .MarshalIndent (resp , "" , " " )
207
+ details , err := json .MarshalIndent (cluster , "" , " " )
204
208
if err != nil {
205
209
return fmt .Errorf ("marshal SKE cluster: %w" , err )
206
210
}
207
211
p .Outputln (string (details ))
208
212
209
213
return nil
210
214
case print .YAMLOutputFormat :
211
- details , err := yaml .MarshalWithOptions (resp , yaml .IndentSequence (true ), yaml .UseJSONMarshaler ())
215
+ details , err := yaml .MarshalWithOptions (cluster , yaml .IndentSequence (true ), yaml .UseJSONMarshaler ())
212
216
if err != nil {
213
217
return fmt .Errorf ("marshal SKE cluster: %w" , err )
214
218
}
@@ -217,10 +221,10 @@ func outputResult(p *print.Printer, model *inputModel, projectLabel string, resp
217
221
return nil
218
222
default :
219
223
operationState := "Created"
220
- if model . Async {
224
+ if async {
221
225
operationState = "Triggered creation of"
222
226
}
223
- p .Outputf ("%s cluster for project %q. Cluster name: %s\n " , operationState , projectLabel , utils .PtrString (resp .Name ))
227
+ p .Outputf ("%s cluster for project %q. Cluster name: %s\n " , operationState , projectLabel , utils .PtrString (cluster .Name ))
224
228
return nil
225
229
}
226
230
}
0 commit comments