1
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-02-02 15:09:33 -05:00

chore(runner): update runner status using proto define

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi.Wu 2022-10-10 18:32:27 +08:00 committed by Jason Song
parent 530faf7227
commit 6f18f76577
5 changed files with 8 additions and 11 deletions

View File

@ -2,7 +2,6 @@ package core
// BuildStatus represents a build status
type BuildStatus string
type RunnerStatus string
// enumerate all the statuses of bot build
const (
@ -17,11 +16,6 @@ const (
StatusFailing BuildStatus = "failure"
StatusKilled BuildStatus = "killed"
StatusError BuildStatus = "error"
// Runner status
StatusIdle RunnerStatus = "idle"
StatusActive RunnerStatus = "active"
StatusOffline RunnerStatus = "offline"
)
func (status BuildStatus) IsPending() bool {

2
go.mod
View File

@ -6,7 +6,7 @@ require (
code.gitea.io/gitea-vet v0.2.2-0.20220122151748-48ebc902541b
code.gitea.io/sdk/gitea v0.15.1
codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570
gitea.com/gitea/proto-go v0.0.0-20221010074642-cc3659a7348b
gitea.com/gitea/proto-go v0.0.0-20221010094818-eedee304e2b9
gitea.com/go-chi/binding v0.0.0-20220309004920-114340dabecb
gitea.com/go-chi/cache v0.2.0
gitea.com/go-chi/captcha v0.0.0-20211013065431-70641c1a35d5

2
go.sum
View File

@ -85,6 +85,8 @@ gitea.com/gitea/act v0.0.0-20221008102131-d89ab14fb580 h1:F/VSl4oP5Gqe0FQ2i6BX/O
gitea.com/gitea/act v0.0.0-20221008102131-d89ab14fb580/go.mod h1:lpzib6X73FHLSaTqTakan1xcsCAVhlZvPSpLns7jkRo=
gitea.com/gitea/proto-go v0.0.0-20221010074642-cc3659a7348b h1:BEEgR2+rEOyWGbY3iyGCIrv6wmlaj9dAECWONexibrI=
gitea.com/gitea/proto-go v0.0.0-20221010074642-cc3659a7348b/go.mod h1:hD8YwSHusjwjEEgubW6XFvnZuNhMZTHz6lwjfltEt/Y=
gitea.com/gitea/proto-go v0.0.0-20221010094818-eedee304e2b9 h1:roFxcMnXJrjZvHBfba5Py6Jin9VTTute0WwzRXhJnQs=
gitea.com/gitea/proto-go v0.0.0-20221010094818-eedee304e2b9/go.mod h1:hD8YwSHusjwjEEgubW6XFvnZuNhMZTHz6lwjfltEt/Y=
gitea.com/go-chi/binding v0.0.0-20220309004920-114340dabecb h1:Yy0Bxzc8R2wxiwXoG/rECGplJUSpXqCsog9PuJFgiHs=
gitea.com/go-chi/binding v0.0.0-20220309004920-114340dabecb/go.mod h1:77TZu701zMXWJFvB8gvTbQ92zQ3DQq/H7l5wAEjQRKc=
gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e/go.mod h1:k2V/gPDEtXGjjMGuBJiapffAXTv76H4snSmlJRLUhH0=

View File

@ -8,11 +8,11 @@ import (
"context"
"fmt"
"code.gitea.io/gitea/core"
"code.gitea.io/gitea/models/db"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/timeutil"
runnerv1 "gitea.com/gitea/proto-go/runner/v1"
"xorm.io/builder"
)
@ -45,8 +45,8 @@ type Runner struct {
RepoRange string // glob match which repositories could use this runner
Token string `xorm:"CHAR(36) UNIQUE"`
// instance status (idle)
Status core.RunnerStatus
// instance status (idle, active, offline)
Status runnerv1.RunnerStatus
// Store OS and Artch.
AgentLabels []string
// Store custom labes use defined.

View File

@ -96,7 +96,7 @@ func (s *Service) Register(
OwnerID: runnerToken.OwnerID,
RepoID: runnerToken.RepoID,
Token: req.Msg.Token,
Status: core.StatusOffline,
Status: runnerv1.RunnerStatus_RUNNER_STATUS_OFFLINE,
AgentLabels: req.Msg.AgentLabels,
CustomLabels: req.Msg.CustomLabels,
}
@ -119,6 +119,7 @@ func (s *Service) Register(
Name: runner.Name,
AgentLabels: runner.AgentLabels,
CustomLabels: runner.CustomLabels,
Status: runner.Status,
},
})