Skip to content

Commit

Permalink
Fix: deployment table post.go and restart.go error (#1032)
Browse files Browse the repository at this point in the history
* feat: adding deployment database

* updating things

* fix reserved word user

* testing and other

* tests

* fixing tests

* fixing things

* help

* fixing various tests

* new types changes

* updating build deployNumber field to deploymentID

* changing build DeployID field back to DeployNumber

* fixing migrations issues

* fixing lint

* fixing lint things

* fixing lint things

* getting new types

* fixing things

* fix pls

* fix pls

* fix pls

* fix pls

* fixing things

* ...

* linter

* linter

* linter

* fixing 2022 copyright lint errors

* hopefully fixing tests

* fixing integration tests

* fixing vaders comments

* fixing vaders comments pt 2

* fix

* fixing eastons comments

* linter

* linter

* making david mays changes

* fixy fix

* fixy fix

* fix: changing code so that deployment builds are updated in post.go and restart.go

---------

Co-authored-by: Claire.Nicholas <[email protected]>
Co-authored-by: ecrupper <[email protected]>
  • Loading branch information
3 people authored Jan 3, 2024
1 parent a7cd07f commit 730b0f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions api/build/restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,13 @@ func RestartBuild(c *gin.Context) {
c.JSON(http.StatusCreated, b)

// if the event is a deployment, update the build list
if !strings.EqualFold(b.GetEvent(), constants.EventDeploy) {
if strings.EqualFold(b.GetEvent(), constants.EventDeploy) {
d, err := database.FromContext(c).GetDeploymentForRepo(c, r, b.GetDeployNumber())
if err != nil {
logger.Errorf("unable to set get deployment for build %s: %v", entry, err)
}

build := append(d.Builds, b)
build := append(d.GetBuilds(), b)

d.SetBuilds(build)

Expand Down
5 changes: 3 additions & 2 deletions api/webhook/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ func PostWebhook(c *gin.Context) {
// set the BuildID field
h.SetBuildID(b.GetID())
// if event is deployment, update the deployment record to include this build
if !strings.EqualFold(b.GetEvent(), constants.EventDeploy) {
if strings.EqualFold(b.GetEvent(), constants.EventDeploy) {
d, err := database.FromContext(c).GetDeploymentForRepo(c, repo, webhook.Deployment.GetNumber())
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
Expand Down Expand Up @@ -695,7 +695,8 @@ func PostWebhook(c *gin.Context) {
return
}
} else {
d.SetBuilds([]*library.Build{b})
build := append(d.GetBuilds(), b)
d.SetBuilds(build)
_, err := database.FromContext(c).UpdateDeployment(d)
if err != nil {
retErr := fmt.Errorf("%s: failed to update deployment %s/%d: %w", baseErr, repo.GetFullName(), d.GetNumber(), err)
Expand Down

0 comments on commit 730b0f4

Please sign in to comment.