Skip to content

Commit c15e6db

Browse files
authored
Merge branch 'master' into golang-al2
2 parents d8dcf44 + a22226f commit c15e6db

File tree

12 files changed

+319
-40
lines changed

12 files changed

+319
-40
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
99

10+
## [2.23.0](https://github.com/netlify/open-api/compare/v2.22.0...v2.23.0) (2023-09-28)
11+
12+
13+
### Features
14+
15+
* add build data ([9a3da54](https://github.com/netlify/open-api/commit/9a3da54945cc9523eaeb705dcfb360417c696578))
16+
17+
18+
### Bug Fixes
19+
20+
* generate go client ([9a785e8](https://github.com/netlify/open-api/commit/9a785e8a15f6ea4d1b2f8feedba188ea1375f712))
21+
22+
## [2.22.0](https://github.com/netlify/open-api/compare/v2.21.1...v2.22.0) (2023-09-22)
23+
24+
25+
### Features
26+
27+
* **go-client:** add poll for processed ([#491](https://github.com/netlify/open-api/issues/491)) ([288f331](https://github.com/netlify/open-api/commit/288f3311da509282172ba41f8c8200736744fea3))
28+
1029
## [2.21.1](https://github.com/netlify/open-api/compare/v2.21.0...v2.21.1) (2023-09-07)
1130

1231

go/models/create_env_vars_params_body_items.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/models/env_var.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/models/function_config.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/models/update_env_var_params_body.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/plumbing/operations/notify_build_start_parameters.go

Lines changed: 58 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/porcelain/deploy.go

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ type DeployOptions struct {
8484
BuildDir string
8585
LargeMediaEnabled bool
8686

87-
IsDraft bool
87+
IsDraft bool
88+
SkipRetry bool
8889

8990
Title string
9091
Branch string
@@ -350,12 +351,14 @@ func (n *Netlify) DoDeploy(ctx context.Context, options *DeployOptions, deploy *
350351
return deploy, nil
351352
}
352353

353-
if err := n.uploadFiles(ctx, deploy, options.files, options.Observer, fileUpload, options.UploadTimeout); err != nil {
354+
skipRetry := options.SkipRetry
355+
356+
if err := n.uploadFiles(ctx, deploy, options.files, options.Observer, fileUpload, options.UploadTimeout, skipRetry); err != nil {
354357
return nil, err
355358
}
356359

357360
if options.functions != nil {
358-
if err := n.uploadFiles(ctx, deploy, options.functions, options.Observer, functionUpload, options.UploadTimeout); err != nil {
361+
if err := n.uploadFiles(ctx, deploy, options.functions, options.Observer, functionUpload, options.UploadTimeout, skipRetry); err != nil {
359362
return nil, err
360363
}
361364
}
@@ -402,12 +405,17 @@ func (n *Netlify) WaitUntilDeployReady(ctx context.Context, d *models.Deploy) (*
402405
return n.waitForState(ctx, d, "prepared", "ready")
403406
}
404407

405-
// WaitUntilDeployLive blocks until the deploy is in the "ready" state. At this point, the deploy is ready to recieve traffic.
408+
// WaitUntilDeployLive blocks until the deploy is in the "ready" state. At this point, the deploy is ready to receive traffic to all of its URLs.
406409
func (n *Netlify) WaitUntilDeployLive(ctx context.Context, d *models.Deploy) (*models.Deploy, error) {
407410
return n.waitForState(ctx, d, "ready")
408411
}
409412

410-
func (n *Netlify) uploadFiles(ctx context.Context, d *models.Deploy, files *deployFiles, observer DeployObserver, t uploadType, timeout time.Duration) error {
413+
// WaitUntilDeployProcessed blocks until the deploy is in the "processed" state. At this point, the deploy is ready to receive traffic via its permalink.
414+
func (n *Netlify) WaitUntilDeployProcessed(ctx context.Context, d *models.Deploy) (*models.Deploy, error) {
415+
return n.waitForState(ctx, d, "processed")
416+
}
417+
418+
func (n *Netlify) uploadFiles(ctx context.Context, d *models.Deploy, files *deployFiles, observer DeployObserver, t uploadType, timeout time.Duration, skipRetry bool) error {
411419
sharedErr := &uploadError{err: nil, mutex: &sync.Mutex{}}
412420
sem := make(chan int, n.uploadLimit)
413421
wg := &sync.WaitGroup{}
@@ -437,7 +445,7 @@ func (n *Netlify) uploadFiles(ctx context.Context, d *models.Deploy, files *depl
437445
select {
438446
case sem <- 1:
439447
wg.Add(1)
440-
go n.uploadFile(ctx, d, file, observer, t, timeout, wg, sem, sharedErr)
448+
go n.uploadFile(ctx, d, file, observer, t, timeout, wg, sem, sharedErr, skipRetry)
441449
case <-ctx.Done():
442450
log.Info("Context terminated, aborting file upload")
443451
return errors.Wrap(ctx.Err(), "aborted file upload early")
@@ -457,7 +465,7 @@ func (n *Netlify) uploadFiles(ctx context.Context, d *models.Deploy, files *depl
457465
return sharedErr.err
458466
}
459467

460-
func (n *Netlify) uploadFile(ctx context.Context, d *models.Deploy, f *FileBundle, c DeployObserver, t uploadType, timeout time.Duration, wg *sync.WaitGroup, sem chan int, sharedErr *uploadError) {
468+
func (n *Netlify) uploadFile(ctx context.Context, d *models.Deploy, f *FileBundle, c DeployObserver, t uploadType, timeout time.Duration, wg *sync.WaitGroup, sem chan int, sharedErr *uploadError, skipRetry bool) {
461469
defer func() {
462470
wg.Done()
463471
<-sem
@@ -545,10 +553,16 @@ func (n *Netlify) uploadFile(ctx context.Context, d *models.Deploy, f *FileBundl
545553
context.GetLogger(ctx).WithError(operationError).Errorf("Failed to upload file %v", f.Name)
546554
apiErr, ok := operationError.(deployApiError)
547555

548-
if ok && apiErr.Code() == 401 {
549-
sharedErr.mutex.Lock()
550-
sharedErr.err = operationError
551-
sharedErr.mutex.Unlock()
556+
if ok {
557+
if apiErr.Code() == 401 {
558+
sharedErr.mutex.Lock()
559+
sharedErr.err = operationError
560+
sharedErr.mutex.Unlock()
561+
}
562+
563+
if skipRetry && (apiErr.Code() == 400 || apiErr.Code() == 422) {
564+
operationError = backoff.Permanent(operationError)
565+
}
552566
}
553567
}
554568

@@ -809,11 +823,12 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
809823
}
810824
}
811825

812-
if function.DisplayName != "" || function.Generator != "" || len(routes) > 0 {
826+
if function.DisplayName != "" || function.Generator != "" || len(routes) > 0 || len(function.BuildData) > 0 {
813827
functionsConfig[file.Name] = models.FunctionConfig{
814828
DisplayName: function.DisplayName,
815829
Generator: function.Generator,
816830
Routes: routes,
831+
BuildData: function.BuildData,
817832
}
818833
}
819834

0 commit comments

Comments
 (0)