Skip to content
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

Fix: deployment table post.go and restart.go error #1032

Merged
merged 44 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a712597
feat: adding deployment database
Sep 22, 2023
3afee3d
updating things
Sep 25, 2023
a189a6f
fix reserved word user
ecrupper Sep 25, 2023
1577eb3
testing and other
Sep 27, 2023
c49b7cf
tests
Sep 28, 2023
e5f7c3c
fixing tests
Oct 24, 2023
03da6ea
merging main into branch
Nov 28, 2023
14d1f4c
fixing things
Dec 15, 2023
183a91b
merging main into branch
Dec 15, 2023
ccb6747
help
Dec 15, 2023
c8cc0d7
fixing various tests
Dec 18, 2023
df3f450
new types changes
Dec 21, 2023
657b460
updating build deployNumber field to deploymentID
Dec 21, 2023
b8e4f1a
changing build DeployID field back to DeployNumber
Dec 22, 2023
027f67c
fixing migrations issues
Dec 22, 2023
1b7305f
Merge branch 'main' of github.com:go-vela/server into feat/deployment…
Dec 22, 2023
5ff37bd
fixing lint
Dec 22, 2023
fbea7f5
fixing lint things
Dec 22, 2023
8e4f2ee
fixing lint things
Dec 22, 2023
9694b4e
getting new types
Dec 22, 2023
dc495ae
fixing things
Dec 22, 2023
442913b
fix pls
Dec 22, 2023
70c641f
fix pls
Dec 22, 2023
13d051b
fix pls
Dec 22, 2023
43cc0fc
fix pls
Dec 22, 2023
5de0961
fixing things
Dec 22, 2023
e8d0d8e
...
Dec 22, 2023
56fe6a1
linter
Dec 22, 2023
f3f5825
linter
Dec 22, 2023
f93b7ed
linter
Dec 22, 2023
e9b7e1c
fixing 2022 copyright lint errors
Dec 22, 2023
f372ab2
hopefully fixing tests
Dec 27, 2023
0c00bcd
fixing integration tests
Dec 27, 2023
0758cb3
fixing vaders comments
Dec 28, 2023
9ba8f52
fixing vaders comments pt 2
Dec 28, 2023
dca4e8c
fix
Dec 28, 2023
85bbac6
fixing eastons comments
Dec 28, 2023
a5a78c5
linter
Dec 28, 2023
21e5481
linter
Dec 28, 2023
f8f6cfd
making david mays changes
Dec 29, 2023
16fc94c
fixy fix
Dec 29, 2023
245a6db
fixy fix
Dec 29, 2023
d8649b5
Merge branch 'main' of github.com:go-vela/server into feat/deployment…
Jan 3, 2024
e1f4bc8
fix: changing code so that deployment builds are updated in post.go a…
Jan 3, 2024
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
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 @@ -179,7 +179,7 @@

defer func() {
// send API call to update the webhook
_, err = database.FromContext(c).UpdateHook(ctx, h)

Check failure on line 182 in api/webhook/post.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] api/webhook/post.go#L182

Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
Raw output
api/webhook/post.go:182:32: Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
		_, err = database.FromContext(c).UpdateHook(ctx, h)
		                             ^
if err != nil {
logrus.Errorf("unable to update webhook %s/%d: %v", r.GetFullName(), h.GetNumber(), err)
}
Expand Down Expand Up @@ -666,7 +666,7 @@
// 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 @@
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 Expand Up @@ -832,7 +833,7 @@
case "archived", "unarchived", constants.ActionEdited:
logrus.Debugf("repository action %s for %s", h.GetEventAction(), r.GetFullName())
// send call to get repository from database
dbRepo, err := database.FromContext(c).GetRepoForOrg(ctx, r.GetOrg(), r.GetName())

Check failure on line 836 in api/webhook/post.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] api/webhook/post.go#L836

Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
Raw output
api/webhook/post.go:836:38: Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
		dbRepo, err := database.FromContext(c).GetRepoForOrg(ctx, r.GetOrg(), r.GetName())
		                                   ^
if err != nil {
retErr := fmt.Errorf("%s: failed to get repo %s: %w", baseErr, r.GetFullName(), err)

Expand All @@ -843,7 +844,7 @@
}

// send API call to capture the last hook for the repo
lastHook, err := database.FromContext(c).LastHookForRepo(ctx, dbRepo)

Check failure on line 847 in api/webhook/post.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] api/webhook/post.go#L847

Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
Raw output
api/webhook/post.go:847:40: Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
		lastHook, err := database.FromContext(c).LastHookForRepo(ctx, dbRepo)
		                                     ^
if err != nil {
retErr := fmt.Errorf("unable to get last hook for repo %s: %w", r.GetFullName(), err)

Expand Down
Loading