From 9be39b8cd4629678dac490eb5f0710cdd12ae00e Mon Sep 17 00:00:00 2001 From: "Bo-Yi.Wu" Date: Thu, 1 Sep 2022 22:00:41 +0800 Subject: [PATCH] chore(gRPC): add update and update step for client Signed-off-by: Bo-Yi.Wu --- client/client.go | 6 ++++++ client/http.go | 30 ++++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 2 ++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/client/client.go b/client/client.go index d8f4c3c..55538bc 100644 --- a/client/client.go +++ b/client/client.go @@ -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 } diff --git a/client/http.go b/client/http.go index 3ae2bf1..953ad83 100644 --- a/client/http.go +++ b/client/http.go @@ -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 +} diff --git a/go.mod b/go.mod index ac13f19..e0d75f5 100644 --- a/go.mod +++ b/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 diff --git a/go.sum b/go.sum index 6a3e2df..ee1d418 100644 --- a/go.sum +++ b/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=