Skip to content

Commit

Permalink
refactor(steps/services): use server API types for steps and services (
Browse files Browse the repository at this point in the history
…#1210)

* refactor(steps/services): use server API types for steps and services

* gci
  • Loading branch information
ecrupper authored Oct 18, 2024
1 parent 37f2c35 commit c701bd8
Show file tree
Hide file tree
Showing 384 changed files with 4,153 additions and 611 deletions.
2 changes: 1 addition & 1 deletion api/admin/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"

"github.com/go-vela/server/constants"
"github.com/go-vela/server/database"
"github.com/go-vela/server/util"
"github.com/go-vela/types"
"github.com/go-vela/types/constants"
)

// swagger:operation PUT /api/v1/admin/clean admin AdminCleanResources
Expand Down
4 changes: 2 additions & 2 deletions api/admin/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ 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/util"
"github.com/go-vela/types/library"
)

// swagger:operation PUT /api/v1/admin/service admin AdminUpdateService
Expand Down Expand Up @@ -59,7 +59,7 @@ func UpdateService(c *gin.Context) {
l.Debug("platform admin: updating service")

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

err := c.Bind(input)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions api/admin/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ 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/util"
"github.com/go-vela/types/library"
)

// swagger:operation PUT /api/v1/admin/step admin AdminUpdateStep
Expand Down Expand Up @@ -58,7 +58,7 @@ func UpdateStep(c *gin.Context) {
l.Debug("platform admin: updating step")

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

err := c.Bind(input)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion api/admin/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"

"github.com/go-vela/server/constants"
"github.com/go-vela/server/internal/token"
"github.com/go-vela/server/util"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/library"
)

Expand Down
2 changes: 1 addition & 1 deletion api/auth/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"

"github.com/go-vela/server/constants"
"github.com/go-vela/server/database"
"github.com/go-vela/server/internal"
"github.com/go-vela/server/router/middleware/user"
"github.com/go-vela/server/util"
"github.com/go-vela/types/constants"
)

// swagger:operation GET /logout authenticate GetLogout
Expand Down
2 changes: 1 addition & 1 deletion api/auth/post_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"

"github.com/go-vela/server/constants"
"github.com/go-vela/server/database"
"github.com/go-vela/server/internal/token"
"github.com/go-vela/server/scm"
"github.com/go-vela/server/util"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/library"
)

Expand Down
2 changes: 1 addition & 1 deletion api/badge.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"

"github.com/go-vela/server/constants"
"github.com/go-vela/server/database"
"github.com/go-vela/server/router/middleware/repo"
"github.com/go-vela/server/util"
"github.com/go-vela/types/constants"
)

// swagger:operation GET /badge/{org}/{repo}/status.svg base GetBadge
Expand Down
2 changes: 1 addition & 1 deletion api/build/approve.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"

"github.com/go-vela/server/constants"
"github.com/go-vela/server/database"
"github.com/go-vela/server/queue"
"github.com/go-vela/server/queue/models"
"github.com/go-vela/server/router/middleware/build"
"github.com/go-vela/server/router/middleware/repo"
"github.com/go-vela/server/router/middleware/user"
"github.com/go-vela/server/util"
"github.com/go-vela/types/constants"
)

// swagger:operation POST /api/v1/repos/{org}/{repo}/builds/{build}/approve builds ApproveBuild
Expand Down
2 changes: 1 addition & 1 deletion api/build/auto_cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (

"github.com/go-vela/server/api/types"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/server/constants"
"github.com/go-vela/server/database"
"github.com/go-vela/server/internal/token"
"github.com/go-vela/types/constants"
)

// AutoCancel is a helper function that checks to see if any pending or running
Expand Down
2 changes: 1 addition & 1 deletion api/build/auto_cancel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/go-vela/server/api/types"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/types/constants"
"github.com/go-vela/server/constants"
)

