Skip to content

add mone logging and some todos #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions go/porcelain/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ import (
)

const (
jsRuntime = "js"
goRuntime = "go"

preProcessingTimeout = time.Minute * 5
jsRuntime = "js"
goRuntime = "go"
)

type uploadType int
Expand Down Expand Up @@ -63,10 +64,11 @@ type DeployOptions struct {

IsDraft bool

Title string
Branch string
CommitRef string
UploadTimeout time.Duration
Title string
Branch string
CommitRef string
UploadTimeout time.Duration
PreProcessTimeout time.Duration

Observer DeployObserver

Expand Down Expand Up @@ -238,7 +240,7 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *

if n.overCommitted(options.files) {
var err error
deploy, err = n.WaitUntilDeployReady(ctx, deploy)
deploy, err = n.WaitUntilDeployReady(ctx, deploy, options.PreProcessTimeout)
if err != nil {
if options.Observer != nil {
options.Observer.OnFailedDelta(deployFiles)
Expand Down Expand Up @@ -270,11 +272,15 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *
return deploy, nil
}

func (n *Netlify) WaitUntilDeployReady(ctx context.Context, d *models.Deploy) (*models.Deploy, error) {
func (n *Netlify) WaitUntilDeployReady(ctx context.Context, d *models.Deploy, timeout time.Duration) (*models.Deploy, error) {
authInfo := context.GetAuthInfo(ctx)
ticker := time.NewTicker(2 * time.Second)
defer ticker.Stop()

if timeout <= 0 {
timeout = preProcessingTimeout
}

params := operations.NewGetSiteDeployParams().WithSiteID(d.SiteID).WithDeployID(d.ID)
start := time.Now()
for t := range ticker.C {
Expand All @@ -296,7 +302,7 @@ func (n *Netlify) WaitUntilDeployReady(ctx context.Context, d *models.Deploy) (*
return nil, fmt.Errorf("Error: preprocessing deploy failed")
}

if t.Sub(start) > preProcessingTimeout {
if t.Sub(start) > timeout {
return nil, fmt.Errorf("Error: preprocessing deploy timed out")
}
}
Expand Down