mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-04 14:35:32 +00:00
Migrates the runner to `connectrpc.com/connect/v2` by pinning actionslib v1.5.0, which carries https://gitea.com/gitea/actionslib/pulls/28. The wire behaviour towards Gitea is unchanged and works against Gitea servers on connect v1 and v2. The client keeps v1's unlimited response size, and the error codes and messages the runner checks stay the same. Reviewed-on: https://gitea.com/gitea/runner/pulls/1325 Reviewed-by: bircni <[email protected]> Co-authored-by: silverwind <[email protected]>
29 lines
979 B
Go
29 lines
979 B
Go
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package client
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"strings"
|
|
|
|
"connectrpc.com/connect/v2"
|
|
runnerv1 "gitea.dev/actionslib/runner/v1"
|
|
)
|
|
|
|
// A Client manages communication with the runner.
|
|
type Client interface {
|
|
Address() string
|
|
Declare(context.Context, *runnerv1.DeclareRequest) (*runnerv1.DeclareResponse, error)
|
|
FetchTask(context.Context, *runnerv1.FetchTaskRequest) (*runnerv1.FetchTaskResponse, error)
|
|
UpdateLog(context.Context, *runnerv1.UpdateLogRequest) (*runnerv1.UpdateLogResponse, error)
|
|
UpdateTask(context.Context, *runnerv1.UpdateTaskRequest) (*runnerv1.UpdateTaskResponse, error)
|
|
}
|
|
|
|
// IsRegistrationRejected reports whether Gitea itself answered "unregistered runner", unlike a proxy's 401.
|
|
func IsRegistrationRejected(err error) bool {
|
|
var connectErr *connect.Error
|
|
return errors.As(err, &connectErr) && strings.HasSuffix(connectErr.Message(), "unregistered runner")
|
|
}
|