File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -194,7 +194,7 @@ function bazel_envoy_api_build() {
194194 --//tools/api_proto_plugin:extra_args=api_version:3.7 \
195195 //tools/protoprint:protoprint_test
196196 echo " Validating API structure..."
197- " ${ENVOY_SRCDIR} " / tools/api/ validate_structure.py
197+ bazel run " ${BAZEL_BUILD_OPTIONS[@]} " // tools/api: validate_structure " ${PWD} /api/envoy "
198198 echo " Testing API..."
199199 bazel_with_collection \
200200 test " ${BAZEL_BUILD_OPTIONS[@]} " \
Original file line number Diff line number Diff line change 1+ load ("@rules_python//python:defs.bzl" , "py_binary" )
2+
3+ licenses (["notice" ]) # Apache 2
4+
5+ py_binary (
6+ name = "validate_structure" ,
7+ srcs = ["validate_structure.py" ],
8+ # deps = [":validate"],
9+ )
Original file line number Diff line number Diff line change 44#
55# ./tools/api/validate_structure.py
66
7+ import argparse
78import pathlib
89import re
910import sys
@@ -77,12 +78,18 @@ def validate_proto_paths(proto_paths):
7778 return error_msgs
7879
7980
80- if __name__ == '__main__' :
81- api_root = 'api/envoy'
82- api_protos = pathlib .Path (api_root ).rglob ('*.proto' )
83- error_msgs = validate_proto_paths (p .relative_to (api_root ) for p in api_protos )
81+ def main (* args ):
82+ parser = argparse .ArgumentParser (description = "Check API structure." )
83+ parser .add_argument ("api_root" , type = str , help = "Specify the path to the api root." )
84+ args = parser .parse_args (args )
85+ api_protos = pathlib .Path (args .api_root ).rglob ('*.proto' )
86+ error_msgs = validate_proto_paths (p .relative_to (args .api_root ) for p in api_protos )
8487 if error_msgs :
8588 for m in error_msgs :
8689 print (m )
8790 sys .exit (1 )
8891 sys .exit (0 )
92+
93+
94+ if __name__ == '__main__' :
95+ main (* sys .argv [1 :])
You can’t perform that action at this time.
0 commit comments