1
1
mirror of https://github.com/go-gitea/gitea synced 2025-12-07 13:28:25 +00:00

refactor: rename tables to bot_*

This commit is contained in:
Jason Song
2022-11-29 12:34:23 +08:00
parent 3ac6bf3db4
commit 04d72d3500
20 changed files with 173 additions and 201 deletions

View File

@@ -56,7 +56,7 @@ func (s *Service) Register(
}
// create new runner
runner := &bots_model.Runner{
runner := &bots_model.BotRunner{
UUID: gouuid.New().String(),
Name: req.Msg.Name,
OwnerID: runnerToken.OwnerID,
@@ -276,7 +276,7 @@ func (s *Service) UpdateLog(
return res, nil
}
func pickTask(ctx context.Context, runner *bots_model.Runner) (*runnerv1.Task, bool, error) {
func pickTask(ctx context.Context, runner *bots_model.BotRunner) (*runnerv1.Task, bool, error) {
t, ok, err := bots_model.CreateTaskForRunner(ctx, runner)
if err != nil {
return nil, false, fmt.Errorf("CreateTaskForRunner: %w", err)
@@ -294,7 +294,7 @@ func pickTask(ctx context.Context, runner *bots_model.Runner) (*runnerv1.Task, b
return task, true, nil
}
func getSecretsOfTask(ctx context.Context, task *bots_model.Task) map[string]string {
func getSecretsOfTask(ctx context.Context, task *bots_model.BotTask) map[string]string {
// Returning an error is worse than returning empty secrets.
secrets := map[string]string{}
@@ -334,7 +334,7 @@ func getSecretsOfTask(ctx context.Context, task *bots_model.Task) map[string]str
return secrets
}
func generateTaskContext(t *bots_model.Task) *structpb.Struct {
func generateTaskContext(t *bots_model.BotTask) *structpb.Struct {
event := map[string]interface{}{}
_ = json.Unmarshal([]byte(t.Job.Run.EventPayload), &event)

View File

@@ -68,9 +68,9 @@ func getMethodName(req connect.AnyRequest) string {
type runnerCtxKey struct{}
func GetRunner(ctx context.Context) *bots_model.Runner {
func GetRunner(ctx context.Context) *bots_model.BotRunner {
if v := ctx.Value(runnerCtxKey{}); v != nil {
if r, ok := v.(*bots_model.Runner); ok {
if r, ok := v.(*bots_model.BotRunner); ok {
return r
}
}

View File

@@ -37,7 +37,7 @@ func RunnersList(ctx *context.Context, tplName base.TplName, opts bots_model.Fin
}
// ownid=0,repo_id=0,means this token is used for global
var token *bots_model.RunnerToken
var token *bots_model.BotRunnerToken
token, err = bots_model.GetUnactivatedRunnerToken(opts.OwnerID, opts.RepoID)
if _, ok := err.(bots_model.ErrRunnerTokenNotExist); ok {
token, err = bots_model.NewRunnerToken(opts.OwnerID, opts.RepoID)

View File

@@ -125,7 +125,7 @@ func ViewPost(ctx *context_module.Context) {
},
}
var task *bots_model.Task
var task *bots_model.BotTask
if current.TaskID > 0 {
var err error
task, err = bots_model.GetTaskByID(ctx, current.TaskID)
@@ -263,7 +263,7 @@ func Cancel(ctx *context_module.Context) {
// getRunJobs gets the jobs of runIndex, and returns jobs[jobIndex], jobs.
// Any error will be written to the ctx.
// It never returns a nil job of an empty jobs, if the jobIndex is out of range, it will be treated as 0.
func getRunJobs(ctx *context_module.Context, runIndex, jobIndex int64) (*bots_model.RunJob, []*bots_model.RunJob) {
func getRunJobs(ctx *context_module.Context, runIndex, jobIndex int64) (*bots_model.BotRunJob, []*bots_model.BotRunJob) {
run, err := bots_model.GetRunByIndex(ctx, ctx.Repo.Repository.ID, runIndex)
if err != nil {
if _, ok := err.(bots_model.ErrRunNotExist); ok {