Skip to content

Commit

Permalink
Fix proto import paths (#2920)
Browse files Browse the repository at this point in the history
* Add failing proto test

* Add a new proto compilation script

A proto file's *import path* is relative to one of the `--proto-path`s.

Previously, the proto files were compiled separately. Some invocations
used different values for the `--proto_path`, which led to inconsistent
import paths in proto file descriptors.

Typically, this wouldn't be a problem. However, if a downstream project
uses `protoregistry.GlobalFiles` to inspect proto dependencies, it will fail
to find a dependency's file descriptor when the dependency was compiled
with a different `--proto_path`.

By using a single script to generate all protobuf files, we can ensure
the `--proto_path` is always set to the same sane value (the root of the
project, as suggested in the [official documentation]).

[official documentation]: https://protobuf.dev/programming-guides/proto2/#importing

* Add go_package options so scripts/gen-proto.sh succeeds

* Remove undesirable `go:generate protoc` directives

* Run `go generate ./...`

* Script uses arrays, I think we need bash

---------

Co-authored-by: Marco Munizaga <git@marcopolo.io>
  • Loading branch information
joshklop and MarcoPolo authored Aug 19, 2024
1 parent a0349af commit 0fb7dac
Show file tree
Hide file tree
Showing 40 changed files with 964 additions and 854 deletions.
2 changes: 0 additions & 2 deletions core/crypto/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
"google.golang.org/protobuf/proto"
)

//go:generate protoc --go_out=. --go_opt=Mpb/crypto.proto=./pb pb/crypto.proto

const (
// RSA is an enum for the supported RSA key type
RSA = iota
Expand Down
113 changes: 57 additions & 56 deletions core/crypto/pb/crypto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0fb7dac

Please sign in to comment.