Skip to content

Commit e9b98ae

Browse files
wolfogrewxiaoguang
andauthored
Enhance routers for the Actions runner operations (#33549)
- Find the runner before deleting - Move the main logic from `routers/web/repo/setting/runners.go` to `routers/web/shared/actions/runners.go`. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 parent 217ffe5 commit e9b98ae

File tree

5 files changed

+387
-207
lines changed

5 files changed

+387
-207
lines changed

models/actions/runner.go

+9
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ func init() {
167167

168168
type FindRunnerOptions struct {
169169
db.ListOptions
170+
IDs []int64
170171
RepoID int64
171172
OwnerID int64 // it will be ignored if RepoID is set
172173
Sort string
@@ -178,6 +179,14 @@ type FindRunnerOptions struct {
178179
func (opts FindRunnerOptions) ToConds() builder.Cond {
179180
cond := builder.NewCond()
180181

182+
if len(opts.IDs) > 0 {
183+
if len(opts.IDs) == 1 {
184+
cond = cond.And(builder.Eq{"id": opts.IDs[0]})
185+
} else {
186+
cond = cond.And(builder.In("id", opts.IDs))
187+
}
188+
}
189+
181190
if opts.RepoID > 0 {
182191
c := builder.NewCond().And(builder.Eq{"repo_id": opts.RepoID})
183192
if opts.WithAvailable {

routers/web/repo/setting/runners.go

-187
This file was deleted.

0 commit comments

Comments
 (0)