@@ -28,9 +28,10 @@ import (
2828)
2929
3030const (
31+ jsRuntime = "js"
32+ goRuntime = "go"
33+
3134 preProcessingTimeout = time .Minute * 5
32- jsRuntime = "js"
33- goRuntime = "go"
3435)
3536
3637type uploadType int
@@ -63,10 +64,11 @@ type DeployOptions struct {
6364
6465 IsDraft bool
6566
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
7072
7173 Observer DeployObserver
7274
@@ -238,7 +240,7 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *
238240
239241 if n .overCommitted (options .files ) {
240242 var err error
241- deploy , err = n .WaitUntilDeployReady (ctx , deploy )
243+ deploy , err = n .WaitUntilDeployReady (ctx , deploy , options . PreProcessTimeout )
242244 if err != nil {
243245 if options .Observer != nil {
244246 options .Observer .OnFailedDelta (deployFiles )
@@ -270,11 +272,15 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *
270272 return deploy , nil
271273}
272274
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 ) {
274276 authInfo := context .GetAuthInfo (ctx )
275277 ticker := time .NewTicker (2 * time .Second )
276278 defer ticker .Stop ()
277279
280+ if timeout <= 0 {
281+ timeout = preProcessingTimeout
282+ }
283+
278284 params := operations .NewGetSiteDeployParams ().WithSiteID (d .SiteID ).WithDeployID (d .ID )
279285 start := time .Now ()
280286 for t := range ticker .C {
@@ -296,7 +302,7 @@ func (n *Netlify) WaitUntilDeployReady(ctx context.Context, d *models.Deploy) (*
296302 return nil , fmt .Errorf ("Error: preprocessing deploy failed" )
297303 }
298304
299- if t .Sub (start ) > preProcessingTimeout {
305+ if t .Sub (start ) > timeout {
300306 return nil , fmt .Errorf ("Error: preprocessing deploy timed out" )
301307 }
302308 }
0 commit comments