mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
chore(runtime): fetch build data
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
631f801aa6
commit
d3d56ed0ef
9 changed files with 77 additions and 78 deletions
|
@ -25,29 +25,12 @@ type Client interface {
|
|||
// Request requests the next available build stage for execution.
|
||||
Request(ctx context.Context, args *runnerv1.RequestRequest) (*runnerv1.Stage, error)
|
||||
|
||||
// Detail fetches build details
|
||||
Detail(ctx context.Context, args *runnerv1.DetailRequest) (*runnerv1.DetailResponse, error)
|
||||
|
||||
// Update updates the build stage.
|
||||
Update(ctxt context.Context, args *runnerv1.UpdateRequest) error
|
||||
|
||||
// UpdateStep updates the build step.
|
||||
UpdateStep(ctx context.Context, args *runnerv1.UpdateStepRequest) error
|
||||
}
|
||||
|
||||
type contextKey string
|
||||
|
||||
const clientContextKey = contextKey("gitea.rpc.client")
|
||||
|
||||
// FromContext returns the client from the context.
|
||||
func FromContext(ctx context.Context) Client {
|
||||
val := ctx.Value(clientContextKey)
|
||||
if val != nil {
|
||||
if c, ok := val.(Client); ok {
|
||||
return c
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WithClient returns a new context with the given client.
|
||||
func WithClient(ctx context.Context, c Client) context.Context {
|
||||
return context.WithValue(ctx, clientContextKey, c)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue