@@ -93,7 +93,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
9393 s .Stop ()
9494 }
9595
96- return outputResult (params .Printer , model , result )
96+ return outputResult (params .Printer , model . OutputFormat , model . Async , model . Name , model . Id , result )
9797 },
9898 }
9999
@@ -143,28 +143,21 @@ func createPayload(model *inputModel) git.CreateInstancePayload {
143143 }
144144}
145145
146- func outputResult (p * print.Printer , model * inputModel , resp * git.Instance ) error {
147- if model == nil {
148- return fmt .Errorf ("input model is nil" )
146+ func outputResult (p * print.Printer , outputFormat string , async bool , instanceName string , modelId * string , resp * git.Instance ) error {
147+ if resp == nil {
148+ return fmt .Errorf ("API resp is nil" )
149149 }
150- var outputFormat string
151- if model . GlobalFlagModel != nil {
152- outputFormat = model . OutputFormat
150+ id := utils . PtrString ( modelId )
151+ if resp . Id != nil {
152+ id = * resp . Id
153153 }
154154
155155 return p .OutputResult (outputFormat , resp , func () error {
156- if resp == nil {
157- return fmt .Errorf ("API resp is nil" )
158- }
159156 operationState := "Created"
160- if model . Async {
157+ if async {
161158 operationState = "Triggered creation of"
162159 }
163- id := utils .PtrString (model .Id )
164- if resp .Id != nil {
165- id = * resp .Id
166- }
167- p .Outputf ("%s instance %q with id %s\n " , operationState , model .Name , id )
160+ p .Outputf ("%s instance %q with id %s\n " , operationState , instanceName , id )
168161 return nil
169162 })
170163}
0 commit comments