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

Remove gogo support #340

Merged
merged 11 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 0 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
branch = "master"
name = "golang.org/x/net"

[[constraint]]
name = "github.com/gogo/protobuf"
version = "1.1.1"

[[constraint]]
branch = "master"
name = "github.com/iancoleman/strcase"
53 changes: 5 additions & 48 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,8 @@ GO_IMPORT_SPACES := ${VALIDATE_IMPORT},\
Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp,\
Mgoogle/protobuf/wrappers.proto=github.com/golang/protobuf/ptypes/wrappers,\
Mgoogle/protobuf/descriptor.proto=github.com/golang/protobuf/protoc-gen-go/descriptor,\
Mgogoproto/gogo.proto=${PACKAGE}/gogoproto
GO_IMPORT:=$(subst $(space),,$(GO_IMPORT_SPACES))

# protoc-gen-gogo parameters
GOGO_IMPORT_SPACES := ${VALIDATE_IMPORT},\
Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/types,\
Mgogoproto/gogo.proto=github.com/gogo/protobuf/gogoproto
GOGO_IMPORT:=$(subst $(space),,$(GOGO_IMPORT_SPACES))

.PHONY: build
build: validate/validate.pb.go
# generates the PGV binary and installs it into $$GOPATH/bin
Expand All @@ -47,8 +35,6 @@ gazelle: vendor
buildozer 'replace deps @com_github_golang_protobuf//ptypes:go_default_library_gen @com_github_golang_protobuf//ptypes:go_default_library' '//...:%go_library'
buildozer 'replace deps @io_bazel_rules_go//proto/wkt:duration_go_proto @com_github_golang_protobuf//ptypes/duration:go_default_library' '//...:%go_library'
buildozer 'replace deps @io_bazel_rules_go//proto/wkt:timestamp_go_proto @com_github_golang_protobuf//ptypes/timestamp:go_default_library' '//...:%go_library'
buildozer 'replace deps //vendor/github.com/gogo/protobuf/proto:go_default_library @com_github_gogo_protobuf//proto:go_default_library' '//...:%go_library'
buildozer 'replace deps //vendor/github.com/gogo/protobuf/types:go_default_library @com_github_gogo_protobuf//types:go_default_library' '//...:%go_library'

vendor:
go mod vendor
Expand All @@ -67,58 +53,45 @@ bin/shadow:
bin/golint:
go build -o $@ ./vendor/golang.org/x/lint/golint

bin/gogofast:
go build -o $@ ./vendor/github.com/gogo/protobuf/protoc-gen-gogofast

bin/protoc-gen-go:
go build -o $@ ./vendor/github.com/golang/protobuf/protoc-gen-go

bin/harness:
cd tests && go build -o ../bin/harness ./harness/executor

.PHONY: harness
harness: testcases tests/harness/go/harness.pb.go tests/harness/gogo/harness.pb.go tests/harness/go/main/go-harness tests/harness/gogo/main/go-harness tests/harness/cc/cc-harness bin/harness
harness: testcases tests/harness/go/harness.pb.go tests/harness/go/main/go-harness tests/harness/cc/cc-harness bin/harness
# runs the test harness, validating a series of test cases in all supported languages
./bin/harness -go -gogo -cc
./bin/harness -go -cc

.PHONY: bazel-harness
bazel-harness:
# runs the test harness via bazel
bazel run //tests/harness/executor:executor --incompatible_new_actions_api=false -- -go -gogo -cc -java -python
bazel run //tests/harness/executor:executor --incompatible_new_actions_api=false -- -go -cc -java -python

