diff --git a/core/status.go b/core/status.go index 371ad6b0b2..bd1476c661 100644 --- a/core/status.go +++ b/core/status.go @@ -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 { diff --git a/go.mod b/go.mod index 121651294c..9df3087b68 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index e9d788ecd4..548d7e1230 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/models/bots/runner.go b/models/bots/runner.go index 047945e1a3..78eb62d405 100644 --- a/models/bots/runner.go +++ b/models/bots/runner.go @@ -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. diff --git a/routers/api/bots/runner/runner.go b/routers/api/bots/runner/runner.go index 8c46d56f47..aadd00bf6a 100644 --- a/routers/api/bots/runner/runner.go +++ b/routers/api/bots/runner/runner.go @@ -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, }, })