protoc-gen-validate
protoc-gen-validate copied to clipboard
Buf.build plugin
Hi!
This protoc plugin already has already schema on buf.build: https://buf.build/envoyproxy/protoc-gen-validate, but it only has proto definitions included, so I made also a plugin, which can be used remotely - https://buf.build/jirkad/plugins/protoc-gen-validate
It would be fine to have this plugin in the official buf.build repo also as it makes generating code using remote plugins super easy :)
Usage:
...
plugins:
- remote: buf.build/jirkad/plugins/protoc-gen-validate:v0.6.1
out: pkg/proto
opt:
- lang=go
- paths=source_relative
Dockerfile:
FROM golang as builder
ENV GOOS=linux GOARCH=amd64 CGO_ENABLED=0
RUN go install github.com/envoyproxy/[email protected]
FROM scratch
COPY --from=builder /go/bin/protoc-gen-validate /protoc-gen-validate
ENTRYPOINT [ "/protoc-gen-validate" ]
-
buf.yaml
version: v1
name: buf.build/envoyproxy/protoc-gen-validate
build:
excludes:
- example-workspace
- java
- tests
lint:
use:
- DEFAULT
breaking:
use:
- FILE
-
buf.work.yaml
version: v1
directories:
- .
-
buf.gen.yaml
version: v1
managed:
enabled: true
go_package_prefix:
default: github.com/envoyproxy/protoc-gen-validate
plugins:
- remote: buf.build/library/plugins/go:v1.27.1-1
out: .
opt:
- paths=source_relative
buf push --tag v0.6.3
-
Dockerfile.buf
FROM golang as builder
ENV GOOS=linux GOARCH=amd64 CGO_ENABLED=0
RUN go install -v github.com/envoyproxy/[email protected]
FROM scratch
LABEL "build.buf.plugins.runtime_library_versions.0.name"="github.com/envoyproxy/protoc-gen-validate"
LABEL "build.buf.plugins.runtime_library_versions.0.version"="v0.6.3"
COPY --from=builder /go/bin/protoc-gen-validate /protoc-gen-validate
ENTRYPOINT ["/protoc-gen-validate"]
# docker login -u anonymous plugins.buf.build
docker build --platform linux/amd64 --force-rm --compress -f Dockerfile.buf -t plugins.buf.build/envoyproxy/protoc-gen-validate:v0.6.3-1 .
Just a friendly comment to revive this issue :smile: I've tested @george-oakling 's plugin and it indeed works like a charm.
To the maintainers, here is more context regarding buf.build remote plugin execution : https://buf.build/blog/remote-plugin-execution
This would be an awesome addition to the proto sources already distributed on the BSR.
Hi guys, just letting you know my unofficial plugin is now available at v0.6.7 tag - https://buf.build/jirkad/plugins/protoc-gen-validate
Enjoy :) and hopefully one day we will have an official release :)
@george-oakling thanks so much ❤️
I desparately want an official release
Really cool work @george-oakling. I hope they accept this plugin. If anyone else is getting started with this stuff (Buf + protoc-gen-validate), I have an example PR.
Would like to see official plugin!
So the strange thing is that the plugins are available in the GH repository. Though they're not published on the BSR 🤔
Just made this issue in the plugins GH repository to ask whether this is intentional. I used the official GH repository to publish the most recent version of protoc-gen-validate
, if anyone needs it, it can be found here: https://buf.build/strmprivacy/plugins/protoc-gen-validate
Did the following steps to create this plugin:
- Cloned https://github.com/bufbuild/plugins/
-
cd plugins/bufbuild/validate-java/v0.6.13
-
buf beta registry plugin create buf.build/strmprivacy/plugins/protoc-gen-validate --visibility public
-
docker buildx build --platform linux/amd64 --push -t plugins.buf.build/strmprivacy/protoc-gen-validate:v0.6.13-1 .
(as I'm using an M1 Mac)
Just updating that PGV can be used as a remote plugin with newer buf CLI (>v1.9.0): ref.
In light of the above development, this issue can probably be closed.