.PHONY: testcases
testcases: bin/gogofast bin/protoc-gen-go
testcases: bin/protoc-gen-go
# generate the test harness case protos
rm -r tests/harness/cases/go || true
mkdir tests/harness/cases/go
rm -r tests/harness/cases/other_package/go || true
mkdir tests/harness/cases/other_package/go
rm -r tests/harness/cases/gogo || true
mkdir tests/harness/cases/gogo
rm -r tests/harness/cases/other_package/gogo || true
mkdir tests/harness/cases/other_package/gogo
# protoc-gen-go makes us go a package at a time
cd tests/harness/cases/other_package && \
protoc \
-I . \
-I ../../../.. \
--go_out="${GO_IMPORT}:./go" \
--plugin=protoc-gen-gogofast=$(shell pwd)/bin/gogofast \
--plugin=protoc-gen-go=$(shell pwd)/bin/protoc-gen-go \
--gogofast_out="${GOGO_IMPORT}:./gogo" \
--validate_out="lang=go:./go" \
--validate_out="lang=gogo:./gogo" \
./*.proto
cd tests/harness/cases && \
protoc \
-I . \
-I ../../.. \
--go_out="Mtests/harness/cases/other_package/embed.proto=${PACKAGE}/tests/harness/cases/other_package/go,${GO_IMPORT}:./go" \
--plugin=protoc-gen-gogofast=$(shell pwd)/bin/gogofast \
--plugin=protoc-gen-go=$(shell pwd)/bin/protoc-gen-go \
--gogofast_out="Mtests/harness/cases/other_package/embed.proto=${PACKAGE}/tests/harness/cases/other_package/gogo,${GOGO_IMPORT}:./gogo" \
--validate_out="lang=go,Mtests/harness/cases/other_package/embed.proto=${PACKAGE}/tests/harness/cases/other_package/go:./go" \
--validate_out="lang=gogo,Mtests/harness/cases/other_package/embed.proto=${PACKAGE}/tests/harness/cases/other_package/gogo:./gogo" \
./*.proto

tests/harness/go/harness.pb.go: bin/protoc-gen-go
Expand All @@ -127,20 +100,10 @@ tests/harness/go/harness.pb.go: bin/protoc-gen-go
--plugin=protoc-gen-go=$(shell pwd)/bin/protoc-gen-go \
--go_out="${GO_IMPORT}:./go" harness.proto

tests/harness/gogo/harness.pb.go: bin/gogofast
# generates the test harness protos
cd tests/harness && protoc -I . \
--plugin=protoc-gen-gogofast=$(shell pwd)/bin/gogofast \
--gogofast_out="${GOGO_IMPORT}:./gogo" harness.proto

tests/harness/go/main/go-harness:
# generates the go-specific test harness
cd tests && go build -o ./harness/go/main/go-harness ./harness/go/main

tests/harness/gogo/main/go-harness:
# generates the gogo-specific test harness
cd tests && go build -o ./harness/gogo/main/go-harness ./harness/gogo/main

tests/harness/cc/cc-harness: tests/harness/cc/harness.cc
# generates the C++-specific test harness
# use bazel which knows how to pull in the C++ common proto libraries
Expand All @@ -159,17 +122,11 @@ ci: lint bazel testcases bazel-harness build_generation_tests
clean:
(which bazel && bazel clean) || true
rm -f \
bin/gogofast \
bin/protoc-gen-go \
bin/harness \
tests/harness/cc/cc-harness \
tests/harness/go/main/go-harness \
tests/harness/gogo/main/go-harness \
tests/harness/gogo/harness.pb.go \
tests/harness/gogo/harness.pb.go \
tests/harness/go/harness.pb.go
rm -rf \
tests/harness/cases/go \
tests/harness/cases/other_package/go \
tests/harness/cases/gogo \
tests/harness/cases/other_package/gogo \
tests/harness/cases/other_package/go
25 changes: 0 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ make build

- **`lang`**: specify the target language to generate. Currently, the only supported options are:
- `go`
- `gogo` for [gogo proto](https://github.com/gogo/protobuf) (experimental)
- `cc` for c++ (partially implemented)
- `java`
- `python`
Expand All @@ -106,30 +105,6 @@ All messages generated include the new `Validate() error` method. PGV requires n

**Note**: by default **example.pb.validate.go** is nested in a directory structure that matches your `option go_package` name. You can change this using the protoc parameter `paths=source_relative:.`. Then `--validate_out` will output the file where it is expected. See Google's protobuf documenation or [packages and input paths](https://github.com/golang/protobuf#packages-and-input-paths) or [parameters](https://github.com/golang/protobuf#parameters) for more information.

#### Gogo

There is an experimental support for [gogo
protobuf](https://github.com/gogo/protobuf) plugin for `go`. Use the following
command to generate `gogo`-compatible validation code:

```sh
protoc \
-I . \
-I ${GOPATH}/src \
-I ${GOPATH}/src/github.com/envoyproxy/protoc-gen-validate \
--gogofast_out=":../generated"\
--validate_out="lang=gogo:../generated" \ example.proto
```

Gogo support has the following limitations:
- only `gogofast` plugin is supported and tested, meaning that the fields
should be properly annotated with `gogoproto` annotations;
- `gogoproto.nullable` is supported on fields;
- `gogoproto.stdduration` is supported on fields;
- `gogoproto.stdtime` is supported on fields;

**Note**: by default **example.pb.validate.go** is nested in a directory structure that matches your `option go_package` name. You can change this using the protoc parameter `paths=source_relative:.`. Then `--validate_out` will output the file where it is expected. See Google's protobuf documenation or [packages and input paths](https://github.com/golang/protobuf#packages-and-input-paths) or [parameters](https://github.com/golang/protobuf#parameters) for more information.

#### Java

Java generation is integrated with the existing protobuf toolchain for java projects. For Maven projects, add the
Expand Down
18 changes: 0 additions & 18 deletions bazel/pgv_proto_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,6 @@ def pgv_go_proto_library(name, proto = None, deps = [], **kwargs):
**kwargs
)

def pgv_gogo_proto_library(name, proto = None, deps = [], **kwargs):
go_proto_compiler(
name = "pgv_plugin_gogo",
suffix = ".pb.validate.go",
valid_archive = False,
plugin = "//:protoc-gen-validate",
options = ["lang=gogo"],
)

go_proto_library(
name = name,
proto = proto,
deps = ["//validate:go_default_library"] + deps,
compilers = ["@io_bazel_rules_go//proto:gogo_proto", "pgv_plugin_gogo"],
visibility = ["//visibility:public"],
**kwargs
)

def pgv_cc_proto_library(
name,
deps = [],
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/envoyproxy/protoc-gen-validate
go 1.14

require (
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.3.1
github.com/iancoleman/strcase v0.0.0-20180726023541-3605ed457bf7
github.com/lyft/protoc-gen-star v0.4.10
Expand Down
5 changes: 0 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/iancoleman/strcase v0.0.0-20180726023541-3605ed457bf7 h1:ux/56T2xqZO/3cP1I2F86qpeoYPCOzk+KF/UH/Ar+lk=
github.com/iancoleman/strcase v0.0.0-20180726023541-3605ed457bf7/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/lyft/protoc-gen-star v0.4.10 h1:yekjh68Yp+AF+IXd/0vLd+DQv+eb6joCTA6qxRmtE2A=
github.com/lyft/protoc-gen-star v0.4.10/go.mod h1:mE8fbna26u7aEA2QCVvvfBU/ZrPgocG1206xAFPcs94=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down Expand Up @@ -35,7 +31,6 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375 h1:SjQ2+AKWgZLc1xej6WSzL+Dfs5Uyd5xcZH1mGC411IA=
Expand Down
24 changes: 0 additions & 24 deletions gogoproto/BUILD.bazel

This file was deleted.

4 changes: 0 additions & 4 deletions gogoproto/README.md

This file was deleted.

Loading