-
Notifications
You must be signed in to change notification settings - Fork 583
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
add support for multiple plugins #717
Changes from all commits
e6f0693
d9d8183
bef4095
77b4ef2
1ebe73a
19ec933
de936d5
7652881
9bb818b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
5.3.1 | ||
5.3.2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.git/ | ||
.idea/ | ||
.bin/ | ||
dist/ | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file was being identified as both a github workflow and a goreleaser config file in vscode - this will remove invalid flagged errors when editing this file. |
||
name: goreleaser | ||
|
||
on: | ||
|
@@ -19,6 +20,7 @@ jobs: | |
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19.x | ||
use-latest: true | ||
cache: true | ||
- uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,31 +25,32 @@ RUN apt update \ | |
&& apt clean | ||
|
||
# bazel | ||
ENV BAZEL_VER=5.3.1 | ||
RUN wget -O bazel https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VER}/bazel-${BAZEL_VER}-linux-$([ $(uname -m) = "aarch64" ] && echo "arm64" || echo "x86_64") \ | ||
ENV BAZEL_VER=5.3.2 | ||
RUN wget -q -O bazel https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VER}/bazel-${BAZEL_VER}-linux-$([ $(uname -m) = "aarch64" ] && echo "arm64" || echo "x86_64") \ | ||
&& chmod +x bazel \ | ||
&& mv bazel usr/local/bin/bazel | ||
|
||
# protoc | ||
ENV PROTOC_VER=21.5 | ||
ENV PROTOC_VER=21.9 | ||
RUN export PROTOC_REL=protoc-${PROTOC_VER}-linux-$([ $(uname -m) = "aarch64" ] && echo "aarch" || echo "x86")_64.zip \ | ||
&& wget https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VER}/${PROTOC_REL} \ | ||
&& wget -q https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VER}/${PROTOC_REL} \ | ||
&& unzip ${PROTOC_REL} -d protoc \ | ||
&& mv protoc /usr/local \ | ||
&& ln -s /usr/local/protoc/bin/protoc /usr/local/bin | ||
&& ln -s /usr/local/protoc/bin/protoc /usr/local/bin \ | ||
&& rm ${PROTOC_REL} | ||
|
||
# go | ||
ENV GOROOT /usr/local/go | ||
ENV GOPATH /go | ||
ENV PATH $GOPATH/bin:$GOROOT/bin:$PATH | ||
RUN export GORELEASE=go1.19.1.linux-$([ $(uname -m) = "aarch64" ] && echo "arm64" || echo "amd64").tar.gz \ | ||
RUN export GORELEASE=go1.19.3.linux-$([ $(uname -m) = "aarch64" ] && echo "arm64" || echo "amd64").tar.gz \ | ||
&& wget -q https://dl.google.com/go/$GORELEASE \ | ||
&& tar -C $(dirname $GOROOT) -xzf $GORELEASE \ | ||
&& rm $GORELEASE \ | ||
&& mkdir -p $GOPATH/{src,bin,pkg} | ||
|
||
# protoc-gen-go | ||
ENV PGG_VER=v1.27.1 | ||
ENV PGG_VER=v1.28.1 | ||
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@${PGG_VER} \ | ||
&& rm -rf $(go env GOCACHE) \ | ||
&& rm -rf $(go env GOMODCACHE) | ||
|
@@ -60,17 +61,19 @@ RUN go install github.com/bazelbuild/buildtools/buildozer@${BDR_VER} \ | |
&& rm -rf $(go env GOCACHE) \ | ||
&& rm -rf $(go env GOMODCACHE) | ||
|
||
WORKDIR ${GOPATH}/src/github.com/envoyproxy/protoc-gen-validate | ||
COPY . . | ||
|
||
# python must be on PATH for the execution of py_binary bazel targets, but | ||
# the distribution we installed doesn't provide this alias | ||
RUN ln -s /usr/bin/python3.8 /usr/bin/python | ||
|
||
WORKDIR ${GOPATH}/src/github.com/envoyproxy/protoc-gen-validate | ||
|
||
# python tooling for linting and uploading to PyPI | ||
COPY requirements.txt . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optimized the docker build to benefit from layer caching so we don't re-download the Python dependencies if any other files change. |
||
RUN python3.8 -m easy_install pip \ | ||
&& python3.8 -m pip install -r requirements.txt | ||
|
||
COPY . . | ||
|
||
RUN make build | ||
|
||
ENTRYPOINT ["make"] | ||
|
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ build: validate/validate.pb.go ## generates the PGV binary and installs it into | |
|
||
.PHONY: bazel | ||
bazel: ## generate the PGV plugin with Bazel | ||
bazel build //tests/... | ||
bazel build //cmd/... //tests/... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verifies that the new commands can build w/ bazel. |
||
|
||
.PHONY: build_generation_tests | ||
build_generation_tests: | ||
|
@@ -53,7 +53,7 @@ bin/golint: | |
GOBIN=$(shell pwd)/bin go install golang.org/x/lint/golint | ||
|
||
bin/protoc-gen-go: | ||
GOBIN=$(shell pwd)/bin go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1 | ||
GOBIN=$(shell pwd)/bin go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1 | ||
|
||
bin/harness: | ||
cd tests && go build -o ../bin/harness ./harness/executor | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
load("@bazel_gazelle//:def.bzl", "gazelle") | ||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") | ||
|
||
# gazelle:prefix github.com/envoyproxy/protoc-gen-validate | ||
# gazelle:exclude tests | ||
# gazelle:exclude example-workspace | ||
# gazelle:exclude validate/validate.h | ||
# gazelle:go_naming_convention import_alias | ||
gazelle(name = "gazelle") | ||
|
||
go_binary( | ||
name = "protoc-gen-validate-cpp", | ||
embed = [":protoc-gen-validate-cpp_lib"], | ||
importpath = "github.com/envoyproxy/protoc-gen-validate/cmd/protoc-gen-validate-cpp", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
go_library( | ||
name = "protoc-gen-validate-cpp_lib", | ||
srcs = ["main.go"], | ||
importpath = "github.com/envoyproxy/protoc-gen-validate/cmd/protoc-gen-validate-cpp", | ||
visibility = ["//visibility:private"], | ||
deps = [ | ||
"//module", | ||
"@com_github_lyft_protoc_gen_star//:protoc-gen-star", | ||
"@com_github_lyft_protoc_gen_star//lang/go", | ||
"@org_golang_google_protobuf//types/pluginpb", | ||
], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/envoyproxy/protoc-gen-validate/module" | ||
pgs "github.com/lyft/protoc-gen-star" | ||
"google.golang.org/protobuf/types/pluginpb" | ||
) | ||
|
||
func main() { | ||
optional := uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL) | ||
pgs. | ||
Init(pgs.DebugEnv("DEBUG_PGV"), pgs.SupportedFeatures(&optional)). | ||
RegisterModule(module.ValidatorForLanguage("cc")). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the main change (along with removing |
||
Render() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
load("@bazel_gazelle//:def.bzl", "gazelle") | ||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") | ||
|
||
# gazelle:prefix github.com/envoyproxy/protoc-gen-validate | ||
# gazelle:exclude tests | ||
# gazelle:exclude example-workspace | ||
# gazelle:exclude validate/validate.h | ||
# gazelle:go_naming_convention import_alias | ||
gazelle(name = "gazelle") | ||
|
||
go_binary( | ||
name = "protoc-gen-validate-go", | ||
embed = [":protoc-gen-validate-go_lib"], | ||
importpath = "github.com/envoyproxy/protoc-gen-validate/cmd/protoc-gen-validate-go", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
go_library( | ||
name = "protoc-gen-validate-go_lib", | ||
srcs = ["main.go"], | ||
importpath = "github.com/envoyproxy/protoc-gen-validate/cmd/protoc-gen-validate-go", | ||
visibility = ["//visibility:private"], | ||
deps = [ | ||
"//module", | ||
"@com_github_lyft_protoc_gen_star//:protoc-gen-star", | ||
"@com_github_lyft_protoc_gen_star//lang/go", | ||
"@org_golang_google_protobuf//types/pluginpb", | ||
], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/envoyproxy/protoc-gen-validate/module" | ||
pgs "github.com/lyft/protoc-gen-star" | ||
pgsgo "github.com/lyft/protoc-gen-star/lang/go" | ||
"google.golang.org/protobuf/types/pluginpb" | ||
) | ||
|
||
func main() { | ||
optional := uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL) | ||
pgs. | ||
Init(pgs.DebugEnv("DEBUG_PGV"), pgs.SupportedFeatures(&optional)). | ||
RegisterModule(module.ValidatorForLanguage("go")). | ||
RegisterPostProcessor(pgsgo.GoFmt()). | ||
Render() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used by
goreleaser
(tested it locally to ensure it built all binaries).