chore: shouldn't import act_runner

This commit is contained in:
Jason Song 2022-11-15 11:52:39 +08:00
parent fc2c70033a
commit 9c6476754d
3 changed files with 5 additions and 6 deletions

1
go.mod
View File

@ -6,7 +6,6 @@ require (
code.gitea.io/gitea-vet v0.2.2-0.20220122151748-48ebc902541b code.gitea.io/gitea-vet v0.2.2-0.20220122151748-48ebc902541b
code.gitea.io/sdk/gitea v0.15.1 code.gitea.io/sdk/gitea v0.15.1
codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570 codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570
gitea.com/gitea/act_runner v0.0.0-20221015084035-e63e22e8c81d
gitea.com/gitea/proto-go v0.0.0-20221028125601-35c4f6b05835 gitea.com/gitea/proto-go v0.0.0-20221028125601-35c4f6b05835
gitea.com/go-chi/binding v0.0.0-20220309004920-114340dabecb gitea.com/go-chi/binding v0.0.0-20220309004920-114340dabecb
gitea.com/go-chi/cache v0.2.0 gitea.com/go-chi/cache v0.2.0

2
go.sum
View File

@ -83,8 +83,6 @@ git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:cliQ4H
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs= git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs=
gitea.com/gitea/act v0.0.0-20221104080934-57978c14b59d h1:Xfdo11dwHpcjFtH0qebucf6zUqei8z9eZ4f0IMvoLjw= gitea.com/gitea/act v0.0.0-20221104080934-57978c14b59d h1:Xfdo11dwHpcjFtH0qebucf6zUqei8z9eZ4f0IMvoLjw=
gitea.com/gitea/act v0.0.0-20221104080934-57978c14b59d/go.mod h1:lpzib6X73FHLSaTqTakan1xcsCAVhlZvPSpLns7jkRo= gitea.com/gitea/act v0.0.0-20221104080934-57978c14b59d/go.mod h1:lpzib6X73FHLSaTqTakan1xcsCAVhlZvPSpLns7jkRo=
gitea.com/gitea/act_runner v0.0.0-20221015084035-e63e22e8c81d h1:WdZqNKX1TB0vH1nOFZhoYdesEGFwvwpKGkwjGaGCmgo=
gitea.com/gitea/act_runner v0.0.0-20221015084035-e63e22e8c81d/go.mod h1:ZDTf3CZrtttQj0EzduNKPRUBPIrPOK6cdx/LFFVX+EE=
gitea.com/gitea/proto-go v0.0.0-20221028125601-35c4f6b05835 h1:27PhT7Nli/pgRo1bDYVZ+hlCKuF9cfFuo+y9muaPVJY= gitea.com/gitea/proto-go v0.0.0-20221028125601-35c4f6b05835 h1:27PhT7Nli/pgRo1bDYVZ+hlCKuF9cfFuo+y9muaPVJY=
gitea.com/gitea/proto-go v0.0.0-20221028125601-35c4f6b05835/go.mod h1:hD8YwSHusjwjEEgubW6XFvnZuNhMZTHz6lwjfltEt/Y= gitea.com/gitea/proto-go v0.0.0-20221028125601-35c4f6b05835/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 h1:Yy0Bxzc8R2wxiwXoG/rECGplJUSpXqCsog9PuJFgiHs=

View File

@ -12,21 +12,23 @@ import (
"code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/timeutil"
"gitea.com/gitea/act_runner/core"
runnerv1 "gitea.com/gitea/proto-go/runner/v1" runnerv1 "gitea.com/gitea/proto-go/runner/v1"
"github.com/bufbuild/connect-go" "github.com/bufbuild/connect-go"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
) )
const runnerOnlineTimeDeltaSecs = 30 const (
runnerOnlineTimeDeltaSecs = 30
uuidHeaderKey = "x-runner-uuid"
)
var WithRunner = connect.WithInterceptors(connect.UnaryInterceptorFunc(func(unaryFunc connect.UnaryFunc) connect.UnaryFunc { var WithRunner = connect.WithInterceptors(connect.UnaryInterceptorFunc(func(unaryFunc connect.UnaryFunc) connect.UnaryFunc {
return func(ctx context.Context, request connect.AnyRequest) (connect.AnyResponse, error) { return func(ctx context.Context, request connect.AnyRequest) (connect.AnyResponse, error) {
if methodName(request) == "Register" { if methodName(request) == "Register" {
return unaryFunc(ctx, request) return unaryFunc(ctx, request)
} }
uuid := request.Header().Get(core.UUIDHeader) uuid := request.Header().Get(uuidHeaderKey)
runner, err := bots_model.GetRunnerByUUID(uuid) runner, err := bots_model.GetRunnerByUUID(uuid)
if err != nil { if err != nil {
if _, ok := err.(bots_model.ErrRunnerNotExist); ok { if _, ok := err.(bots_model.ErrRunnerNotExist); ok {