func Test_isCancelable(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/build/cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import (
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"

"github.com/go-vela/server/constants"
"github.com/go-vela/server/database"
"github.com/go-vela/server/internal/token"
"github.com/go-vela/server/router/middleware/build"
"github.com/go-vela/server/router/middleware/executors"
"github.com/go-vela/server/router/middleware/repo"
"github.com/go-vela/server/router/middleware/user"
"github.com/go-vela/server/util"
"github.com/go-vela/types/constants"
)

// swagger:operation DELETE /api/v1/repos/{org}/{repo}/builds/{build}/cancel builds CancelBuild
Expand Down
5 changes: 2 additions & 3 deletions api/build/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ import (
"github.com/sirupsen/logrus"

"github.com/go-vela/server/api/types"
"github.com/go-vela/server/constants"
"github.com/go-vela/server/database"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/library"
)

// cleanBuild is a helper function to kill the build
// without execution. This will kill all resources,
// like steps and services, for the build.
func CleanBuild(ctx context.Context, database database.Interface, b *types.Build, services []*library.Service, steps []*library.Step, e error) {
func CleanBuild(ctx context.Context, database database.Interface, b *types.Build, services []*types.Service, steps []*types.Step, e error) {
l := logrus.WithFields(logrus.Fields{
"build": b.GetNumber(),
"build_id": b.GetID(),
Expand Down
2 changes: 1 addition & 1 deletion api/build/compile_publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import (
"github.com/go-vela/server/api/types"
"github.com/go-vela/server/compiler"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/server/constants"
"github.com/go-vela/server/database"
"github.com/go-vela/server/internal"
"github.com/go-vela/server/queue"
"github.com/go-vela/server/queue/models"
"github.com/go-vela/server/scm"
"github.com/go-vela/types/constants"
)

// CompileAndPublishConfig is a struct that contains information for the CompileAndPublish function.
Expand Down
24 changes: 12 additions & 12 deletions api/build/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import (
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"

"github.com/go-vela/server/api/types"
"github.com/go-vela/server/compiler"
"github.com/go-vela/server/compiler/types/pipeline"
"github.com/go-vela/server/constants"
"github.com/go-vela/server/database"
"github.com/go-vela/server/internal"
"github.com/go-vela/server/router/middleware/build"
"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/constants"
"github.com/go-vela/types/library"
)

// Graph contains nodes, and relationships between nodes, or edges.
Expand All @@ -46,10 +46,10 @@ type node struct {
Name string `json:"name"`

// vela metadata
Status string `json:"status"`
StartedAt int `json:"started_at"`
FinishedAt int `json:"finished_at"`
Steps []*library.Step `json:"steps"`
Status string `json:"status"`
StartedAt int `json:"started_at"`
FinishedAt int `json:"finished_at"`
Steps []*types.Step `json:"steps"`

// unexported data used for building edges
Stage *pipeline.Stage `json:"-"`
Expand All @@ -67,7 +67,7 @@ type edge struct {

// stg represents a stage's steps and some metadata for producing node/edge information.
type stg struct {
steps []*library.Step
steps []*types.Step
// used for tracking stage status
success int
running int
Expand Down Expand Up @@ -241,7 +241,7 @@ func GetBuildGraph(c *gin.Context) {
}

// retrieve the steps for the build from the step table
steps := []*library.Step{}
steps := []*types.Step{}
page := 1
perPage := 100

Expand Down Expand Up @@ -279,7 +279,7 @@ func GetBuildGraph(c *gin.Context) {
}

// retrieve the services for the build from the service table
services := []*library.Service{}
services := []*types.Service{}
page = 1
perPage = 100

Expand Down Expand Up @@ -359,7 +359,7 @@ func GetBuildGraph(c *gin.Context) {
// initialize a stage tracker
if _, ok := stageMap[name]; !ok {
stageMap[name] = &stg{
steps: []*library.Step{},
steps: []*types.Step{},
}
}

Expand Down Expand Up @@ -615,13 +615,13 @@ func nodeFromStage(nodeID, cluster int, stage *pipeline.Stage, s *stg) *node {
}

// nodeFromService returns a new node from a service.
func nodeFromService(nodeID int, service *library.Service) *node {
func nodeFromService(nodeID int, service *types.Service) *node {
return &node{
ID: nodeID,
Cluster: ServiceCluster,
Name: service.GetName(),
Stage: nil,
Steps: []*library.Step{},
Steps: []*types.Step{},
Status: service.GetStatus(),
StartedAt: int(service.GetStarted()),
FinishedAt: int(service.GetFinished()),
Expand Down
2 changes: 1 addition & 1 deletion api/build/list_org.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (

"github.com/go-vela/server/api"
"github.com/go-vela/server/api/types"
"github.com/go-vela/server/constants"
"github.com/go-vela/server/database"
"github.com/go-vela/server/router/middleware/org"
"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/constants"
)

// swagger:operation GET /api/v1/repos/{org}/builds builds ListBuildsForOrg
Expand Down
2 changes: 1 addition & 1 deletion api/build/list_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (

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

// swagger:operation GET /api/v1/repos/{org}/{repo}/builds builds ListBuildsForRepo
Expand Down
2 changes: 1 addition & 1 deletion api/build/restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/sirupsen/logrus"

"github.com/go-vela/server/compiler"
"github.com/go-vela/server/constants"
"github.com/go-vela/server/database"
"github.com/go-vela/server/internal"
"github.com/go-vela/server/queue"
Expand All @@ -21,7 +22,6 @@ import (
"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/constants"
)

// swagger:operation POST /api/v1/repos/{org}/{repo}/builds/{build} builds RestartBuild
Expand Down
2 changes: 1 addition & 1 deletion api/build/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"

"github.com/go-vela/server/constants"
"github.com/go-vela/server/internal/token"
"github.com/go-vela/server/router/middleware/build"
"github.com/go-vela/server/router/middleware/claims"
"github.com/go-vela/server/router/middleware/repo"
"github.com/go-vela/server/util"
"github.com/go-vela/types/constants"
"github.com/go-vela/types/library"
)

Expand Down
7 changes: 3 additions & 4 deletions api/build/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import (
"github.com/sirupsen/logrus"

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

// swagger:operation PUT /api/v1/repos/{org}/{repo}/builds/{build} builds UpdateBuild
Expand Down Expand Up @@ -191,7 +190,7 @@ func UpdateComponentStatuses(c *gin.Context, b *types.Build, status string) erro
l.Debug("updating component statuses")

// retrieve the steps for the build from the step table
steps := []*library.Step{}
steps := []*types.Step{}
page := 1
perPage := 100

Expand Down Expand Up @@ -230,7 +229,7 @@ func UpdateComponentStatuses(c *gin.Context, b *types.Build, status string) erro
}

// retrieve the services for the build from the service table
services := []*library.Service{}
services := []*types.Service{}
page = 1

for page > 0 {
Expand Down
2 changes: 1 addition & 1 deletion api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/sirupsen/logrus"

"github.com/go-vela/server/constants"
"github.com/go-vela/server/database"
"github.com/go-vela/server/queue"
"github.com/go-vela/types/constants"
)

// MetricsQueryParameters holds query parameter information pertaining to requested metrics.
Expand Down
2 changes: 1 addition & 1 deletion api/repo/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (

"github.com/go-vela/server/api/types"
"github.com/go-vela/server/api/types/actions"
"github.com/go-vela/server/constants"
"github.com/go-vela/server/database"
"github.com/go-vela/server/router/middleware/settings"
"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/constants"
)

// swagger:operation POST /api/v1/repos repos CreateRepo
Expand Down
2 changes: 1 addition & 1 deletion api/repo/list_org.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
"github.com/sirupsen/logrus"

"github.com/go-vela/server/api"
"github.com/go-vela/server/constants"
"github.com/go-vela/server/database"
"github.com/go-vela/server/router/middleware/org"
"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/constants"
)

// swagger:operation GET /api/v1/repos/{org} repos ListReposForOrg
Expand Down
Loading

0 comments on commit c701bd8

Please sign in to comment.