@@ -27,7 +27,6 @@ const (
2727
2828type inputModel struct {
2929 * globalflags.GlobalFlagModel
30- Id * string
3130 Name string
3231 Flavor string
3332 Acl []string
@@ -79,20 +78,19 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
7978 if err != nil {
8079 return fmt .Errorf ("create stackit git instance: %w" , err )
8180 }
82- model .Id = result .Id
8381
8482 // Wait for async operation, if async mode not enabled
8583 if ! model .Async {
8684 s := spinner .New (params .Printer )
8785 s .Start ("Creating stackit git instance" )
88- _ , err = wait .CreateGitInstanceWaitHandler (ctx , apiClient , model .ProjectId , * model .Id ).WaitWithContext (ctx )
86+ _ , err = wait .CreateGitInstanceWaitHandler (ctx , apiClient , model .ProjectId , * result .Id ).WaitWithContext (ctx )
8987 if err != nil {
9088 return fmt .Errorf ("wait for stackit git Instance creation: %w" , err )
9189 }
9290 s .Stop ()
9391 }
9492
95- return outputResult (params .Printer , model .OutputFormat , model .Async , model .Name , * model . Id , result )
93+ return outputResult (params .Printer , model .OutputFormat , model .Async , model .Name , result )
9694 },
9795 }
9896
@@ -142,17 +140,20 @@ func createPayload(model *inputModel) git.CreateInstancePayload {
142140 }
143141}
144142
145- func outputResult (p * print.Printer , outputFormat string , async bool , instanceName , modelId string , resp * git.Instance ) error {
143+ func outputResult (p * print.Printer , outputFormat string , async bool , instanceName string , resp * git.Instance ) error {
146144 if resp == nil {
147145 return fmt .Errorf ("API resp is nil" )
148146 }
147+ if resp .Id == nil {
148+ return fmt .Errorf ("API resp is missing instance id" )
149+ }
149150
150151 return p .OutputResult (outputFormat , resp , func () error {
151152 operationState := "Created"
152153 if async {
153154 operationState = "Triggered creation of"
154155 }
155- p .Outputf ("%s instance %q with id %s\n " , operationState , instanceName , modelId )
156+ p .Outputf ("%s instance %q with id %s\n " , operationState , instanceName , * resp . Id )
156157 return nil
157158 })
158159}
0 commit comments