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

fix: ipns protobuf namespace conflict #794

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The following emojis are used to highlight certain changes:
### Fixed

- `gateway` Fix redirect URLs for subdirectories with characters that need escaping. [#779](https://github.com/ipfs/boxo/pull/779)
- `ipns` Defined a `go_package` name in `ipns-record.proto` to avoid protobuf conflicts [#789](https://github.com/ipfs/boxo/pull/789)
- `ipns` Fix `ipns` protobuf namespace conflicts by using full package name `github.com/ipfs/boxo/ipns/pb/record.proto` instead of the generic `record.proto` [#794](https://github.com/ipfs/boxo/pull/794)

### Security

Expand Down
31 changes: 31 additions & 0 deletions ipns/pb/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This Makefile is designed to work around namespace conflicts that occur when
# multiple repositories depend on .proto files with generic filenames. Due to
# the way protobuf registers files (e.g., foo.proto or pb/foo.proto), naming
# collisions can occur when the same filename is used across different
# packages.
#
# The only way to generate a *.pb.go file that includes the full package path
# (e.g., github.com/org/repo/pb/foo.proto) is to place the .proto file in a
# directory structure that mirrors its package path.
#
# References:
# * https://protobuf.dev/reference/go/faq#namespace-conflict
# * https://github.com/golang/protobuf/issues/1122#issuecomment-2045945265

PKG_PATH = github.com/ipfs/boxo/ipns/pb
PROTONAME = record
PROTOFILE = ${PROTONAME}.proto

all: clean build

build:
mkdir -p ${PKG_PATH}
cp ${PROTOFILE} ${PKG_PATH}
protoc --go_out=. ${PKG_PATH}/${PROTOFILE}
mv ${PKG_PATH}/${PROTONAME}.pb.go .
rm -rf $(firstword $(subst /, ,${PKG_PATH}))
gammazero marked this conversation as resolved.
Show resolved Hide resolved

clean:
rm -f *.pb.go

.PHONY: all build clean
gammazero marked this conversation as resolved.
Show resolved Hide resolved
270 changes: 0 additions & 270 deletions ipns/pb/ipns-record.pb.go

This file was deleted.

Loading
Loading