Skip to content

Commit 5c4e59c

Browse files
authored
Merge pull request #262 from netlify/261-wait-until-deploy-live
Add WaitUntilDeployLive Go client method
2 parents af7f43b + e2c70ae commit 5c4e59c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

go/porcelain/deploy.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ func (n *Netlify) waitForState(ctx context.Context, d *models.Deploy, timeout ti
311311
context.GetLogger(ctx).WithFields(logrus.Fields{
312312
"deploy_id": d.ID,
313313
"state": resp.Payload.State,
314-
}).Debug("Waiting until deploy ready")
314+
}).Debugf("Waiting until deploy state in %s", states)
315315

316316
for _, state := range states {
317317
if resp.Payload.State == state {
@@ -331,6 +331,7 @@ func (n *Netlify) waitForState(ctx context.Context, d *models.Deploy, timeout ti
331331
return d, nil
332332
}
333333

334+
// WaitUntilDeployReady blocks until the deploy is in the "prepared" or "ready" state.
334335
func (n *Netlify) WaitUntilDeployReady(ctx context.Context, d *models.Deploy, timeout time.Duration) (*models.Deploy, error) {
335336
if timeout <= 0 {
336337
timeout = preProcessingTimeout
@@ -339,6 +340,15 @@ func (n *Netlify) WaitUntilDeployReady(ctx context.Context, d *models.Deploy, ti
339340
return n.waitForState(ctx, d, timeout, "prepared", "ready")
340341
}
341342

343+
// WaitUntilDeployLive blocks until the deploy is in the or "ready" state. At this point, the deploy is ready to recieve traffic.
344+
func (n *Netlify) WaitUntilDeployLive(ctx context.Context, d *models.Deploy, timeout time.Duration) (*models.Deploy, error) {
345+
if timeout <= 0 {
346+
timeout = preProcessingTimeout
347+
}
348+
349+
return n.waitForState(ctx, d, timeout, "ready")
350+
}
351+
342352
func (n *Netlify) uploadFiles(ctx context.Context, d *models.Deploy, files *deployFiles, observer DeployObserver, t uploadType, timeout time.Duration) error {
343353
sharedErr := &uploadError{err: nil, mutex: &sync.Mutex{}}
344354
sem := make(chan int, n.uploadLimit)

0 commit comments

Comments
 (0)