mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2024-11-24 05:38:10 +03:00
chore(gRPC): add update and update step for client
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
f2fb8798fa
commit
9be39b8cd4
4 changed files with 39 additions and 1 deletions
|
@ -24,4 +24,10 @@ type Client interface {
|
|||
|
||||
// Request requests the next available build stage for execution.
|
||||
Request(ctx context.Context, args *runnerv1.RequestRequest) (*runnerv1.Stage, 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
|
||||
}
|
||||
|
|
|
@ -123,3 +123,33 @@ func (p *HTTPClient) Request(ctx context.Context, arg *runnerv1.RequestRequest)
|
|||
|
||||
return res.Msg.Stage, err
|
||||
}
|
||||
|
||||
// Update updates the build stage.
|
||||
func (p *HTTPClient) Update(ctx context.Context, arg *runnerv1.UpdateRequest) error {
|
||||
client := runnerv1connect.NewRunnerServiceClient(
|
||||
p.Client,
|
||||
p.Endpoint,
|
||||
p.opts...,
|
||||
)
|
||||
req := connect.NewRequest(arg)
|
||||
req.Header().Set("X-Runner-Token", p.Secret)
|
||||
|
||||
_, err := client.Update(ctx, req)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// UpdateStep updates the build step.
|
||||
func (p *HTTPClient) UpdateStep(ctx context.Context, arg *runnerv1.UpdateStepRequest) error {
|
||||
client := runnerv1connect.NewRunnerServiceClient(
|
||||
p.Client,
|
||||
p.Endpoint,
|
||||
p.opts...,
|
||||
)
|
||||
req := connect.NewRequest(arg)
|
||||
req.Header().Set("X-Runner-Token", p.Secret)
|
||||
|
||||
_, err := client.UpdateStep(ctx, req)
|
||||
|
||||
return err
|
||||
}
|
||||
|
|
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module gitea.com/gitea/act_runner
|
|||
go 1.18
|
||||
|
||||
require (
|
||||
gitea.com/gitea/proto-go v0.0.0-20220901061207-b88901a1b9bc
|
||||
gitea.com/gitea/proto-go v0.0.0-20220901135226-82a982903134
|
||||
github.com/bufbuild/connect-go v0.3.0
|
||||
github.com/docker/docker v20.10.17+incompatible
|
||||
github.com/joho/godotenv v1.4.0
|
||||
|
|
2
go.sum
2
go.sum
|
@ -33,6 +33,8 @@ gitea.com/gitea/proto-go v0.0.0-20220828031749-616e40329b57 h1:eVM6m3h5KpmJM2+LE
|
|||
gitea.com/gitea/proto-go v0.0.0-20220828031749-616e40329b57/go.mod h1:hD8YwSHusjwjEEgubW6XFvnZuNhMZTHz6lwjfltEt/Y=
|
||||
gitea.com/gitea/proto-go v0.0.0-20220901061207-b88901a1b9bc h1:kTVjwKxXma2yAdgXz8T1tiJihtWFK8jGLqArX2NownM=
|
||||
gitea.com/gitea/proto-go v0.0.0-20220901061207-b88901a1b9bc/go.mod h1:hD8YwSHusjwjEEgubW6XFvnZuNhMZTHz6lwjfltEt/Y=
|
||||
gitea.com/gitea/proto-go v0.0.0-20220901135226-82a982903134 h1:5ofH0FGEkIj/P9a6oFDgkdmGSWow1yD1uubiftMA2Kw=
|
||||
gitea.com/gitea/proto-go v0.0.0-20220901135226-82a982903134/go.mod h1:hD8YwSHusjwjEEgubW6XFvnZuNhMZTHz6lwjfltEt/Y=
|
||||
github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
|
||||
|
|
Loading…
Reference in a new issue