Skip to content

Commit 3db6801

Browse files
authored
refactor: remove types dependency (#610)
1 parent 0e10f28 commit 3db6801

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+122
-233
lines changed

api/build.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"github.com/gin-gonic/gin"
1010

11-
"github.com/go-vela/types"
11+
api "github.com/go-vela/server/api/types"
1212
"github.com/go-vela/worker/router/middleware/executor"
1313
)
1414

@@ -47,7 +47,7 @@ func GetBuild(c *gin.Context) {
4747
if err != nil {
4848
msg := fmt.Errorf("unable to read build: %w", err).Error()
4949

50-
c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg})
50+
c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg})
5151

5252
return
5353
}
@@ -90,7 +90,7 @@ func CancelBuild(c *gin.Context) {
9090
if err != nil {
9191
msg := fmt.Errorf("unable to cancel build: %w", err).Error()
9292

93-
c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg})
93+
c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg})
9494

9595
return
9696
}

api/executor.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/gin-gonic/gin"
1010

1111
api "github.com/go-vela/server/api/types"
12-
"github.com/go-vela/types"
1312
"github.com/go-vela/worker/executor"
1413
exec "github.com/go-vela/worker/router/middleware/executor"
1514
)
@@ -57,7 +56,7 @@ func GetExecutor(c *gin.Context) {
5756
if err != nil {
5857
msg := fmt.Errorf("unable to retrieve build: %w", err).Error()
5958

60-
c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg})
59+
c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg})
6160

6261
return
6362
}
@@ -67,7 +66,7 @@ func GetExecutor(c *gin.Context) {
6766
if err != nil {
6867
msg := fmt.Errorf("unable to retrieve pipeline: %w", err).Error()
6968

70-
c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg})
69+
c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg})
7170

7271
return
7372
}
@@ -104,7 +103,7 @@ func GetExecutors(c *gin.Context) {
104103
if value == nil {
105104
msg := "no running executors found"
106105

107-
c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg})
106+
c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg})
108107

109108
return
110109
}
@@ -114,7 +113,7 @@ func GetExecutors(c *gin.Context) {
114113
if !ok {
115114
msg := "unable to get executors"
116115

117-
c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg})
116+
c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg})
118117

119118
return
120119
}
@@ -136,7 +135,7 @@ func GetExecutors(c *gin.Context) {
136135
if err != nil {
137136
msg := fmt.Errorf("unable to retrieve build: %w", err).Error()
138137

139-
c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg})
138+
c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg})
140139

141140
return
142141
}
@@ -146,7 +145,7 @@ func GetExecutors(c *gin.Context) {
146145
if err != nil {
147146
msg := fmt.Errorf("unable to retrieve pipeline: %w", err).Error()
148147

149-
c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg})
148+
c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg})
150149

151150
return
152151
}

api/pipeline.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"github.com/gin-gonic/gin"
1010

11-
"github.com/go-vela/types"
11+
api "github.com/go-vela/server/api/types"
1212
"github.com/go-vela/worker/router/middleware/executor"
1313
)
1414

@@ -46,7 +46,7 @@ func GetPipeline(c *gin.Context) {
4646
if err != nil {
4747
msg := fmt.Errorf("unable to read pipeline: %w", err).Error()
4848

49-
c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg})
49+
c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg})
5050

5151
return
5252
}

api/repo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"github.com/gin-gonic/gin"
1010

11-
"github.com/go-vela/types"
11+
api "github.com/go-vela/server/api/types"
1212
"github.com/go-vela/worker/router/middleware/executor"
1313
)
1414

