Skip to content

Commit

Permalink
refactor(deployment): use server API types for deployment (#1197)
Browse files Browse the repository at this point in the history
* refactor(deployment): use server API types for deployment

* gci

* fix tests

---------

Co-authored-by: Tim Huynh <tim_huynh94@yahoo.com>
  • Loading branch information
ecrupper and timhuynh94 authored Oct 2, 2024
1 parent 23e4c60 commit 79667fd
Show file tree
Hide file tree
Showing 45 changed files with 2,050 additions and 386 deletions.
6 changes: 3 additions & 3 deletions api/deployment/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"

"github.com/go-vela/server/api/types"
"github.com/go-vela/server/database"
"github.com/go-vela/server/router/middleware/repo"
"github.com/go-vela/server/router/middleware/user"
"github.com/go-vela/server/scm"
"github.com/go-vela/server/util"
"github.com/go-vela/types/library"
)

// swagger:operation POST /api/v1/deployments/{org}/{repo} deployments CreateDeployment
Expand Down Expand Up @@ -72,7 +72,7 @@ func CreateDeployment(c *gin.Context) {
l.Debugf("creating new deployment for repo %s", r.GetFullName())

// capture body from API request
input := new(library.Deployment)
input := new(types.Deployment)

err := c.Bind(input)
if err != nil {
Expand All @@ -84,7 +84,7 @@ func CreateDeployment(c *gin.Context) {
}

// update fields in deployment object
input.SetRepoID(r.GetID())
input.SetRepo(r)
input.SetCreatedBy(u.GetName())
input.SetCreatedAt(time.Now().Unix())

Expand Down
41 changes: 0 additions & 41 deletions api/types/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"time"

"github.com/go-vela/types/constants"
"github.com/go-vela/types/library"
"github.com/go-vela/types/raw"
)

Expand Down Expand Up @@ -1206,43 +1205,3 @@ func (b *Build) String() string {
b.GetTitle(),
)
}

// TODO: remove this when Deployment is moved from types and uses Build type instead of library type.
func (b *Build) ToLibrary() *library.Build {
return &library.Build{
ID: b.ID,
RepoID: b.GetRepo().ID,
PipelineID: b.PipelineID,
Number: b.Number,
Parent: b.Parent,
Event: b.Event,
EventAction: b.EventAction,
Status: b.Status,
Error: b.Error,
Enqueued: b.Enqueued,
Created: b.Created,
Started: b.Started,
Finished: b.Finished,
Deploy: b.Deploy,
DeployNumber: b.DeployNumber,
DeployPayload: b.DeployPayload,
Clone: b.Clone,
Source: b.Source,
Title: b.Title,
Message: b.Message,
Commit: b.Commit,
Sender: b.Sender,
Author: b.Author,
Email: b.Email,
Link: b.Link,
Branch: b.Branch,
Ref: b.Ref,
BaseRef: b.BaseRef,
HeadRef: b.HeadRef,
Host: b.Host,
Runtime: b.Runtime,
Distribution: b.Distribution,
ApprovedAt: b.ApprovedAt,
ApprovedBy: b.ApprovedBy,
}
}
Loading

0 comments on commit 79667fd

Please sign in to comment.