feat(runner): begin runner view ui

This commit is contained in:
fuxiaohei
2022-10-09 20:44:12 +08:00
committed by Jason Song
parent 1a78fd3494
commit 206b2a104e
5 changed files with 108 additions and 44 deletions

View File

@ -19,6 +19,7 @@ import (
// ErrRunnerNotExist represents an error for bot runner not exist
type ErrRunnerNotExist struct {
ID int64
UUID string
Token string
}
@ -79,6 +80,7 @@ type FindRunnerOptions struct {
db.ListOptions
RepoID int64
OwnerID int64
Sort string
}
func (opts FindRunnerOptions) toCond() builder.Cond {
@ -140,6 +142,20 @@ func GetRunnerByUUID(uuid string) (*Runner, error) {
return &runner, nil
}
// GetRunnerByID returns a bot runner via id
func GetRunnerByID(id int64) (*Runner, error) {
var runner Runner
has, err := db.GetEngine(db.DefaultContext).Where("id=?", id).Get(&runner)
if err != nil {
return nil, err
} else if !has {
return nil, ErrRunnerNotExist{
ID: id,
}
}
return &runner, nil
}
// GetRunnerByToken returns a bot runner via token
func GetRunnerByToken(token string) (*Runner, error) {
var runner Runner