@@ -46,7 +46,7 @@ func GetRepo(c *gin.Context) {
4646
if err != nil {
4747
msg := fmt.Errorf("unable to read build: %w", err).Error()
4848

49-
c.AbortWithStatusJSON(http.StatusInternalServerError, types.Error{Message: &msg})
49+
c.AbortWithStatusJSON(http.StatusInternalServerError, api.Error{Message: &msg})
5050

5151
return
5252
}

cmd/vela-worker/exec.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ import (
1515
"github.com/go-vela/sdk-go/vela"
1616
api "github.com/go-vela/server/api/types"
1717
"github.com/go-vela/server/compiler/types/pipeline"
18+
"github.com/go-vela/server/constants"
1819
"github.com/go-vela/server/queue/models"
19-
"github.com/go-vela/types"
20-
"github.com/go-vela/types/constants"
21-
"github.com/go-vela/types/library"
2220
"github.com/go-vela/worker/executor"
2321
"github.com/go-vela/worker/runtime"
2422
"github.com/go-vela/worker/version"
@@ -36,7 +34,7 @@ func (w *Worker) exec(index int, config *api.Worker) error {
3634

3735
var (
3836
execBuildClient *vela.Client
39-
execBuildExecutable *library.BuildExecutable
37+
execBuildExecutable *api.BuildExecutable
4038
p *pipeline.Build
4139
item *models.Item
4240
retries = 3
@@ -188,7 +186,7 @@ func (w *Worker) exec(index int, config *api.Worker) error {
188186
// If the ItemVersion is older or newer than what we expect, then it might
189187
// not be safe to process the build. Fail the build and loop to the next item.
190188
// TODO: Ask the server to re-compile and requeue the build instead of failing it.
191-
logrus.Errorf("Failing stale queued build due to wrong item version: want %d, got %d", types.ItemVersion, item.ItemVersion)
189+
logrus.Errorf("Failing stale queued build due to wrong item version: want %d, got %d", models.ItemVersion, item.ItemVersion)
192190

193191
build := item.Build
194192
build.SetError("Unable to process stale build (queued before Vela upgrade/downgrade).")

cmd/vela-worker/operate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
"golang.org/x/sync/errgroup"
1111

1212
api "github.com/go-vela/server/api/types"
13+
"github.com/go-vela/server/constants"
1314
"github.com/go-vela/server/queue"
14-
"github.com/go-vela/types/constants"
1515
)
1616

1717
// operate is a helper function to initiate all

cmd/vela-worker/register.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import (
1111
"github.com/sirupsen/logrus"
1212

1313
api "github.com/go-vela/server/api/types"
14-
"github.com/go-vela/types/constants"
15-
"github.com/go-vela/types/library"
14+
"github.com/go-vela/server/constants"
1615
)
1716

1817
// checkIn is a helper function to phone home to the server.
@@ -21,7 +20,7 @@ func (w *Worker) checkIn(config *api.Worker) (bool, string, error) {
2120
logrus.Infof("retrieving worker %s from the server", config.GetHostname())
2221

2322
var (
24-
tkn *library.Token
23+
tkn *api.Token
2524
retries = 3
2625
)
2726

cmd/vela-worker/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414

1515
api "github.com/go-vela/server/api/types"
1616
"github.com/go-vela/server/compiler/types/pipeline"
17+
"github.com/go-vela/server/constants"
1718
"github.com/go-vela/server/queue"
18-
"github.com/go-vela/types/constants"
1919
"github.com/go-vela/worker/executor"
2020
"github.com/go-vela/worker/runtime"
2121
)

executor/executor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
"github.com/sirupsen/logrus"
99

10-
"github.com/go-vela/types/constants"
10+
"github.com/go-vela/server/constants"
1111
)
1212

1313
// New creates and returns a Vela engine capable of

executor/executor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
api "github.com/go-vela/server/api/types"
1515
"github.com/go-vela/server/api/types/actions"
1616
"github.com/go-vela/server/compiler/types/pipeline"
17+
"github.com/go-vela/server/constants"
1718
"github.com/go-vela/server/mock/server"
18-
"github.com/go-vela/types/constants"
1919
"github.com/go-vela/worker/executor/linux"
2020
"github.com/go-vela/worker/executor/local"
2121
"github.com/go-vela/worker/runtime/docker"

0 commit comments

Comments
 (0)