-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat(api/database)!: store deployment record in database for Vela-targeted deployments #1030
Changes from all commits
a712597
3afee3d
a189a6f
1577eb3
c49b7cf
e5f7c3c
03da6ea
14d1f4c
183a91b
ccb6747
c8cc0d7
df3f450
657b460
b8e4f1a
027f67c
1b7305f
5ff37bd
fbea7f5
8e4f2ee
9694b4e
dc495ae
442913b
70c641f
13d051b
43cc0fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//nolint:dupl // ignore similar code | ||
package admin | ||
|
||
import ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,10 @@ package deployment | |
import ( | ||
"fmt" | ||
"net/http" | ||
"time" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/go-vela/server/database" | ||
"github.com/go-vela/server/router/middleware/org" | ||
"github.com/go-vela/server/router/middleware/repo" | ||
"github.com/go-vela/server/router/middleware/user" | ||
|
@@ -82,7 +84,8 @@ func CreateDeployment(c *gin.Context) { | |
|
||
// update fields in deployment object | ||
input.SetRepoID(r.GetID()) | ||
input.SetUser(u.GetName()) | ||
input.SetCreatedBy(u.GetName()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
input.SetCreatedAt(time.Now().Unix()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
|
||
if len(input.GetDescription()) == 0 { | ||
input.SetDescription("Deployment request from Vela") | ||
|
@@ -107,5 +110,15 @@ func CreateDeployment(c *gin.Context) { | |
return | ||
} | ||
|
||
c.JSON(http.StatusCreated, input) | ||
// send API call to create the deployment | ||
d, err := database.FromContext(c).CreateDeployment(c, input) | ||
if err != nil { | ||
retErr := fmt.Errorf("unable to create new deployment for %s: %w", r.GetFullName(), err) | ||
|
||
util.HandleError(c, http.StatusInternalServerError, retErr) | ||
|
||
return | ||
} | ||
|
||
c.JSON(http.StatusCreated, d) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
if statements should only be cuddled with assignments used in the if statement itself (wsl)