Skip to content

Commit aa80af0

Browse files
committed
remove WorkflowAPI interface because these route handlers are not reused
1 parent c246182 commit aa80af0

File tree

3 files changed

+21
-62
lines changed

3 files changed

+21
-62
lines changed

routers/api/v1/api.go

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -915,21 +915,6 @@ func Routes() *web.Router {
915915
})
916916
}
917917

918-
addActionsWorkflowRoutes := func(
919-
m *web.Router,
920-
actw actions.WorkflowAPI,
921-
) {
922-
m.Group("/actions", func() {
923-
m.Group("/workflows", func() {
924-
m.Get("", reqToken(), actw.ListRepositoryWorkflows)
925-
m.Get("/{workflow_id}", reqToken(), actw.GetWorkflow)
926-
m.Put("/{workflow_id}/disable", reqToken(), reqRepoWriter(unit.TypeActions), actw.DisableWorkflow)
927-
m.Post("/{workflow_id}/dispatches", reqToken(), reqRepoWriter(unit.TypeActions), bind(api.CreateActionWorkflowDispatch{}), actw.DispatchWorkflow)
928-
m.Put("/{workflow_id}/enable", reqToken(), reqRepoWriter(unit.TypeActions), actw.EnableWorkflow)
929-
}, context.ReferencesGitRepo(), reqRepoReader(unit.TypeActions))
930-
})
931-
}
932-
933918
m.Group("", func() {
934919
// Miscellaneous (no scope required)
935920
if setting.API.EnableSwagger {
@@ -1170,15 +1155,17 @@ func Routes() *web.Router {
11701155
m.Post("/accept", repo.AcceptTransfer)
11711156
m.Post("/reject", repo.RejectTransfer)
11721157
}, reqToken())
1173-
addActionsRoutes(
1174-
m,
1175-
reqOwner(),
1176-
repo.NewAction(),
1177-
)
1178-
addActionsWorkflowRoutes(
1179-
m,
1180-
repo.NewActionWorkflow(),
1181-
)
1158+
1159+
addActionsRoutes(m, reqOwner(), repo.NewAction()) // it adds the routes for secrets/variables and runner management
1160+
1161+
m.Group("/actions/workflows", func() {
1162+
m.Get("", reqToken(), repo.ActionsListRepositoryWorkflows)
1163+
m.Get("/{workflow_id}", reqToken(), repo.ActionsGetWorkflow)
1164+
m.Put("/{workflow_id}/disable", reqToken(), reqRepoWriter(unit.TypeActions), repo.ActionsDisableWorkflow)
1165+
m.Post("/{workflow_id}/dispatches", reqToken(), reqRepoWriter(unit.TypeActions), bind(api.CreateActionWorkflowDispatch{}), repo.ActionsDispatchWorkflow)
1166+
m.Put("/{workflow_id}/enable", reqToken(), reqRepoWriter(unit.TypeActions), repo.ActionsEnableWorkflow)
1167+
}, context.ReferencesGitRepo(), reqRepoReader(unit.TypeActions))
1168+
11821169
m.Group("/hooks/git", func() {
11831170
m.Combo("").Get(repo.ListGitHooks)
11841171
m.Group("/{id}", func() {

routers/api/v1/repo/action.go

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -585,16 +585,8 @@ func ListActionTasks(ctx *context.APIContext) {
585585
ctx.JSON(http.StatusOK, &res)
586586
}
587587

588-
// ActionWorkflow implements actions_service.WorkflowAPI
589-
type ActionWorkflow struct{}
590-
591-
// NewActionWorkflow creates a new ActionWorkflow service
592-
func NewActionWorkflow() actions_service.WorkflowAPI {
593-
return ActionWorkflow{}
594-
}
595-
596-
func (a ActionWorkflow) ListRepositoryWorkflows(ctx *context.APIContext) {
597-
// swagger:operation GET /repos/{owner}/{repo}/actions/workflows repository ListRepositoryWorkflows
588+
func ActionsListRepositoryWorkflows(ctx *context.APIContext) {
589+
// swagger:operation GET /repos/{owner}/{repo}/actions/workflows repository ActionsListRepositoryWorkflows
598590
// ---
599591
// summary: List repository workflows
600592
// produces:
@@ -633,8 +625,8 @@ func (a ActionWorkflow) ListRepositoryWorkflows(ctx *context.APIContext) {
633625
ctx.JSON(http.StatusOK, &api.ActionWorkflowResponse{Workflows: workflows, TotalCount: int64(len(workflows))})
634626
}
635627

636-
func (a ActionWorkflow) GetWorkflow(ctx *context.APIContext) {
637-
// swagger:operation GET /repos/{owner}/{repo}/actions/workflows/{workflow_id} repository GetWorkflow
628+
func ActionsGetWorkflow(ctx *context.APIContext) {
629+
// swagger:operation GET /repos/{owner}/{repo}/actions/workflows/{workflow_id} repository ActionsGetWorkflow
638630
// ---
639631
// summary: Get a workflow
640632
// produces:
@@ -689,8 +681,8 @@ func (a ActionWorkflow) GetWorkflow(ctx *context.APIContext) {
689681
ctx.JSON(http.StatusOK, workflow)
690682
}
691683

692-
func (a ActionWorkflow) DisableWorkflow(ctx *context.APIContext) {
693-
// swagger:operation PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable repository DisableWorkflow
684+
func ActionsDisableWorkflow(ctx *context.APIContext) {
685+
// swagger:operation PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable repository ActionsDisableWorkflow
694686
// ---
695687
// summary: Disable a workflow
696688
// produces:
@@ -738,8 +730,8 @@ func (a ActionWorkflow) DisableWorkflow(ctx *context.APIContext) {
738730
ctx.Status(http.StatusNoContent)
739731
}
740732

741-
func (a ActionWorkflow) DispatchWorkflow(ctx *context.APIContext) {
742-
// swagger:operation POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches repository DispatchWorkflow
733+
func ActionsDispatchWorkflow(ctx *context.APIContext) {
734+
// swagger:operation POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches repository ActionsDispatchWorkflow
743735
// ---
744736
// summary: Create a workflow dispatch event
745737
// produces:
@@ -828,8 +820,8 @@ func (a ActionWorkflow) DispatchWorkflow(ctx *context.APIContext) {
828820
ctx.Status(http.StatusNoContent)
829821
}
830822

831-
func (a ActionWorkflow) EnableWorkflow(ctx *context.APIContext) {
832-
// swagger:operation PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable repository EnableWorkflow
823+
func ActionsEnableWorkflow(ctx *context.APIContext) {
824+
// swagger:operation PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable repository ActionsEnableWorkflow
833825
// ---
834826
// summary: Enable a workflow
835827
// produces:

services/actions/workflow_interface.go

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)