@@ -28,9 +28,10 @@ import (
28
28
)
29
29
30
30
const (
31
+ jsRuntime = "js"
32
+ goRuntime = "go"
33
+
31
34
preProcessingTimeout = time .Minute * 5
32
- jsRuntime = "js"
33
- goRuntime = "go"
34
35
)
35
36
36
37
type uploadType int
@@ -63,10 +64,11 @@ type DeployOptions struct {
63
64
64
65
IsDraft bool
65
66
66
- Title string
67
- Branch string
68
- CommitRef string
69
- UploadTimeout time.Duration
67
+ Title string
68
+ Branch string
69
+ CommitRef string
70
+ UploadTimeout time.Duration
71
+ PreProcessTimeout time.Duration
70
72
71
73
Observer DeployObserver
72
74
@@ -238,7 +240,7 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *
238
240
239
241
if n .overCommitted (options .files ) {
240
242
var err error
241
- deploy , err = n .WaitUntilDeployReady (ctx , deploy )
243
+ deploy , err = n .WaitUntilDeployReady (ctx , deploy , options . PreProcessTimeout )
242
244
if err != nil {
243
245
if options .Observer != nil {
244
246
options .Observer .OnFailedDelta (deployFiles )
@@ -270,11 +272,15 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *
270
272
return deploy , nil
271
273
}
272
274
273
- func (n * Netlify ) WaitUntilDeployReady (ctx context.Context , d * models.Deploy ) (* models.Deploy , error ) {
275
+ func (n * Netlify ) WaitUntilDeployReady (ctx context.Context , d * models.Deploy , timeout time. Duration ) (* models.Deploy , error ) {
274
276
authInfo := context .GetAuthInfo (ctx )
275
277
ticker := time .NewTicker (2 * time .Second )
276
278
defer ticker .Stop ()
277
279
280
+ if timeout <= 0 {
281
+ timeout = preProcessingTimeout
282
+ }
283
+
278
284
params := operations .NewGetSiteDeployParams ().WithSiteID (d .SiteID ).WithDeployID (d .ID )
279
285
start := time .Now ()
280
286
for t := range ticker .C {
@@ -296,7 +302,7 @@ func (n *Netlify) WaitUntilDeployReady(ctx context.Context, d *models.Deploy) (*
296
302
return nil , fmt .Errorf ("Error: preprocessing deploy failed" )
297
303
}
298
304
299
- if t .Sub (start ) > preProcessingTimeout {
305
+ if t .Sub (start ) > timeout {
300
306
return nil , fmt .Errorf ("Error: preprocessing deploy timed out" )
301
307
}
302
308
}
0 commit comments