@@ -143,7 +143,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
143143 s .Stop ()
144144 }
145145
146- return outputResult (p , model , projectLabel , resp )
146+ return outputResult (p , model . OutputFormat , model . Async , projectLabel , resp )
147147 },
148148 }
149149 configureFlags (cmd )
@@ -197,18 +197,22 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *ske.APIClie
197197 return req
198198}
199199
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 {
202206 case print .JSONOutputFormat :
203- details , err := json .MarshalIndent (resp , "" , " " )
207+ details , err := json .MarshalIndent (cluster , "" , " " )
204208 if err != nil {
205209 return fmt .Errorf ("marshal SKE cluster: %w" , err )
206210 }
207211 p .Outputln (string (details ))
208212
209213 return nil
210214 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 ())
212216 if err != nil {
213217 return fmt .Errorf ("marshal SKE cluster: %w" , err )
214218 }
@@ -217,10 +221,10 @@ func outputResult(p *print.Printer, model *inputModel, projectLabel string, resp
217221 return nil
218222 default :
219223 operationState := "Created"
220- if model . Async {
224+ if async {
221225 operationState = "Triggered creation of"
222226 }
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 ))
224228 return nil
225229 }
226230}
0 commit comments