From a6cdc21e8fd799dc240706e263db8e1a2f32a6f4 Mon Sep 17 00:00:00 2001 From: kruskall <99559985+kruskall@users.noreply.github.com> Date: Wed, 6 Sep 2023 10:44:50 +0200 Subject: [PATCH] build: bump google.golang.org/grpc and fix failing tests and compile errors (#1505) * test: improve tools to generate testservice pb message * lint: fix linter issues * build: bump google.golang.org/grpc and fix failing tests and compile errors --------- Co-authored-by: Victor Martinez --- Makefile | 4 + internal/apmgodog/go.mod | 16 +- internal/apmgodog/go.sum | 35 +- internal/apmgodog/suitecontext_test.go | 7 +- module/apmgokit/go.mod | 16 +- module/apmgokit/go.sum | 52 ++- module/apmgokit/grpc_test.go | 6 +- module/apmgrpc/client_test.go | 6 +- module/apmgrpc/go.mod | 16 +- module/apmgrpc/go.sum | 52 ++- .../apmgrpc/internal/testservice/generate.go | 20 - .../internal/testservice/testservice.pb.go | 352 +++++++++--------- .../internal/testservice/testservice.proto | 2 +- .../testservice/testservice_grpc.pb.go | 159 ++++++++ module/apmgrpc/server_test.go | 16 +- scripts/generate-testservice.sh | 11 + scripts/install-protobuf.sh | 37 ++ 17 files changed, 500 insertions(+), 307 deletions(-) delete mode 100644 module/apmgrpc/internal/testservice/generate.go create mode 100644 module/apmgrpc/internal/testservice/testservice_grpc.pb.go create mode 100755 scripts/generate-testservice.sh create mode 100755 scripts/install-protobuf.sh diff --git a/Makefile b/Makefile index 501cd0d84..caba0a149 100644 --- a/Makefile +++ b/Makefile @@ -72,5 +72,9 @@ update-licenses: model/marshal_fastjson.go: model/model.go go generate ./model +module/apmgrpc/internal/testservice/testservice.pb.go: + ./scripts/install-protobuf.sh + ./scripts/generate-testservice.sh + scripts/Dockerfile-testing: $(wildcard module/*) go generate ./scripts diff --git a/internal/apmgodog/go.mod b/internal/apmgodog/go.mod index 1bf2a7c19..95297da9a 100644 --- a/internal/apmgodog/go.mod +++ b/internal/apmgodog/go.mod @@ -8,7 +8,8 @@ require ( go.elastic.co/apm/module/apmhttp/v2 v2.4.4 go.elastic.co/apm/v2 v2.4.4 go.elastic.co/fastjson v1.1.0 - google.golang.org/grpc v1.21.1 + google.golang.org/grpc v1.57.0 + google.golang.org/grpc/examples v0.0.0-20230831183909-e498bbc9bd37 ) require ( @@ -19,8 +20,8 @@ require ( github.com/elastic/go-sysinfo v1.7.1 // indirect github.com/elastic/go-windows v1.0.0 // indirect github.com/gofrs/uuid v4.0.0+incompatible // indirect - github.com/golang/protobuf v1.3.2 // indirect - github.com/google/go-cmp v0.5.4 // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/google/go-cmp v0.5.9 // indirect github.com/hashicorp/go-immutable-radix v1.3.0 // indirect github.com/hashicorp/go-memdb v1.3.0 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect @@ -30,10 +31,11 @@ require ( github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/testify v1.8.4 // indirect - golang.org/x/net v0.10.0 // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/text v0.9.0 // indirect - google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a // indirect + golang.org/x/net v0.14.0 // indirect + golang.org/x/sys v0.11.0 // indirect + golang.org/x/text v0.12.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect ) diff --git a/internal/apmgodog/go.sum b/internal/apmgodog/go.sum index a3873f03c..093b10dd0 100644 --- a/internal/apmgodog/go.sum +++ b/internal/apmgodog/go.sum @@ -61,7 +61,6 @@ github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPh github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= @@ -69,14 +68,17 @@ github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -255,8 +257,8 @@ golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -280,13 +282,13 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -311,7 +313,6 @@ golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5/go.mod h1:EkVYQZoAsY45+roY golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -329,12 +330,20 @@ google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRn google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a h1:Ob5/580gVHBJZgXnff1cZDbG+xLtMVE5mDRTe+nIsX4= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1 h1:j6XxA85m/6txkUCHvzlV5f+HBNl/1r5cZ2A/3IEFOO8= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= +google.golang.org/grpc/examples v0.0.0-20230831183909-e498bbc9bd37 h1:kNDwMX0e15RGrBh4L1jfhVxyddRi6J/y8Gg+dcZr+S8= +google.golang.org/grpc/examples v0.0.0-20230831183909-e498bbc9bd37/go.mod h1:GGFp5xqHkVYOZBc9//ZnLinno7HB6j97fG1nL3au94o= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/apmgodog/suitecontext_test.go b/internal/apmgodog/suitecontext_test.go index 7e067672d..2463c71bb 100644 --- a/internal/apmgodog/suitecontext_test.go +++ b/internal/apmgodog/suitecontext_test.go @@ -29,11 +29,11 @@ import ( "strconv" "strings" "sync" - "time" "github.com/cucumber/godog" "google.golang.org/grpc" "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials/insecure" pb "google.golang.org/grpc/examples/helloworld/helloworld" "google.golang.org/grpc/status" "google.golang.org/grpc/test/bufconn" @@ -93,8 +93,8 @@ func (c *featureContext) initTestSuite(s *godog.TestSuiteContext) { pb.RegisterGreeterServer(c.grpcServer, c.grpcService) grpcListener := bufconn.Listen(1) grpcClient, err := grpc.Dial("bufconn", - grpc.WithInsecure(), - grpc.WithDialer(func(string, time.Duration) (net.Conn, error) { return grpcListener.Dial() }), + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithContextDialer(func(ctx context.Context, s string) (net.Conn, error) { return grpcListener.DialContext(ctx) }), grpc.WithUnaryInterceptor(apmgrpc.NewUnaryClientInterceptor()), ) if err != nil { @@ -478,6 +478,7 @@ func parseGRPCStatusCode(s string) (codes.Code, error) { type helloworldGRPCService struct { panic bool err error + pb.UnimplementedGreeterServer } func (h *helloworldGRPCService) SayHello(ctx context.Context, req *pb.HelloRequest) (*pb.HelloReply, error) { diff --git a/module/apmgokit/go.mod b/module/apmgokit/go.mod index 5fe508276..ba224b8b1 100644 --- a/module/apmgokit/go.mod +++ b/module/apmgokit/go.mod @@ -7,7 +7,8 @@ require ( go.elastic.co/apm/module/apmgrpc/v2 v2.4.4 go.elastic.co/apm/module/apmhttp/v2 v2.4.4 go.elastic.co/apm/v2 v2.4.4 - google.golang.org/grpc v1.17.0 + google.golang.org/grpc v1.57.0 + google.golang.org/grpc/examples v0.0.0-20230831183909-e498bbc9bd37 ) require ( @@ -17,18 +18,19 @@ require ( github.com/elastic/go-windows v1.0.0 // indirect github.com/go-logfmt/logfmt v0.4.0 // indirect github.com/go-stack/stack v1.8.0 // indirect - github.com/golang/protobuf v1.2.0 // indirect - github.com/google/go-cmp v0.5.4 // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/google/go-cmp v0.5.9 // indirect github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect go.elastic.co/fastjson v1.1.0 // indirect - golang.org/x/net v0.10.0 // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/text v0.9.0 // indirect - google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 // indirect + golang.org/x/net v0.14.0 // indirect + golang.org/x/sys v0.11.0 // indirect + golang.org/x/text v0.12.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect ) diff --git a/module/apmgokit/go.sum b/module/apmgokit/go.sum index 3eb8cc312..fd8789f99 100644 --- a/module/apmgokit/go.sum +++ b/module/apmgokit/go.sum @@ -1,7 +1,5 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -15,19 +13,17 @@ github.com/go-logfmt/logfmt v0.4.0 h1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80n github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 h1:Iju5GlWwrvL6UBg4zJJt3btmonfrMlCDdsejg4CZE7c= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 h1:rp+c0RAYOWj8l6qbCUTSiRLG/iKnW3K3/QfPPuSsBt4= github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -52,47 +48,43 @@ go.elastic.co/fastjson v1.1.0 h1:3MrGBWWVIxe/xvsbpghtkFoPciPhOCmjsR/HfwEeQR4= go.elastic.co/fastjson v1.1.0/go.mod h1:boNGISWMjQsUPy/t6yqt2/1Wx4YNPSe+mZjlyw9vKKI= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/grpc v1.17.0 h1:TRJYBgMclJvGYn2rIMjj+h9KtMt5r1Ij7ODVRIZkwhk= -google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= +google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= +google.golang.org/grpc/examples v0.0.0-20230831183909-e498bbc9bd37 h1:kNDwMX0e15RGrBh4L1jfhVxyddRi6J/y8Gg+dcZr+S8= +google.golang.org/grpc/examples v0.0.0-20230831183909-e498bbc9bd37/go.mod h1:GGFp5xqHkVYOZBc9//ZnLinno7HB6j97fG1nL3au94o= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M= howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0= diff --git a/module/apmgokit/grpc_test.go b/module/apmgokit/grpc_test.go index 5a5ce4561..f9d8a7dae 100644 --- a/module/apmgokit/grpc_test.go +++ b/module/apmgokit/grpc_test.go @@ -28,6 +28,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" pb "google.golang.org/grpc/examples/helloworld/helloworld" "go.elastic.co/apm/module/apmgrpc/v2" @@ -52,7 +53,7 @@ func Example_grpcServer() { endpoint, encodeRequest, decodeResponse, - )} + ), pb.UnimplementedGreeterServer{}} // When creating the underlying gRPC server, use the apmgrpc.NewUnaryServerInterceptor // function (from module/apmgrpc). This will trace all incoming requests. @@ -153,6 +154,7 @@ func TestGRPCTransport(t *testing.T) { type helloWorldService struct { sayHello *kitgrpc.Server + pb.UnimplementedGreeterServer } func (s *helloWorldService) SayHello(ctx context.Context, req *pb.HelloRequest) (*pb.HelloReply, error) { @@ -186,7 +188,7 @@ func newServer(t *testing.T, tracer *apm.Tracer, server pb.GreeterServer, opts . func newClient(t *testing.T, addr net.Addr) *grpc.ClientConn { conn, err := grpc.Dial( - addr.String(), grpc.WithInsecure(), + addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithUnaryInterceptor(apmgrpc.NewUnaryClientInterceptor()), ) require.NoError(t, err) diff --git a/module/apmgrpc/client_test.go b/module/apmgrpc/client_test.go index 7084e6cb5..d87179dcb 100644 --- a/module/apmgrpc/client_test.go +++ b/module/apmgrpc/client_test.go @@ -26,11 +26,13 @@ import ( "testing" "time" + "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" pb "google.golang.org/grpc/examples/helloworld/helloworld" "google.golang.org/grpc/status" + "google.golang.org/protobuf/testing/protocmp" "go.elastic.co/apm/module/apmgrpc/v2/internal/testservice" "go.elastic.co/apm/module/apmhttp/v2" @@ -65,7 +67,7 @@ func testClientSpan(t *testing.T, traceparentHeaders ...string) { defer conn.Close() resp, err := client.SayHello(context.Background(), &pb.HelloRequest{Name: "birita"}) require.NoError(t, err) - assert.Equal(t, resp, &pb.HelloReply{Message: "hello, birita"}) + assert.Empty(t, cmp.Diff(resp, &pb.HelloReply{Message: "hello, birita"}, protocmp.Transform())) // The client interceptor starts no transactions, only spans. tracer.Flush(nil) @@ -81,7 +83,7 @@ func testClientSpan(t *testing.T, traceparentHeaders ...string) { }, func(ctx context.Context) { resp, err = client.SayHello(ctx, &pb.HelloRequest{Name: "birita"}) require.NoError(t, err) - assert.Equal(t, resp, &pb.HelloReply{Message: "hello, birita"}) + assert.Empty(t, cmp.Diff(resp, &pb.HelloReply{Message: "hello, birita"}, protocmp.Transform())) }) require.Len(t, clientSpans, 1) diff --git a/module/apmgrpc/go.mod b/module/apmgrpc/go.mod index f50ebe625..6c6a8896e 100644 --- a/module/apmgrpc/go.mod +++ b/module/apmgrpc/go.mod @@ -1,12 +1,14 @@ module go.elastic.co/apm/module/apmgrpc/v2 require ( - github.com/golang/protobuf v1.2.0 + github.com/google/go-cmp v0.5.9 github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 github.com/stretchr/testify v1.8.4 go.elastic.co/apm/module/apmhttp/v2 v2.4.4 go.elastic.co/apm/v2 v2.4.4 - google.golang.org/grpc v1.17.0 + google.golang.org/grpc v1.57.0 + google.golang.org/grpc/examples v0.0.0-20230831183909-e498bbc9bd37 + google.golang.org/protobuf v1.31.0 ) require ( @@ -14,16 +16,16 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/elastic/go-sysinfo v1.7.1 // indirect github.com/elastic/go-windows v1.0.0 // indirect - github.com/google/go-cmp v0.5.4 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 // indirect go.elastic.co/fastjson v1.1.0 // indirect - golang.org/x/net v0.10.0 // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/text v0.9.0 // indirect - google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 // indirect + golang.org/x/net v0.14.0 // indirect + golang.org/x/sys v0.11.0 // indirect + golang.org/x/text v0.12.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect gopkg.in/yaml.v3 v3.0.1 // indirect howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect ) diff --git a/module/apmgrpc/go.sum b/module/apmgrpc/go.sum index 730b1b19d..2d54ae973 100644 --- a/module/apmgrpc/go.sum +++ b/module/apmgrpc/go.sum @@ -1,7 +1,5 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -9,19 +7,17 @@ github.com/elastic/go-sysinfo v1.7.1 h1:Wx4DSARcKLllpKT2TnFVdSUJOsybqMYCNQZq1/wO github.com/elastic/go-sysinfo v1.7.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0= github.com/elastic/go-windows v1.0.0 h1:qLURgZFkkrYyTTkvYpsZIgf83AUsdIHfvlJaqaZ7aSY= github.com/elastic/go-windows v1.0.0/go.mod h1:TsU0Nrp7/y3+VwE82FoZF8gC/XFg/Elz6CcloAxnPgU= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 h1:Iju5GlWwrvL6UBg4zJJt3btmonfrMlCDdsejg4CZE7c= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 h1:rp+c0RAYOWj8l6qbCUTSiRLG/iKnW3K3/QfPPuSsBt4= github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -44,47 +40,43 @@ go.elastic.co/fastjson v1.1.0 h1:3MrGBWWVIxe/xvsbpghtkFoPciPhOCmjsR/HfwEeQR4= go.elastic.co/fastjson v1.1.0/go.mod h1:boNGISWMjQsUPy/t6yqt2/1Wx4YNPSe+mZjlyw9vKKI= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/grpc v1.17.0 h1:TRJYBgMclJvGYn2rIMjj+h9KtMt5r1Ij7ODVRIZkwhk= -google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= +google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= +google.golang.org/grpc/examples v0.0.0-20230831183909-e498bbc9bd37 h1:kNDwMX0e15RGrBh4L1jfhVxyddRi6J/y8Gg+dcZr+S8= +google.golang.org/grpc/examples v0.0.0-20230831183909-e498bbc9bd37/go.mod h1:GGFp5xqHkVYOZBc9//ZnLinno7HB6j97fG1nL3au94o= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M= howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0= diff --git a/module/apmgrpc/internal/testservice/generate.go b/module/apmgrpc/internal/testservice/generate.go deleted file mode 100644 index ae1809db5..000000000 --- a/module/apmgrpc/internal/testservice/generate.go +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to Elasticsearch B.V. under one or more contributor -// license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright -// ownership. Elasticsearch B.V. licenses this file to you under -// the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -//go:generate protoc --go_out=plugins=grpc:. --go_opt=paths=source_relative testservice.proto - -package testservice diff --git a/module/apmgrpc/internal/testservice/testservice.pb.go b/module/apmgrpc/internal/testservice/testservice.pb.go index 06e07129e..a635f946f 100644 --- a/module/apmgrpc/internal/testservice/testservice.pb.go +++ b/module/apmgrpc/internal/testservice/testservice.pb.go @@ -16,233 +16,225 @@ // under the License. // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v4.24.2 // source: testservice.proto -package testservice // import "go.elastic.co/apm/module/apmgrpc/internal/testservice" +package testservice import ( - fmt "fmt" + reflect "reflect" + sync "sync" - proto "github.com/golang/protobuf/proto" - - math "math" - - context "context" - - grpc "google.golang.org/grpc" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type AccumulateRequest struct { - Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *AccumulateRequest) Reset() { *m = AccumulateRequest{} } -func (m *AccumulateRequest) String() string { return proto.CompactTextString(m) } -func (*AccumulateRequest) ProtoMessage() {} -func (*AccumulateRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_testservice_6101db31074a6f55, []int{0} -} -func (m *AccumulateRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_AccumulateRequest.Unmarshal(m, b) -} -func (m *AccumulateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_AccumulateRequest.Marshal(b, m, deterministic) -} -func (dst *AccumulateRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_AccumulateRequest.Merge(dst, src) -} -func (m *AccumulateRequest) XXX_Size() int { - return xxx_messageInfo_AccumulateRequest.Size(m) + Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` } -func (m *AccumulateRequest) XXX_DiscardUnknown() { - xxx_messageInfo_AccumulateRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_AccumulateRequest proto.InternalMessageInfo -func (m *AccumulateRequest) GetValue() int64 { - if m != nil { - return m.Value +func (x *AccumulateRequest) Reset() { + *x = AccumulateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_testservice_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return 0 -} - -type AccumulateReply struct { - Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` } -func (m *AccumulateReply) Reset() { *m = AccumulateReply{} } -func (m *AccumulateReply) String() string { return proto.CompactTextString(m) } -func (*AccumulateReply) ProtoMessage() {} -func (*AccumulateReply) Descriptor() ([]byte, []int) { - return fileDescriptor_testservice_6101db31074a6f55, []int{1} -} -func (m *AccumulateReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_AccumulateReply.Unmarshal(m, b) -} -func (m *AccumulateReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_AccumulateReply.Marshal(b, m, deterministic) -} -func (dst *AccumulateReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_AccumulateReply.Merge(dst, src) -} -func (m *AccumulateReply) XXX_Size() int { - return xxx_messageInfo_AccumulateReply.Size(m) -} -func (m *AccumulateReply) XXX_DiscardUnknown() { - xxx_messageInfo_AccumulateReply.DiscardUnknown(m) +func (x *AccumulateRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -var xxx_messageInfo_AccumulateReply proto.InternalMessageInfo +func (*AccumulateRequest) ProtoMessage() {} -func (m *AccumulateReply) GetValue() int64 { - if m != nil { - return m.Value +func (x *AccumulateRequest) ProtoReflect() protoreflect.Message { + mi := &file_testservice_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return 0 + return mi.MessageOf(x) } -func init() { - proto.RegisterType((*AccumulateRequest)(nil), "go.elastic.co.apm.module.apmgrpc.testservice.AccumulateRequest") - proto.RegisterType((*AccumulateReply)(nil), "go.elastic.co.apm.module.apmgrpc.testservice.AccumulateReply") +// Deprecated: Use AccumulateRequest.ProtoReflect.Descriptor instead. +func (*AccumulateRequest) Descriptor() ([]byte, []int) { + return file_testservice_proto_rawDescGZIP(), []int{0} } -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// AccumulatorClient is the client API for Accumulator service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type AccumulatorClient interface { - Accumulate(ctx context.Context, opts ...grpc.CallOption) (Accumulator_AccumulateClient, error) +func (x *AccumulateRequest) GetValue() int64 { + if x != nil { + return x.Value + } + return 0 } -type accumulatorClient struct { - cc *grpc.ClientConn -} +type AccumulateReply struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func NewAccumulatorClient(cc *grpc.ClientConn) AccumulatorClient { - return &accumulatorClient{cc} + Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` } -func (c *accumulatorClient) Accumulate(ctx context.Context, opts ...grpc.CallOption) (Accumulator_AccumulateClient, error) { - stream, err := c.cc.NewStream(ctx, &_Accumulator_serviceDesc.Streams[0], "/go.elastic.co.apm.module.apmgrpc.testservice.Accumulator/Accumulate", opts...) - if err != nil { - return nil, err +func (x *AccumulateReply) Reset() { + *x = AccumulateReply{} + if protoimpl.UnsafeEnabled { + mi := &file_testservice_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - x := &accumulatorAccumulateClient{stream} - return x, nil } -type Accumulator_AccumulateClient interface { - Send(*AccumulateRequest) error - Recv() (*AccumulateReply, error) - grpc.ClientStream +func (x *AccumulateReply) String() string { + return protoimpl.X.MessageStringOf(x) } -type accumulatorAccumulateClient struct { - grpc.ClientStream -} - -func (x *accumulatorAccumulateClient) Send(m *AccumulateRequest) error { - return x.ClientStream.SendMsg(m) -} +func (*AccumulateReply) ProtoMessage() {} -func (x *accumulatorAccumulateClient) Recv() (*AccumulateReply, error) { - m := new(AccumulateReply) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err +func (x *AccumulateReply) ProtoReflect() protoreflect.Message { + mi := &file_testservice_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return m, nil + return mi.MessageOf(x) } -// AccumulatorServer is the server API for Accumulator service. -type AccumulatorServer interface { - Accumulate(Accumulator_AccumulateServer) error +// Deprecated: Use AccumulateReply.ProtoReflect.Descriptor instead. +func (*AccumulateReply) Descriptor() ([]byte, []int) { + return file_testservice_proto_rawDescGZIP(), []int{1} } -func RegisterAccumulatorServer(s *grpc.Server, srv AccumulatorServer) { - s.RegisterService(&_Accumulator_serviceDesc, srv) +func (x *AccumulateReply) GetValue() int64 { + if x != nil { + return x.Value + } + return 0 } -func _Accumulator_Accumulate_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(AccumulatorServer).Accumulate(&accumulatorAccumulateServer{stream}) -} +var File_testservice_proto protoreflect.FileDescriptor + +var file_testservice_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x74, 0x65, 0x73, 0x74, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x2c, 0x67, 0x6f, 0x2e, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x2e, + 0x63, 0x6f, 0x2e, 0x61, 0x70, 0x6d, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x61, 0x70, + 0x6d, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x22, 0x29, 0x0a, 0x11, 0x41, 0x63, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x27, 0x0a, 0x0f, + 0x41, 0x63, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x32, 0xa2, 0x01, 0x0a, 0x0b, 0x41, 0x63, 0x63, 0x75, 0x6d, 0x75, + 0x6c, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x92, 0x01, 0x0a, 0x0a, 0x41, 0x63, 0x63, 0x75, 0x6d, 0x75, + 0x6c, 0x61, 0x74, 0x65, 0x12, 0x3f, 0x2e, 0x67, 0x6f, 0x2e, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69, + 0x63, 0x2e, 0x63, 0x6f, 0x2e, 0x61, 0x70, 0x6d, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, + 0x61, 0x70, 0x6d, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3d, 0x2e, 0x67, 0x6f, 0x2e, 0x65, 0x6c, 0x61, 0x73, 0x74, + 0x69, 0x63, 0x2e, 0x63, 0x6f, 0x2e, 0x61, 0x70, 0x6d, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, + 0x2e, 0x61, 0x70, 0x6d, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x75, 0x6d, 0x75, 0x6c, 0x61, 0x74, 0x65, 0x52, + 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x6f, + 0x2e, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x2e, 0x63, 0x6f, 0x2f, 0x61, 0x70, 0x6d, 0x2f, + 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x6d, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x76, + 0x32, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_testservice_proto_rawDescOnce sync.Once + file_testservice_proto_rawDescData = file_testservice_proto_rawDesc +) -type Accumulator_AccumulateServer interface { - Send(*AccumulateReply) error - Recv() (*AccumulateRequest, error) - grpc.ServerStream +func file_testservice_proto_rawDescGZIP() []byte { + file_testservice_proto_rawDescOnce.Do(func() { + file_testservice_proto_rawDescData = protoimpl.X.CompressGZIP(file_testservice_proto_rawDescData) + }) + return file_testservice_proto_rawDescData } -type accumulatorAccumulateServer struct { - grpc.ServerStream +var file_testservice_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_testservice_proto_goTypes = []interface{}{ + (*AccumulateRequest)(nil), // 0: go.elastic.co.apm.module.apmgrpc.testservice.AccumulateRequest + (*AccumulateReply)(nil), // 1: go.elastic.co.apm.module.apmgrpc.testservice.AccumulateReply } - -func (x *accumulatorAccumulateServer) Send(m *AccumulateReply) error { - return x.ServerStream.SendMsg(m) +var file_testservice_proto_depIdxs = []int32{ + 0, // 0: go.elastic.co.apm.module.apmgrpc.testservice.Accumulator.Accumulate:input_type -> go.elastic.co.apm.module.apmgrpc.testservice.AccumulateRequest + 1, // 1: go.elastic.co.apm.module.apmgrpc.testservice.Accumulator.Accumulate:output_type -> go.elastic.co.apm.module.apmgrpc.testservice.AccumulateReply + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name } -func (x *accumulatorAccumulateServer) Recv() (*AccumulateRequest, error) { - m := new(AccumulateRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err +func init() { file_testservice_proto_init() } +func file_testservice_proto_init() { + if File_testservice_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_testservice_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AccumulateRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_testservice_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AccumulateReply); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } - return m, nil -} - -var _Accumulator_serviceDesc = grpc.ServiceDesc{ - ServiceName: "go.elastic.co.apm.module.apmgrpc.testservice.Accumulator", - HandlerType: (*AccumulatorServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{ - { - StreamName: "Accumulate", - Handler: _Accumulator_Accumulate_Handler, - ServerStreams: true, - ClientStreams: true, + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_testservice_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, }, - }, - Metadata: "testservice.proto", -} - -func init() { proto.RegisterFile("testservice.proto", fileDescriptor_testservice_6101db31074a6f55) } - -var fileDescriptor_testservice_6101db31074a6f55 = []byte{ - // 201 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2c, 0x49, 0x2d, 0x2e, - 0x29, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xd2, 0x49, - 0xcf, 0xd7, 0x4b, 0xcd, 0x49, 0x2c, 0x2e, 0xc9, 0x4c, 0xd6, 0x4b, 0xce, 0xd7, 0x4b, 0x2c, 0xc8, - 0xd5, 0xcb, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0x05, 0x31, 0xd3, 0x8b, 0x0a, 0x92, 0xf5, 0x90, 0xf4, - 0x28, 0x69, 0x72, 0x09, 0x3a, 0x26, 0x27, 0x97, 0xe6, 0x96, 0xe6, 0x24, 0x96, 0xa4, 0x06, 0xa5, - 0x16, 0x96, 0xa6, 0x16, 0x97, 0x08, 0x89, 0x70, 0xb1, 0x96, 0x25, 0xe6, 0x94, 0xa6, 0x4a, 0x30, - 0x2a, 0x30, 0x6a, 0x30, 0x07, 0x41, 0x38, 0x4a, 0xea, 0x5c, 0xfc, 0xc8, 0x4a, 0x0b, 0x72, 0x2a, - 0xb1, 0x2b, 0x34, 0x5a, 0xc4, 0xc8, 0xc5, 0x0d, 0x57, 0x99, 0x5f, 0x24, 0x34, 0x89, 0x91, 0x8b, - 0x0b, 0xa1, 0x53, 0xc8, 0x5e, 0x8f, 0x14, 0x17, 0xea, 0x61, 0x38, 0x4f, 0xca, 0x96, 0x7c, 0x03, - 0x0a, 0x72, 0x2a, 0x95, 0x18, 0x34, 0x18, 0x0d, 0x18, 0x9d, 0xcc, 0xa3, 0x4c, 0x51, 0x4c, 0xd1, - 0x4f, 0x2c, 0xc8, 0xd5, 0x87, 0x98, 0xa2, 0x0f, 0x35, 0x45, 0x3f, 0x33, 0xaf, 0x24, 0xb5, 0x28, - 0x2f, 0x31, 0x47, 0x1f, 0xc9, 0xb8, 0x24, 0x36, 0x70, 0x30, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, - 0xff, 0xb0, 0xb9, 0xd9, 0xf0, 0x7b, 0x01, 0x00, 0x00, + GoTypes: file_testservice_proto_goTypes, + DependencyIndexes: file_testservice_proto_depIdxs, + MessageInfos: file_testservice_proto_msgTypes, + }.Build() + File_testservice_proto = out.File + file_testservice_proto_rawDesc = nil + file_testservice_proto_goTypes = nil + file_testservice_proto_depIdxs = nil } diff --git a/module/apmgrpc/internal/testservice/testservice.proto b/module/apmgrpc/internal/testservice/testservice.proto index 27b1503b7..bbccdf887 100644 --- a/module/apmgrpc/internal/testservice/testservice.proto +++ b/module/apmgrpc/internal/testservice/testservice.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package go.elastic.co.apm.module.apmgrpc.testservice; -option go_package = "go.elastic.co/apm/module/apmgrpc/internal/testservice"; +option go_package = "go.elastic.co/apm/module/apmgrpc/v2/internal/testservice"; service Accumulator { rpc Accumulate(stream AccumulateRequest) returns (stream AccumulateReply) {} diff --git a/module/apmgrpc/internal/testservice/testservice_grpc.pb.go b/module/apmgrpc/internal/testservice/testservice_grpc.pb.go new file mode 100644 index 000000000..3a66f1c81 --- /dev/null +++ b/module/apmgrpc/internal/testservice/testservice_grpc.pb.go @@ -0,0 +1,159 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.24.2 +// source: testservice.proto + +package testservice + +import ( + context "context" + + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + Accumulator_Accumulate_FullMethodName = "/go.elastic.co.apm.module.apmgrpc.testservice.Accumulator/Accumulate" +) + +// AccumulatorClient is the client API for Accumulator service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type AccumulatorClient interface { + Accumulate(ctx context.Context, opts ...grpc.CallOption) (Accumulator_AccumulateClient, error) +} + +type accumulatorClient struct { + cc grpc.ClientConnInterface +} + +func NewAccumulatorClient(cc grpc.ClientConnInterface) AccumulatorClient { + return &accumulatorClient{cc} +} + +func (c *accumulatorClient) Accumulate(ctx context.Context, opts ...grpc.CallOption) (Accumulator_AccumulateClient, error) { + stream, err := c.cc.NewStream(ctx, &Accumulator_ServiceDesc.Streams[0], Accumulator_Accumulate_FullMethodName, opts...) + if err != nil { + return nil, err + } + x := &accumulatorAccumulateClient{stream} + return x, nil +} + +type Accumulator_AccumulateClient interface { + Send(*AccumulateRequest) error + Recv() (*AccumulateReply, error) + grpc.ClientStream +} + +type accumulatorAccumulateClient struct { + grpc.ClientStream +} + +func (x *accumulatorAccumulateClient) Send(m *AccumulateRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *accumulatorAccumulateClient) Recv() (*AccumulateReply, error) { + m := new(AccumulateReply) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// AccumulatorServer is the server API for Accumulator service. +// All implementations must embed UnimplementedAccumulatorServer +// for forward compatibility +type AccumulatorServer interface { + Accumulate(Accumulator_AccumulateServer) error + mustEmbedUnimplementedAccumulatorServer() +} + +// UnimplementedAccumulatorServer must be embedded to have forward compatible implementations. +type UnimplementedAccumulatorServer struct { +} + +func (UnimplementedAccumulatorServer) Accumulate(Accumulator_AccumulateServer) error { + return status.Errorf(codes.Unimplemented, "method Accumulate not implemented") +} +func (UnimplementedAccumulatorServer) mustEmbedUnimplementedAccumulatorServer() {} + +// UnsafeAccumulatorServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to AccumulatorServer will +// result in compilation errors. +type UnsafeAccumulatorServer interface { + mustEmbedUnimplementedAccumulatorServer() +} + +func RegisterAccumulatorServer(s grpc.ServiceRegistrar, srv AccumulatorServer) { + s.RegisterService(&Accumulator_ServiceDesc, srv) +} + +func _Accumulator_Accumulate_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(AccumulatorServer).Accumulate(&accumulatorAccumulateServer{stream}) +} + +type Accumulator_AccumulateServer interface { + Send(*AccumulateReply) error + Recv() (*AccumulateRequest, error) + grpc.ServerStream +} + +type accumulatorAccumulateServer struct { + grpc.ServerStream +} + +func (x *accumulatorAccumulateServer) Send(m *AccumulateReply) error { + return x.ServerStream.SendMsg(m) +} + +func (x *accumulatorAccumulateServer) Recv() (*AccumulateRequest, error) { + m := new(AccumulateRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// Accumulator_ServiceDesc is the grpc.ServiceDesc for Accumulator service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Accumulator_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "go.elastic.co.apm.module.apmgrpc.testservice.Accumulator", + HandlerType: (*AccumulatorServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "Accumulate", + Handler: _Accumulator_Accumulate_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "testservice.proto", +} diff --git a/module/apmgrpc/server_test.go b/module/apmgrpc/server_test.go index a86cc94cf..68358e924 100644 --- a/module/apmgrpc/server_test.go +++ b/module/apmgrpc/server_test.go @@ -31,6 +31,7 @@ import ( "strings" "testing" + "github.com/google/go-cmp/cmp" grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery" "github.com/stretchr/testify/assert" @@ -38,9 +39,12 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/examples/helloworld/helloworld" pb "google.golang.org/grpc/examples/helloworld/helloworld" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" + "google.golang.org/protobuf/testing/protocmp" "go.elastic.co/apm/module/apmgrpc/v2" "go.elastic.co/apm/module/apmgrpc/v2/internal/testservice" @@ -106,7 +110,7 @@ func testServerTransactionHappy(t *testing.T, p testParams) { ctx := metadata.AppendToOutgoingContext(context.Background(), header, traceparentValue) resp, err := p.client.SayHello(ctx, &pb.HelloRequest{Name: "birita"}) require.NoError(t, err) - assert.Equal(t, resp, &pb.HelloReply{Message: "hello, birita"}) + assert.Empty(t, cmp.Diff(resp, &pb.HelloReply{Message: "hello, birita"}, protocmp.Transform())) } p.tracer.Flush(nil) payloads := p.transport.Payloads() @@ -248,7 +252,7 @@ func TestServerIgnorer(t *testing.T) { resp, err := client.SayHello(context.Background(), &pb.HelloRequest{Name: "birita"}) require.NoError(t, err) - assert.Equal(t, resp, &pb.HelloReply{Message: "hello, birita"}) + assert.Empty(t, cmp.Diff(resp, &pb.HelloReply{Message: "hello, birita"}, protocmp.Transform())) tracer.Flush(nil) assert.Empty(t, transport.Payloads()) @@ -312,7 +316,7 @@ func TestServerTLS(t *testing.T) { resp, err := client.SayHello(context.Background(), &pb.HelloRequest{Name: "birita"}) require.NoError(t, err) - assert.Equal(t, resp, &pb.HelloReply{Message: "hello, birita"}) + assert.Empty(t, cmp.Diff(resp, &pb.HelloReply{Message: "hello, birita"}, protocmp.Transform())) tracer.Flush(nil) payloads := transport.Payloads() @@ -378,7 +382,7 @@ func newGreeterServerTLS(t *testing.T, tracer *apm.Tracer, tlsConfig *tls.Config func newGreeterClient(t *testing.T, addr net.Addr) (*grpc.ClientConn, pb.GreeterClient) { conn, err := grpc.Dial( - addr.String(), grpc.WithInsecure(), + addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithUnaryInterceptor(apmgrpc.NewUnaryClientInterceptor()), grpc.WithUserAgent("apmgrpc_test"), ) @@ -422,7 +426,7 @@ func newAccumulatorServer(t *testing.T, tracer *apm.Tracer, opts ...apmgrpc.Serv func newAccumulatorClient(t *testing.T, addr net.Addr) (*grpc.ClientConn, testservice.AccumulatorClient) { conn, err := grpc.Dial( - addr.String(), grpc.WithInsecure(), + addr.String(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithStreamInterceptor(apmgrpc.NewStreamClientInterceptor()), ) require.NoError(t, err) @@ -432,6 +436,7 @@ func newAccumulatorClient(t *testing.T, addr net.Addr) (*grpc.ClientConn, testse type helloworldServer struct { panic bool err error + helloworld.UnimplementedGreeterServer } func (s *helloworldServer) SayHello(ctx context.Context, req *pb.HelloRequest) (*pb.HelloReply, error) { @@ -463,6 +468,7 @@ type accumulator struct { err error transactionFromContext *apm.Transaction + testservice.UnimplementedAccumulatorServer } func (a *accumulator) Accumulate(srv testservice.Accumulator_AccumulateServer) error { diff --git a/scripts/generate-testservice.sh b/scripts/generate-testservice.sh new file mode 100755 index 000000000..b7a4a17a3 --- /dev/null +++ b/scripts/generate-testservice.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +TOOLS_DIR=$(dirname "$(readlink -f -- "$0")") + +PATH="${TOOLS_DIR}/build/bin:${PATH}" protoc \ + --proto_path=./module/apmgrpc/internal/testservice/ \ + --go_out=./module/apmgrpc \ + --go-grpc_out=./module/apmgrpc \ + --go_opt=module=go.elastic.co/apm/module/apmgrpc/v2 \ + --go-grpc_opt=module=go.elastic.co/apm/module/apmgrpc/v2 \ + ./module/apmgrpc/internal/testservice/testservice.proto diff --git a/scripts/install-protobuf.sh b/scripts/install-protobuf.sh new file mode 100755 index 000000000..7e728d0c4 --- /dev/null +++ b/scripts/install-protobuf.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +PLATFORM=$(go env GOOS) +PROTOBUF_VERSION="24.2" +PROTOC_GO_VERSION="v1.31.0" +PROTOC_GO_GRPC_VERSION="v1.3.0" + + +if [ "${PLATFORM}" = "darwin" ]; then + PROTOBUF_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-osx-x86_64.zip" +elif [ "${PLATFORM}" = "linux" ]; then + PROTOBUF_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip" +elif [ "${PLATFORM}" = "windows" ]; then + PROTOBUF_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-win64.zip" +else + echo "Unsupported platform: ${PLATFORM}" + exit 1 +fi + +TOOLS_DIR=$(dirname "$(readlink -f -- "$0")") +BUILD_DIR="${TOOLS_DIR}/build" +PROTOBUF_ZIP="/tmp/protobuf.zip" + +curl -L "${PROTOBUF_URL}" -o "${PROTOBUF_ZIP}" + +if ! unzip -o "${PROTOBUF_ZIP}" -d "${BUILD_DIR}"; then + echo "failed to extract protobuf" + exit 1 +fi + +if ! PATH="${BUILD_DIR}/bin" protoc --version; then + echo "failed to verify protobuf installation" + exit 1 +fi + +GOBIN="${BUILD_DIR}/bin" go install "google.golang.org/protobuf/cmd/protoc-gen-go@${PROTOC_GO_VERSION}" +GOBIN="${BUILD_DIR}/bin" go install "google.golang.org/grpc/cmd/protoc-gen-go-grpc@${PROTOC_GO_GRPC_VERSION}"