Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define a go_package for protobuf, rename to a more unique ipns-record.proto #789

Merged
merged 4 commits into from
Jan 16, 2025

Conversation

dereknola
Copy link
Contributor

This is an attempt to address #788

Note in the first commit that I first attempted to follow the online recommendations from:

Thus I also renamed to file itself to something less generic. Note that this should not affect external use, as the package is still pb and since #339, external usage of the protobuf is around the ipns package, not the ipns/pb package directly.

If someone with more knowledge around protobuf generation can see a better way to address the issue or improve this PR, please let me know.

- Use relative source to reduce static values
Signed-off-by: Derek Nola <[email protected]>
@dereknola dereknola requested a review from a team as a code owner January 10, 2025 20:57
Copy link

welcome bot commented Jan 10, 2025

Thank you for submitting this PR!
A maintainer will be here shortly to review it.
We are super grateful, but we are also overloaded! Help us by making sure that:

  • The context for this PR is clear, with relevant discussion, decisions
    and stakeholders linked/mentioned.

  • Your contribution itself is clear (code comments, self-review for the
    rest) and in its best form. Follow the code contribution
    guidelines

    if they apply.

Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment.
Next steps:

  • A maintainer will triage and assign priority to this PR, commenting on
    any missing things and potentially assigning a reviewer for high
    priority items.

  • The PR gets reviews, discussed and approvals as needed.

  • The PR is merged by maintainers when it has been approved and comments addressed.

We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution.
We are very grateful for your contribution!

@guillaumemichel
Copy link
Contributor

@dereknola does the updated protobuf actually fix your issues?

I suspect that it might be coming from other protobufs where the package name might be too generic such as go-libp2p-kad-dht and go-libp2p-record for example.

I already have opened PRs for these two repos, I'll update the package name, and push to get them merged.

@dereknola
Copy link
Contributor Author

dereknola commented Jan 15, 2025

@guillaumemichel Yes, the PR I've submitted does fix our issue in K3s. I've got a branch here where the boxo dependecy is replaced with my own version (i.e. this current PR commit). Here is the record grep on that branch

derek@degion:~/rancher/k3s$ grep -rF 'record.proto' vendor/
vendor/go.etcd.io/etcd/server/v3/wal/walpb/record.pb.go:// source: record.proto
vendor/go.etcd.io/etcd/server/v3/wal/walpb/record.pb.go:func init() { proto.RegisterFile("record.proto", fileDescriptor_bf94fd919e302a1d) }
vendor/github.com/libp2p/go-libp2p-record/pb/record.pb.go:// source: record.proto
vendor/github.com/libp2p/go-libp2p-record/pb/record.pb.go:func init() { proto.RegisterFile("record.proto", fileDescriptor_bf94fd919e302a1d) }
vendor/github.com/libp2p/go-libp2p-record/pb/record.proto:// `protoc --gogo_out=. record.proto`
vendor/github.com/libp2p/go-libp2p-kad-dht/pb/dht.proto:import "github.com/libp2p/go-libp2p-record/pb/record.proto";
vendor/github.com/libp2p/go-libp2p/p2p/protocol/identify/pb/identify.proto:  // github.com/libp2p/go-libp2p/core/peer/pb/peer_record.proto for message definitions.
vendor/github.com/libp2p/go-libp2p/p2p/protocol/identify/pb/identify.pb.go:	// github.com/libp2p/go-libp2p/core/peer/pb/peer_record.proto for message definitions.
vendor/github.com/libp2p/go-libp2p/core/peer/pb/peer_record.pb.go:// source: core/peer/pb/peer_record.proto
vendor/github.com/ipfs/boxo/ipns/pb/ipns-record.pb.go:// source: ipns-record.proto
vendor/github.com/ipfs/boxo/ipns/record.go://go:generate protoc -I=pb --go_out=paths=source_relative:pb pb/ipns-record.proto

I appreciate you opening the other two PRs. Its possible that if those got merged it would also fix our issue, I haven't tried replacing those.

Copy link
Contributor

@guillaumemichel guillaumemichel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dereknola for your contribution!

Looks good to me! What seems to matter is the go_package option, filename shouldn't create conflict, though renaming it to ipns-record.proto adds clarity 👍🏻

TIL: https://protobuf.dev/programming-guides/proto3/#packages

In Go, the package directive is ignored, and the generated .pb.go file is in the package named after the corresponding go_proto_library Bazel rule. For open source projects, you must provide either a go_package option or set the Bazel -M flag.

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 72.22222% with 30 lines in your changes missing coverage. Please review.

Project coverage is 60.47%. Comparing base (11b5100) to head (34a082c).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
ipns/pb/ipns-record.pb.go 72.22% 29 Missing and 1 partial ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #789      +/-   ##
==========================================
- Coverage   60.48%   60.47%   -0.01%     
==========================================
  Files         245      245              
  Lines       31138    31138              
==========================================
- Hits        18833    18830       -3     
- Misses      10625    10628       +3     
  Partials     1680     1680              
Files with missing lines Coverage Δ
ipns/record.go 68.21% <ø> (ø)
ipns/pb/ipns-record.pb.go 72.22% <72.22%> (ø)

... and 14 files with indirect coverage changes

@guillaumemichel guillaumemichel merged commit b7d0d20 into ipfs:main Jan 16, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

record.proto is too generic and results in conflict with other packages
2 participants