From 3051ad77e0bbb202bc7dd47caa874653c0bc3caf Mon Sep 17 00:00:00 2001 From: Caleb Doxsey Date: Tue, 19 Oct 2021 14:36:23 -0600 Subject: [PATCH] protoc: add xds repo (#2687) * protoc: add xds repo * fix protoc-gen-validate dependency --- go.mod | 3 +++ go.sum | 3 +++ pkg/grpc/protoc.bash | 11 ++++++++--- scripts/protoc | 7 +++++-- scripts/protoc-gen-validate | 3 +++ tools.go | 1 + 6 files changed, 23 insertions(+), 5 deletions(-) create mode 100755 scripts/protoc-gen-validate diff --git a/go.mod b/go.mod index 235d9d220..57ab75d1b 100644 --- a/go.mod +++ b/go.mod @@ -154,6 +154,7 @@ require ( github.com/gostaticanalysis/forcetypeassert v0.0.0-20200621232751-01d4955beaa5 // indirect github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/hashicorp/hcl v1.0.0 // indirect + github.com/iancoleman/strcase v0.0.0-20180726023541-3605ed457bf7 // indirect github.com/imdario/mergo v0.3.12 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jgautheron/goconst v1.5.1 // indirect @@ -169,6 +170,7 @@ require ( github.com/ldez/gomoddirectives v0.2.2 // indirect github.com/ldez/tagliatelle v0.2.0 // indirect github.com/libdns/libdns v0.2.1 // indirect + github.com/lyft/protoc-gen-star v0.5.1 // indirect github.com/magiconair/properties v1.8.5 // indirect github.com/maratori/testpackage v1.0.1 // indirect github.com/matoous/godox v0.0.0-20210227103229-6504466cf951 // indirect @@ -238,6 +240,7 @@ require ( github.com/yeya24/promlinter v0.1.0 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect + golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect golang.org/x/mod v0.4.2 // indirect golang.org/x/sys v0.0.0-20210917161153-d61c044b1678 // indirect golang.org/x/text v0.3.6 // indirect diff --git a/go.sum b/go.sum index cfcaacee8..59d06c73a 100644 --- a/go.sum +++ b/go.sum @@ -740,6 +740,7 @@ github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKEN github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +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/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -840,6 +841,7 @@ github.com/libdns/libdns v0.2.1/go.mod h1:yQCXzk1lEZmmCPa857bnk4TsOiqYasqpyOEeSO github.com/lithammer/shortuuid/v3 v3.0.7 h1:trX0KTHy4Pbwo/6ia8fscyHoGA+mf1jWbPJVuvyJQQ8= github.com/lithammer/shortuuid/v3 v3.0.7/go.mod h1:vMk8ke37EmiewwolSO1NLW8vP4ZaKlRuDIi8tWWmAts= github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= +github.com/lyft/protoc-gen-star v0.5.1 h1:sImehRT+p7lW9n6R7MQc5hVgzWGEkDVZU4AsBQ4Isu8= github.com/lyft/protoc-gen-star v0.5.1/go.mod h1:9toiA3cC7z5uVbODF7kEQ91Xn7XNFkVUl+SrEe+ZORU= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= @@ -1406,6 +1408,7 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= diff --git a/pkg/grpc/protoc.bash b/pkg/grpc/protoc.bash index 9fd1beab4..4764ec193 100755 --- a/pkg/grpc/protoc.bash +++ b/pkg/grpc/protoc.bash @@ -49,6 +49,12 @@ _protos=( "envoy/type/v3/percent.proto" "envoy/type/v3/range.proto" "envoy/type/v3/semantic_version.proto" +) +_imports=() +for _proto in "${_protos[@]}"; do + _imports+=("M${_proto}=github.com/envoyproxy/go-control-plane/$(dirname "$_proto")") +done +_xds_protos=( "udpa/annotations/migrate.proto" "udpa/annotations/security.proto" "udpa/annotations/sensitive.proto" @@ -60,9 +66,8 @@ _protos=( "xds/core/v3/resource_locator.proto" "xds/annotations/v3/status.proto" ) -_imports=() -for _proto in "${_protos[@]}"; do - _imports+=("M${_proto}=github.com/envoyproxy/go-control-plane/$(dirname "$_proto")") +for _proto in "${_xds_protos[@]}"; do + _imports+=("M${_proto}=github.com/cncf/xds/go/$(dirname "$_proto")") done _import_paths=$(join_by , "${_imports[@]}") diff --git a/scripts/protoc b/scripts/protoc index 22db279d4..ec87192fc 100755 --- a/scripts/protoc +++ b/scripts/protoc @@ -27,9 +27,10 @@ download() { } download $_protoc_3pp_path protoc-gen-validate https://github.com/envoyproxy/protoc-gen-validate/tarball/v0.6.1 -download $_protoc_3pp_path data-plane-api https://github.com/envoyproxy/data-plane-api/tarball/805eb4057c2d3c053a019172e7e431519d42efc8 +download $_protoc_3pp_path data-plane-api https://github.com/envoyproxy/data-plane-api/tarball/main download $_protoc_3pp_path udpa https://github.com/cncf/udpa/tarball/main -download $_protoc_3pp_path googleapis https://github.com/googleapis/googleapis/tarball/82944da21578a53b74e547774cf62ed31a05b841 +download $_protoc_3pp_path xds https://github.com/cncf/xds/tarball/main +download $_protoc_3pp_path googleapis https://github.com/googleapis/googleapis/tarball/master mkdir -p "$_protoc_path" "$_protoc_3pp_path" if [ ! -f "$_protoc_path/bin/protoc" ]; then @@ -44,9 +45,11 @@ fi exec "$_protoc_path/bin/protoc" \ -I "$_protoc_3pp_path/data-plane-api" \ -I "$_protoc_3pp_path/udpa" \ + -I "$_protoc_3pp_path/xds" \ -I "$_protoc_3pp_path/protoc-gen-validate" \ -I "$_protoc_3pp_path/googleapis" \ --experimental_allow_proto3_optional \ --plugin="protoc-gen-go=$_dir/protoc-gen-go" \ --plugin="protoc-gen-grpc-web=$_dir/protoc-gen-grpc-web" \ + --plugin="protoc-gen-validate=$_dir/protoc-gen-validate" \ "$@" diff --git a/scripts/protoc-gen-validate b/scripts/protoc-gen-validate new file mode 100755 index 000000000..78c8dc20c --- /dev/null +++ b/scripts/protoc-gen-validate @@ -0,0 +1,3 @@ +#!/bin/bash +set -euo pipefail +exec go run github.com/envoyproxy/protoc-gen-validate "$@" diff --git a/tools.go b/tools.go index c5a0ac5e2..5cef69217 100644 --- a/tools.go +++ b/tools.go @@ -5,6 +5,7 @@ package pomerium import ( _ "github.com/client9/misspell/cmd/misspell" + _ "github.com/envoyproxy/protoc-gen-validate" _ "github.com/golang/mock/mockgen" _ "github.com/golang/protobuf/protoc-gen-go" _ "github.com/golangci/golangci-lint/cmd/golangci-lint"