diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 5aba140f..33ba356a 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -41,3 +41,7 @@ jobs: uses: ./ with: entrypoint: example/stub-subfolders/entrypoint.sh + - name: Run microservice example + uses: ./ + with: + entrypoint: example/ms/entrypoint.sh diff --git a/api/openapi/api.yaml b/api/openapi/api.yaml index d93a3ae3..8744f91f 100644 --- a/api/openapi/api.yaml +++ b/api/openapi/api.yaml @@ -272,6 +272,9 @@ components: StubInput: type: object properties: + ignoreArrayOrder: + type: boolean + default: false equals: type: object additionalProperties: true diff --git a/deployments/docker-compose/docker-compose.yml b/deployments/docker-compose/docker-compose.yml index 2043ad98..e617f033 100644 --- a/deployments/docker-compose/docker-compose.yml +++ b/deployments/docker-compose/docker-compose.yml @@ -1,23 +1,42 @@ version: '3.8' services: - simple: - image: bavix/gripmock:latest - entrypoint: example/simple/entrypoint.sh - stream: + ms: image: bavix/gripmock:latest - entrypoint: example/stream/entrypoint.sh - well_known_types: + entrypoint: example/ms/entrypoint.sh + volumes: + - ./../../protogen/example/ms:/go/src/github.com/bavix/gripmock/protogen/example/ms + multi-files: image: bavix/gripmock:latest - entrypoint: example/well_known_types/entrypoint.sh + entrypoint: example/multi-files/entrypoint.sh + volumes: + - ./../../protogen/example/multi-files:/go/src/github.com/bavix/gripmock/protogen/example/multi-files multi-package: image: bavix/gripmock:latest entrypoint: example/multi-package/entrypoint.sh - multi-files: - image: bavix/gripmock:latest - entrypoint: example/multi-files/entrypoint.sh + volumes: + - ./../../protogen/example/multi-package:/go/src/github.com/bavix/gripmock/protogen/example/multi-package one-of: image: bavix/gripmock:latest entrypoint: example/one-of/entrypoint.sh + volumes: + - ./../../protogen/example/one-of:/go/src/github.com/bavix/gripmock/protogen/example/one-of + simple: + image: bavix/gripmock:latest + entrypoint: example/simple/entrypoint.sh + volumes: + - ./../../protogen/example/simple:/go/src/github.com/bavix/gripmock/protogen/example/simple + stream: + image: bavix/gripmock:latest + entrypoint: example/stream/entrypoint.sh + volumes: + - ./../../protogen/example/stream:/go/src/github.com/bavix/gripmock/protogen/example/stream stub-subfolders: image: bavix/gripmock:latest entrypoint: example/stub-subfolders/entrypoint.sh + volumes: + - ./../../protogen/example/stub-subfolders:/go/src/github.com/bavix/gripmock/protogen/example/stub-subfolders + well_known_types: + image: bavix/gripmock:latest + entrypoint: example/well_known_types/entrypoint.sh + volumes: + - ./../../protogen/example/well_known_types:/go/src/github.com/bavix/gripmock/protogen/example/well_known_types diff --git a/example/ms/client/main.go b/example/ms/client/main.go new file mode 100644 index 00000000..23355c24 --- /dev/null +++ b/example/ms/client/main.go @@ -0,0 +1,54 @@ +package main + +import ( + "context" + "github.com/google/uuid" + "log" + "time" + + pb "github.com/bavix/gripmock/protogen/example/ms" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" +) + +//nolint:gomnd +func main() { + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + defer cancel() + + conn, err := grpc.DialContext(ctx, "localhost:4770", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()) + if err != nil { + log.Fatalf("did not connect: %v", err) + } + defer conn.Close() + + c := pb.NewMicroServiceClient(conn) + + r1, err := c.SayHello(context.Background(), &pb.Request{V1: [][]byte{ + u2bytes("ab0ed195-6ac5-4006-a98b-6978c6ed1c6b"), // 3 + u2bytes("99aebcf2-b56d-4923-9266-ab72bf5b9d0b"), // 1 + u2bytes("5659bec5-dda5-4e87-bef4-e9e37c60eb1c"), // 2 + u2bytes("77465064-a0ce-48a3-b7e4-d50f88e55093"), // 0 + }}) + if err != nil { + log.Fatalf("error from grpc: %v", err) + } + log.Printf("Result: %d", r1.Code) + + r2, err := c.SayHello(context.Background(), &pb.Request{V2: []string{ + "e3484119-24e1-42d9-b4c2-7d6004ee86d9", // 1 + "c30f45d2-f8a4-4a94-a994-4cc349bca457", // 3 + "f1e9ed24-93ba-4e4f-ab9f-3942196d5c03", // 0 + "cc991218-a920-40c8-9f42-3b329c8723f2", // 2 + }}) + if err != nil { + log.Fatalf("error from grpc: %v", err) + } + log.Printf("Result: %d", r2.Code) +} + +func u2bytes(v string) []byte { + u := uuid.MustParse(v) + + return u[:] +} diff --git a/example/ms/entrypoint.sh b/example/ms/entrypoint.sh new file mode 100755 index 00000000..1aa38462 --- /dev/null +++ b/example/ms/entrypoint.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +# this file is used by .github/workflows/integration-test.yml + +gripmock --stub=example/ms/stub example/ms/ms.proto & + +# wait for generated files to be available and gripmock is up +sleep 2 + +go run example/ms/client/*.go \ No newline at end of file diff --git a/example/ms/ms.proto b/example/ms/ms.proto new file mode 100644 index 00000000..dbc07ea6 --- /dev/null +++ b/example/ms/ms.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package ms; + +option go_package = "github.com/bavix/gripmock/example/ms"; + +service MicroService { + rpc SayHello (Request) returns (Reply); +} + +message Request { + repeated bytes v1 = 1; + repeated string v2 = 2; +} + +message Reply { + int64 code = 1; +} diff --git a/example/ms/stub/strict.yml b/example/ms/stub/strict.yml new file mode 100644 index 00000000..fcb3cbfc --- /dev/null +++ b/example/ms/stub/strict.yml @@ -0,0 +1,28 @@ +--- +- service: MicroService + method: SayHello + input: + ignoreArrayOrder: true + equals: + v1: + - {{ uuid2base64 "77465064-a0ce-48a3-b7e4-d50f88e55093" }} + - {{ uuid2base64 "99aebcf2-b56d-4923-9266-ab72bf5b9d0b" }} + - {{ uuid2base64 "5659bec5-dda5-4e87-bef4-e9e37c60eb1c" }} + - {{ uuid2base64 "ab0ed195-6ac5-4006-a98b-6978c6ed1c6b" }} + output: + data: + code: 1000 + +- service: MicroService + method: SayHello + input: + ignoreArrayOrder: true + equals: + v2: + - f1e9ed24-93ba-4e4f-ab9f-3942196d5c03 + - e3484119-24e1-42d9-b4c2-7d6004ee86d9 + - cc991218-a920-40c8-9f42-3b329c8723f2 + - c30f45d2-f8a4-4a94-a994-4cc349bca457 + output: + data: + code: 2000 diff --git a/example/simple/client/main.go b/example/simple/client/main.go index be26fb5f..efd5cb11 100644 --- a/example/simple/client/main.go +++ b/example/simple/client/main.go @@ -193,4 +193,11 @@ func main() { log.Fatalf("expected: 18446744073709551615, received: %d", r.Vuint64) } log.Printf("Greeting: %s (return code %d)", r.Message, r.ReturnCode) + + // ignoreArrayOrder=true + r, err = c.SayHello(context.Background(), &pb.Request{Values: []int64{10, 20, 30, 40, 50, 60, 70}}) + if err != nil { + log.Fatalf("error from grpc: %v", err) + } + log.Printf("Greeting: %s (return code %d)", r.Message, r.ReturnCode) } diff --git a/example/simple/simple.proto b/example/simple/simple.proto index cff540c1..0b01dd80 100644 --- a/example/simple/simple.proto +++ b/example/simple/simple.proto @@ -15,6 +15,7 @@ message Request { string name = 1; int64 vint64 = 2; uint64 vuint64 = 3; + repeated int64 values = 4; } // The response message containing the greetings diff --git a/example/simple/stub/strict.yml b/example/simple/stub/strict.yml new file mode 100644 index 00000000..5c463373 --- /dev/null +++ b/example/simple/stub/strict.yml @@ -0,0 +1,17 @@ +--- +- service: Gripmock + method: SayHello + input: + ignoreArrayOrder: true + equals: + values: + - 10 + - 20 + - 30 + - 60 + - 50 + - 40 + - 70 + output: + data: + message: "7. strict mode" diff --git a/go.mod b/go.mod index 366b0a39..4de2e835 100644 --- a/go.mod +++ b/go.mod @@ -45,12 +45,12 @@ require ( go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/trace v1.21.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect - golang.org/x/net v0.19.0 // indirect + golang.org/x/net v0.20.0 // indirect golang.org/x/sys v0.16.0 // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect - google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect + google.golang.org/genproto v0.0.0-20240108191215-35c7eff3a6b1 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240108191215-35c7eff3a6b1 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 53cc383c..37a6fcf8 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,6 @@ github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSw github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= -github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= @@ -49,8 +47,6 @@ github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 h1:6UKoz5ujsI55KNpsJH3UwCq3T8kKbZwNZBNPuTTje8U= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1/go.mod h1:YvJ2f6MplWDhfxiUC3KpyTy76kYUZA4W3pTv/wdKQ9Y= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 h1:Wqo399gCIufwto+VfwCSvsnfGpF/w5E9CNxSwbpD6No= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0/go.mod h1:qmOFXW2epJhM0qSnUUYpldc7gVz2KMQwJ/QYCDIa7XU= github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -124,19 +120,18 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= -golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= -golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ= +golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -149,8 +144,6 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -173,18 +166,12 @@ golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSm golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto v0.0.0-20231212172506-995d672761c0 h1:YJ5pD9rF8o9Qtta0Cmy9rdBwkSjrTCT6XTiUQVOtIos= -google.golang.org/genproto v0.0.0-20231212172506-995d672761c0/go.mod h1:l/k7rMz0vFTBPy+tFSGvXEd3z+BcoG1k7EHbqm+YBsY= -google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 h1:nz5NESFLZbJGPFxDT/HCn+V1mZ8JGNoY4nUpmW/Y2eg= -google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917/go.mod h1:pZqR+glSb11aJ+JQcczCvgf47+duRuzNSKqE8YAQnV0= -google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0 h1:s1w3X6gQxwrLEpxnLd/qXTVLgQE2yXwaOaoa6IlY/+o= -google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0/go.mod h1:CAny0tYF+0/9rmDB9fahA9YLzX3+AEVl1qXbv5hhj6c= -google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 h1:rcS6EyEaoCO52hQDupoSfrxI3R6C2Tq741is7X8OvnM= -google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917/go.mod h1:CmlNWB9lSezaYELKS5Ym1r44VrrbPUa7JTvw+6MbpJ0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 h1:/jFB8jK5R3Sq3i/lmeZO0cATSzFfZaJq1J2Euan3XKU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0/go.mod h1:FUoWkonphQm3RhTS+kOEhF8h0iDpm4tdXolVCeZ9KKA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 h1:6G8oQ016D88m1xAKljMlBOOGWDZkes4kMhgGFlf8WcQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917/go.mod h1:xtjpI3tXFPP051KaWnhvxkiubL/6dJ18vLVf7q2pTOU= +google.golang.org/genproto v0.0.0-20240108191215-35c7eff3a6b1 h1:/IWabOtPziuXTEtI1KYCpM6Ss7vaAkeMxk+uXV/xvZs= +google.golang.org/genproto v0.0.0-20240108191215-35c7eff3a6b1/go.mod h1:+Rvu7ElI+aLzyDQhpHMFMMltsD6m7nqpuWDd2CwJw3k= +google.golang.org/genproto/googleapis/api v0.0.0-20240108191215-35c7eff3a6b1 h1:OPXtXn7fNMaXwO3JvOmF1QyTc00jsSFFz1vXXBOdCDo= +google.golang.org/genproto/googleapis/api v0.0.0-20240108191215-35c7eff3a6b1/go.mod h1:B5xPO//w8qmBDjGReYLpR6UJPnkldGkCSMoH/2vxJeg= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 h1:gphdwh0npgs8elJ4T6J+DQJHPVF7RsuJHCfwztUb4J4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1/go.mod h1:daQN87bsDqDoe316QbbvX60nMoJQa4r6Ds0ZuoAe5yA= google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= diff --git a/internal/app/storage.go b/internal/app/storage.go index 8889a007..c1dc5114 100644 --- a/internal/app/storage.go +++ b/internal/app/storage.go @@ -54,7 +54,7 @@ func findStub(stubStorage *storage.StubStorage, stub *findStubPayload) (*storage var closestMatch []closeMatch for _, strange := range stubs { - cmpData, cmpDataErr := inputCmp(strange.Input, stub.Data) + cmpData, cmpDataErr := inputCmp(strange.Input, stub.Data, strange.Input.IgnoreArrayOrder) if cmpDataErr != nil { if cmpData != nil { closestMatch = append(closestMatch, *cmpData) @@ -64,7 +64,7 @@ func findStub(stubStorage *storage.StubStorage, stub *findStubPayload) (*storage } if strange.CheckHeaders() { - if cmpHeaders, cmpHeadersErr := inputCmp(strange.Headers, stub.Headers); cmpHeadersErr != nil { + if cmpHeaders, cmpHeadersErr := inputCmp(strange.Headers, stub.Headers, false); cmpHeadersErr != nil { if cmpHeaders != nil { closestMatch = append(closestMatch, closeMatch{ rule: cmpData.rule, @@ -86,31 +86,31 @@ func findStub(stubStorage *storage.StubStorage, stub *findStubPayload) (*storage return nil, stubNotFoundError(stub, closestMatch) } -func inputCmp(input storage.Input, data map[string]interface{}) (*closeMatch, error) { - if expect := input.Equals; expect != nil { +func inputCmp(input storage.InputInterface, data map[string]interface{}, ignoreArrayOrder bool) (*closeMatch, error) { + if expect := input.GetEquals(); expect != nil { closeMatchVal := closeMatch{rule: "equals", expect: expect} - if equals(input.Equals, data) { + if equals(input.GetEquals(), data, ignoreArrayOrder) { return &closeMatchVal, nil } return &closeMatchVal, ErrNotFound } - if expect := input.Contains; expect != nil { + if expect := input.GetContains(); expect != nil { closeMatchVal := closeMatch{rule: "contains", expect: expect} - if contains(input.Contains, data) { + if contains(input.GetContains(), data, ignoreArrayOrder) { return &closeMatchVal, nil } return &closeMatchVal, ErrNotFound } - if expect := input.Matches; expect != nil { + if expect := input.GetMatches(); expect != nil { closeMatchVal := closeMatch{rule: "matches", expect: expect} - if matches(input.Matches, data) { + if matches(input.GetMatches(), data, ignoreArrayOrder) { return &closeMatchVal, nil } @@ -211,20 +211,20 @@ func regexMatch(expect, actual interface{}) bool { return reflect.DeepEqual(expect, actual) } -func equals(expect, actual map[string]interface{}) bool { - return find(expect, actual, true, true, reflect.DeepEqual) +func equals(expect, actual map[string]interface{}, ignoreArrayOrder bool) bool { + return find(expect, actual, true, true, reflect.DeepEqual, ignoreArrayOrder) } -func contains(expect, actual map[string]interface{}) bool { - return find(expect, actual, true, false, reflect.DeepEqual) +func contains(expect, actual map[string]interface{}, ignoreArrayOrder bool) bool { + return find(expect, actual, true, false, reflect.DeepEqual, ignoreArrayOrder) } -func matches(expect, actual map[string]interface{}) bool { - return find(expect, actual, true, false, regexMatch) +func matches(expect, actual map[string]interface{}, ignoreArrayOrder bool) bool { + return find(expect, actual, true, false, regexMatch, ignoreArrayOrder) } //nolint:cyclop -func find(expect, actual interface{}, acc, exactMatch bool, f matchFunc) bool { +func find(expect, actual interface{}, acc, exactMatch bool, f matchFunc, ignoreArrayOrder bool) bool { // circuit brake if !acc { return false @@ -245,9 +245,13 @@ func find(expect, actual interface{}, acc, exactMatch bool, f matchFunc) bool { return false } + if ignoreArrayOrder { + return cmpValue(expectArrayValue, actualArrayValue, f) + } + for expectItemIndex, expectItemValue := range expectArrayValue { actualItemValue := actualArrayValue[expectItemIndex] - acc = find(expectItemValue, actualItemValue, acc, exactMatch, f) + acc = find(expectItemValue, actualItemValue, acc, exactMatch, f, ignoreArrayOrder) } return acc @@ -270,7 +274,7 @@ func find(expect, actual interface{}, acc, exactMatch bool, f matchFunc) bool { for expectItemKey, expectItemValue := range expectMapValue { actualItemValue := actualMapValue[expectItemKey] - acc = find(expectItemValue, actualItemValue, acc, exactMatch, f) + acc = find(expectItemValue, actualItemValue, acc, exactMatch, f, ignoreArrayOrder) } return acc @@ -278,3 +282,42 @@ func find(expect, actual interface{}, acc, exactMatch bool, f matchFunc) bool { return f(expect, actual) } + +func cmpValue(a, b []interface{}, f matchFunc) bool { + if len(a) != len(b) { + return false + } + + if f(a, b) { + return true + } + + d := len(a) + c := make([]interface{}, 0, d) + + usedA := make(map[int]bool, len(a)) + usedB := make(map[int]bool, len(b)) + + for i := 0; i < d; i++ { + for ia, va := range a { + if usedA[ia] { + continue + } + + for ib, vb := range b { + if usedB[ib] { + continue + } + + if f(va, vb) { + c = append(c, va) + + usedA[ia] = true + usedB[ib] = true + } + } + } + } + + return d == len(c) +} diff --git a/internal/domain/rest/api.gen.go b/internal/domain/rest/api.gen.go index 08723c40..7059df10 100644 --- a/internal/domain/rest/api.gen.go +++ b/internal/domain/rest/api.gen.go @@ -63,9 +63,10 @@ type StubHeaders struct { // StubInput defines model for StubInput. type StubInput struct { - Contains map[string]interface{} `json:"contains,omitempty"` - Equals map[string]interface{} `json:"equals,omitempty"` - Matches map[string]interface{} `json:"matches,omitempty"` + Contains map[string]interface{} `json:"contains,omitempty"` + Equals map[string]interface{} `json:"equals,omitempty"` + IgnoreArrayOrder *bool `json:"ignoreArrayOrder,omitempty"` + Matches map[string]interface{} `json:"matches,omitempty"` } // StubList defines model for StubList. diff --git a/internal/pkg/patcher/writer_test.go b/internal/pkg/patcher/writer_test.go index c3e4506c..678e74b5 100644 --- a/internal/pkg/patcher/writer_test.go +++ b/internal/pkg/patcher/writer_test.go @@ -13,7 +13,7 @@ import ( func TestWriterWrapper_OptionUpdate(t *testing.T) { pile, err := os.OpenFile( - "./../../../protogen/example/multi-files/file1.proto", + "./../../../example/multi-files/file1.proto", os.O_RDONLY, 0o444, ) diff --git a/pkg/sdk/api.gen.go b/pkg/sdk/api.gen.go index 0f64e17a..63acddb4 100644 --- a/pkg/sdk/api.gen.go +++ b/pkg/sdk/api.gen.go @@ -67,9 +67,10 @@ type StubHeaders struct { // StubInput defines model for StubInput. type StubInput struct { - Contains map[string]interface{} `json:"contains,omitempty"` - Equals map[string]interface{} `json:"equals,omitempty"` - Matches map[string]interface{} `json:"matches,omitempty"` + Contains map[string]interface{} `json:"contains,omitempty"` + Equals map[string]interface{} `json:"equals,omitempty"` + IgnoreArrayOrder *bool `json:"ignoreArrayOrder,omitempty"` + Matches map[string]interface{} `json:"matches,omitempty"` } // StubList defines model for StubList. diff --git a/pkg/storage/stubs.go b/pkg/storage/stubs.go index 03f5624e..db3e539c 100644 --- a/pkg/storage/stubs.go +++ b/pkg/storage/stubs.go @@ -17,12 +17,12 @@ var ( ) type Stub struct { - ID *uuid.UUID `json:"id,omitempty"` - Service string `json:"service"` - Method string `json:"method"` - Headers Input `json:"headers"` - Input Input `json:"input"` - Output Output `json:"output"` + ID *uuid.UUID `json:"id,omitempty"` + Service string `json:"service"` + Method string `json:"method"` + Headers InputHeader `json:"headers"` + Input InputData `json:"input"` + Output Output `json:"output"` } func (s *Stub) GetID() uuid.UUID { @@ -34,12 +34,49 @@ func (s *Stub) GetID() uuid.UUID { return *s.ID } -type Input struct { +type InputInterface interface { + GetEquals() map[string]interface{} + GetContains() map[string]interface{} + GetMatches() map[string]interface{} +} + +type InputData struct { + IgnoreArrayOrder bool `json:"ignoreArrayOrder,omitempty"` + Equals map[string]interface{} `json:"equals"` + Contains map[string]interface{} `json:"contains"` + Matches map[string]interface{} `json:"matches"` +} + +func (i InputData) GetEquals() map[string]interface{} { + return i.Equals +} + +func (i InputData) GetContains() map[string]interface{} { + return i.Contains +} + +func (i InputData) GetMatches() map[string]interface{} { + return i.Matches +} + +type InputHeader struct { Equals map[string]interface{} `json:"equals"` Contains map[string]interface{} `json:"contains"` Matches map[string]interface{} `json:"matches"` } +func (i InputHeader) GetEquals() map[string]interface{} { + return i.Equals +} + +func (i InputHeader) GetContains() map[string]interface{} { + return i.Contains +} + +func (i InputHeader) GetMatches() map[string]interface{} { + return i.Matches +} + type Output struct { Headers map[string]string `json:"headers"` Data map[string]interface{} `json:"data"` @@ -49,8 +86,8 @@ type Output struct { type storage struct { ID uuid.UUID - Headers Input - Input Input + Headers InputHeader + Input InputData Output Output } diff --git a/protoc-gen-gripmock/go.mod b/protoc-gen-gripmock/go.mod index def8d1d3..cd70f3d4 100644 --- a/protoc-gen-gripmock/go.mod +++ b/protoc-gen-gripmock/go.mod @@ -6,7 +6,7 @@ require ( go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 golang.org/x/text v0.14.0 - golang.org/x/tools v0.16.1 + golang.org/x/tools v0.17.0 google.golang.org/protobuf v1.32.0 ) @@ -19,8 +19,8 @@ require ( go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/trace v1.21.0 // indirect golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.19.0 // indirect + golang.org/x/net v0.20.0 // indirect golang.org/x/sys v0.16.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 // indirect google.golang.org/grpc v1.60.1 // indirect ) diff --git a/protoc-gen-gripmock/go.sum b/protoc-gen-gripmock/go.sum index f1ab9f4b..e98206eb 100644 --- a/protoc-gen-gripmock/go.sum +++ b/protoc-gen-gripmock/go.sum @@ -11,8 +11,6 @@ github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7 github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= -github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= @@ -39,25 +37,21 @@ go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8 go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= -golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= +golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 h1:/jFB8jK5R3Sq3i/lmeZO0cATSzFfZaJq1J2Euan3XKU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0/go.mod h1:FUoWkonphQm3RhTS+kOEhF8h0iDpm4tdXolVCeZ9KKA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 h1:6G8oQ016D88m1xAKljMlBOOGWDZkes4kMhgGFlf8WcQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917/go.mod h1:xtjpI3tXFPP051KaWnhvxkiubL/6dJ18vLVf7q2pTOU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 h1:gphdwh0npgs8elJ4T6J+DQJHPVF7RsuJHCfwztUb4J4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1/go.mod h1:daQN87bsDqDoe316QbbvX60nMoJQa4r6Ds0ZuoAe5yA= google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= diff --git a/protogen/example/ms/ms.pb.go b/protogen/example/ms/ms.pb.go new file mode 100644 index 00000000..40d26b6d --- /dev/null +++ b/protogen/example/ms/ms.pb.go @@ -0,0 +1,219 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.32.0 +// protoc v4.24.4 +// source: ms.proto + +package ms + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +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 Request struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + V1 [][]byte `protobuf:"bytes,1,rep,name=v1,proto3" json:"v1,omitempty"` + V2 []string `protobuf:"bytes,2,rep,name=v2,proto3" json:"v2,omitempty"` +} + +func (x *Request) Reset() { + *x = Request{} + if protoimpl.UnsafeEnabled { + mi := &file_ms_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Request) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Request) ProtoMessage() {} + +func (x *Request) ProtoReflect() protoreflect.Message { + mi := &file_ms_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 mi.MessageOf(x) +} + +// Deprecated: Use Request.ProtoReflect.Descriptor instead. +func (*Request) Descriptor() ([]byte, []int) { + return file_ms_proto_rawDescGZIP(), []int{0} +} + +func (x *Request) GetV1() [][]byte { + if x != nil { + return x.V1 + } + return nil +} + +func (x *Request) GetV2() []string { + if x != nil { + return x.V2 + } + return nil +} + +type Reply struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` +} + +func (x *Reply) Reset() { + *x = Reply{} + if protoimpl.UnsafeEnabled { + mi := &file_ms_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Reply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Reply) ProtoMessage() {} + +func (x *Reply) ProtoReflect() protoreflect.Message { + mi := &file_ms_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 mi.MessageOf(x) +} + +// Deprecated: Use Reply.ProtoReflect.Descriptor instead. +func (*Reply) Descriptor() ([]byte, []int) { + return file_ms_proto_rawDescGZIP(), []int{1} +} + +func (x *Reply) GetCode() int64 { + if x != nil { + return x.Code + } + return 0 +} + +var File_ms_proto protoreflect.FileDescriptor + +var file_ms_proto_rawDesc = []byte{ + 0x0a, 0x08, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x6d, 0x73, 0x22, 0x29, + 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x76, 0x31, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x02, 0x76, 0x31, 0x12, 0x0e, 0x0a, 0x02, 0x76, 0x32, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02, 0x76, 0x32, 0x22, 0x1b, 0x0a, 0x05, 0x52, 0x65, 0x70, + 0x6c, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x32, 0x32, 0x0a, 0x0c, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x22, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, + 0x6c, 0x6f, 0x12, 0x0b, 0x2e, 0x6d, 0x73, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x09, 0x2e, 0x6d, 0x73, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x76, 0x69, 0x78, 0x2f, 0x67, + 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, + 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x6d, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file_ms_proto_rawDescOnce sync.Once + file_ms_proto_rawDescData = file_ms_proto_rawDesc +) + +func file_ms_proto_rawDescGZIP() []byte { + file_ms_proto_rawDescOnce.Do(func() { + file_ms_proto_rawDescData = protoimpl.X.CompressGZIP(file_ms_proto_rawDescData) + }) + return file_ms_proto_rawDescData +} + +var file_ms_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_ms_proto_goTypes = []interface{}{ + (*Request)(nil), // 0: ms.Request + (*Reply)(nil), // 1: ms.Reply +} +var file_ms_proto_depIdxs = []int32{ + 0, // 0: ms.MicroService.SayHello:input_type -> ms.Request + 1, // 1: ms.MicroService.SayHello:output_type -> ms.Reply + 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 init() { file_ms_proto_init() } +func file_ms_proto_init() { + if File_ms_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_ms_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Request); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_ms_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Reply); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_ms_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_ms_proto_goTypes, + DependencyIndexes: file_ms_proto_depIdxs, + MessageInfos: file_ms_proto_msgTypes, + }.Build() + File_ms_proto = out.File + file_ms_proto_rawDesc = nil + file_ms_proto_goTypes = nil + file_ms_proto_depIdxs = nil +} diff --git a/protogen/example/ms/ms.proto b/protogen/example/ms/ms.proto new file mode 100644 index 00000000..030f29a7 --- /dev/null +++ b/protogen/example/ms/ms.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package ms; + +option go_package = "github.com/bavix/gripmock/protogen/example/ms"; + +service MicroService { + rpc SayHello (Request) returns (Reply); +} + +message Request { + repeated bytes v1 = 1; + repeated string v2 = 2; +} + +message Reply { + int64 code = 1; +} diff --git a/protogen/example/ms/ms_grpc.pb.go b/protogen/example/ms/ms_grpc.pb.go new file mode 100644 index 00000000..091f1372 --- /dev/null +++ b/protogen/example/ms/ms_grpc.pb.go @@ -0,0 +1,109 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.24.4 +// source: ms.proto + +package ms + +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 ( + MicroService_SayHello_FullMethodName = "/ms.MicroService/SayHello" +) + +// MicroServiceClient is the client API for MicroService 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 MicroServiceClient interface { + SayHello(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Reply, error) +} + +type microServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewMicroServiceClient(cc grpc.ClientConnInterface) MicroServiceClient { + return µServiceClient{cc} +} + +func (c *microServiceClient) SayHello(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Reply, error) { + out := new(Reply) + err := c.cc.Invoke(ctx, MicroService_SayHello_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MicroServiceServer is the server API for MicroService service. +// All implementations must embed UnimplementedMicroServiceServer +// for forward compatibility +type MicroServiceServer interface { + SayHello(context.Context, *Request) (*Reply, error) + mustEmbedUnimplementedMicroServiceServer() +} + +// UnimplementedMicroServiceServer must be embedded to have forward compatible implementations. +type UnimplementedMicroServiceServer struct { +} + +func (UnimplementedMicroServiceServer) SayHello(context.Context, *Request) (*Reply, error) { + return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") +} +func (UnimplementedMicroServiceServer) mustEmbedUnimplementedMicroServiceServer() {} + +// UnsafeMicroServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to MicroServiceServer will +// result in compilation errors. +type UnsafeMicroServiceServer interface { + mustEmbedUnimplementedMicroServiceServer() +} + +func RegisterMicroServiceServer(s grpc.ServiceRegistrar, srv MicroServiceServer) { + s.RegisterService(&MicroService_ServiceDesc, srv) +} + +func _MicroService_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Request) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MicroServiceServer).SayHello(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: MicroService_SayHello_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MicroServiceServer).SayHello(ctx, req.(*Request)) + } + return interceptor(ctx, in, info, handler) +} + +// MicroService_ServiceDesc is the grpc.ServiceDesc for MicroService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var MicroService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "ms.MicroService", + HandlerType: (*MicroServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SayHello", + Handler: _MicroService_SayHello_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ms.proto", +} diff --git a/protogen/example/multi-files/file1.pb.go b/protogen/example/multi-files/file1.pb.go index ea8431f5..d7785056 100644 --- a/protogen/example/multi-files/file1.pb.go +++ b/protogen/example/multi-files/file1.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.23.4 +// protoc-gen-go v1.32.0 +// protoc v4.24.4 // source: file1.proto package multi_files @@ -139,11 +139,11 @@ var file_file1_proto_rawDesc = []byte{ 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x14, 0x2e, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x31, 0x1a, 0x12, 0x2e, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x79, - 0x31, 0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x74, 0x6f, 0x6b, 0x6f, 0x70, 0x65, 0x64, 0x69, 0x61, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, - 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x65, 0x78, 0x61, 0x6d, - 0x70, 0x6c, 0x65, 0x2f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x2d, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x31, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x62, 0x61, 0x76, 0x69, 0x78, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, + 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x2d, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( diff --git a/protogen/example/multi-files/file1.proto b/protogen/example/multi-files/file1.proto index c9d58e2b..3a2c30b3 100644 --- a/protogen/example/multi-files/file1.proto +++ b/protogen/example/multi-files/file1.proto @@ -1,9 +1,8 @@ syntax = "proto3"; -option go_package = "github.com/bavix/gripmock/protogen/example/multi-files"; package multifiles; - +option go_package = "github.com/bavix/gripmock/protogen/example/multi-files"; // The Gripmock service definition. service Gripmock1 { // simple unary method diff --git a/protogen/example/multi-files/file1_grpc.pb.go b/protogen/example/multi-files/file1_grpc.pb.go index faa71d0f..edf9b303 100644 --- a/protogen/example/multi-files/file1_grpc.pb.go +++ b/protogen/example/multi-files/file1_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.23.4 +// - protoc v4.24.4 // source: file1.proto package multi_files diff --git a/protogen/example/multi-files/file2.pb.go b/protogen/example/multi-files/file2.pb.go index a0cb8e3a..d2167d4c 100644 --- a/protogen/example/multi-files/file2.pb.go +++ b/protogen/example/multi-files/file2.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.23.4 +// protoc-gen-go v1.32.0 +// protoc v4.24.4 // source: file2.proto package multi_files @@ -139,11 +139,11 @@ var file_file2_proto_rawDesc = []byte{ 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x14, 0x2e, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x32, 0x1a, 0x12, 0x2e, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x79, - 0x32, 0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x74, 0x6f, 0x6b, 0x6f, 0x70, 0x65, 0x64, 0x69, 0x61, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, - 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x65, 0x78, 0x61, 0x6d, - 0x70, 0x6c, 0x65, 0x2f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x2d, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x32, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x62, 0x61, 0x76, 0x69, 0x78, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, + 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x2d, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( diff --git a/protogen/example/multi-files/file2.proto b/protogen/example/multi-files/file2.proto index 31502f27..fa1c9df3 100644 --- a/protogen/example/multi-files/file2.proto +++ b/protogen/example/multi-files/file2.proto @@ -1,9 +1,8 @@ syntax = "proto3"; -option go_package = "github.com/bavix/gripmock/protogen/example/multi-files"; package multifiles; - +option go_package = "github.com/bavix/gripmock/protogen/example/multi-files"; service Gripmock2 { // simple unary method rpc SayHello (Request2) returns (Reply2); diff --git a/protogen/example/multi-files/file2_grpc.pb.go b/protogen/example/multi-files/file2_grpc.pb.go index 8091c5ea..77735cdd 100644 --- a/protogen/example/multi-files/file2_grpc.pb.go +++ b/protogen/example/multi-files/file2_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.23.4 +// - protoc v4.24.4 // source: file2.proto package multi_files diff --git a/protogen/example/multi-package/bar/bar.pb.go b/protogen/example/multi-package/bar/bar.pb.go index c81ad4af..fa19e2fc 100644 --- a/protogen/example/multi-package/bar/bar.pb.go +++ b/protogen/example/multi-package/bar/bar.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.23.4 -// source: bar.proto +// protoc-gen-go v1.32.0 +// protoc v4.24.4 +// source: bar/bar.proto package bar @@ -31,7 +31,7 @@ type Bar struct { func (x *Bar) Reset() { *x = Bar{} if protoimpl.UnsafeEnabled { - mi := &file_bar_proto_msgTypes[0] + mi := &file_bar_bar_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -44,7 +44,7 @@ func (x *Bar) String() string { func (*Bar) ProtoMessage() {} func (x *Bar) ProtoReflect() protoreflect.Message { - mi := &file_bar_proto_msgTypes[0] + mi := &file_bar_bar_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -57,7 +57,7 @@ func (x *Bar) ProtoReflect() protoreflect.Message { // Deprecated: Use Bar.ProtoReflect.Descriptor instead. func (*Bar) Descriptor() ([]byte, []int) { - return file_bar_proto_rawDescGZIP(), []int{0} + return file_bar_bar_proto_rawDescGZIP(), []int{0} } func (x *Bar) GetName() string { @@ -67,36 +67,36 @@ func (x *Bar) GetName() string { return "" } -var File_bar_proto protoreflect.FileDescriptor +var File_bar_bar_proto protoreflect.FileDescriptor -var file_bar_proto_rawDesc = []byte{ - 0x0a, 0x09, 0x62, 0x61, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x62, 0x61, 0x72, - 0x22, 0x19, 0x0a, 0x03, 0x42, 0x61, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x42, 0x5a, 0x40, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x6f, 0x6b, 0x6f, 0x70, 0x65, - 0x64, 0x69, 0x61, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, +var file_bar_bar_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x62, 0x61, 0x72, 0x2f, 0x62, 0x61, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x03, 0x62, 0x61, 0x72, 0x22, 0x19, 0x0a, 0x03, 0x42, 0x61, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x42, + 0x3e, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, + 0x76, 0x69, 0x78, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x2d, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2f, 0x62, 0x61, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_bar_proto_rawDescOnce sync.Once - file_bar_proto_rawDescData = file_bar_proto_rawDesc + file_bar_bar_proto_rawDescOnce sync.Once + file_bar_bar_proto_rawDescData = file_bar_bar_proto_rawDesc ) -func file_bar_proto_rawDescGZIP() []byte { - file_bar_proto_rawDescOnce.Do(func() { - file_bar_proto_rawDescData = protoimpl.X.CompressGZIP(file_bar_proto_rawDescData) +func file_bar_bar_proto_rawDescGZIP() []byte { + file_bar_bar_proto_rawDescOnce.Do(func() { + file_bar_bar_proto_rawDescData = protoimpl.X.CompressGZIP(file_bar_bar_proto_rawDescData) }) - return file_bar_proto_rawDescData + return file_bar_bar_proto_rawDescData } -var file_bar_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_bar_proto_goTypes = []interface{}{ +var file_bar_bar_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_bar_bar_proto_goTypes = []interface{}{ (*Bar)(nil), // 0: bar.Bar } -var file_bar_proto_depIdxs = []int32{ +var file_bar_bar_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type 0, // [0:0] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name @@ -104,13 +104,13 @@ var file_bar_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for field type_name } -func init() { file_bar_proto_init() } -func file_bar_proto_init() { - if File_bar_proto != nil { +func init() { file_bar_bar_proto_init() } +func file_bar_bar_proto_init() { + if File_bar_bar_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_bar_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_bar_bar_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Bar); i { case 0: return &v.state @@ -127,18 +127,18 @@ func file_bar_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_bar_proto_rawDesc, + RawDescriptor: file_bar_bar_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_bar_proto_goTypes, - DependencyIndexes: file_bar_proto_depIdxs, - MessageInfos: file_bar_proto_msgTypes, + GoTypes: file_bar_bar_proto_goTypes, + DependencyIndexes: file_bar_bar_proto_depIdxs, + MessageInfos: file_bar_bar_proto_msgTypes, }.Build() - File_bar_proto = out.File - file_bar_proto_rawDesc = nil - file_bar_proto_goTypes = nil - file_bar_proto_depIdxs = nil + File_bar_bar_proto = out.File + file_bar_bar_proto_rawDesc = nil + file_bar_bar_proto_goTypes = nil + file_bar_bar_proto_depIdxs = nil } diff --git a/protogen/example/multi-package/bar/bar.proto b/protogen/example/multi-package/bar/bar.proto index 29a7710f..04789417 100644 --- a/protogen/example/multi-package/bar/bar.proto +++ b/protogen/example/multi-package/bar/bar.proto @@ -1,9 +1,8 @@ syntax = "proto3"; -option go_package = "github.com/bavix/gripmock/protogen/example/multi-package/bar"; package bar; // this go_package is simulating alias collision - +option go_package = "github.com/bavix/gripmock/protogen/example/multi-package/bar"; message Bar{ string name = 1; diff --git a/protogen/example/multi-package/foo.pb.go b/protogen/example/multi-package/foo.pb.go index 2ab1f9d4..298a7126 100644 --- a/protogen/example/multi-package/foo.pb.go +++ b/protogen/example/multi-package/foo.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.23.4 +// protoc-gen-go v1.32.0 +// protoc v4.24.4 // source: foo.proto // simulating neighboring .proto file @@ -76,11 +76,11 @@ var file_foo_proto_rawDesc = []byte{ 0x0a, 0x09, 0x66, 0x6f, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x66, 0x6f, 0x6f, 0x22, 0x26, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3e, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x6f, 0x6b, 0x6f, 0x70, 0x65, 0x64, 0x69, 0x61, - 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, - 0x65, 0x6e, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x6d, 0x75, 0x6c, 0x74, 0x69, - 0x2d, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x76, 0x69, 0x78, 0x2f, 0x67, 0x72, 0x69, + 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x65, + 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x2d, 0x70, 0x61, 0x63, + 0x6b, 0x61, 0x67, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/protogen/example/multi-package/foo.proto b/protogen/example/multi-package/foo.proto index b8d883d2..64a13914 100644 --- a/protogen/example/multi-package/foo.proto +++ b/protogen/example/multi-package/foo.proto @@ -1,12 +1,11 @@ syntax = "proto3"; -option go_package = "github.com/bavix/gripmock/protogen/example/multi-package"; // simulating neighboring .proto file // but different package package foo; // simulating dummy private repo - +option go_package = "github.com/bavix/gripmock/protogen/example/multi-package"; message Response { string response = 1; diff --git a/protogen/example/multi-package/hello.pb.go b/protogen/example/multi-package/hello.pb.go index 519bb44a..1a9c4d5d 100644 --- a/protogen/example/multi-package/hello.pb.go +++ b/protogen/example/multi-package/hello.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.23.4 +// protoc-gen-go v1.32.0 +// protoc v4.24.4 // source: hello.proto package multi_package @@ -29,11 +29,11 @@ var file_hello_proto_rawDesc = []byte{ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x2c, 0x0a, 0x08, 0x47, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x12, 0x20, 0x0a, 0x05, 0x47, 0x72, 0x65, 0x65, 0x74, 0x12, 0x08, 0x2e, 0x62, 0x61, 0x72, 0x2e, 0x42, 0x61, 0x72, 0x1a, 0x0d, 0x2e, 0x66, 0x6f, 0x6f, 0x2e, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3e, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x74, 0x6f, 0x6b, 0x6f, 0x70, 0x65, 0x64, 0x69, 0x61, 0x2f, 0x67, 0x72, 0x69, - 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x65, - 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x2d, 0x70, 0x61, 0x63, - 0x6b, 0x61, 0x67, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x76, 0x69, 0x78, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, + 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x2f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x2d, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var file_hello_proto_goTypes = []interface{}{ diff --git a/protogen/example/multi-package/hello_grpc.pb.go b/protogen/example/multi-package/hello_grpc.pb.go index e1de979a..01674993 100644 --- a/protogen/example/multi-package/hello_grpc.pb.go +++ b/protogen/example/multi-package/hello_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.23.4 +// - protoc v4.24.4 // source: hello.proto package multi_package diff --git a/protogen/example/one-of/oneof.pb.go b/protogen/example/one-of/oneof.pb.go index ac918802..d4f0ee70 100644 --- a/protogen/example/one-of/oneof.pb.go +++ b/protogen/example/one-of/oneof.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.23.4 +// protoc-gen-go v1.32.0 +// protoc v4.24.4 // source: oneof.proto package one_of @@ -275,11 +275,11 @@ var file_oneof_proto_rawDesc = []byte{ 0x32, 0x34, 0x0a, 0x08, 0x47, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x12, 0x28, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x0e, 0x2e, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x6f, 0x6e, 0x65, 0x6f, 0x66, - 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x6f, 0x6b, 0x6f, 0x70, 0x65, 0x64, 0x69, 0x61, 0x2f, 0x67, - 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, - 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x6f, 0x6e, 0x65, 0x2d, 0x6f, 0x66, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x76, 0x69, 0x78, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, + 0x6f, 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x65, 0x78, 0x61, + 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x6f, 0x6e, 0x65, 0x2d, 0x6f, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( diff --git a/protogen/example/one-of/oneof.proto b/protogen/example/one-of/oneof.proto index 72ec4bc9..f9888a1d 100644 --- a/protogen/example/one-of/oneof.proto +++ b/protogen/example/one-of/oneof.proto @@ -1,9 +1,8 @@ syntax = "proto3"; -option go_package = "github.com/bavix/gripmock/protogen/example/one-of"; package oneof; - +option go_package = "github.com/bavix/gripmock/protogen/example/one-of"; // The Gripmock service definition. service Gripmock { diff --git a/protogen/example/one-of/oneof_grpc.pb.go b/protogen/example/one-of/oneof_grpc.pb.go index 645dd68d..093abf6b 100644 --- a/protogen/example/one-of/oneof_grpc.pb.go +++ b/protogen/example/one-of/oneof_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.23.4 +// - protoc v4.24.4 // source: oneof.proto package one_of diff --git a/protogen/example/simple/simple.pb.go b/protogen/example/simple/simple.pb.go index d83c90e8..83ac2833 100644 --- a/protogen/example/simple/simple.pb.go +++ b/protogen/example/simple/simple.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.24.3 +// protoc-gen-go v1.32.0 +// protoc v4.24.4 // source: simple.proto package simple @@ -26,9 +26,10 @@ type Request struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Vint64 int64 `protobuf:"varint,2,opt,name=vint64,proto3" json:"vint64,omitempty"` - Vuint64 uint64 `protobuf:"varint,3,opt,name=vuint64,proto3" json:"vuint64,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Vint64 int64 `protobuf:"varint,2,opt,name=vint64,proto3" json:"vint64,omitempty"` + Vuint64 uint64 `protobuf:"varint,3,opt,name=vuint64,proto3" json:"vuint64,omitempty"` + Values []int64 `protobuf:"varint,4,rep,packed,name=values,proto3" json:"values,omitempty"` } func (x *Request) Reset() { @@ -84,6 +85,13 @@ func (x *Request) GetVuint64() uint64 { return 0 } +func (x *Request) GetValues() []int64 { + if x != nil { + return x.Values + } + return nil +} + // The response message containing the greetings type Reply struct { state protoimpl.MessageState @@ -160,26 +168,28 @@ var File_simple_proto protoreflect.FileDescriptor var file_simple_proto_rawDesc = []byte{ 0x0a, 0x0c, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, - 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x22, 0x4f, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x22, 0x67, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x76, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, - 0x76, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x22, 0x74, 0x0a, 0x05, 0x52, 0x65, 0x70, 0x6c, 0x79, - 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, - 0x74, 0x75, 0x72, 0x6e, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x76, - 0x69, 0x6e, 0x74, 0x36, 0x34, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x76, 0x69, 0x6e, - 0x74, 0x36, 0x34, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x32, 0x36, 0x0a, - 0x08, 0x47, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x12, 0x2a, 0x0a, 0x08, 0x53, 0x61, 0x79, - 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x0f, 0x2e, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x2e, - 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x2a, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x76, 0x69, 0x78, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, - 0x63, 0x6b, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x73, 0x69, 0x6d, 0x70, 0x6c, - 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x76, 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x03, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, + 0x74, 0x0a, 0x05, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x5f, 0x63, 0x6f, 0x64, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x43, + 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x06, 0x76, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x12, 0x18, 0x0a, 0x07, 0x76, + 0x75, 0x69, 0x6e, 0x74, 0x36, 0x34, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x75, + 0x69, 0x6e, 0x74, 0x36, 0x34, 0x32, 0x36, 0x0a, 0x08, 0x47, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, + 0x6b, 0x12, 0x2a, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x0f, 0x2e, + 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, + 0x2e, 0x73, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x33, 0x5a, + 0x31, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x76, 0x69, + 0x78, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x67, 0x65, 0x6e, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x73, 0x69, 0x6d, 0x70, + 0x6c, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/protogen/example/simple/simple.proto b/protogen/example/simple/simple.proto index fbed9cca..55661ae4 100644 --- a/protogen/example/simple/simple.proto +++ b/protogen/example/simple/simple.proto @@ -1,9 +1,8 @@ syntax = "proto3"; -option go_package = "github.com/bavix/gripmock/protogen/example/simple"; package simple; - +option go_package = "github.com/bavix/gripmock/protogen/example/simple"; // The Gripmock service definition. service Gripmock { @@ -14,10 +13,15 @@ service Gripmock { // The request message containing the user's name. message Request { string name = 1; + int64 vint64 = 2; + uint64 vuint64 = 3; + repeated int64 values = 4; } // The response message containing the greetings message Reply { string message = 1; int32 return_code = 2; + int64 vint64 = 3; + uint64 vuint64 = 4; } \ No newline at end of file diff --git a/protogen/example/simple/simple_grpc.pb.go b/protogen/example/simple/simple_grpc.pb.go index 8f457ad5..7d6d02fb 100644 --- a/protogen/example/simple/simple_grpc.pb.go +++ b/protogen/example/simple/simple_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.24.3 +// - protoc v4.24.4 // source: simple.proto package simple diff --git a/protogen/example/stream/stream.pb.go b/protogen/example/stream/stream.pb.go index 122449f9..b09dc7c7 100644 --- a/protogen/example/stream/stream.pb.go +++ b/protogen/example/stream/stream.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.23.4 +// protoc-gen-go v1.32.0 +// protoc v4.24.4 // source: stream.proto package stream @@ -134,11 +134,11 @@ var file_stream_proto_rawDesc = []byte{ 0x6d, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x28, 0x01, 0x12, 0x33, 0x0a, 0x0d, 0x62, 0x69, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x12, 0x0f, 0x2e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x73, 0x74, - 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x28, 0x01, 0x30, 0x01, 0x42, 0x37, - 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x6f, 0x6b, - 0x6f, 0x70, 0x65, 0x64, 0x69, 0x61, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, - 0x2f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x65, 0x61, 0x6d, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x28, 0x01, 0x30, 0x01, 0x42, 0x33, + 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x76, + 0x69, 0x78, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x73, 0x74, 0x72, + 0x65, 0x61, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/protogen/example/stream/stream.proto b/protogen/example/stream/stream.proto index 20d10598..84b38305 100644 --- a/protogen/example/stream/stream.proto +++ b/protogen/example/stream/stream.proto @@ -1,9 +1,8 @@ syntax = "proto3"; -option go_package = "github.com/bavix/gripmock/protogen/example/stream"; package stream; - +option go_package = "github.com/bavix/gripmock/protogen/example/stream"; // The Gripmock service definition. service Gripmock { // server to client sreaming diff --git a/protogen/example/stream/stream_grpc.pb.go b/protogen/example/stream/stream_grpc.pb.go index f38eaff7..7afb25ce 100644 --- a/protogen/example/stream/stream_grpc.pb.go +++ b/protogen/example/stream/stream_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.23.4 +// - protoc v4.24.4 // source: stream.proto package stream diff --git a/protogen/example/stub-subfolders/stub-subfolders.pb.go b/protogen/example/stub-subfolders/stub-subfolders.pb.go index fc51ca8e..11150138 100644 --- a/protogen/example/stub-subfolders/stub-subfolders.pb.go +++ b/protogen/example/stub-subfolders/stub-subfolders.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.23.4 +// protoc-gen-go v1.32.0 +// protoc v4.24.4 // source: stub-subfolders.proto package stub_subfolders @@ -140,11 +140,11 @@ var file_stub_subfolders_proto_rawDesc = []byte{ 0x6c, 0x6c, 0x6f, 0x12, 0x18, 0x2e, 0x73, 0x74, 0x75, 0x62, 0x5f, 0x73, 0x75, 0x62, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x73, 0x74, 0x75, 0x62, 0x5f, 0x73, 0x75, 0x62, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x73, 0x2e, - 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x40, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x6f, 0x6b, 0x6f, 0x70, 0x65, 0x64, 0x69, 0x61, 0x2f, 0x67, 0x72, - 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, - 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x73, 0x74, 0x75, 0x62, 0x2d, 0x73, 0x75, 0x62, - 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x76, 0x69, 0x78, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, + 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x65, 0x78, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x2f, 0x73, 0x74, 0x75, 0x62, 0x2d, 0x73, 0x75, 0x62, 0x66, 0x6f, 0x6c, 0x64, + 0x65, 0x72, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/protogen/example/stub-subfolders/stub-subfolders_grpc.pb.go b/protogen/example/stub-subfolders/stub-subfolders_grpc.pb.go index 5050a49f..b436ce3d 100644 --- a/protogen/example/stub-subfolders/stub-subfolders_grpc.pb.go +++ b/protogen/example/stub-subfolders/stub-subfolders_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.23.4 +// - protoc v4.24.4 // source: stub-subfolders.proto package stub_subfolders diff --git a/protogen/example/well_known_types/wkt.pb.go b/protogen/example/well_known_types/wkt.pb.go index 14f64d48..e3e9d428 100644 --- a/protogen/example/well_known_types/wkt.pb.go +++ b/protogen/example/well_known_types/wkt.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.23.4 +// protoc-gen-go v1.32.0 +// protoc v4.24.4 // source: wkt.proto package well_known_types import ( + _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" apipb "google.golang.org/protobuf/types/known/apipb" @@ -25,20 +26,24 @@ var File_wkt_proto protoreflect.FileDescriptor var file_wkt_proto_rawDesc = []byte{ 0x0a, 0x09, 0x77, 0x6b, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x77, 0x65, 0x6c, - 0x6c, 0x5f, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x1a, 0x1b, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, - 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x70, 0x69, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x43, 0x0a, 0x08, 0x47, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, - 0x6b, 0x12, 0x37, 0x0a, 0x07, 0x41, 0x70, 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, - 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x70, 0x69, 0x42, 0x41, 0x5a, 0x3f, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x6f, 0x6b, 0x6f, 0x70, 0x65, 0x64, - 0x69, 0x61, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x77, 0x65, 0x6c, - 0x6c, 0x5f, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6c, 0x5f, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x1a, 0x1c, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, + 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x32, 0x65, 0x0a, 0x08, 0x47, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x12, + 0x59, 0x0a, 0x07, 0x41, 0x70, 0x69, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, + 0x74, 0x79, 0x1a, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x70, 0x69, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, + 0x3a, 0x01, 0x2a, 0x22, 0x15, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, + 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2d, 0x69, 0x6e, 0x66, 0x6f, 0x42, 0x3d, 0x5a, 0x3b, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x76, 0x69, 0x78, 0x2f, 0x67, + 0x72, 0x69, 0x70, 0x6d, 0x6f, 0x63, 0x6b, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, + 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x77, 0x65, 0x6c, 0x6c, 0x5f, 0x6b, 0x6e, + 0x6f, 0x77, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var file_wkt_proto_goTypes = []interface{}{ diff --git a/protogen/example/well_known_types/wkt.proto b/protogen/example/well_known_types/wkt.proto index 6fb7a77f..647f296a 100644 --- a/protogen/example/well_known_types/wkt.proto +++ b/protogen/example/well_known_types/wkt.proto @@ -1,15 +1,20 @@ syntax = "proto3"; -option go_package = "github.com/bavix/gripmock/protogen/example/well_known_types"; package well_known_types; +import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/api.proto"; - +option go_package = "github.com/bavix/gripmock/protogen/example/well_known_types"; service Gripmock { // this shows us example on using WKT as dependency // api.proto in particular has go_package alias with semicolon // "google.golang.org/genproto/protobuf/api;api" - rpc ApiInfo(google.protobuf.Empty) returns (google.protobuf.Api); + rpc ApiInfo(google.protobuf.Empty) returns (google.protobuf.Api) { + option (google.api.http) = { + post: "/v1/gripmock/api-info" + body: "*" + }; + } } diff --git a/protogen/example/well_known_types/wkt_grpc.pb.go b/protogen/example/well_known_types/wkt_grpc.pb.go index 27f11543..753de317 100644 --- a/protogen/example/well_known_types/wkt_grpc.pb.go +++ b/protogen/example/well_known_types/wkt_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.23.4 +// - protoc v4.24.4 // source: wkt.proto package well_known_types diff --git a/protogen/go.mod b/protogen/go.mod index 95a93c2f..e8e35dde 100644 --- a/protogen/go.mod +++ b/protogen/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 - google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 + google.golang.org/genproto/googleapis/api v0.0.0-20240108191215-35c7eff3a6b1 google.golang.org/grpc v1.60.1 google.golang.org/protobuf v1.32.0 ) @@ -18,9 +18,9 @@ require ( go.opentelemetry.io/otel v1.21.0 // indirect go.opentelemetry.io/otel/metric v1.21.0 // indirect go.opentelemetry.io/otel/trace v1.21.0 // indirect - golang.org/x/net v0.19.0 // indirect + golang.org/x/net v0.20.0 // indirect golang.org/x/sys v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect - google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect + google.golang.org/genproto v0.0.0-20240108191215-35c7eff3a6b1 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 // indirect ) diff --git a/protogen/go.sum b/protogen/go.sum index e20becea..aa75aa6f 100644 --- a/protogen/go.sum +++ b/protogen/go.sum @@ -12,8 +12,6 @@ github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7 github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= -github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= @@ -38,12 +36,10 @@ go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ3 go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc= go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY= golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= @@ -51,18 +47,12 @@ golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto v0.0.0-20231212172506-995d672761c0 h1:YJ5pD9rF8o9Qtta0Cmy9rdBwkSjrTCT6XTiUQVOtIos= -google.golang.org/genproto v0.0.0-20231212172506-995d672761c0/go.mod h1:l/k7rMz0vFTBPy+tFSGvXEd3z+BcoG1k7EHbqm+YBsY= -google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917 h1:nz5NESFLZbJGPFxDT/HCn+V1mZ8JGNoY4nUpmW/Y2eg= -google.golang.org/genproto v0.0.0-20240102182953-50ed04b92917/go.mod h1:pZqR+glSb11aJ+JQcczCvgf47+duRuzNSKqE8YAQnV0= -google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0 h1:s1w3X6gQxwrLEpxnLd/qXTVLgQE2yXwaOaoa6IlY/+o= -google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0/go.mod h1:CAny0tYF+0/9rmDB9fahA9YLzX3+AEVl1qXbv5hhj6c= -google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 h1:rcS6EyEaoCO52hQDupoSfrxI3R6C2Tq741is7X8OvnM= -google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917/go.mod h1:CmlNWB9lSezaYELKS5Ym1r44VrrbPUa7JTvw+6MbpJ0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 h1:/jFB8jK5R3Sq3i/lmeZO0cATSzFfZaJq1J2Euan3XKU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0/go.mod h1:FUoWkonphQm3RhTS+kOEhF8h0iDpm4tdXolVCeZ9KKA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 h1:6G8oQ016D88m1xAKljMlBOOGWDZkes4kMhgGFlf8WcQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917/go.mod h1:xtjpI3tXFPP051KaWnhvxkiubL/6dJ18vLVf7q2pTOU= +google.golang.org/genproto v0.0.0-20240108191215-35c7eff3a6b1 h1:/IWabOtPziuXTEtI1KYCpM6Ss7vaAkeMxk+uXV/xvZs= +google.golang.org/genproto v0.0.0-20240108191215-35c7eff3a6b1/go.mod h1:+Rvu7ElI+aLzyDQhpHMFMMltsD6m7nqpuWDd2CwJw3k= +google.golang.org/genproto/googleapis/api v0.0.0-20240108191215-35c7eff3a6b1 h1:OPXtXn7fNMaXwO3JvOmF1QyTc00jsSFFz1vXXBOdCDo= +google.golang.org/genproto/googleapis/api v0.0.0-20240108191215-35c7eff3a6b1/go.mod h1:B5xPO//w8qmBDjGReYLpR6UJPnkldGkCSMoH/2vxJeg= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1 h1:gphdwh0npgs8elJ4T6J+DQJHPVF7RsuJHCfwztUb4J4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240108191215-35c7eff3a6b1/go.mod h1:daQN87bsDqDoe316QbbvX60nMoJQa4r6Ds0ZuoAe5yA= google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=