66 "fmt"
77 "os"
88 "strings"
9+ "time"
910
1011 "github.com/AlecAivazis/survey/v2"
1112 "github.com/fatih/camelcase"
@@ -87,8 +88,20 @@ func create(opts *createOptions) error {
8788
8889 log .Println ("Creating your codespace..." )
8990
90- codespace , err := apiClient .CreateCodespace (ctx , userResult .User , repository , machine , branch , locationResult .Location )
91+ codespace , err := apiClient .CreateCodespace (
92+ ctx , userResult .User , repository , machine , branch , locationResult .Location ,
93+ )
9194 if err != nil {
95+ if err == api .ErrCreateAsyncRetry {
96+ createRetryCtx , cancelRetry := context .WithTimeout (ctx , 2 * time .Minute )
97+ defer cancelRetry ()
98+
99+ codespace , err = pollForProvisionedCodespace (createRetryCtx , codespace )
100+ if err != nil {
101+ return fmt .Errorf ("error creating codespace after retry: %w" , err )
102+ }
103+ }
104+
92105 return fmt .Errorf ("error creating codespace: %w" , err )
93106 }
94107
@@ -105,6 +118,10 @@ func create(opts *createOptions) error {
105118 return nil
106119}
107120
121+ func pollForProvisionedCodespace (ctx context.Context , provisioningCodespace * api.Codespace ) (* api.Codespace , error ) {
122+ return nil , nil
123+ }
124+
108125// showStatus polls the codespace for a list of post create states and their status. It will keep polling
109126// until all states have finished. Once all states have finished, we poll once more to check if any new
110127// states have been introduced and stop polling otherwise.
0 commit comments