Repository navigation
Publish the generator as a BSR remote plugin - #8
Merged
Merged
Conversation
Consumers currently need the binary on PATH, which is why svc/crm silently
generated nothing when a stale copy shadowed it. A remote plugin removes
that: buf runs the published image, and buf.gen.yaml names a version.
plugins:
- remote: buf.build/roderm/go-sqlmap:v0.1.0
buf.plugin.yaml carries the metadata, including the runtime module the
generated code imports -- pkg/query and pkg/generated/schema/v1 are not
optional for compiling the output, so registry.go.deps pins them. It also
declares protocolbuffers/go as a dependency, since .sqlmap.go extends the
message types that plugin emits.
Because those pins reference the release, plugin_version and
registry.go.deps have to match the git tag. The release workflow checks
that before pushing rather than shipping a plugin whose generated SDKs
require a module version that does not exist yet.
The Dockerfile follows what the BSR requires: linux/amd64, a scratch base
via a multi-stage build, and a non-root user. The resulting image is 8MB.
Verified by building the image and driving it through protoc as a real
plugin: the output for testdata/subtype.proto is byte-identical to the
golden file.
Note the plugin is a separate BSR resource from the existing
buf.build/roderm/protoc-gen-go-sqlmap *module*, which carries the protos;
pushing this does not publish the sqlmap extensions.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consumers currently need
protoc-gen-go-sqlmaponPATH. That is howsvc/crmsilently generated nothing for a while: a stale copy in a differentbindirectory shadowed the freshly installed one, andbuf generateexited 0. A remote plugin removes the class of problem — buf runs the published image andbuf.gen.yamlnames a version:What's here
buf.plugin.yaml— plugin metadata. Two dependency declarations matter:deps: buf.build/protocolbuffers/go— the generated.sqlmap.goextends the message types that plugin emits, so it is only compilable alongside them.registry.go.deps— pinsgithub.com/roderm/protoc-gen-go-sqlmap, because the generated code importspkg/query(Mask,Conn) andpkg/generated/schema/v1(SchemaTable). Those are not optional extras; without them the output does not compile.Dockerfile— what the BSR requires:linux/amd64,scratchbase via multi-stage build, non-root user. Resulting image is 8MB.Release workflow job — pushes on tag, but only after checking
plugin_versionandregistry.go.depsmatch the tag. Since those pins reference the release, publishing them out of step would ship a plugin whose generated SDKs require a module version that does not exist. I verified the check fails on a drifted tag rather than only passing on a matching one.Verification
Built the image and drove it through
protocas a real plugin, via a wrapper runningdocker run --rm -i. Output fortestdata/subtype.protois byte-identical to the golden file, so the containerised plugin behaves exactly like the local binary.Notes for reviewers
buf.build/roderm/protoc-gen-go-sqlmapmodule, which carries the protos. Pushing this plugin does not publish thesubtypes/subtype_ofextensions — that still needs a modulebuf push, and remains what blockssvc/crm.plugin_versionisv0.1.0while the latest tag isv0.0.2. I picked a minor bump given what has landed since; change it if you would rather it werev0.0.3.min_versionis"1.27", matchinggo.mod. That is a high floor for consumers of the generated SDKs — worth lowering if it excludes anyone, since nothing in the runtime packages obviously needs 1.27.buf beta registry plugin push; buf's docs say it will graduate tobuf registry plugin push.🤖 Generated with Claude Code