tokopedia / gripmock

gRPC Mock Server
Apache License 2.0
647 stars 157 forks source link

document `--imports` examples and constraints #164

Open kanaksinghal opened 4 months ago

kanaksinghal commented 4 months ago

great tool, but I was stuck on proto imports

issues:

  1. setting grand parent dir of my main proto file in imports option doesn't work and I figured why after debugging the code
  2. /protobuf/google is not up to date. missing google/api/annotations.proto

I have my file structure like this:

- go.mod
- go.sum
- vendor
    - github.com
        - repo1
            - .../x.proto
        - repo2
            - .../y.proto
        - repo3
            - .../main.proto

I did this:

docker run --rm -p 4770:4770 -p 4771:4771 -v ./vendor:/vendor --imports="/vendor,/protobuf" /vendor/github.com/repo3/.../main.proto

it returns

github.com/repo1/.../x.proto File not found
github.com/repo2/.../y.proto File not found

after debugging the code I realised, that the /vendor is never passed to -I in protoc since it was part of the main.proto file path and this behaviour was not documented at all... 🤷‍♂️ so mounting another dir for imports worked like this:

docker run --rm -p 4770:4770 -p 4771:4771 -v ./vendor:/vendor -v ./vendor/github.com/repo3:/repo3 --imports="/vendor,/protobuf" /repo3/.../main.proto
0bon commented 2 months ago

Any progress with this ? I am stuck on the same error. proto file Imports are not found during the run