├── .buildkite └── pipeline.yml ├── .codecov.yml ├── .dockerignore ├── .fossa.yml ├── .github ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── BUILD.bazel ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── Dockerfile ├── Dockerfile.buildkite ├── LICENSE ├── Makefile ├── WORKSPACE ├── bazel ├── BUILD.bazel └── deps.bzl ├── cmd └── prototool │ ├── BUILD.bazel │ └── main.go ├── docker-compose.yml ├── docs ├── README.md ├── breaking.md ├── create.md ├── development.md ├── docker.md ├── faq.md ├── grpc.md ├── install.md ├── lint.md ├── maintenance.md ├── protoc.md ├── release.md └── vim.md ├── etc ├── bin │ ├── brewgen.sh │ ├── grpcgen.sh │ └── releasegen.sh ├── config │ └── example │ │ └── prototool.yaml ├── docker │ └── testing │ │ ├── bin │ │ └── test.sh │ │ ├── etc │ │ └── wkt.txt │ │ └── proto │ │ ├── prototool.yaml │ │ └── uber │ │ └── prototool │ │ └── v1 │ │ └── foo_api.proto └── style │ ├── google │ ├── google.proto │ └── prototool.yaml │ └── uber1 │ ├── dep │ └── dep.proto │ ├── prototool.yaml │ └── uber1.proto ├── example ├── cmd │ └── excited │ │ ├── BUILD.bazel │ │ └── main.go ├── gen │ └── go │ │ └── uber │ │ ├── bar │ │ └── v1 │ │ │ ├── BUILD.bazel │ │ │ └── bar.pb.go │ │ └── foo │ │ └── v1 │ │ ├── BUILD.bazel │ │ ├── excited_api.pb.go │ │ ├── foo.pb.go │ │ └── hello_api.pb.go └── proto │ ├── prototool.yaml │ └── uber │ ├── bar │ └── v1 │ │ └── bar.proto │ └── foo │ └── v1 │ ├── excited_api.proto │ ├── foo.proto │ └── hello_api.proto ├── go.mod ├── go.sum ├── internal ├── breaking │ ├── BUILD.bazel │ ├── breaking.go │ ├── breaking_test.go │ ├── check_enum_values_not_deleted.go │ ├── check_enum_values_same_name.go │ ├── check_enums_not_deleted.go │ ├── check_message_fields_not_deleted.go │ ├── check_message_fields_same_label.go │ ├── check_message_fields_same_name.go │ ├── check_message_fields_same_oneof.go │ ├── check_message_fields_same_type.go │ ├── check_message_oneofs_fields_not_removed.go │ ├── check_message_oneofs_not_deleted.go │ ├── check_messages_not_deleted.go │ ├── check_packages_no_beta_deps.go │ ├── check_packages_not_deleted.go │ ├── check_service_methods_not_deleted.go │ ├── check_service_methods_same_client_streaming.go │ ├── check_service_methods_same_request_type.go │ ├── check_service_methods_same_response_type.go │ ├── check_service_methods_same_server_streaming.go │ ├── check_services_not_deleted.go │ ├── helpers.go │ ├── runner.go │ ├── strings.go │ └── testdata │ │ └── one │ │ ├── from │ │ ├── bar │ │ │ ├── v1 │ │ │ │ └── bar.proto │ │ │ ├── v1beta1 │ │ │ │ └── bar.proto │ │ │ └── v2 │ │ │ │ └── bar.proto │ │ ├── foo │ │ │ ├── v1 │ │ │ │ └── foo.proto │ │ │ ├── v1beta1 │ │ │ │ └── foo.proto │ │ │ └── v1beta2 │ │ │ │ └── foo.proto │ │ └── prototool.yaml │ │ └── to │ │ ├── bar │ │ ├── v1beta1 │ │ │ └── bar.proto │ │ └── v2 │ │ │ └── bar.proto │ │ ├── foo │ │ ├── v1 │ │ │ └── foo.proto │ │ └── v1beta1 │ │ │ └── foo.proto │ │ └── prototool.yaml ├── buf │ ├── BUILD.bazel │ ├── buf.go │ └── buf_test.go ├── cfginit │ ├── BUILD.bazel │ └── cfginit.go ├── cmd │ ├── BUILD.bazel │ ├── cmd.go │ ├── cmd_test.go │ ├── flags.go │ ├── gen-prototool-bash-completion │ │ ├── BUILD.bazel │ │ └── main.go │ ├── gen-prototool-manpages │ │ ├── BUILD.bazel │ │ └── main.go │ ├── gen-prototool-zsh-completion │ │ ├── BUILD.bazel │ │ └── main.go │ ├── templates.go │ └── testdata │ │ ├── bar │ │ └── dep.proto │ │ ├── compile │ │ ├── errors_on_import │ │ │ ├── dep_errors.proto │ │ │ ├── errors_on_import.proto │ │ │ └── prototool.yaml │ │ ├── extra_import │ │ │ ├── dep.proto │ │ │ ├── extra_import.proto │ │ │ └── prototool.yaml │ │ ├── json │ │ │ ├── json_camel_case_conflict.proto │ │ │ └── prototool.json │ │ ├── notimported │ │ │ ├── dep.proto │ │ │ ├── not_imported.proto │ │ │ └── prototool.yaml │ │ ├── proto2 │ │ │ ├── prototool.yaml │ │ │ └── syntax_proto2.proto │ │ ├── recursive │ │ │ ├── one.proto │ │ │ ├── prototool.yaml │ │ │ └── two.proto │ │ ├── semicolon │ │ │ ├── missing_package_semicolon.proto │ │ │ └── prototool.yaml │ │ └── syntax │ │ │ ├── missing_syntax.proto │ │ │ └── prototool.yaml │ │ ├── create │ │ ├── one │ │ │ └── prototool.yaml │ │ ├── two │ │ │ ├── protobuf_file_header.txt │ │ │ └── prototool.yaml │ │ ├── version2five │ │ │ └── prototool.yaml │ │ ├── version2four │ │ │ └── prototool.yaml │ │ ├── version2one │ │ │ └── prototool.yaml │ │ ├── version2three │ │ │ └── prototool.yaml │ │ └── version2two │ │ │ └── prototool.yaml │ │ ├── foo │ │ ├── bar │ │ │ └── dep.proto │ │ ├── prototool.json │ │ └── success.proto │ │ ├── format-fix-v2 │ │ ├── foo.proto │ │ ├── foo.proto.golden │ │ └── prototool.yaml │ │ ├── format-fix │ │ ├── foo.proto │ │ ├── foo.proto.golden │ │ └── prototool.yaml │ │ ├── format │ │ ├── proto2 │ │ │ ├── foo │ │ │ │ ├── bar │ │ │ │ │ ├── bar_proto2.proto │ │ │ │ │ └── bar_proto2.proto.golden │ │ │ │ ├── foo_proto2.proto │ │ │ │ └── foo_proto2.proto.golden │ │ │ └── prototool.yaml │ │ └── proto3 │ │ │ ├── foo │ │ │ ├── bar │ │ │ │ ├── bar.proto │ │ │ │ └── bar.proto.golden │ │ │ ├── foo.proto │ │ │ └── foo.proto.golden │ │ │ └── prototool.json │ │ ├── generate │ │ └── descriptorset │ │ │ ├── foo.proto │ │ │ └── prototool.yaml │ │ ├── grpc │ │ ├── gen │ │ │ └── grpcpb │ │ │ │ ├── BUILD.bazel │ │ │ │ └── grpc.pb.go │ │ ├── grpc.proto │ │ ├── prototool.yaml │ │ └── tls │ │ │ ├── cacert.crl │ │ │ ├── cacert.crt │ │ │ ├── cacert.key │ │ │ ├── client.crt │ │ │ ├── client.csr │ │ │ ├── client.key │ │ │ ├── self-signed-client.crt │ │ │ ├── self-signed-client.key │ │ │ ├── self-signed-server.crt │ │ │ ├── self-signed-server.key │ │ │ ├── server.crt │ │ │ ├── server.csr │ │ │ └── server.key │ │ └── lint │ │ ├── afterservice │ │ ├── foo │ │ │ └── v1 │ │ │ │ ├── hello2api.proto │ │ │ │ ├── hello3api.proto │ │ │ │ └── hello_api.proto │ │ └── prototool.yaml │ │ ├── allgroup │ │ ├── bar │ │ │ └── dep.proto │ │ ├── lots.proto │ │ └── prototool.yaml │ │ ├── apisuffix │ │ ├── foo.proto │ │ └── prototool.yaml │ │ ├── base │ │ ├── base_file.proto │ │ └── prototool.yaml │ │ ├── capitalized │ │ ├── message_name_not_capitalized.proto │ │ └── prototool.yaml │ │ ├── empty │ │ ├── base_file.proto │ │ └── prototool.yaml │ │ ├── emptycustom │ │ ├── base_file.proto │ │ └── prototool.yaml │ │ ├── enumexceptmessages │ │ ├── foo.proto │ │ └── prototool.yaml │ │ ├── fieldnamesfilename │ │ ├── hello.proto │ │ └── prototool.yaml │ │ ├── fieldscomments │ │ ├── foo │ │ │ └── v1 │ │ │ │ └── foo.proto │ │ └── prototool.yaml │ │ ├── fieldssentencecomments │ │ ├── foo │ │ │ └── v1 │ │ │ │ └── foo.proto │ │ └── prototool.yaml │ │ ├── fieldstimeduration │ │ ├── hello.proto │ │ └── prototool.yaml │ │ ├── filename │ │ ├── fileNameInvalid.proto │ │ └── prototool.yaml │ │ ├── fileoptions │ │ ├── file_options_incorrect.proto │ │ └── prototool.yaml │ │ ├── fileoptionsjava │ │ ├── file_options_incorrect.proto │ │ └── prototool.yaml │ │ ├── floats │ │ ├── foo │ │ │ └── v1 │ │ │ │ └── foo.proto │ │ └── prototool.yaml │ │ ├── floatsnosuppress │ │ ├── foo │ │ │ └── v1 │ │ │ │ └── foo.proto │ │ └── prototool.yaml │ │ ├── gogonotimported │ │ ├── gogo │ │ │ └── gogo.proto │ │ ├── gogonotimported.proto │ │ └── prototool.yaml │ │ ├── gopackagelongform │ │ ├── gopackagelongform.proto │ │ └── prototool.yaml │ │ ├── ignoredir │ │ ├── bar │ │ │ └── v1 │ │ │ │ └── bar.proto │ │ ├── foo │ │ │ └── v1 │ │ │ │ └── foo.proto │ │ └── prototool.yaml │ │ ├── importsnotpublic │ │ ├── bar │ │ │ └── bar.proto │ │ ├── foo.proto │ │ └── prototool.yaml │ │ ├── importsnotweak │ │ ├── bar │ │ │ └── bar.proto │ │ ├── foo.proto │ │ └── prototool.yaml │ │ ├── inlinecomments │ │ ├── foo │ │ │ └── v1 │ │ │ │ ├── foo.proto │ │ │ │ └── hello_api.proto │ │ └── prototool.yaml │ │ ├── keyword │ │ ├── package_starts_with_keyword.proto │ │ └── prototool.yaml │ │ ├── lots │ │ ├── bar │ │ │ └── dep.proto │ │ ├── lots.proto │ │ └── prototool.yaml │ │ ├── majorbetaversioned │ │ ├── foo │ │ │ └── foo.proto │ │ └── prototool.yaml │ │ ├── naming │ │ ├── foo │ │ │ └── v1 │ │ │ │ └── foo.proto │ │ └── prototool.yaml │ │ ├── nodescriptor │ │ ├── foo │ │ │ └── v1 │ │ │ │ └── foo.proto │ │ └── prototool.yaml │ │ ├── nogoogleapihttp │ │ ├── foo │ │ │ └── v1 │ │ │ │ └── hello_api.proto │ │ ├── google │ │ │ └── api │ │ │ │ └── api.proto │ │ └── prototool.yaml │ │ ├── nojsonname │ │ ├── foo.proto │ │ └── prototool.yaml │ │ ├── nokeywords │ │ ├── foo │ │ │ └── public │ │ │ │ ├── public.proto │ │ │ │ └── public_suppressed.proto │ │ └── prototool.yaml │ │ ├── noplurals │ │ ├── foo │ │ │ └── v1 │ │ │ │ └── foo.proto │ │ └── prototool.yaml │ │ ├── noreserved │ │ ├── foo.proto │ │ └── prototool.yaml │ │ ├── nostreaming │ │ ├── foo │ │ │ └── v1 │ │ │ │ └── hello_api.proto │ │ └── prototool.yaml │ │ ├── notempty │ │ ├── foo │ │ │ └── v1 │ │ │ │ ├── hello.proto │ │ │ │ └── hello_api.proto │ │ └── prototool.yaml │ │ ├── onlyinfile │ │ ├── foo │ │ │ └── v1 │ │ │ │ └── hello_api.proto │ │ └── prototool.yaml │ │ ├── packagelowercase │ │ ├── foo_bar │ │ │ └── v1 │ │ │ │ └── foo.proto │ │ └── prototool.yaml │ │ ├── required │ │ ├── file_options_required.proto │ │ └── prototool.yaml │ │ ├── samedir │ │ ├── bar1.proto │ │ ├── foo1.proto │ │ ├── foo2.proto │ │ └── prototool.yaml │ │ ├── samedirgopkg │ │ ├── bar1.proto │ │ ├── foo1.proto │ │ ├── foo2.proto │ │ └── prototool.yaml │ │ ├── samedirjavapkg │ │ ├── bar1.proto │ │ ├── foo1.proto │ │ ├── foo2.proto │ │ └── prototool.yaml │ │ ├── servicenamefilename │ │ ├── foo │ │ │ └── v1 │ │ │ │ ├── another_api.proto │ │ │ │ └── foo.proto │ │ └── prototool.yaml │ │ ├── syntaxproto2 │ │ ├── prototool.yaml │ │ └── syntax_proto2.proto │ │ ├── version2 │ │ ├── foo │ │ │ └── v1 │ │ │ │ ├── foo.proto │ │ │ │ └── hello_api.proto │ │ └── prototool.yaml │ │ └── wktsuffix │ │ ├── foo │ │ └── foo.proto │ │ └── prototool.yaml ├── create │ ├── BUILD.bazel │ ├── create.go │ └── handler.go ├── desc │ ├── BUILD.bazel │ └── desc.go ├── diff │ ├── BUILD.bazel │ ├── diff.go │ └── diff_test.go ├── exec │ ├── BUILD.bazel │ ├── exec.go │ └── runner.go ├── extract │ ├── BUILD.bazel │ ├── extract.go │ ├── extract_test.go │ └── testdata │ │ └── one │ │ ├── prototool.yaml │ │ └── uber │ │ └── proto │ │ ├── bar │ │ └── v1 │ │ │ ├── one.proto │ │ │ └── two.proto │ │ └── foo │ │ └── v1 │ │ ├── one.proto │ │ └── two.proto ├── file │ ├── BUILD.bazel │ ├── file.go │ ├── file_test.go │ ├── proto_set_provider.go │ ├── proto_set_provider_test.go │ └── testdata │ │ ├── invalid │ │ ├── prototool.json │ │ └── prototool.yaml │ │ └── valid │ │ └── base │ │ ├── a │ │ ├── d │ │ │ ├── file.proto │ │ │ ├── file2.proto │ │ │ ├── file3.proto │ │ │ └── prototool.yaml │ │ ├── e │ │ │ └── file.proto │ │ ├── f │ │ │ └── file.proto │ │ └── file.proto │ │ ├── b │ │ ├── file.proto │ │ ├── g │ │ │ └── h │ │ │ │ └── file.proto │ │ └── prototool.json │ │ ├── c │ │ ├── file.proto │ │ └── i │ │ │ └── file.proto │ │ ├── d │ │ ├── file.proto │ │ ├── g │ │ │ └── h │ │ │ │ └── file.proto │ │ └── prototool.yaml │ │ └── prototool.yaml ├── format │ ├── BUILD.bazel │ ├── base_visitor.go │ ├── first_pass_visitor.go │ ├── format.go │ ├── main_visitor.go │ └── transformer.go ├── git │ ├── BUILD.bazel │ └── git.go ├── grpc │ ├── BUILD.bazel │ ├── grpc.go │ ├── handler.go │ ├── handler_test.go │ └── invocation_event_handler.go ├── lint │ ├── BUILD.bazel │ ├── base_linter.go │ ├── base_visitor.go │ ├── check_comments_no_c_style.go │ ├── check_comments_no_inline.go │ ├── check_enum_field_names_upper_snake_case.go │ ├── check_enum_field_names_uppercase.go │ ├── check_enum_field_prefixes.go │ ├── check_enum_field_prefixes_except_message.go │ ├── check_enum_fields_have_comments.go │ ├── check_enum_fields_have_sentence_comments.go │ ├── check_enum_names_camel_case.go │ ├── check_enum_names_capitalized.go │ ├── check_enum_zero_values_invalid.go │ ├── check_enum_zero_values_invalid_except_message.go │ ├── check_enums_have_comments.go │ ├── check_enums_have_sentence_comments.go │ ├── check_enums_no_allow_alias.go │ ├── check_fields_not_reserved.go │ ├── check_file_header.go │ ├── check_file_names_lower_snake_case.go │ ├── check_file_options_equal.go │ ├── check_file_options_required.go │ ├── check_file_options_same_in_dir.go │ ├── check_file_options_unset.go │ ├── check_go_package_not_long_form.go │ ├── check_gogo_not_imported.go │ ├── check_imports_not_public.go │ ├── check_imports_not_weak.go │ ├── check_message_field_names_filename.go │ ├── check_message_field_names_filepath.go │ ├── check_message_field_names_lower_snake_case.go │ ├── check_message_field_names_lowercase.go │ ├── check_message_field_names_no_descriptor.go │ ├── check_message_fields_duration.go │ ├── check_message_fields_have_comments.go │ ├── check_message_fields_have_sentence_comments.go │ ├── check_message_fields_no_json_name.go │ ├── check_message_fields_not_floats.go │ ├── check_message_fields_time.go │ ├── check_message_names_camel_case.go │ ├── check_message_names_capitalized.go │ ├── check_messages_have_comments.go │ ├── check_messages_have_comments_except_request_response_types.go │ ├── check_messages_have_sentence_comments_except_request_response_types.go │ ├── check_messages_not_empty_except_request_response_types.go │ ├── check_names.go │ ├── check_oneof_names_lower_snake_case.go │ ├── check_package_is_declared.go │ ├── check_package_lower_case.go │ ├── check_package_lower_snake_case.go │ ├── check_package_major_beta_versioned.go │ ├── check_package_no_keywords.go │ ├── check_packages_same_in_dir.go │ ├── check_request_response_names_match_rpc.go │ ├── check_request_response_types_after_service.go │ ├── check_request_response_types_in_same_file.go │ ├── check_request_response_types_only_in_file.go │ ├── check_request_response_types_unique.go │ ├── check_rpc_names_camel_case.go │ ├── check_rpc_names_capitalized.go │ ├── check_rpc_options_no_google_api_http.go │ ├── check_rpcs_have_comments.go │ ├── check_rpcs_have_sentence_comments.go │ ├── check_rpcs_no_streaming.go │ ├── check_service_names_api_suffix.go │ ├── check_service_names_camel_case.go │ ├── check_service_names_capitalized.go │ ├── check_service_names_match_file_name.go │ ├── check_service_names_singular.go │ ├── check_services_have_comments.go │ ├── check_services_have_sentence_comments.go │ ├── check_syntax_proto3.go │ ├── check_wkt_directly_imported.go │ ├── check_wkt_duration_suffix.go │ ├── check_wkt_timestamp_suffix.go │ ├── lint.go │ └── runner.go ├── protoc │ ├── BUILD.bazel │ ├── compiler.go │ ├── downloader.go │ ├── downloader_test.go │ └── protoc.go ├── protostrs │ ├── BUILD.bazel │ ├── protostrs.go │ └── protostrs_test.go ├── reflect │ ├── BUILD.bazel │ ├── gen │ │ └── uber │ │ │ └── proto │ │ │ └── reflect │ │ │ └── v1 │ │ │ ├── BUILD.bazel │ │ │ └── reflect.pb.go │ ├── proto │ │ ├── prototool.yaml │ │ └── uber │ │ │ └── proto │ │ │ └── reflect │ │ │ └── v1 │ │ │ └── reflect.proto │ ├── reflect.go │ ├── reflect_test.go │ └── testdata │ │ └── one │ │ ├── prototool.yaml │ │ └── uber │ │ └── proto │ │ ├── bar │ │ └── v1 │ │ │ ├── one.proto │ │ │ └── two.proto │ │ └── foo │ │ └── v1 │ │ ├── one.proto │ │ └── two.proto ├── settings │ ├── BUILD.bazel │ ├── config_provider.go │ └── settings.go ├── strs │ ├── BUILD.bazel │ ├── strs.go │ └── strs_test.go ├── testing │ ├── BUILD.bazel │ └── testing.go ├── text │ ├── BUILD.bazel │ ├── text.go │ └── text_test.go ├── vars │ ├── BUILD.bazel │ └── vars.go └── wkt │ ├── BUILD.bazel │ └── wkt.go ├── style ├── README.md ├── prototool.yaml └── uber │ ├── road │ └── v1 │ │ └── road.proto │ ├── trip │ └── v1 │ │ ├── trip.proto │ │ └── trip_api.proto │ └── user │ └── v1 │ └── user.proto └── vim └── prototool ├── ale_linters └── proto │ ├── prototool.vim │ ├── prototool_all.vim │ ├── prototool_compile.vim │ └── prototool_lint.vim └── plugin └── prototool.vim /.buildkite/pipeline.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - name: ':docker: :package: buildkite' 3 | plugins: 4 | - docker-compose#v3.0.2: 5 | build: buildkite 6 | image-repository: 027047743804.dkr.ecr.us-east-2.amazonaws.com/uber 7 | agents: 8 | queue: builders 9 | - name: ':docker: :package: app' 10 | plugins: 11 | - docker-compose#v3.0.2: 12 | build: app 13 | image-repository: 027047743804.dkr.ecr.us-east-2.amazonaws.com/uber 14 | agents: 15 | queue: builders 16 | - wait 17 | - name: 'make lint' 18 | command: make lint 19 | plugins: 20 | - docker-compose#v3.0.2: 21 | run: buildkite 22 | agents: 23 | queue: workers 24 | - name: 'make codecov' 25 | command: make codecov 26 | plugins: 27 | - docker-compose#v3.0.2: 28 | run: buildkite 29 | agents: 30 | queue: workers 31 | - name: 'make bazeltest' 32 | command: make bazeltest 33 | plugins: 34 | - docker-compose#v3.0.2: 35 | run: buildkite 36 | agents: 37 | queue: workers 38 | - name: 'make bazelbuild' 39 | command: make bazelbuild 40 | plugins: 41 | - docker-compose#v3.0.2: 42 | run: buildkite 43 | agents: 44 | queue: workers 45 | - name: 'make fossa' 46 | command: make fossa 47 | plugins: 48 | - docker-compose#v3.0.2: 49 | run: buildkite 50 | agents: 51 | queue: workers 52 | - name: 'docker test' 53 | command: bash etc/docker/testing/bin/test.sh 54 | plugins: 55 | - docker-compose#v3.0.2: 56 | run: app 57 | volumes: 58 | - "./:/work" 59 | agents: 60 | queue: workers 61 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | branch: dev 3 | coverage: 4 | range: 50...90 5 | status: 6 | project: 7 | default: 8 | enabled: yes 9 | target: 50% 10 | patch: 11 | default: 12 | enabled: yes 13 | target: 50% 14 | ignore: 15 | - /cmd/prototool 16 | - /example/cmd/excited 17 | - /example/gen/go/uber/bar/v1 18 | - /example/gen/go/uber/foo/v1 19 | - /internal/cmd/gen-prototool-bash-completion 20 | - /internal/cmd/gen-prototool-manpages 21 | - /internal/cmd/gen-prototool-zsh-completion 22 | - /internal/cmd/testdata/grpc/gen/grpcpb 23 | - /internal/reflect/gen/uber/proto/reflect/v1 24 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .glide 2 | .idea 3 | .tmp 4 | bazel-bin/ 5 | bazel-genfiles/ 6 | bazel-out/ 7 | bazel-prototool/ 8 | bazel-testlogs/ 9 | brew 10 | etc/docker/testing/gen 11 | example/gen/java 12 | cmd/prototool/prototool 13 | internal/cmd/gen-prototool-bash-completion/gen-prototool-bash-completion 14 | internal/cmd/gen-prototool-zsh-completion/gen-prototool-zsh-completion 15 | internal/cmd/gen-prototool-manpages/gen-prototool-manpages 16 | internal/cmd/testdata/create/one/a/b/bar/baz.proto 17 | internal/cmd/testdata/create/one/a/c/bar/baz.proto 18 | internal/cmd/testdata/create/one/b/c/bar/baz.proto 19 | internal/cmd/testdata/create/one/baz.proto 20 | internal/cmd/testdata/create/two/baz.proto 21 | internal/cmd/testdata/create/version2one/a/b/bar/baz.proto 22 | internal/cmd/testdata/create/version2one/a/c/bar/baz.proto 23 | internal/cmd/testdata/create/version2one/b/c/bar/baz.proto 24 | internal/cmd/testdata/create/version2two/baz.proto 25 | internal/cmd/testdata/create/version2three/a/b/bar/v1/baz.proto 26 | internal/cmd/testdata/create/version2three/a/c/bar/v1/baz.proto 27 | internal/cmd/testdata/create/version2three/b/c/bar/v1beta1/baz.proto 28 | internal/cmd/testdata/create/version2three/baz.proto 29 | internal/cmd/testdata/create/version2four/baz.proto 30 | internal/cmd/testdata/create/version2five/baz.proto 31 | internal/cmd/testdata/generate/descriptorset/descriptorset.bin 32 | internal/cmd/testcache 33 | internal/extract/testcache 34 | internal/breaking/testcache 35 | internal/reflect/testcache 36 | main 37 | prototool.iml 38 | release 39 | vendor 40 | -------------------------------------------------------------------------------- /.fossa.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | cli: 3 | server: https://app.fossa.com 4 | fetcher: custom 5 | project: https://github.com/uber/prototool 6 | analyze: 7 | modules: 8 | - name: github.com/uber/prototool/cmd/prototool 9 | type: go 10 | target: github.com/uber/prototool/cmd/prototool 11 | path: cmd/prototool 12 | - name: github.com/uber/prototool/internal/cmd/gen-prototool-bash-completion 13 | type: go 14 | target: github.com/uber/prototool/internal/cmd/gen-prototool-bash-completion 15 | path: internal/cmd/gen-prototool-bash-completion 16 | - name: github.com/uber/prototool/internal/cmd/gen-prototool-manpages 17 | type: go 18 | target: github.com/uber/prototool/internal/cmd/gen-prototool-manpages 19 | path: internal/cmd/gen-prototool-manpages 20 | - name: github.com/uber/prototool/internal/cmd/gen-prototool-zsh-completion 21 | type: go 22 | target: github.com/uber/prototool/internal/cmd/gen-prototool-zsh-completion 23 | path: internal/cmd/gen-prototool-zsh-completion 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thanks for filing an issue! We appreciate the input. 2 | 3 | Before filing, a couple guidelines: 4 | 5 | - If this is a question about Protobuf, do not file an issue here. Consult the 6 | Protobuf Language Guide at https://developers.google.com/protocol-buffers/docs/proto3 7 | or ask your question on the Protobuf Mailing List at https://groups.google.com/forum/#!forum/protobuf. 8 | - If this is an issue with Protoc, do not file an issue here. File your issue 9 | on the Protobuf repository at https://github.com/protocolbuffers/protobuf. 10 | - If this is a feature request, please provide a rough outline of the actual changes 11 | you'd like to see with as many specifics as you can provide. 12 | - If this is a bug report, please provide specific steps to reproduce your issue. 13 | 14 | Please do not @ individual maintainers in the description! We appreciate it. 15 | 16 | If your issue doesn't meet the guidelines, we'll comment as such and close the issue - we don't 17 | mean to be impersonal, but we have to reduce the support burden and cannot be supporting all 18 | of Protobuf. If the issue is a feature request and we don't think it meets the guidelines, 19 | don't feel like us closing the issue means we can't ever address it, unless we specifically 20 | note that we won't be adding a given feature (in which case the issue should stay closed) 21 | - provide more specifics and re-open the issue. If the issue is a bug report, unless we respond 22 | that Prototool is working as intended, add steps to reproduce the issue and re-open the issue. 23 | 24 | Again, thanks for your input, and we hope Prototool helps your development! 25 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thanks for your pull request! We really appreciate all OSS efforts, big or small. 2 | 3 | Before submitting, make sure to: 4 | 5 | - Review the issue template at https://github.com/uber/prototool/blob/dev/.github/ISSUE_TEMPLATE.md for 6 | general guidance on filing Prototool requests. 7 | - Run `make` to make sure all tests pass. This is functionally equivalent to the tests run on CI. 8 | 9 | PRs will not be properly evaluated until they pass CI - we've done what we can to make this easy 10 | to replicate locally, and we apologize if this comes across as impersonal. Our goal is to streamline 11 | Prototool development and make sure everyone is on the same page here. 12 | 13 | Please do not @ individual maintainers in the description! We appreciate it. 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.glide 2 | /.idea 3 | /.tmp 4 | /.vscode 5 | /prototool 6 | /bazel-* 7 | /brew 8 | /etc/docker/testing/gen 9 | /example/gen/java 10 | /cmd/prototool/prototool 11 | /internal/cmd/gen-prototool-bash-completion/gen-prototool-bash-completion 12 | /internal/cmd/gen-prototool-zsh-completion/gen-prototool-zsh-completion 13 | /internal/cmd/gen-prototool-manpages/gen-prototool-manpages 14 | /internal/cmd/testdata/create/one/a/b/bar/baz.proto 15 | /internal/cmd/testdata/create/one/a/c/bar/baz.proto 16 | /internal/cmd/testdata/create/one/b/c/bar/baz.proto 17 | /internal/cmd/testdata/create/one/baz.proto 18 | /internal/cmd/testdata/create/two/baz.proto 19 | /internal/cmd/testdata/create/version2one/a/b/bar/baz.proto 20 | /internal/cmd/testdata/create/version2one/a/c/bar/baz.proto 21 | /internal/cmd/testdata/create/version2one/b/c/bar/baz.proto 22 | /internal/cmd/testdata/create/version2two/baz.proto 23 | /internal/cmd/testdata/create/version2three/a/b/bar/v1/baz.proto 24 | /internal/cmd/testdata/create/version2three/a/c/bar/v1/baz.proto 25 | /internal/cmd/testdata/create/version2three/b/c/bar/v1beta1/baz.proto 26 | /internal/cmd/testdata/create/version2three/baz.proto 27 | /internal/cmd/testdata/create/version2four/baz.proto 28 | /internal/cmd/testdata/create/version2five/baz.proto 29 | /internal/cmd/testdata/generate/descriptorset/descriptorset.bin 30 | /internal/cmd/testcache 31 | /internal/extract/testcache 32 | /internal/breaking/testcache 33 | /internal/reflect/testcache 34 | /main 35 | /prototool.iml 36 | /release 37 | /vendor 38 | -------------------------------------------------------------------------------- /BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@bazel_gazelle//:def.bzl", "gazelle") 2 | 3 | # gazelle:prefix github.com/uber/prototool 4 | # gazelle:proto disable_global 5 | gazelle(name = "gazelle") 6 | -------------------------------------------------------------------------------- /Dockerfile.buildkite: -------------------------------------------------------------------------------- 1 | FROM golang:1.12.4-stretch 2 | 3 | ENV GO111MODULE=on \ 4 | GOPATH= 5 | RUN apt-get update -yq && \ 6 | apt-get install -yq build-essential unzip && \ 7 | rm -rf /var/lib/apt/lists/* 8 | WORKDIR /app 9 | COPY go.mod go.sum /app/ 10 | RUN go mod download 11 | COPY Makefile /app 12 | RUN make deps 13 | COPY . /app/ 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019 Uber Technologies, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /WORKSPACE: -------------------------------------------------------------------------------- 1 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 2 | load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") 3 | 4 | http_archive( 5 | name = "io_bazel_rules_go", 6 | urls = [ 7 | "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.22.1/rules_go-v0.22.1.tar.gz", 8 | "https://github.com/bazelbuild/rules_go/releases/download/v0.22.1/rules_go-v0.22.1.tar.gz", 9 | ], 10 | sha256 = "e6a6c016b0663e06fa5fccf1cd8152eab8aa8180c583ec20c872f4f9953a7ac5", 11 | ) 12 | 13 | load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies", "go_register_toolchains") 14 | 15 | go_rules_dependencies() 16 | 17 | go_register_toolchains() 18 | 19 | http_archive( 20 | name = "bazel_gazelle", 21 | urls = [ 22 | "https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/bazel-gazelle/releases/download/v0.20.0/bazel-gazelle-v0.20.0.tar.gz", 23 | "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.20.0/bazel-gazelle-v0.20.0.tar.gz", 24 | ], 25 | sha256 = "d8c45ee70ec39a57e7a05e5027c32b1576cc7f16d9dd37135b0eddde45cf1b10", 26 | ) 27 | 28 | load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") 29 | 30 | gazelle_dependencies() 31 | 32 | git_repository( 33 | name = "com_google_protobuf", 34 | commit = "d0bfd5221182da1a7cc280f3337b5e41a89539cf", 35 | remote = "https://github.com/protocolbuffers/protobuf", 36 | shallow_since = "1581711200 -0800" 37 | ) 38 | 39 | load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") 40 | 41 | protobuf_deps() 42 | 43 | load("//bazel:deps.bzl", "prototool_deps") 44 | 45 | prototool_deps() 46 | 47 | load("//bazel:deps.bzl", "prototool_deps") 48 | 49 | # gazelle:repository_macro bazel/deps.bzl%prototool_deps 50 | prototool_deps() 51 | -------------------------------------------------------------------------------- /bazel/BUILD.bazel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/bazel/BUILD.bazel -------------------------------------------------------------------------------- /cmd/prototool/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["main.go"], 6 | importpath = "github.com/uber/prototool/cmd/prototool", 7 | visibility = ["//visibility:private"], 8 | deps = ["//internal/cmd:go_default_library"], 9 | ) 10 | 11 | go_binary( 12 | name = "prototool", 13 | embed = [":go_default_library"], 14 | visibility = ["//visibility:public"], 15 | ) 16 | -------------------------------------------------------------------------------- /cmd/prototool/main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package main 22 | 23 | import ( 24 | "os" 25 | 26 | "github.com/uber/prototool/internal/cmd" 27 | ) 28 | 29 | func main() { 30 | os.Exit(cmd.Do(os.Args[1:], os.Stdin, os.Stdout, os.Stderr)) 31 | } 32 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | buildkite: 4 | build: 5 | context: . 6 | dockerfile: Dockerfile.buildkite 7 | cache_from: 8 | - golang:1.12.4-stretch 9 | environment: 10 | - CI 11 | - CODECOV_TOKEN 12 | - BUILDKITE 13 | - BUILDKITE_AGENT_ACCESS_TOKEN 14 | - BUILDKITE_BRANCH 15 | - BUILDKITE_BUILD_ID 16 | - BUILDKITE_BUILD_NUMBER 17 | - BUILDKITE_BUILD_URL 18 | - BUILDKITE_COMMIT 19 | - BUILDKITE_JOB_ID 20 | - BUILDKITE_PROJECT_SLUG 21 | - BUILDKITE_PULL_REQUEST 22 | - BUILDKITE_TAG 23 | - FOSSA_API_KEY 24 | app: 25 | build: 26 | context: . 27 | dockerfile: Dockerfile 28 | cache_from: 29 | - golang:1.12.4-alpine3.9 30 | -------------------------------------------------------------------------------- /docs/development.md: -------------------------------------------------------------------------------- 1 | # Development 2 | 3 | [Back to README.md](README.md) 4 | 5 | Prototool is under active development. If you want to help, here's some places to start: 6 | 7 | - Try out `prototool` and file feature requests or bug reports. 8 | - Submit PRs with any changes you'd like to see made. 9 | 10 | We appreciate any input you have! 11 | 12 | Before filing an issue or submitting a PR, make sure to review the 13 | [Issue Guidelines](../.github/ISSUE_TEMPLATE.md), and before submitting a PR, make sure to also 14 | review the [PR Guidelines](../.github/PULL_REQUEST_TEMPLATE.md). The Issue Guidelines will show up 15 | in the description field when filing a new issue, and the PR guidelines will show up in the 16 | description field when submitting a PR, but clear the description field of this pre-populated text 17 | once you've read it. 18 | 19 | Note that development of Prototool will only work with Golang 1.12 or newer. 20 | 21 | Before submitting a PR, make sure to: 22 | 23 | - Run `make generate` to make sure there is no diff. 24 | - Run `make` to make sure all tests pass. This is functionally equivalent to the tests run on CI. 25 | 26 | The entire implementation is purposefully under the `internal` package to not expose any API for 27 | the time being. 28 | 29 | To use the locally-installed tools on your command line: 30 | 31 | ``` 32 | . $(make env) 33 | ``` 34 | 35 | ## Maintainers 36 | 37 | See [maintenance.md](maintenance.md) for maintenance-related tasks. 38 | -------------------------------------------------------------------------------- /etc/bin/brewgen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #################################################################################### 4 | ##### ** THIS SCRIPT SHOULD ONLY BE CALLED BY THE CORRESPONDING MAKE TARGET ** ##### 5 | #################################################################################### 6 | 7 | set -eu 8 | 9 | DIR="$(cd "$(dirname "${0}")/../.." && pwd)" 10 | cd "${DIR}" 11 | 12 | BUILD_DIR="brew" 13 | 14 | rm -rf "${BUILD_DIR}" 15 | mkdir -p "${BUILD_DIR}/bin" 16 | mkdir -p "${BUILD_DIR}/etc/bash_completion.d" 17 | mkdir -p "${BUILD_DIR}/etc/zsh/site-functions" 18 | mkdir -p "${BUILD_DIR}/share/man/man1" 19 | go run internal/cmd/gen-prototool-bash-completion/main.go > "${BUILD_DIR}/etc/bash_completion.d/prototool" 20 | go run internal/cmd/gen-prototool-zsh-completion/main.go > "${BUILD_DIR}/etc/zsh/site-functions/_prototool" 21 | go run internal/cmd/gen-prototool-manpages/main.go "${BUILD_DIR}/share/man/man1" 22 | CGO_ENABLED=0 \ 23 | go build \ 24 | -a \ 25 | -installsuffix cgo \ 26 | -o "${BUILD_DIR}/bin/prototool" \ 27 | cmd/prototool/main.go 28 | -------------------------------------------------------------------------------- /etc/bin/grpcgen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #################################################################################### 4 | ##### ** THIS SCRIPT SHOULD ONLY BE CALLED BY THE CORRESPONDING MAKE TARGET ** ##### 5 | #################################################################################### 6 | 7 | set -euo pipefail 8 | 9 | DIR="$(cd "$(dirname "${0}")/../.." && pwd)" 10 | cd "${DIR}" 11 | 12 | # https://bbengfort.github.io/programmer/2017/03/03/secure-grpc.html 13 | 14 | check_which() { 15 | if ! command -v "${1}" >/dev/null 2>/dev/null; then 16 | echo "${1} is not installed" >&2 17 | exit 1 18 | fi 19 | } 20 | 21 | check_which openssl 22 | check_which certstrap 23 | 24 | cd internal/cmd/testdata/grpc 25 | rm -rf tls 26 | 27 | certstrap --depot-path tls init --common-name "cacert" --passphrase "" 28 | certstrap --depot-path tls request-cert --ip 127.0.0.1 --cn server --passphrase "" 29 | certstrap --depot-path tls sign server --CA cacert --expires "100 years" 30 | certstrap --depot-path tls request-cert --cn client --passphrase "" 31 | certstrap --depot-path tls sign client --CA cacert --expires "100 years" 32 | 33 | openssl req -new -newkey rsa:2048 -x509 -sha256 -nodes -days 36500 -extensions v3_req \ 34 | -keyout tls/self-signed-server.key -out tls/self-signed-server.crt \ 35 | -config <(cat <<-EOF 36 | [req] 37 | default_bits = 2048 38 | req_extensions = v3_req 39 | prompt = no 40 | distinguished_name = dn 41 | 42 | [ dn ] 43 | C=US 44 | ST=Denial 45 | L=Springfield 46 | O=Dis 47 | emailAddress=server@server.local 48 | CN = server.local 49 | 50 | [ v3_req ] 51 | basicConstraints = CA:FALSE 52 | keyUsage = nonRepudiation, digitalSignature, keyEncipherment 53 | subjectAltName = @alt_names 54 | 55 | [ alt_names ] 56 | IP.1 = 127.0.0.1 57 | EOF 58 | ) 59 | openssl req -new -newkey rsa:2048 -x509 -sha256 -nodes -days 36500 \ 60 | -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=client.local" \ 61 | -keyout tls/self-signed-client.key -out tls/self-signed-client.crt 62 | -------------------------------------------------------------------------------- /etc/docker/testing/etc/wkt.txt: -------------------------------------------------------------------------------- 1 | /usr/include/google/protobuf/duration.proto 2 | /usr/include/google/protobuf/empty.proto 3 | /usr/include/google/protobuf/descriptor.proto 4 | /usr/include/google/protobuf/any.proto 5 | /usr/include/google/protobuf/field_mask.proto 6 | /usr/include/google/protobuf/source_context.proto 7 | /usr/include/google/protobuf/struct.proto 8 | /usr/include/google/protobuf/timestamp.proto 9 | /usr/include/google/protobuf/type.proto 10 | /usr/include/google/protobuf/compiler/plugin.proto 11 | /usr/include/google/protobuf/api.proto 12 | /usr/include/google/protobuf/wrappers.proto 13 | -------------------------------------------------------------------------------- /etc/docker/testing/proto/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | generate: 4 | go_options: 5 | import_path: github.com/uber/prototool/etc/docker/testing/proto 6 | plugins: 7 | - name: cpp 8 | output: ../gen/cpp 9 | - name: csharp 10 | output: ../gen/csharp 11 | - name: java 12 | output: ../gen/java 13 | - name: js 14 | output: ../gen/js 15 | - name: objc 16 | output: ../gen/objc 17 | - name: php 18 | output: ../gen/php 19 | - name: python 20 | output: ../gen/python 21 | - name: ruby 22 | output: ../gen/ruby 23 | - name: grpc-cpp 24 | path: grpc_cpp_plugin 25 | output: ../gen/cpp 26 | - name: grpc-csharp 27 | path: grpc_csharp_plugin 28 | output: ../gen/csharp 29 | - name: grpc-node 30 | path: grpc_node_plugin 31 | output: ../gen/node 32 | - name: grpc-objective_c 33 | path: grpc_objective_c_plugin 34 | output: ../gen/objective_c 35 | - name: grpc-php 36 | path: grpc_php_plugin 37 | output: ../gen/php 38 | - name: grpc-python 39 | path: grpc_python_plugin 40 | output: ../gen/python 41 | - name: grpc-ruby 42 | path: grpc_ruby_plugin 43 | output: ../gen/ruby 44 | - name: go 45 | type: go 46 | output: ../gen/go 47 | - name: gofast 48 | type: go 49 | output: ../gen/gofast 50 | - name: gogo 51 | type: gogo 52 | output: ../gen/gogo 53 | - name: gogofast 54 | type: gogo 55 | output: ../gen/gogofast 56 | - name: gogofaster 57 | type: gogo 58 | output: ../gen/gogofaster 59 | - name: gogoslick 60 | type: gogo 61 | output: ../gen/gogoslick 62 | - name: grpc-gateway 63 | type: go 64 | output: ../gen/grpc-gateway 65 | - name: grpc-web 66 | flags: mode=grpcweb 67 | output: ../gen/grpc-web 68 | - name: swagger 69 | output: ../gen/swagger 70 | - name: twirp 71 | type: go 72 | output: ../gen/twirp 73 | - name: twirp_python 74 | output: ../gen/twirp_python 75 | - name: yarpc-go 76 | type: gogo 77 | output: ../gen/yarpc-go 78 | -------------------------------------------------------------------------------- /etc/docker/testing/proto/uber/prototool/v1/foo_api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package uber.prototool.v1; 4 | 5 | option csharp_namespace = "Uber.Prototool.V1"; 6 | option go_package = "prototoolv1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "FooApiProto"; 9 | option java_package = "com.uber.prototool.v1"; 10 | option objc_class_prefix = "UPX"; 11 | option php_namespace = "Uber\\Prototool\\V1"; 12 | 13 | import "google/protobuf/timestamp.proto"; 14 | 15 | // The Foo API. 16 | service FooAPI { 17 | // Perform a bar. 18 | rpc Bar(BarRequest) returns (BarResponse); 19 | } 20 | 21 | message BarRequest { 22 | google.protobuf.Timestamp bar_time = 1; 23 | } 24 | 25 | message BarResponse {} 26 | -------------------------------------------------------------------------------- /etc/style/google/google.proto: -------------------------------------------------------------------------------- 1 | // Protobuf Google Style Guide 2 | // 3 | // This style guide matches https://developers.google.com/protocol-buffers/docs/style. 4 | 5 | syntax = "proto2"; 6 | 7 | package style.google; 8 | 9 | // Use CamelCase (with an initial capital) for message names – for example, SongServerRequest. 10 | // Use underscore_separated_names for field names – for example, song_name. 11 | 12 | message SongServerRequest { 13 | required string song_name = 1; 14 | } 15 | 16 | // Use CamelCase (with an initial capital) for enum type names and CAPITALS_WITH_UNDERSCORES for value names. 17 | 18 | enum Foo { 19 | FIRST_VALUE = 0; 20 | SECOND_VALUE = 1; 21 | } 22 | 23 | // If your .proto defines an RPC service, you should use CamelCase (with an initial capital) 24 | // for both the service name and any RPC method names. 25 | 26 | message FooRequest {} 27 | 28 | message FooResponse {} 29 | 30 | service FooService { 31 | rpc GetSomething(FooRequest) returns (FooResponse); 32 | } 33 | -------------------------------------------------------------------------------- /etc/style/google/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: google 3 | -------------------------------------------------------------------------------- /etc/style/uber1/dep/dep.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package style.uber.dep; 4 | 5 | option go_package = "deppb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "DepProto"; 8 | option java_package = "com.style.uber.dep"; 9 | 10 | // Dep is a dep. 11 | message Dep { 12 | string value = 1; 13 | } 14 | -------------------------------------------------------------------------------- /etc/style/uber1/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber1 3 | -------------------------------------------------------------------------------- /example/cmd/excited/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["main.go"], 6 | importpath = "github.com/uber/prototool/example/cmd/excited", 7 | visibility = ["//visibility:private"], 8 | deps = [ 9 | "//example/gen/go/uber/foo/v1:go_default_library", 10 | "@org_golang_google_grpc//:go_default_library", 11 | ], 12 | ) 13 | 14 | go_binary( 15 | name = "excited", 16 | embed = [":go_default_library"], 17 | visibility = ["//visibility:public"], 18 | ) 19 | -------------------------------------------------------------------------------- /example/gen/go/uber/bar/v1/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["bar.pb.go"], 6 | importpath = "github.com/uber/prototool/example/gen/go/uber/bar/v1", 7 | visibility = ["//visibility:public"], 8 | deps = ["@com_github_golang_protobuf//proto:go_default_library"], 9 | ) 10 | -------------------------------------------------------------------------------- /example/gen/go/uber/foo/v1/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "excited_api.pb.go", 7 | "foo.pb.go", 8 | "hello_api.pb.go", 9 | ], 10 | importpath = "github.com/uber/prototool/example/gen/go/uber/foo/v1", 11 | visibility = ["//visibility:public"], 12 | deps = [ 13 | "//example/gen/go/uber/bar/v1:go_default_library", 14 | "@com_github_golang_protobuf//proto:go_default_library", 15 | "@com_github_golang_protobuf//ptypes/duration:go_default_library", 16 | "@com_github_golang_protobuf//ptypes/timestamp:go_default_library", 17 | "@org_golang_google_grpc//:go_default_library", 18 | "@org_golang_google_grpc//codes:go_default_library", 19 | "@org_golang_google_grpc//status:go_default_library", 20 | ], 21 | ) 22 | -------------------------------------------------------------------------------- /example/proto/prototool.yaml: -------------------------------------------------------------------------------- 1 | protoc: 2 | version: 3.11.0 3 | lint: 4 | group: uber2 5 | rules: 6 | remove: 7 | - REQUEST_RESPONSE_NAMES_MATCH_RPC 8 | - REQUEST_RESPONSE_TYPES_UNIQUE 9 | file_header: 10 | path: ../../LICENSE 11 | generate: 12 | go_options: 13 | import_path: github.com/uber/prototool/example/proto 14 | plugins: 15 | - name: go 16 | type: go 17 | flags: plugins=grpc 18 | output: ../gen/go 19 | - name: java 20 | output: ../gen/java 21 | -------------------------------------------------------------------------------- /example/proto/uber/bar/v1/bar.proto: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | syntax = "proto3"; 22 | 23 | package uber.bar.v1; 24 | 25 | option csharp_namespace = "Uber.Bar.V1"; 26 | option go_package = "barv1"; 27 | option java_multiple_files = true; 28 | option java_outer_classname = "BarProto"; 29 | option java_package = "com.uber.bar.v1"; 30 | option objc_class_prefix = "UBX"; 31 | option php_namespace = "Uber\\Bar\\V1"; 32 | 33 | // Hello is a hello. 34 | message Hello { 35 | int64 hello = 1; 36 | } 37 | -------------------------------------------------------------------------------- /example/proto/uber/foo/v1/hello_api.proto: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | syntax = "proto3"; 22 | 23 | package uber.foo.v1; 24 | 25 | option csharp_namespace = "Uber.Foo.V1"; 26 | option go_package = "foov1"; 27 | option java_multiple_files = true; 28 | option java_outer_classname = "HelloApiProto"; 29 | option java_package = "com.uber.foo.v1"; 30 | option objc_class_prefix = "UFX"; 31 | option php_namespace = "Uber\\Foo\\V1"; 32 | 33 | // HelloAPI controls Foos and Bars. 34 | service HelloAPI { 35 | // Foo does a foo. 36 | rpc Foo(FooRequest) returns (FooResponse); 37 | // Bar does a bar. 38 | rpc Bar(BarRequest) returns (BarResponse); 39 | } 40 | 41 | message FooRequest {} 42 | 43 | message FooResponse {} 44 | 45 | message BarRequest { 46 | int64 id = 1; 47 | } 48 | 49 | message BarResponse {} 50 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/uber/prototool 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/emicklei/proto v1.9.0 7 | github.com/fullstorydev/grpcurl v1.4.0 8 | github.com/gobuffalo/flect v0.2.1 9 | github.com/gofrs/flock v0.7.1 10 | github.com/golang/protobuf v1.3.4 11 | github.com/jhump/protoreflect v1.6.0 12 | github.com/mitchellh/go-wordwrap v1.0.0 13 | github.com/spf13/cobra v0.0.6 14 | github.com/spf13/pflag v1.0.5 15 | github.com/stretchr/testify v1.5.1 16 | go.uber.org/multierr v1.5.0 17 | go.uber.org/zap v1.14.0 18 | golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect 19 | golang.org/x/net v0.0.0-20200301022130-244492dfa37a // indirect 20 | golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 // indirect 21 | golang.org/x/text v0.3.2 // indirect 22 | golang.org/x/tools v0.0.0-20200311222014-c807066ff753 // indirect 23 | google.golang.org/genproto v0.0.0-20200311144346-b662892dd51b // indirect 24 | google.golang.org/grpc v1.28.0 25 | gopkg.in/yaml.v2 v2.2.8 26 | ) 27 | -------------------------------------------------------------------------------- /internal/breaking/check_packages_not_deleted.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package breaking 22 | 23 | import ( 24 | "github.com/uber/prototool/internal/extract" 25 | "github.com/uber/prototool/internal/text" 26 | ) 27 | 28 | func checkPackagesNotDeleted(addFailure func(*text.Failure), from *extract.PackageSet, to *extract.PackageSet) error { 29 | fromPackageNameToPackage := from.PackageNameToPackage() 30 | toPackageNameToPackage := to.PackageNameToPackage() 31 | for fromPackageName := range fromPackageNameToPackage { 32 | if _, ok := toPackageNameToPackage[fromPackageName]; !ok { 33 | addFailure(newPackagesNotDeletedFailure(fromPackageName)) 34 | } 35 | } 36 | return nil 37 | } 38 | 39 | func newPackagesNotDeletedFailure(packageName string) *text.Failure { 40 | return newTextFailuref(`Package %q was deleted.`, packageName) 41 | } 42 | -------------------------------------------------------------------------------- /internal/breaking/testdata/one/from/bar/v1/bar.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package bar.v1; 4 | 5 | option csharp_namespace = "Bar.V1"; 6 | option go_package = "barv1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "BarProto"; 9 | option java_package = "com.bar.v1"; 10 | option objc_class_prefix = "BXX"; 11 | option php_namespace = "Bar\\V1"; 12 | 13 | message One {} 14 | -------------------------------------------------------------------------------- /internal/breaking/testdata/one/from/bar/v1beta1/bar.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package bar.v1beta1; 4 | 5 | option csharp_namespace = "Bar.V1Beta1"; 6 | option go_package = "barv1beta1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "BarProto"; 9 | option java_package = "com.bar.v1beta1"; 10 | option objc_class_prefix = "BXX"; 11 | option php_namespace = "Bar\\V1Beta1"; 12 | 13 | message One {} 14 | -------------------------------------------------------------------------------- /internal/breaking/testdata/one/from/bar/v2/bar.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package bar.v2; 4 | 5 | option csharp_namespace = "Bar.V2"; 6 | option go_package = "barv2"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "BarProto"; 9 | option java_package = "com.bar.v2"; 10 | option objc_class_prefix = "BXX"; 11 | option php_namespace = "Bar\\V2"; 12 | 13 | message One {} 14 | -------------------------------------------------------------------------------- /internal/breaking/testdata/one/from/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | -------------------------------------------------------------------------------- /internal/breaking/testdata/one/to/bar/v1beta1/bar.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package bar.v1beta1; 4 | 5 | option csharp_namespace = "Bar.V1Beta1"; 6 | option go_package = "barv1beta1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "BarProto"; 9 | option java_package = "com.bar.v1beta1"; 10 | option objc_class_prefix = "BXX"; 11 | option php_namespace = "Bar\\V1Beta1"; 12 | 13 | message One {} 14 | -------------------------------------------------------------------------------- /internal/breaking/testdata/one/to/bar/v2/bar.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package bar.v2; 4 | 5 | option csharp_namespace = "Bar.V2"; 6 | option go_package = "barv2"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "BarProto"; 9 | option java_package = "com.bar.v2"; 10 | option objc_class_prefix = "BXX"; 11 | option php_namespace = "Bar\\V2"; 12 | 13 | message One {} 14 | -------------------------------------------------------------------------------- /internal/breaking/testdata/one/to/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | rules: 4 | remove: 5 | - REQUEST_RESPONSE_NAMES_MATCH_RPC 6 | - REQUEST_RESPONSE_TYPES_UNIQUE 7 | -------------------------------------------------------------------------------- /internal/buf/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["buf.go"], 6 | importpath = "github.com/uber/prototool/internal/buf", 7 | visibility = ["//:__subpackages__"], 8 | ) 9 | 10 | go_test( 11 | name = "go_default_test", 12 | srcs = ["buf_test.go"], 13 | embed = [":go_default_library"], 14 | deps = ["@com_github_stretchr_testify//assert:go_default_library"], 15 | ) 16 | -------------------------------------------------------------------------------- /internal/buf/buf_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package buf 22 | 23 | import ( 24 | "testing" 25 | 26 | "github.com/stretchr/testify/assert" 27 | ) 28 | 29 | func TestBasic(t *testing.T) { 30 | testPrinter( 31 | t, 32 | "onetwothree\n", 33 | func(p *Printer) { 34 | p.P(`one`, `two`, `three`) 35 | }, 36 | ) 37 | testPrinter( 38 | t, 39 | "one two three\n", 40 | func(p *Printer) { 41 | p.P(`one `, `two `, `three`) 42 | }, 43 | ) 44 | testPrinter( 45 | t, 46 | "one\n twothree\n four\n\nfive\n\n", 47 | func(p *Printer) { 48 | // purposefully adding space 49 | p.P(`one `) 50 | p.In() 51 | p.P(`two`, `three`) 52 | // purposefully adding space 53 | p.P(` four`) 54 | p.Out() 55 | p.P() 56 | p.P(`five`) 57 | p.P() 58 | }, 59 | ) 60 | } 61 | 62 | func testPrinter(t *testing.T, expected string, f func(*Printer)) { 63 | printer := NewPrinter(" ") 64 | f(printer) 65 | assert.Equal(t, expected, printer.String()) 66 | } 67 | -------------------------------------------------------------------------------- /internal/cfginit/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["cfginit.go"], 6 | importpath = "github.com/uber/prototool/internal/cfginit", 7 | visibility = ["//:__subpackages__"], 8 | ) 9 | -------------------------------------------------------------------------------- /internal/cmd/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "cmd.go", 7 | "flags.go", 8 | "templates.go", 9 | ], 10 | importpath = "github.com/uber/prototool/internal/cmd", 11 | visibility = ["//:__subpackages__"], 12 | deps = [ 13 | "//internal/exec:go_default_library", 14 | "@com_github_mitchellh_go_wordwrap//:go_default_library", 15 | "@com_github_spf13_cobra//:go_default_library", 16 | "@com_github_spf13_cobra//doc:go_default_library", 17 | "@com_github_spf13_pflag//:go_default_library", 18 | "@org_uber_go_zap//:go_default_library", 19 | "@org_uber_go_zap//zapcore:go_default_library", 20 | ], 21 | ) 22 | 23 | go_test( 24 | name = "go_default_test", 25 | srcs = ["cmd_test.go"], 26 | data = glob(["testdata/**"]), 27 | embed = [":go_default_library"], 28 | deps = [ 29 | "//internal/cmd/testdata/grpc/gen/grpcpb:go_default_library", 30 | "//internal/lint:go_default_library", 31 | "//internal/settings:go_default_library", 32 | "//internal/vars:go_default_library", 33 | "@com_github_golang_protobuf//proto:go_default_library", 34 | "@com_github_golang_protobuf//protoc-gen-go/descriptor:go_default_library", 35 | "@com_github_stretchr_testify//assert:go_default_library", 36 | "@com_github_stretchr_testify//require:go_default_library", 37 | "@org_golang_google_grpc//:go_default_library", 38 | "@org_golang_google_grpc//codes:go_default_library", 39 | "@org_golang_google_grpc//credentials:go_default_library", 40 | "@org_golang_google_grpc//status:go_default_library", 41 | ], 42 | ) 43 | -------------------------------------------------------------------------------- /internal/cmd/gen-prototool-bash-completion/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["main.go"], 6 | importpath = "github.com/uber/prototool/internal/cmd/gen-prototool-bash-completion", 7 | visibility = ["//visibility:private"], 8 | deps = ["//internal/cmd:go_default_library"], 9 | ) 10 | 11 | go_binary( 12 | name = "gen-prototool-bash-completion", 13 | embed = [":go_default_library"], 14 | visibility = ["//:__subpackages__"], 15 | ) 16 | -------------------------------------------------------------------------------- /internal/cmd/gen-prototool-bash-completion/main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package main 22 | 23 | import ( 24 | "os" 25 | 26 | "github.com/uber/prototool/internal/cmd" 27 | ) 28 | 29 | func main() { 30 | os.Exit(cmd.GenBashCompletion(os.Stdin, os.Stdout, os.Stderr)) 31 | } 32 | -------------------------------------------------------------------------------- /internal/cmd/gen-prototool-manpages/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["main.go"], 6 | importpath = "github.com/uber/prototool/internal/cmd/gen-prototool-manpages", 7 | visibility = ["//visibility:private"], 8 | deps = ["//internal/cmd:go_default_library"], 9 | ) 10 | 11 | go_binary( 12 | name = "gen-prototool-manpages", 13 | embed = [":go_default_library"], 14 | visibility = ["//:__subpackages__"], 15 | ) 16 | -------------------------------------------------------------------------------- /internal/cmd/gen-prototool-manpages/main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package main 22 | 23 | import ( 24 | "os" 25 | 26 | "github.com/uber/prototool/internal/cmd" 27 | ) 28 | 29 | func main() { 30 | os.Exit(cmd.GenManpages(os.Args[1:], os.Stdin, os.Stdout, os.Stderr)) 31 | } 32 | -------------------------------------------------------------------------------- /internal/cmd/gen-prototool-zsh-completion/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["main.go"], 6 | importpath = "github.com/uber/prototool/internal/cmd/gen-prototool-zsh-completion", 7 | visibility = ["//visibility:private"], 8 | deps = ["//internal/cmd:go_default_library"], 9 | ) 10 | 11 | go_binary( 12 | name = "gen-prototool-zsh-completion", 13 | embed = [":go_default_library"], 14 | visibility = ["//:__subpackages__"], 15 | ) 16 | -------------------------------------------------------------------------------- /internal/cmd/gen-prototool-zsh-completion/main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package main 22 | 23 | import ( 24 | "os" 25 | 26 | "github.com/uber/prototool/internal/cmd" 27 | ) 28 | 29 | func main() { 30 | os.Exit(cmd.GenZshCompletion(os.Stdin, os.Stdout, os.Stderr)) 31 | } 32 | -------------------------------------------------------------------------------- /internal/cmd/testdata/bar/dep.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package bar; 4 | 5 | option go_package = "barpb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "BarProto"; 8 | option java_package = "com.bar"; 9 | 10 | // Dep is a dep. 11 | message Dep { 12 | int64 hello = 1; 13 | } 14 | -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/errors_on_import/dep_errors.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | // not valid! 4 | package foo 5 | 6 | message DepError { 7 | int64 hello = 1; 8 | } 9 | -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/errors_on_import/errors_on_import.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | import "google/protobuf/timestamp.proto"; 6 | import "dep_errors.proto"; 7 | 8 | message Woot { 9 | int64 hello = 1; 10 | foo.DepError dep = 2; 11 | google.protobuf.Timestamp timestamp = 3; 12 | } 13 | -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/errors_on_import/prototool.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/cmd/testdata/compile/errors_on_import/prototool.yaml -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/extra_import/dep.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "FooProto"; 8 | option java_package = "com.foo"; 9 | 10 | // Dep is a dep. 11 | message Dep { 12 | int64 hello = 1; 13 | } 14 | -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/extra_import/extra_import.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | import "google/protobuf/timestamp.proto"; 6 | import "dep.proto"; 7 | 8 | message Bar { 9 | int64 hello = 1; 10 | google.protobuf.Timestamp timestamp = 2; 11 | } 12 | -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/extra_import/prototool.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/cmd/testdata/compile/extra_import/prototool.yaml -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/json/json_camel_case_conflict.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | message Boo { 6 | int64 helloWorld = 1; 7 | int64 helloworld = 2; 8 | } -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/json/prototool.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/cmd/testdata/compile/json/prototool.json -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/notimported/dep.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "FooProto"; 8 | option java_package = "com.foo"; 9 | 10 | // Dep is a dep. 11 | message Dep { 12 | int64 hello = 1; 13 | } 14 | -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/notimported/not_imported.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "FooProto"; 8 | option java_package = "com.foo"; 9 | 10 | message NotImported { 11 | Dep dep = 1; 12 | } 13 | -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/notimported/prototool.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/cmd/testdata/compile/notimported/prototool.yaml -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/proto2/prototool.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/cmd/testdata/compile/proto2/prototool.yaml -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/proto2/syntax_proto2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package foo; 4 | -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/recursive/one.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | import "two.proto"; 6 | 7 | message One {} 8 | -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/recursive/prototool.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/cmd/testdata/compile/recursive/prototool.yaml -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/recursive/two.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | import "one.proto"; 6 | 7 | message Two {} 8 | -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/semicolon/missing_package_semicolon.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo 4 | 5 | message Bar { 6 | int64 hello = 1; 7 | } 8 | -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/semicolon/prototool.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/cmd/testdata/compile/semicolon/prototool.yaml -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/syntax/missing_syntax.proto: -------------------------------------------------------------------------------- 1 | package foo; 2 | 3 | message Bar { 4 | int64 hello = 1; 5 | } 6 | -------------------------------------------------------------------------------- /internal/cmd/testdata/compile/syntax/prototool.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/cmd/testdata/compile/syntax/prototool.yaml -------------------------------------------------------------------------------- /internal/cmd/testdata/create/one/prototool.yaml: -------------------------------------------------------------------------------- 1 | create: 2 | packages: 3 | - directory: a/b 4 | name: foo 5 | - directory: a 6 | name: foobar 7 | -------------------------------------------------------------------------------- /internal/cmd/testdata/create/two/protobuf_file_header.txt: -------------------------------------------------------------------------------- 1 | this 2 | is a 3 | header 4 | -------------------------------------------------------------------------------- /internal/cmd/testdata/create/two/prototool.yaml: -------------------------------------------------------------------------------- 1 | create: 2 | packages: 3 | - directory: . 4 | name: foo 5 | lint: 6 | file_header: 7 | path: protobuf_file_header.txt 8 | -------------------------------------------------------------------------------- /internal/cmd/testdata/create/version2five/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | java_package_prefix: au.com 4 | create: 5 | packages: 6 | - directory: . 7 | name: foo.v1 8 | -------------------------------------------------------------------------------- /internal/cmd/testdata/create/version2four/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | create: 4 | packages: 5 | - directory: . 6 | name: foo.v1 7 | -------------------------------------------------------------------------------- /internal/cmd/testdata/create/version2one/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | create: 4 | packages: 5 | - directory: a/b 6 | name: foo 7 | - directory: a 8 | name: foobar 9 | -------------------------------------------------------------------------------- /internal/cmd/testdata/create/version2three/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | create: 4 | packages: 5 | - directory: a/b 6 | name: foo 7 | - directory: a 8 | name: foobar 9 | -------------------------------------------------------------------------------- /internal/cmd/testdata/create/version2two/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | file_header: 4 | content: | 5 | // this 6 | // is a 7 | // header 8 | is_commented: true 9 | create: 10 | packages: 11 | - directory: . 12 | name: foo 13 | -------------------------------------------------------------------------------- /internal/cmd/testdata/foo/bar/dep.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package bar; 4 | 5 | option go_package = "barpb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "DepProto"; 8 | option java_package = "com.bar"; 9 | 10 | // Dep is a dep. 11 | message Dep { 12 | int64 hello = 1; 13 | } 14 | -------------------------------------------------------------------------------- /internal/cmd/testdata/foo/prototool.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/cmd/testdata/foo/prototool.json -------------------------------------------------------------------------------- /internal/cmd/testdata/foo/success.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | import "google/protobuf/timestamp.proto"; 6 | import "bar/dep.proto"; 7 | 8 | option go_package = "foopb"; 9 | option java_multiple_files = true; 10 | option java_outer_classname = "SuccessProto"; 11 | option java_package = "com.foo"; 12 | 13 | // Baz is a baz. 14 | message Baz { 15 | int64 hello = 1; 16 | bar.Dep dep = 2; 17 | google.protobuf.Timestamp timestamp = 3; 18 | } 19 | -------------------------------------------------------------------------------- /internal/cmd/testdata/format-fix-v2/foo.proto: -------------------------------------------------------------------------------- 1 | // foo 2 | 3 | // bar 4 | 5 | syntax = "proto3"; // inline comment1 6 | 7 | // baz 8 | 9 | package foo.bar.v1; // inline comment3 10 | 11 | // bat 12 | // ban 13 | 14 | // comment9 15 | import "google/protobuf/timestamp.proto"; // inline comment9 16 | 17 | // comment11 18 | option java_multiple_files = true; //inline comment11 19 | // comment4 20 | option go_package = "issssoopb"; // inline comment4 21 | // comment5 22 | option java_outer_classname = "FdsddooProto"; // inline comment5 23 | 24 | // Baz is a baz. 25 | message Baz { 26 | 27 | int64 hello = 1; 28 | 29 | // unassociated comment 30 | 31 | // another unassociated comment 32 | 33 | google.protobuf.Timestamp timestamp = 3; /* inline c-style comment */ 34 | 35 | 36 | map m = 11; 37 | 38 | oneof test_oneof { 39 | int64 foo1 = 8; 40 | string foo2 = 9; 41 | // comment18 42 | } 43 | 44 | } 45 | 46 | // Bat is a bat. 47 | message Bat { 48 | reserved 2 to 10, 1000 to 1100; 49 | reserved "foo"; 50 | reserved "bar", "baz"; 51 | // NestedBat is a nested bat. 52 | message NestedBat { 53 | int64 hello = 1; 54 | } 55 | } 56 | 57 | // Empty is an empty message. 58 | message Empty { 59 | } 60 | 61 | // Something is something. 62 | enum Something { 63 | // comment25 64 | SOMETHING_INVALID = 0; // inline comment25 65 | // comment27 66 | SOMETHING_UNSET = 1; // inline comment27 67 | // comment28 68 | SOMETHING_FOO = 2; // inline comment28 69 | } 70 | 71 | // Daylight is the daylight service. 72 | service Daylight { 73 | rpc Hello(Bat) returns (Empty) { 74 | } // inline comment23 75 | rpc Foo(Empty) returns (Bat); // inline comment24 76 | } 77 | -------------------------------------------------------------------------------- /internal/cmd/testdata/format-fix-v2/foo.proto.golden: -------------------------------------------------------------------------------- 1 | // foo 2 | 3 | // bar 4 | 5 | syntax = "proto3"; // inline comment1 6 | 7 | package foo.bar.v1; // inline comment3 8 | 9 | option csharp_namespace = "Foo.Bar.V1"; 10 | // comment4 11 | option go_package = "barv1"; // inline comment4 12 | // comment11 13 | option java_multiple_files = true; //inline comment11 14 | // comment5 15 | option java_outer_classname = "FooProto"; // inline comment5 16 | option java_package = "au.com.foo.bar.v1"; 17 | option objc_class_prefix = "FBX"; 18 | option php_namespace = "Foo\\Bar\\V1"; 19 | 20 | // comment9 21 | import "google/protobuf/timestamp.proto"; // inline comment9 22 | 23 | // baz 24 | 25 | // bat 26 | // ban 27 | 28 | // Baz is a baz. 29 | message Baz { 30 | int64 hello = 1; 31 | // unassociated comment 32 | 33 | // another unassociated comment 34 | 35 | google.protobuf.Timestamp timestamp = 3; // inline c-style comment 36 | map m = 11; 37 | oneof test_oneof { 38 | int64 foo1 = 8; 39 | string foo2 = 9; 40 | // comment18 41 | 42 | } 43 | } 44 | 45 | // Bat is a bat. 46 | message Bat { 47 | reserved 2 to 10, 1000 to 1100; 48 | reserved "foo"; 49 | reserved "bar", "baz"; 50 | // NestedBat is a nested bat. 51 | message NestedBat { 52 | int64 hello = 1; 53 | } 54 | } 55 | 56 | // Empty is an empty message. 57 | message Empty {} 58 | 59 | // Something is something. 60 | enum Something { 61 | // comment25 62 | SOMETHING_INVALID = 0; // inline comment25 63 | // comment27 64 | SOMETHING_UNSET = 1; // inline comment27 65 | // comment28 66 | SOMETHING_FOO = 2; // inline comment28 67 | } 68 | 69 | // Daylight is the daylight service. 70 | service Daylight { 71 | rpc Hello(Bat) returns (Empty); // inline comment23 72 | rpc Foo(Empty) returns (Bat); // inline comment24 73 | } 74 | -------------------------------------------------------------------------------- /internal/cmd/testdata/format-fix-v2/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | java_package_prefix: au.com 4 | -------------------------------------------------------------------------------- /internal/cmd/testdata/format-fix/foo.proto: -------------------------------------------------------------------------------- 1 | // foo 2 | 3 | // bar 4 | 5 | syntax = "proto3"; // inline comment1 6 | 7 | // baz 8 | 9 | package foo; // inline comment3 10 | 11 | // bat 12 | // ban 13 | 14 | // comment9 15 | import "google/protobuf/timestamp.proto"; // inline comment9 16 | 17 | // comment11 18 | option java_multiple_files = true; //inline comment11 19 | // comment4 20 | option go_package = "issssoopb"; // inline comment4 21 | // comment5 22 | option java_outer_classname = "FdsddooProto"; // inline comment5 23 | 24 | // Baz is a baz. 25 | message Baz { 26 | 27 | int64 hello = 1; 28 | 29 | // unassociated comment 30 | 31 | // another unassociated comment 32 | 33 | google.protobuf.Timestamp timestamp = 3; /* inline c-style comment */ 34 | 35 | 36 | map m = 11; 37 | 38 | oneof test_oneof { 39 | int64 foo1 = 8; 40 | string foo2 = 9; 41 | // comment18 42 | } 43 | 44 | } 45 | 46 | // Bat is a bat. 47 | message Bat { 48 | reserved 2 to 10, 1000 to 1100; 49 | reserved "foo"; 50 | reserved "bar", "baz"; 51 | // NestedBat is a nested bat. 52 | message NestedBat { 53 | int64 hello = 1; 54 | } 55 | } 56 | 57 | // Empty is an empty message. 58 | message Empty { 59 | } 60 | 61 | // Something is something. 62 | enum Something { 63 | // comment25 64 | SOMETHING_INVALID = 0; // inline comment25 65 | // comment27 66 | SOMETHING_UNSET = 1; // inline comment27 67 | // comment28 68 | SOMETHING_FOO = 2; // inline comment28 69 | } 70 | 71 | // Daylight is the daylight service. 72 | service Daylight { 73 | rpc Hello(Bat) returns (Empty) { 74 | } // inline comment23 75 | rpc Foo(Empty) returns (Bat); // inline comment24 76 | } 77 | -------------------------------------------------------------------------------- /internal/cmd/testdata/format-fix/foo.proto.golden: -------------------------------------------------------------------------------- 1 | // foo 2 | 3 | // bar 4 | 5 | syntax = "proto3"; // inline comment1 6 | 7 | package foo; // inline comment3 8 | 9 | // comment4 10 | option go_package = "foopb"; // inline comment4 11 | // comment11 12 | option java_multiple_files = true; //inline comment11 13 | // comment5 14 | option java_outer_classname = "FooProto"; // inline comment5 15 | option java_package = "com.foo"; 16 | 17 | // comment9 18 | import "google/protobuf/timestamp.proto"; // inline comment9 19 | 20 | // baz 21 | 22 | // bat 23 | // ban 24 | 25 | // Baz is a baz. 26 | message Baz { 27 | int64 hello = 1; 28 | // unassociated comment 29 | 30 | // another unassociated comment 31 | 32 | google.protobuf.Timestamp timestamp = 3; // inline c-style comment 33 | map m = 11; 34 | oneof test_oneof { 35 | int64 foo1 = 8; 36 | string foo2 = 9; 37 | // comment18 38 | 39 | } 40 | } 41 | 42 | // Bat is a bat. 43 | message Bat { 44 | reserved 2 to 10, 1000 to 1100; 45 | reserved "foo"; 46 | reserved "bar", "baz"; 47 | // NestedBat is a nested bat. 48 | message NestedBat { 49 | int64 hello = 1; 50 | } 51 | } 52 | 53 | // Empty is an empty message. 54 | message Empty {} 55 | 56 | // Something is something. 57 | enum Something { 58 | // comment25 59 | SOMETHING_INVALID = 0; // inline comment25 60 | // comment27 61 | SOMETHING_UNSET = 1; // inline comment27 62 | // comment28 63 | SOMETHING_FOO = 2; // inline comment28 64 | } 65 | 66 | // Daylight is the daylight service. 67 | service Daylight { 68 | rpc Hello(Bat) returns (Empty); // inline comment23 69 | rpc Foo(Empty) returns (Bat); // inline comment24 70 | } 71 | -------------------------------------------------------------------------------- /internal/cmd/testdata/format-fix/prototool.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/cmd/testdata/format-fix/prototool.yaml -------------------------------------------------------------------------------- /internal/cmd/testdata/format/proto2/foo/bar/bar_proto2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | import "google/protobuf/descriptor.proto"; 4 | 5 | package bar; 6 | 7 | option go_package = "barpb"; 8 | option java_multiple_files = true; 9 | option java_outer_classname = "BarProto2Proto"; 10 | option java_package = "com.bar"; 11 | 12 | extend google.protobuf.MessageOptions { 13 | optional bool message_option_proto2 = 90001 [default = false]; 14 | } 15 | 16 | extend google.protobuf.FileOptions { 17 | optional bool file_option_proto2 = 90002 [default = false]; 18 | } 19 | -------------------------------------------------------------------------------- /internal/cmd/testdata/format/proto2/foo/bar/bar_proto2.proto.golden: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package bar; 4 | 5 | option go_package = "barpb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "BarProto2Proto"; 8 | option java_package = "com.bar"; 9 | 10 | import "google/protobuf/descriptor.proto"; 11 | 12 | extend google.protobuf.MessageOptions { 13 | optional bool message_option_proto2 = 90001 [default = false]; 14 | } 15 | 16 | extend google.protobuf.FileOptions { 17 | optional bool file_option_proto2 = 90002 [default = false]; 18 | } 19 | -------------------------------------------------------------------------------- /internal/cmd/testdata/format/proto2/foo/foo_proto2.proto: -------------------------------------------------------------------------------- 1 | // foo 2 | 3 | // bar 4 | 5 | syntax = "proto2"; // inline comment1 6 | 7 | // baz 8 | 9 | // comment3 10 | package foo; // inline comment3 11 | 12 | // bat 13 | // ban 14 | 15 | // comment2 16 | import weak "foo/bar/bar_proto2.proto"; // inline comment2 17 | 18 | 19 | 20 | // comment11 21 | option java_multiple_files = true; //inline comment11 22 | // comment12 23 | option java_package = "com.foo"; // inline comment23 24 | // comment4 25 | option go_package = "foopb"; // inline comment4 26 | // comment5 27 | option java_outer_classname = "FooProto2Proto"; // inline comment5 28 | // comment7 29 | option (bar.file_option_proto2) = true; //inline comment7 30 | 31 | // FooProto2 is a foo proto2. 32 | message FooProto2 { 33 | extensions 10 to 20; 34 | extensions 100 to 200, 2000 to 2500; 35 | extensions 2700 to 2800, 3000 to max; 36 | 37 | optional int64 hello = 1; 38 | 39 | // comment20 40 | optional group Group = 2 { 41 | required int64 bar = 3; 42 | optional int64 bar2 = 4; 43 | } 44 | repeated int64 baz = 5; 45 | } 46 | 47 | message FooSomething {} 48 | 49 | // SomeService is a service. 50 | service SomeService { 51 | rpc Echo(FooSomething) returns (FooProto2) {} 52 | } 53 | -------------------------------------------------------------------------------- /internal/cmd/testdata/format/proto2/foo/foo_proto2.proto.golden: -------------------------------------------------------------------------------- 1 | // foo 2 | 3 | // bar 4 | 5 | syntax = "proto2"; // inline comment1 6 | 7 | // comment3 8 | package foo; // inline comment3 9 | 10 | // comment7 11 | option (bar.file_option_proto2) = true; //inline comment7 12 | // comment4 13 | option go_package = "foopb"; // inline comment4 14 | // comment11 15 | option java_multiple_files = true; //inline comment11 16 | // comment5 17 | option java_outer_classname = "FooProto2Proto"; // inline comment5 18 | // comment12 19 | option java_package = "com.foo"; // inline comment23 20 | 21 | // comment2 22 | import weak "foo/bar/bar_proto2.proto"; // inline comment2 23 | 24 | // baz 25 | 26 | // bat 27 | // ban 28 | 29 | // FooProto2 is a foo proto2. 30 | message FooProto2 { 31 | extensions 10 to 20; 32 | extensions 100 to 200, 2000 to 2500; 33 | extensions 2700 to 2800, 3000 to max; 34 | optional int64 hello = 1; 35 | // comment20 36 | optional group Group = 2 { 37 | required int64 bar = 3; 38 | optional int64 bar2 = 4; 39 | } 40 | repeated int64 baz = 5; 41 | } 42 | 43 | message FooSomething {} 44 | 45 | // SomeService is a service. 46 | service SomeService { 47 | rpc Echo(FooSomething) returns (FooProto2); 48 | } 49 | -------------------------------------------------------------------------------- /internal/cmd/testdata/format/proto2/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | rules: 3 | remove: 4 | - RPCS_HAVE_COMMENTS 5 | - REQUEST_RESPONSE_TYPES_UNIQUE 6 | ignores: 7 | - id: SYNTAX_PROTO3 8 | files: 9 | - bar/bar_proto2.proto 10 | - foo/foo_proto2.proto 11 | -------------------------------------------------------------------------------- /internal/cmd/testdata/format/proto3/foo/bar/bar.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | import "google/protobuf/descriptor.proto"; 4 | 5 | package bar; 6 | 7 | option go_package = "barpb"; 8 | option java_multiple_files = true; 9 | option java_outer_classname = "BarProto"; 10 | option java_package = "com.bar"; 11 | 12 | // Dep is a dep. 13 | message Dep { 14 | int64 hello = 1; 15 | int64 bar = 2; 16 | Dep recursive = 3; 17 | repeated int64 repeated_bar = 4; 18 | repeated Dep repeated_dep = 5; 19 | } 20 | 21 | extend google.protobuf.MessageOptions { 22 | bool message_option = 80001; 23 | Dep message_dep_option = 80003; 24 | } 25 | 26 | extend google.protobuf.FileOptions { 27 | bool file_option = 80002; 28 | Dep file_dep_option = 80004; 29 | } 30 | 31 | extend google.protobuf.FieldOptions { 32 | bool field_option = 80006; 33 | Dep field_dep_option = 80007; 34 | repeated int64 repeated_field_option = 80017; 35 | repeated Dep repeated_field_dep_option = 80018; 36 | } 37 | 38 | extend google.protobuf.OneofOptions { 39 | bool oneof_option = 80008; 40 | Dep oneof_dep_option = 80009; 41 | } 42 | 43 | extend google.protobuf.MethodOptions { 44 | bool method_option = 80010; 45 | Dep method_dep_option = 80011; 46 | } 47 | 48 | extend google.protobuf.EnumOptions { 49 | bool enum_option = 80012; 50 | Dep enum_dep_option = 80014; 51 | } 52 | 53 | extend google.protobuf.EnumValueOptions { 54 | bool enum_value_option = 80015; 55 | Dep enum_value_dep_option = 80016; 56 | } 57 | 58 | extend google.protobuf.ServiceOptions { 59 | bool service_option = 80012; 60 | Dep service_dep_option = 80014; 61 | } 62 | -------------------------------------------------------------------------------- /internal/cmd/testdata/format/proto3/foo/bar/bar.proto.golden: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package bar; 4 | 5 | option go_package = "barpb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "BarProto"; 8 | option java_package = "com.bar"; 9 | 10 | import "google/protobuf/descriptor.proto"; 11 | 12 | // Dep is a dep. 13 | message Dep { 14 | int64 hello = 1; 15 | int64 bar = 2; 16 | Dep recursive = 3; 17 | repeated int64 repeated_bar = 4; 18 | repeated Dep repeated_dep = 5; 19 | } 20 | 21 | extend google.protobuf.MessageOptions { 22 | bool message_option = 80001; 23 | Dep message_dep_option = 80003; 24 | } 25 | 26 | extend google.protobuf.FileOptions { 27 | bool file_option = 80002; 28 | Dep file_dep_option = 80004; 29 | } 30 | 31 | extend google.protobuf.FieldOptions { 32 | bool field_option = 80006; 33 | Dep field_dep_option = 80007; 34 | repeated int64 repeated_field_option = 80017; 35 | repeated Dep repeated_field_dep_option = 80018; 36 | } 37 | 38 | extend google.protobuf.OneofOptions { 39 | bool oneof_option = 80008; 40 | Dep oneof_dep_option = 80009; 41 | } 42 | 43 | extend google.protobuf.MethodOptions { 44 | bool method_option = 80010; 45 | Dep method_dep_option = 80011; 46 | } 47 | 48 | extend google.protobuf.EnumOptions { 49 | bool enum_option = 80012; 50 | Dep enum_dep_option = 80014; 51 | } 52 | 53 | extend google.protobuf.EnumValueOptions { 54 | bool enum_value_option = 80015; 55 | Dep enum_value_dep_option = 80016; 56 | } 57 | 58 | extend google.protobuf.ServiceOptions { 59 | bool service_option = 80012; 60 | Dep service_dep_option = 80014; 61 | } 62 | -------------------------------------------------------------------------------- /internal/cmd/testdata/format/proto3/prototool.json: -------------------------------------------------------------------------------- 1 | { 2 | "lint": { 3 | "rules": { 4 | "remove": [ 5 | "RPCS_HAVE_COMMENTS", 6 | "REQUEST_RESPONSE_TYPES_UNIQUE" 7 | ] 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /internal/cmd/testdata/generate/descriptorset/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "FooProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | // A bar. 14 | message Bar {} 15 | -------------------------------------------------------------------------------- /internal/cmd/testdata/generate/descriptorset/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | generate: 4 | plugins: 5 | - name: descriptor_set 6 | file_suffix: bin 7 | output: . 8 | -------------------------------------------------------------------------------- /internal/cmd/testdata/grpc/gen/grpcpb/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["grpc.pb.go"], 6 | importpath = "github.com/uber/prototool/internal/cmd/testdata/grpc/gen/grpcpb", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "@com_github_golang_protobuf//proto:go_default_library", 10 | "@org_golang_google_grpc//:go_default_library", 11 | "@org_golang_google_grpc//codes:go_default_library", 12 | "@org_golang_google_grpc//status:go_default_library", 13 | ], 14 | ) 15 | -------------------------------------------------------------------------------- /internal/cmd/testdata/grpc/grpc.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package grpc; 4 | 5 | option go_package = "grpcpb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "GrpcProto"; 8 | option java_package = "com.grpc"; 9 | 10 | message Foo { 11 | string bar = 1; 12 | } 13 | 14 | message ExclamationRequest { 15 | string value = 1; 16 | } 17 | 18 | message ExclamationResponse { 19 | string value = 1; 20 | } 21 | 22 | // ExcitedService is a service with exciting transformations. 23 | service ExcitedService { 24 | // Exclamation adds an exclamation to the request value. 25 | rpc Exclamation(ExclamationRequest) returns (ExclamationResponse) {} 26 | // ExclamationClientStream adds an exclamation to the combined request values. 27 | rpc ExclamationClientStream(stream ExclamationRequest) returns (ExclamationResponse) {} 28 | // ExclamationServerStream adds an exclamation to the request value 29 | // and streams each character as a response. 30 | rpc ExclamationServerStream(ExclamationRequest) returns (stream ExclamationResponse) {} 31 | // ExclamationBidiStream adds an exclamation to the each request value. 32 | rpc ExclamationBidiStream(stream ExclamationRequest) returns (stream ExclamationResponse) {} 33 | } 34 | -------------------------------------------------------------------------------- /internal/cmd/testdata/grpc/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | rules: 3 | remove: 4 | - REQUEST_RESPONSE_TYPES_UNIQUE 5 | generate: 6 | go_options: 7 | import_path: github.com/uber/prototool/internal/cmd/testdata/grpc 8 | plugins: 9 | - name: go 10 | type: go 11 | flags: plugins=grpc 12 | output: gen/grpcpb 13 | -------------------------------------------------------------------------------- /internal/cmd/testdata/grpc/tls/cacert.crl: -------------------------------------------------------------------------------- 1 | -----BEGIN X509 CRL----- 2 | MIICgDBqAgEBMA0GCSqGSIb3DQEBCwUAMBExDzANBgNVBAMTBmNhY2VydBcNMTkw 3 | MzA5MjE0MTM4WhcNMjAwOTA5MjE0MTM2WjAAoCMwITAfBgNVHSMEGDAWgBQutivJ 4 | fLPpGQzEsIrXebSLEuhXhDANBgkqhkiG9w0BAQsFAAOCAgEAGAwfi4/RGV/Wd3QR 5 | GF+DcnlAYb0JY+fcmhJ0hChsSLAnOv34SDk1O9G1/TCPgNRXIedg3QLYiF3Ogbed 6 | rELehUT5RdB6F8gbpxRE/gk6raE6VmFwrwvnBG4eKBTX9+4xVJQ6c+9ZigRU4vQm 7 | EEXVnwHpIu0YBJ+LGajZfApYWSbgiAcEVFkqLFcXpYvMR/yTptghJxL5aulZbI8X 8 | YnWwguk4XX8+leLfoAEbSNEHlMzP7OntOqea/lLOuTP9QStM3fYHbCtQwhx4iYwv 9 | hhoNJGTBkAH/HQlIUMFYVqGtPyCNhVBcS5feMBKKASb3l9kr5hyFbxc4MFSH/1Tf 10 | 1gLBi0wtV2p55qckT+bC2kj3CJbzaWlTw2U7T6QtR1KBjgYnZGlVQj/Sxr6Tof8F 11 | qeULqbX7bbQdZFomIXiS+VAI4ZDJQ1uB9SAkEJU/Q05hOygvaDuAH+imFyyOwSW3 12 | /x+mGwRVElvWmcdvWjpta6knoKZsWGYGgd381IlFBZvBcpS2atQFC43bTXtixKls 13 | UlPAp0VOeE6om2BoR2Olf75EmnXVZNSNW3Jd7CwESf2llYLKWMNg94UuTbzclGo5 14 | nxoijG5IrSg7e0mTtlVTO+9KmgOUC4beodjoAZ36oc/bh/xIuIlztP8CLn1Sre62 15 | B0cuYAZP9Aw5JSGI+yxLTJ0DFPw= 16 | -----END X509 CRL----- 17 | -------------------------------------------------------------------------------- /internal/cmd/testdata/grpc/tls/cacert.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIE4jCCAsqgAwIBAgIBATANBgkqhkiG9w0BAQsFADARMQ8wDQYDVQQDEwZjYWNl 3 | cnQwHhcNMTkwMzA5MjE0MTM2WhcNMjAwOTA5MjE0MTM2WjARMQ8wDQYDVQQDEwZj 4 | YWNlcnQwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDM3s17wcNfv2AH 5 | ljOMIPUD4ZcXjWJvs16Nrdff91lmq0f9RK2dYP1r4c2XtT4E81JD+mZMCaTI/AqY 6 | UMrxJlrF0nDB7GiILGkrQhr1hrncM0r7pHC91j6HvdHbQVttmSrjgGrVDbk4URmR 7 | sNZdx4GCDHRlMZqfDfVZp4KR0Fgh9Hm1pW2d9E3nqtUKFIAiho7hYsO9ok141NSg 8 | nSHbXBC7G8eaCo0AJb+S++b7q3sHW7CNna1a/95+zoj+m64n88hHY27aIH8mRlhW 9 | 6n5a3lxgRUQbygWY30IJ5wKYKEKqymRzD38Q7L3BC2utbCHDPMJhl9GO9tG8l6j6 10 | rMXbsJXGgTHQ7qmN7gboy3bOyGA9ePFW00HCOZURn5l5oxcQVGbzTA6LoTuTMdnx 11 | SmtRL+lZvkciXVs9GEgvwZjb5+GFpvwvS3WICgiI3lrjx8vir7cRCuOeWqitPvZP 12 | KqSvSQVLg9LLr+AxchxbbsdYimwFI1EmhNDEEzgzapah9M4q182OB4T3TUxsgrF+ 13 | 1Bvbu/BQuKng1KhDo4JyR1259RgAeYso/OqxJMMXRY9T8rahnmktBmglPW6E8sZS 14 | fRNjKnovLgBIEJk0ZycfpWWLnSX1sW9pMWtuFXf0aB1TPyAw3E7ek93cRYtcBzLT 15 | A1NvEFjw9IXXdfGrX320I/wWOo6auQIDAQABo0UwQzAOBgNVHQ8BAf8EBAMCAQYw 16 | EgYDVR0TAQH/BAgwBgEB/wIBADAdBgNVHQ4EFgQULrYryXyz6RkMxLCK13m0ixLo 17 | V4QwDQYJKoZIhvcNAQELBQADggIBAFx5PYMUEDzRmHuDZuH5nq652Eicq+/uJ1Ph 18 | +7F6WsXgWyWQY/+VNNKm+BWUiBlvI29Vn4abGTxTZehGPeeK3au7DvFWtPFkqVSo 19 | fxMnaYkUG6fvKgrOWcY0U6IWsF6WBKrD1YyVZ2QutF2r6qGHaQxbqqWUbfD4IPEU 20 | uHWWZ1SYv/moPiyLU1R7/OZ3lxrjeiB7cNwrgKkGT6Bf77DPd6+5m2jZ1x1RUrr5 21 | ex8XwkztVPsoGZFXacPTpq9nOxlRGaKPD75xl7chwkCfx9vtnHokPYOACzvl7GZU 22 | Ak8s+/8riEx3DHLzjVoPTxG4ON8qMcs9V9jmBsj+1MD0b6Li288a5TbQEXVcVzBj 23 | 2FHywqztOSFCICOh6kizVzohLWWWmIeXEEl0t+TXF/YlDB8ldr7CalTldbAQCv/K 24 | omrATRd2EUcyrmEE1fPuMCJqKwpDSEmgVW5MNhmqdCvxpP9tinxmPXTI8YmjX04+ 25 | 7w8AJQdDbrXdGwXLrFIkTdhafQY33wX4RRZ4gK/tVPid97a/qyAH+Ipx8apsrdYV 26 | E1xmiNsCmbCKyNDA3ZO6KkFh8UJ0/GNjIzT3ThGG2TPXclHX1TXIjdM7sG1zN3xh 27 | 1JWqWWYFKNEcFhV7+8UcLtrDaI2ZF8Wg2yrCbn6ISNZ/Argi88Ele8sa7F+d8EQT 28 | 1Kpr/yuI 29 | -----END CERTIFICATE----- 30 | -------------------------------------------------------------------------------- /internal/cmd/testdata/grpc/tls/client.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEHTCCAgWgAwIBAgIQeOOoRS8IXPFTa9rfz03IojANBgkqhkiG9w0BAQsFADAR 3 | MQ8wDQYDVQQDEwZjYWNlcnQwHhcNMTkwMzA5MjE0MTM4WhcNMjAwOTA5MjE0MTM2 4 | WjARMQ8wDQYDVQQDEwZjbGllbnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK 5 | AoIBAQDDEMxSkdh6R90L+d9kXl7lHx2178kBloGyx07j4whoCsxy98/6LVEBDtEZ 6 | nXZtdI4z3F6VaQakqx3CTc1lkQHwvSa150E7puAUgmRPp5xwpR7O2qEaIXujhWfo 7 | 4kV/DJ3po6I5tioPdEF82URNBfz2pw93m5i6Kgecaojw5j2uevwIPe70H5PXqAZg 8 | pn3zcVC5JKUg8dm7GvPy5sYiJ9ZYX/sj04ErvLKQhcZoyjJufz9szwyvQfosiDri 9 | fo5Tzd/iu/LErRgVN/iKA9DNZdVn1Pi2Wc3bbXjgjHVpEc732/n85Co8QdoUDblb 10 | Fq4aglxzx6qcj+qwQmXwHEG6k9I3AgMBAAGjcTBvMA4GA1UdDwEB/wQEAwIDuDAd 11 | BgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwHQYDVR0OBBYEFCh9r78vxk9s 12 | olJJVN1t5BiQqwz1MB8GA1UdIwQYMBaAFC62K8l8s+kZDMSwitd5tIsS6FeEMA0G 13 | CSqGSIb3DQEBCwUAA4ICAQCFQVsbsg/XwCsOT9mDw6bBzkQcF2q9LwVSwQr36saH 14 | GGzpUtRlx5xoIdXobBTIv7yZcat9mNJc74b8R2A2qtS9r7VqTI6jU8Z9sWaUEiHz 15 | y+kP1EFGhk6JOaU4PxtDvIuuZr7yBV5KHMq7EN06PmVb8hC+MbK5OURUaciV7UzG 16 | haGZp6avCbidi4gD2fHv7ffF8zwCZH/ynkFoOSzf/KGDfIRjkKJVVhNAVMklYmBD 17 | TjsNfL1uZcd4Y/p9q+Umc4v+cDLdmtQt1FwA8huKz5oI45LdkqYaAgMmfEfLPD38 18 | Li6SAHpgr+VyQ9YYDxLuryT8BDL69xCq3CNKyUtkfNMKlFP6mZdUO5tvxlV8HerM 19 | ZgD6rH/JHeT1sX+t7pEHh6knOhyCuQ/grjugz4cirDCPgICdAH7VwFBS14mAv+lr 20 | oqUdoloqdI3xevZnVODH+9IT/Y83yEjtaumeyfFyYMQ3mM3/y5NDgDg6gUu3gGSm 21 | 19AAXzloYW9Re3kAYCesXNfKZiDn4Mk2AiBC4Le3Yucs5nVwFLT9Wn3JHdL6vTog 22 | 9AiPsXo0AkENhA9ij41p7xPB5cOmLvhoCD0jSXCF2BHRx8HjGxqLYdlO6hYc07Cd 23 | Ur8jRUhZwaYc0KNzxlGHbo8OmJfYgJWKx+TEuutYbE9MgWm9pwwGTF0YDECfemk7 24 | NA== 25 | -----END CERTIFICATE----- 26 | -------------------------------------------------------------------------------- /internal/cmd/testdata/grpc/tls/client.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIICVjCCAT4CAQAwETEPMA0GA1UEAxMGY2xpZW50MIIBIjANBgkqhkiG9w0BAQEF 3 | AAOCAQ8AMIIBCgKCAQEAwxDMUpHYekfdC/nfZF5e5R8dte/JAZaBssdO4+MIaArM 4 | cvfP+i1RAQ7RGZ12bXSOM9xelWkGpKsdwk3NZZEB8L0mtedBO6bgFIJkT6eccKUe 5 | ztqhGiF7o4Vn6OJFfwyd6aOiObYqD3RBfNlETQX89qcPd5uYuioHnGqI8OY9rnr8 6 | CD3u9B+T16gGYKZ983FQuSSlIPHZuxrz8ubGIifWWF/7I9OBK7yykIXGaMoybn8/ 7 | bM8Mr0H6LIg64n6OU83f4rvyxK0YFTf4igPQzWXVZ9T4tlnN22144Ix1aRHO99v5 8 | /OQqPEHaFA25WxauGoJcc8eqnI/qsEJl8BxBupPSNwIDAQABoAAwDQYJKoZIhvcN 9 | AQELBQADggEBAIzkEMlnvDzhCeG7PJiTAISWqwhuIooyD9AOBF2Nefd5CzzleGP2 10 | Ou9OTyGc7yhNk2mgQz/4F37aenCglDwxgRiHijOqGnQhT4W8S+sh9uYut0SaPfE4 11 | BgiEk4Bw+ESy2jIibjxg8//J2753GZsIvlMALQNBSGbk2Mew1Y9CfRxyjWBDJ8Mt 12 | WHJBpVf33CPNACdWDXwZVLsWWCOBqcCjogh1iPNv6srQBBR810M6vF17bumX5rv3 13 | cl5T0aq8pdY4VvEOUnHeAQHEZOb1akDbfoVKOJW4JUTDFgsV5y1VYQB93J7bjODQ 14 | J2C/CQMEXum5T0OEXQcyT0v2beJ3eXbV4Z0= 15 | -----END CERTIFICATE REQUEST----- 16 | -------------------------------------------------------------------------------- /internal/cmd/testdata/grpc/tls/client.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpAIBAAKCAQEAwxDMUpHYekfdC/nfZF5e5R8dte/JAZaBssdO4+MIaArMcvfP 3 | +i1RAQ7RGZ12bXSOM9xelWkGpKsdwk3NZZEB8L0mtedBO6bgFIJkT6eccKUeztqh 4 | GiF7o4Vn6OJFfwyd6aOiObYqD3RBfNlETQX89qcPd5uYuioHnGqI8OY9rnr8CD3u 5 | 9B+T16gGYKZ983FQuSSlIPHZuxrz8ubGIifWWF/7I9OBK7yykIXGaMoybn8/bM8M 6 | r0H6LIg64n6OU83f4rvyxK0YFTf4igPQzWXVZ9T4tlnN22144Ix1aRHO99v5/OQq 7 | PEHaFA25WxauGoJcc8eqnI/qsEJl8BxBupPSNwIDAQABAoIBAQCzrK9nhuuNhtA3 8 | DcwVGU/zX/vv75SIn+eLk0Y5ZpABtaCobVbmrAMnJEy6eW3yWB/76Qo+OWVjHDLn 9 | HN8KpMzSwIf9matelNFmUsyvCkZxA8ci5gLqnNjTwDf8LR+ybR6vbIgq/H41ifIg 10 | W8gr4k4lq6/1jh7Zq4kjLIZCzvEV2poRnGZdyzVtXV127NoObsrwTuvY11FGjQw7 11 | O97rPMhph9AhTOU8mP9iI4iDfMwb8eJpebx3VYbAnsMfQIVYUpXns916sSI3xxqE 12 | M3tfNdmRDuLD0GtQbwXS8uuDLOfueK14Ts9CavSpNkd5/bXZ6kKxOug8orjyxHmW 13 | Ik1PLw1BAoGBANKVzuNlsC+m3dW5dBXv2Q3xfqU43cgvTLLfIQl9IxrXJ1UXBY6O 14 | 0yvSeuUkHTg7aUEocZiVaXtMYce5/xAhm1HVG6xWl6h1GVwHq3/HLcWZWHPBCKBV 15 | TLGdnY6OaiIccfeYujw0s6ypS+hm3iAM7NaMAy/Lp1HTtPB57d+PCX4RAoGBAO0i 16 | K6IuIwsY9AJgVPKbOaJljzNQhAzw8FjOu1Z6pUyMFdMbpsKtVw7IRqFJid+sqT/K 17 | Q2x63d9g6U6ekmMtulx6IdFoNj0uekD2NkpHSwgip+UeoD0M1NDsD8HswuwBVS3F 18 | PAXbiyDA11+fK8G//nRtS4JOpxQcGWDSxnX6DqPHAoGAa3GgE4nosQd0m/15a0/q 19 | 8SBMO8Sd8+ueOI1777l3VdR87v9GCIx61hsYNR2OAwjdFS+rdeyV2yEHqr4Nk49y 20 | Dfirm+y6iGrmu3v2VsWrZuxsovLUkemzrdP7dabYI/tbcrbsHpfNLMVcQ4Fox/WQ 21 | SY86eQJxpmBcK24qniv+7eECgYEA7Eaj21DFMgWG++coPSNVZe5zpNmQ+aQIlzRF 22 | jYFeusrJ5DMlEczNdbkwRvyTF/9eFGVgkPJLqItTbDar/Y5Opl463ABOKt/oiFnK 23 | 9m/a3xxI1g6R8sKaOiE8Ain6flVFnflsORnropMDBg/+9WpsC23rUsczyuHEl6js 24 | fhjOBXkCgYAJV8PQSr7JSU57ru/A6TP1oJ8trtWmOqReRFGGtt0vqMKv6CIANyjY 25 | A1THhVVvAU6tUep07SJizYcSXW7I9gpNpa+F9u0H1pS4qK/aimbAufhUtoV8EGsM 26 | +y/TbN2tEIQymmQIAjnjAReKQqhhBNSbk6zf6zhxC3ERSB/3OLSy1g== 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /internal/cmd/testdata/grpc/tls/self-signed-client.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDMDCCAhgCCQCmeuVGybe3JzANBgkqhkiG9w0BAQsFADBZMQswCQYDVQQGEwJV 3 | UzEPMA0GA1UECAwGRGVuaWFsMRQwEgYDVQQHDAtTcHJpbmdmaWVsZDEMMAoGA1UE 4 | CgwDRGlzMRUwEwYDVQQDDAxjbGllbnQubG9jYWwwIBcNMTkwMzA5MjE0MTQxWhgP 5 | MjExOTAyMTMyMTQxNDFaMFkxCzAJBgNVBAYTAlVTMQ8wDQYDVQQIDAZEZW5pYWwx 6 | FDASBgNVBAcMC1NwcmluZ2ZpZWxkMQwwCgYDVQQKDANEaXMxFTATBgNVBAMMDGNs 7 | aWVudC5sb2NhbDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMGR2H7b 8 | hblSyJPLoN8XE/+dMx2E7NLI5xX2Ey7e1IIrq05az310doqtZ9AwXzYMTKjZwMG6 9 | 6Gno3pnlgm7skevzlQszO4kHeHsBnPiL/USL9pMhKLMnshTaTfP4e9X8qUMZOfvq 10 | pIiQdlNlNqRHi5JdgEbeztGoDMj/2+/EqB96zm6ig0tRpH9NJ9UxSutrWW2jtlYD 11 | 495txR+SI3OSYPoGNC3tNBIBWcQCAVwVld5Evd8bVQzq15eUYkX0rvq0UI92Sl9P 12 | UqCG1Ba393fbWL20dNsxYxrq037ku9aJUF590FvpNSsoCk/cA8mES/sTn0cpb4V+ 13 | TQzJsigetUHcMsUCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEADJjkrInxAlBs/vJP 14 | QmmfncLaTxo/zROAGgbIvpUssB43/AmP6Rgv3nly22bhsI8fHw+I9wZTPESdc802 15 | 89D8uhseSghH/iLSSQfnEOe1inyz8IuNv9L2h6+mKB11jw99R2chUxJc7NjZrXWd 16 | bLcg9byuaR3Jx2wHb3T05Ay1FEfCmXQKe9K9ZukmAJy8h929+23f8JqMUqmTnmKX 17 | 0cUWtw8c3TvaYi8AXuhK0yK3Hr08cJ8agYXzPlV25slnVft6KA1+cOgaeIyuK783 18 | e5hRU3myuvDNV6Bz2yMAfsfGch6Sc7BLmq7vjPO4wYo0aUKmFbcuaJrVPPi3AwEy 19 | u8GBhg== 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /internal/cmd/testdata/grpc/tls/self-signed-client.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDBkdh+24W5UsiT 3 | y6DfFxP/nTMdhOzSyOcV9hMu3tSCK6tOWs99dHaKrWfQMF82DEyo2cDBuuhp6N6Z 4 | 5YJu7JHr85ULMzuJB3h7AZz4i/1Ei/aTISizJ7IU2k3z+HvV/KlDGTn76qSIkHZT 5 | ZTakR4uSXYBG3s7RqAzI/9vvxKgfes5uooNLUaR/TSfVMUrra1lto7ZWA+PebcUf 6 | kiNzkmD6BjQt7TQSAVnEAgFcFZXeRL3fG1UM6teXlGJF9K76tFCPdkpfT1KghtQW 7 | t/d321i9tHTbMWMa6tN+5LvWiVBefdBb6TUrKApP3APJhEv7E59HKW+Ffk0MybIo 8 | HrVB3DLFAgMBAAECggEAD3oRzVLQBllQIEEPw8acmrt+8sVGCjR2BZN/RSgb5ayI 9 | LeOk42sEb2IeAs9bTX7+QiHm/5ZqLs2nvrZTD3tqz2rSZ+rYv8QRJgSjAFxxC6IF 10 | PQ5RqsFpw7EQuokLnbht8Cd8M2A3d5PVYiWdkNUHm9ROBVybPLgrDYcnlqwqpRmQ 11 | +2DShs7wt4ocMNEjt5FIjyMovFAYR6CKqaVoDO/EJQAlBSi5izZT2Qrn899h7bMm 12 | Hp0ptV8e+z6Z7YabsP6sfyFOQoeUQkf/MD5zseymcf/uUbbMR3Xg4dY+bO8/pBsh 13 | S8oA4HpAFPn8W2i+DAsbXvID+KG1AWYWPmy+Dzn3oQKBgQDk2yAbkiph7Iok2BMQ 14 | geZpurjOfhYcgdlnBST8KEoie1qC8X7AhwULeTYdceM8LvStib95PIJ7v/bJQlRH 15 | kM3PqOVsucf17VMCY1OktIA3lu+Lmp2MSqm0n83iKOKG5QbxY+cw1ETOl1QZE4+l 16 | ti189gxlaiQgTjNnVxOCWa7rTwKBgQDYh04ikAskjYrwee0m1e2s2EGtolfc3xRz 17 | fhZN32td64FiBv8gGgoH+Mfu6wLGexVAUhJdcvTZL6wyaZwLlfMiCK0iPzv9PoY2 18 | 6p2VlAwpbM8OsUe5MdvgWdsJ/Lb6jm8uXK7uVMfY4EupkVvCkQ5rTbk7nTl1rgVO 19 | 5Ti1QOVrqwKBgFe1d2e5rA6dlhAq05um/USWME/LWPQR+90UxqjxVABFIFpA7aAh 20 | 3xgXm1rLlBgzsshzm3N+ck+1MYLOrfhDke09QLhbtzwUeZTXtm3QU7d6XFI3rpve 21 | 3Y2BFWnQ24hxbCjFbgxzve8jZjK6IXqUCHj036ladYAAGIlJgQubDYPXAoGBALr1 22 | YU7Qhv6BxITNEiqlLro+Y79T3H+WkqcCKKoGjkMjFK0ak3EZaq3lbmRpwRS1s+y8 23 | sKTFnIpm8kz5CUarq6ooSa23YcnREbwbKgO8OCAQllv+UIqkdVCq5UkjTq7bCz7B 24 | wj2BMKmfSVVZcBx4eTXHf3fs0m882dJ8c1F1fmJPAoGBAK/DEdJVF69Ea2qUneBg 25 | Y0pLXB5uATafx/Ob1C/45LZWmq/bhrnzya7BtasjZqZq8TgYr/OhBzz3L8c1GQEb 26 | OwkgYm2HMEpxF19HqrrxCYxffc17P4itKfXkLvgBFwNraEBD83Lqt1sjjHkqNV6X 27 | nrbcoTab17oeYFI1WKreIdJB 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /internal/cmd/testdata/grpc/tls/self-signed-server.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDqjCCApKgAwIBAgIJAMbsccMGDD1zMA0GCSqGSIb3DQEBCwUAMH0xCzAJBgNV 3 | BAYTAlVTMQ8wDQYDVQQIDAZEZW5pYWwxFDASBgNVBAcMC1NwcmluZ2ZpZWxkMQww 4 | CgYDVQQKDANEaXMxIjAgBgkqhkiG9w0BCQEWE3NlcnZlckBzZXJ2ZXIubG9jYWwx 5 | FTATBgNVBAMMDHNlcnZlci5sb2NhbDAgFw0xOTAzMDkyMTQxNDBaGA8yMTE5MDIx 6 | MzIxNDE0MFowfTELMAkGA1UEBhMCVVMxDzANBgNVBAgMBkRlbmlhbDEUMBIGA1UE 7 | BwwLU3ByaW5nZmllbGQxDDAKBgNVBAoMA0RpczEiMCAGCSqGSIb3DQEJARYTc2Vy 8 | dmVyQHNlcnZlci5sb2NhbDEVMBMGA1UEAwwMc2VydmVyLmxvY2FsMIIBIjANBgkq 9 | hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6m8Mlkfb7TSuZk8nfv4pMRN4Ad/p8jQb 10 | 6NWiuHBcOAFQE97ximbXzEYQdt9N8hJHeHC+Fz9zwk4nPgiDpGhz9vvyfiyzrEet 11 | bFvEKbzqDwxh4cXiyWMRWvompP6nAf9hnZPsgra2j5nUgVg1bQ8dppDY5YvZUxyg 12 | /r83N1CHRgTHxHuuK9BUjRzZwUH0K31+AspuS1awxXW0BMyVIwBJstfr4O2GHuX+ 13 | UY3wq7Q0rao4BVxaodKhkEDiSXunvQRqydmq2rwctWEP1wbz7gotymT9z6usR3Xy 14 | +B013XQYz8teed8Sz0FsjzEgq5U6BGD6+tnBNZBZPkDXugHoqoJntQIDAQABoysw 15 | KTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIF4DAPBgNVHREECDAGhwR/AAABMA0GCSqG 16 | SIb3DQEBCwUAA4IBAQBBQPHAd6ecmyCPY5u5J0N7ZiaVHf9oTjKqMDd8JbzieuBY 17 | Bj1J9J3J5L63E45EpoqNDzdXzD86yweydhZz6tvtEGRH0r/mAJJ6PbePRAs6wMSr 18 | jatHTXCLkbODrGcd+xDvi4Aq3+UdopyXap+wxJdAAuTmh/DVOBOe4jLQFFee3tdq 19 | lqCq8dhHgEzs3wNHeaNNxVIWJIVWEs5Xkk8nEEK5e4N142/k9Qk7KSf8HJA2F7Im 20 | jwlLT62jPS57zCkljs+uzEe+6HJ4QjTCJ6tbk4RFNlltExWalubguMpTPgA6/9Qj 21 | eab0jQ/tvD/nbvWteGhHUXckGOttiZwPRpxIlbMW 22 | -----END CERTIFICATE----- 23 | -------------------------------------------------------------------------------- /internal/cmd/testdata/grpc/tls/self-signed-server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDqbwyWR9vtNK5m 3 | Tyd+/ikxE3gB3+nyNBvo1aK4cFw4AVAT3vGKZtfMRhB2303yEkd4cL4XP3PCTic+ 4 | CIOkaHP2+/J+LLOsR61sW8QpvOoPDGHhxeLJYxFa+iak/qcB/2Gdk+yCtraPmdSB 5 | WDVtDx2mkNjli9lTHKD+vzc3UIdGBMfEe64r0FSNHNnBQfQrfX4Cym5LVrDFdbQE 6 | zJUjAEmy1+vg7YYe5f5RjfCrtDStqjgFXFqh0qGQQOJJe6e9BGrJ2aravBy1YQ/X 7 | BvPuCi3KZP3Pq6xHdfL4HTXddBjPy1553xLPQWyPMSCrlToEYPr62cE1kFk+QNe6 8 | Aeiqgme1AgMBAAECggEBAN9qj4tU1lI8Z4xXGSPconMDw9W9iB3r7UE7AAVYB3rU 9 | PXWCfZzRoA0sJJq0+3qcUwKEJ5TOQsrFYn6q7JItfX6+4329qkmgUbU3yz2frUxE 10 | F7Brv1L/l9WlGlkZ2x17PZNIGxkDef5msu/Fmbzir/ZCioJQgf/EA+ZjYwLTOufM 11 | 6YYudo6TvLB0/xekPfXyLh/oY+6bLqXAL1GHprspBOFBKt7rVelfZlHf0zq2rTfl 12 | mKObmTEofzdXiQNAx/lWSWDny55pp8Y/YVb3Ww15eSIa0yoaNOL7/byLQ6CIYXCQ 13 | G5jpY1nPSH89K+/EZBGOi/XEHGpgLiCWfxeH76xZ/K0CgYEA9mjlXH/xOWGTa3ms 14 | j6QfaNsKujhcQPaLbUup7V72dv7sJvihQAb4V7uu5+auzMdjz/r5tIT2MfwueXDC 15 | nMwtLLl4BbT4Sobg/3r7yYboSHm7H7tPCfHPWFKw3kv0hKg9jOwHBGV2c/i7BW0s 16 | UsYxLdBSzhSL4CMVgzSD6Sh4c/cCgYEA847Up6smHwa493XdtsIvXCJZPNf0bUV4 17 | WF2c6fM/5gxR7XooX3hwF8PY215uoH9tnhyCZSKYuuHxO3UFFlOql0+XvC6Z0dRc 18 | yojj2pEV9R8y+/XR7Q4mx4jFv7lru3ugcWVLXgk/JIRJ3fy3dkJYMXRrnjhM6NIH 19 | AO4U50uIvrMCgYARxs+FNNW6RgfUoRqJ4lVBw0uq05YUObUlVWgU79zoCMwQo68+ 20 | Z0JTUf70S/ggXeIdhwWsuErqoD7aFAB2P2Si7V5zSvL+rWxeAglYKJtpXx7Y0zKI 21 | jSFgRdbssp4ZU+nc2MpIzukUxMT5Rz8DWbkCjRzsMR9GNEHBDXDWyUynUQKBgEMt 22 | NgI49n7AP+whGlH6JU3oO2zIs6Yf7x2QVGNCsHEnHMG/W7tZYLFtVzbKSQEDpJxj 23 | iKOUc0O4ZezcTdbmpLqvPU6uG8cAJ8fFEfOK6N9/B3TvTENyD8ghNUm4PrqrUol0 24 | QuFg84WC50zPE1sO2Xxqe/Rb2vqsUzoycJmK/+B5AoGBANJKdfeK1SQ26P6OdnpG 25 | GzTNLvGYS00xhO6OmEnYjieaeX76ub/k3uQZB7SrzBrN/lHEOnjXKPS4Cchtr3IB 26 | /j+w4wtdG6vA5dRLoN8zDptmPinJPzVwvlu/X/ofaaXpphEuV9lkCpzn4zPFC2Tn 27 | DGeZxYkDsoE5gwB25SiFi//c 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /internal/cmd/testdata/grpc/tls/server.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEMTCCAhmgAwIBAgIRAMTOBLoHKcIhvg5r0yi9isowDQYJKoZIhvcNAQELBQAw 3 | ETEPMA0GA1UEAxMGY2FjZXJ0MB4XDTE5MDMwOTIxNDEzOFoXDTIwMDkwOTIxNDEz 4 | NlowETEPMA0GA1UEAxMGc2VydmVyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB 5 | CgKCAQEArxCOOhqYanFgVkvMKb2MiH6roqd/2Wa5zkZOxFSbcalou6XVr0ccI1rB 6 | C+4361krCV6NIocvNxFvbULpAEquxC5hPVW69lg5l1wZKtk8+ZehC5a1UIHyy/Ol 7 | lym5hMshC5WGPTWvUmijqVcH7rSGwhbDX5aquWlnRx92TDKsVHK7yA6Abimt8XxA 8 | 8sauguHJ6q4uGRlDM1RFec6fSa4+YdBimxxAQAH9DFsvVYT7bfCjLtYF1A2SAjx/ 9 | Vvdh0foUJ6XT0o67ooucaZLkoXLAIf/v2LIoTzBSqtGoQAyHYtv9FaCJxkf/ktTi 10 | kh8UG7e/CnGcK4rt67VzUzIvj+zbEQIDAQABo4GDMIGAMA4GA1UdDwEB/wQEAwID 11 | uDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwHQYDVR0OBBYEFJIIFkKZ 12 | mbe/JSiObqYIluFv5AytMB8GA1UdIwQYMBaAFC62K8l8s+kZDMSwitd5tIsS6FeE 13 | MA8GA1UdEQQIMAaHBH8AAAEwDQYJKoZIhvcNAQELBQADggIBAGH7kgeV7NdMTgmS 14 | IUhffssB3bT02WjSNuMfdeTRXqRYgYevEOt/+eaYl60lRWRAtIS/2t1iQuIWQY4U 15 | wQ3jiAB9HFEURDNhrQSeFnqor/qtzawD+o1JjpKIjbj/1D5QR6VeBXxHmUk7VM2q 16 | 4JPvuCKhLUzCBTMhTk7XmjE/y/dEb17XXsQsfFDfB7efEdWUyv/X6WYVK9uhWWYp 17 | bkML+RzvoRQZ8A4oxn7WZCvGvVc16PIHQx6pAtjWmbS78pGHAOGI7rI0mOOmMMtr 18 | GjQYNrhM3ENmZIblJZ7lcxB0LR4hN+tSt+I2qHgrRlC1+aiuDjDbeUX3W/Hw6gVd 19 | TAlOHYIs+HeF/dm0NmDTVywSTvGhsfVqP7k+b4nhPrPKkMRItFIUMYk446UTIIw9 20 | ZbvC7vEDBxuThQ3cDlr2kJYOn9l0rpUY/7mcvRok/bGLIGGVeBv2YRrpC7db5bRe 21 | 70p720mC7Ugc8p9GuDQPYN3kxtYaKLgVpSESHphaybwxtC4JjixBlayh3vGAObVI 22 | x0k23g+Awv2QznkFpt8QCXe9b+SmKVVziybp4CuVWck8zH27v8zflwgLslHmzWk2 23 | kGSgOeJHvj/ayr37VPK+1jojQYiBb8fPCNS/eWrDRd9XKJa6gO3NTjPdXQlB1pvL 24 | TR6KBpLH8c5GU5aBtiyavRktP/XF 25 | -----END CERTIFICATE----- 26 | -------------------------------------------------------------------------------- /internal/cmd/testdata/grpc/tls/server.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIICeDCCAWACAQAwETEPMA0GA1UEAxMGc2VydmVyMIIBIjANBgkqhkiG9w0BAQEF 3 | AAOCAQ8AMIIBCgKCAQEArxCOOhqYanFgVkvMKb2MiH6roqd/2Wa5zkZOxFSbcalo 4 | u6XVr0ccI1rBC+4361krCV6NIocvNxFvbULpAEquxC5hPVW69lg5l1wZKtk8+Zeh 5 | C5a1UIHyy/Ollym5hMshC5WGPTWvUmijqVcH7rSGwhbDX5aquWlnRx92TDKsVHK7 6 | yA6Abimt8XxA8sauguHJ6q4uGRlDM1RFec6fSa4+YdBimxxAQAH9DFsvVYT7bfCj 7 | LtYF1A2SAjx/Vvdh0foUJ6XT0o67ooucaZLkoXLAIf/v2LIoTzBSqtGoQAyHYtv9 8 | FaCJxkf/ktTikh8UG7e/CnGcK4rt67VzUzIvj+zbEQIDAQABoCIwIAYJKoZIhvcN 9 | AQkOMRMwETAPBgNVHREECDAGhwR/AAABMA0GCSqGSIb3DQEBCwUAA4IBAQCZlmJN 10 | nnq0UoM12zzyyEmnAqohLPg+ucyi/uRDjOCQy+IZRdyUtJ68y6V9sBf7Ye+DDzGT 11 | P9H4K3EJ8Wd1n1rx0SA/ZigE+qqmDXWzgTaDfxL73DMV+myuvRscZl1tpzCAuTN6 12 | K2mrPXyboFrzl0OUU7H5WQ8NZrhe5ARPcmfQeUyVVRUcb4Kcw7mc8AV/MBmRIDK1 13 | FI+6bTq01ivSdIWCe77aYw05JsvQaqN26qLsM/hOYW/CGN50bM/2iGu1w0wFPGoQ 14 | NX0uVWGlgo1CAib12uyF3z0UsppchozGd3pBdNwACLcGoDNLfm6au+YxMc3cKXnp 15 | I8lGlLiBskMVecsD 16 | -----END CERTIFICATE REQUEST----- 17 | -------------------------------------------------------------------------------- /internal/cmd/testdata/grpc/tls/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpAIBAAKCAQEArxCOOhqYanFgVkvMKb2MiH6roqd/2Wa5zkZOxFSbcalou6XV 3 | r0ccI1rBC+4361krCV6NIocvNxFvbULpAEquxC5hPVW69lg5l1wZKtk8+ZehC5a1 4 | UIHyy/Ollym5hMshC5WGPTWvUmijqVcH7rSGwhbDX5aquWlnRx92TDKsVHK7yA6A 5 | bimt8XxA8sauguHJ6q4uGRlDM1RFec6fSa4+YdBimxxAQAH9DFsvVYT7bfCjLtYF 6 | 1A2SAjx/Vvdh0foUJ6XT0o67ooucaZLkoXLAIf/v2LIoTzBSqtGoQAyHYtv9FaCJ 7 | xkf/ktTikh8UG7e/CnGcK4rt67VzUzIvj+zbEQIDAQABAoIBAGX6ze9ZCMqQ6x66 8 | Ht991Ly6lX819csOBVT9Les+oiKPHjyZeSYW1XRe7K/ngFmv4tsdYjfn6gA5PuC2 9 | JocN+kq7/dc99qCEemAKvXpxfAylYKIgk9SnLmnSr/ajzrdloQVfgAhuGoh1/kiq 10 | MyvBq/KqUfuACEnj9c6/rCjtJ+g0ytCUpai4XyhN8QbDHbCUuVuJLIKdj6gU05hf 11 | Opbl00OvT7a+VmCdzN/ajJj1/+7eKFdq5xjbSAB8JflPwiewnZ5SpK4w45P74GMd 12 | ySo5Ek7NRHXnHZ8AV//XbcSqshsL3Xn2/Uv6YWG1VgolbzTV7RcE0G/nniIgXwmh 13 | s0/xuKUCgYEA4Ghk4hGX5nMPcdSsF1HGQWR6gy7PZAQiUXjC1FVoOgb1DfJr6xsK 14 | DSNWoxnOCpV4Kw4arbFyrutTX8FtJYBIRXg2tY+hGJSO4X4TRP3Dv6r8sMKLIpWb 15 | TmjiVijD9iio+cpeqYXpJrEj88UQ9QII6vVTq/IVVoEx+5T3D8/I+o8CgYEAx7XY 16 | vncwxSK5pXpOFi2OuP9QoPxQEOODLHNYJlnM4sUR2fBx9oIrJrsbu5W4UPAWTfBj 17 | stLMjnPvwIyW/I8nKralxNYo1DG2L0aSrB5T3MIlKWEcTaRMebEOrAhaijObnDJG 18 | m79Guz4CVzDPslVjhmRFRToD+mR+x4h5TjWaIF8CgYEAmAZhAb4Fd/tO5UC8bPfb 19 | JYXacXCO0yTx0tvKsWpCt7zq2s32SkoBHzFnigr7SLRFunVNoYnrNZD65I33UUZ8 20 | r4NnHMz2x94shZqRl1WK/RfrJBxHgeB0XEQ1wUTQrLyS7NYqFxI/BxVOU+CXQkRk 21 | ojgcvQm9ZuMTZ2pdjXqonwUCgYAWugj6U9IG/RanUC3GtFSDlPp194CdC2cIDfBA 22 | HQQF4mtPo980MEf81lonlLgu7cN8BxkxZm/E3kiwXs9n2lqYr8RZjA2FaErVQnC6 23 | iZD9lFJqTRTNeR8C0jVbOnAjPhA9TDNg0fmYoUve5D0ejD0RNCP15s5BFmKfDlbP 24 | oaXyfQKBgQCoZBBF9IE67CtvusTL8sC3RlkmEWgOnMQy2B/shHuhBUqQEeBAvyQN 25 | vq+8DDvJ3jSDb1kdXaHsl4YXbst4tZ5f2fJWavegJMzuHteTYIO7qj7fB9wWqFWp 26 | AQggfmRK8zX3+sMmDrLa5xx8NrsM59ir3SGIOqnpJguAcAxiKtctLQ== 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/afterservice/foo/v1/hello2api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "Hello2apiProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | message SendFoo2Request {} 14 | 15 | message SendFoo2Response {} 16 | 17 | // Hello2API is the second HelloAPI. 18 | service Hello2API { 19 | // SendFoo2 sends foos. 20 | rpc SendFoo2(SendFoo2Request) returns (SendFoo2Response); 21 | } 22 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/afterservice/foo/v1/hello3api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "Hello3apiProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | // Hello2API is the third HelloAPI. 14 | service Hello3API { 15 | // SendFoo3 sends foos. 16 | rpc SendFoo3(SendFoo3Request) returns (SendFoo3Response); 17 | } 18 | 19 | message SendFoo3Response {} 20 | 21 | message SendFoo3Request {} 22 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/afterservice/foo/v1/hello_api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "HelloApiProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | message SendFooRequest {} 14 | 15 | // HelloAPI is the first HelloAPI. 16 | service HelloAPI { 17 | // SendFoo sends foos. 18 | rpc SendFoo(SendFooRequest) returns (SendFooResponse); 19 | } 20 | 21 | message SendFooResponse {} 22 | 23 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/afterservice/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/allgroup/bar/dep.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package bar; 4 | 5 | option go_package = "barpb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "BarProto"; 8 | option java_package = "com.bar"; 9 | 10 | // Dep is a dep. 11 | message Dep { 12 | int64 hello = 1; 13 | } 14 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/allgroup/lots.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.bAr; 4 | 5 | import "bar/dep.proto"; 6 | 7 | message baz {} 8 | 9 | message Baz_bat {} 10 | 11 | message Bat { 12 | int64 Hello = 1; 13 | int64 helloWorld = 2; 14 | int64 hello_world_one_ = 3; 15 | int64 _hello_world_two = 4; 16 | int64 hello_world_three = 5; 17 | // normal comment 18 | int64 world = 6; // normal inline comment 19 | /* 20 | c-style comment 21 | */ 22 | int64 world2 = 7; 23 | int64 world3 = 8; /* c-style inline comment */ 24 | } 25 | 26 | service hello {} 27 | 28 | service World_woot {} 29 | 30 | message FooRequest {} 31 | message FooResponse {} 32 | 33 | 34 | message BarOneRequest { 35 | // message Foo 36 | message Hello {} 37 | } 38 | message BarOneResponse {} 39 | 40 | message Boo { 41 | message BooRequest {} 42 | } 43 | 44 | service Foobar { 45 | rpc Foo(FooRequest) returns (FooResponse) {} 46 | rpc FooOne(FooRequest) returns (FooResponse) {} 47 | rpc FooTwo(FooRequest) returns (FooResponse) {} 48 | rpc barOne(BarOneRequest) returns (BarOneResponse) {} 49 | rpc BarTwo(FooRequest) returns (bar.Dep) {} 50 | rpc Boo(Boo.BooRequest) returns (bar.Dep) {} 51 | } 52 | 53 | enum Hello { 54 | HELLO_INVALID = 0; 55 | HELLO_UNSET = 1; 56 | HELLO_TREE = 2; 57 | HELLO_BALLOON = 3; 58 | FOO_LAMP_POST = 4; 59 | } 60 | 61 | message Foo { 62 | message Bar { 63 | enum Baz { 64 | BAZ_INVALID = 0; 65 | } 66 | enum Bat { 67 | FOO_BAR_BAT_NONE = 0; 68 | } 69 | } 70 | } 71 | 72 | enum Bar { 73 | BAR_NONE = 0; 74 | } 75 | 76 | /* c-style file comment */ 77 | 78 | message Woo { 79 | /* c-style reserved comment */ 80 | reserved 10; 81 | /* c-style oneof comment */ 82 | oneof woo { 83 | /* c-style oneof field comment */ 84 | int64 field = 1; 85 | } 86 | } 87 | 88 | enum Hoo { 89 | HOO_INVALID = 0; 90 | HOO_one = 1; 91 | } 92 | 93 | enum Hoo_one { 94 | HOO_ONE_INVALID = 0; 95 | } 96 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/allgroup/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | rules: 3 | add: 4 | - ENUM_FIELD_NAMES_UPPERCASE 5 | - ENUMS_HAVE_COMMENTS 6 | - FILE_OPTIONS_UNSET_JAVA_MULTIPLE_FILES 7 | - FILE_OPTIONS_UNSET_JAVA_OUTER_CLASSNAME 8 | - MESSAGE_FIELDS_NOT_FLOATS 9 | - MESSAGES_HAVE_COMMENTS 10 | - MESSAGES_HAVE_COMMENTS_EXCEPT_REQUEST_RESPONSE_TYPES 11 | - MESSAGE_FIELD_NAMES_LOWERCASE 12 | - REQUEST_RESPONSE_NAMES_MATCH_RPC 13 | - RPCS_HAVE_COMMENTS 14 | - SERVICES_HAVE_COMMENTS 15 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/apisuffix/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "FooProto"; 8 | option java_package = "com.foo"; 9 | 10 | service HelloService {} 11 | 12 | service Hello {} 13 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/apisuffix/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | rules: 3 | add: 4 | - SERVICE_NAMES_API_SUFFIX 5 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/base/base_file.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/base/prototool.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/cmd/testdata/lint/base/prototool.yaml -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/capitalized/message_name_not_capitalized.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "MessageNameNotCapitalizedProto"; 8 | option java_package = "com.foo"; 9 | 10 | // baz is a baz. 11 | message baz { 12 | int64 hello = 1; 13 | } 14 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/capitalized/prototool.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/cmd/testdata/lint/capitalized/prototool.yaml -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/empty/base_file.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/empty/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: empty 3 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/emptycustom/base_file.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/emptycustom/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: empty 3 | rules: 4 | add: 5 | - RPC_NAMES_CAMEL_CASE 6 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/enumexceptmessages/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "FooProto"; 8 | option java_package = "com.foo"; 9 | 10 | enum One { 11 | ONE_INVALID = 0; 12 | ONE_ONE = 1; 13 | } 14 | 15 | enum OneBad { 16 | INVALID = 0; 17 | ONE = 1; 18 | } 19 | 20 | enum OneBadTwo { 21 | FOO = 0; 22 | } 23 | 24 | message Bar { 25 | enum One { 26 | ONE_INVALID = 0; 27 | ONE_ONE = 1; 28 | } 29 | 30 | enum OneBad { 31 | INVALID = 0; 32 | ONE = 1; 33 | } 34 | 35 | enum OneBadTwo { 36 | FOO = 0; 37 | } 38 | 39 | message Baz { 40 | enum One { 41 | ONE_INVALID = 0; 42 | ONE_ONE = 1; 43 | } 44 | 45 | enum OneBad { 46 | INVALID = 0; 47 | ONE = 1; 48 | } 49 | 50 | enum OneBadTwo { 51 | FOO = 0; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/enumexceptmessages/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | rules: 3 | add: 4 | - ENUM_FIELD_PREFIXES_EXCEPT_MESSAGE 5 | - ENUM_ZERO_VALUES_INVALID_EXCEPT_MESSAGE 6 | remove: 7 | - ENUM_FIELD_PREFIXES 8 | - ENUM_ZERO_VALUES_INVALID 9 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/fieldnamesfilename/hello.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "HelloProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | message Foo { 14 | message NestedFoo { 15 | message NestedNestedFoo { 16 | string sfile_name = 1; 17 | oneof hello { 18 | string file_name = 2; 19 | } 20 | } 21 | string sfile_names = 1; 22 | } 23 | string file_names = 1; 24 | map map_file_name = 2; 25 | } 26 | 27 | message Bar { 28 | message NestedBar { 29 | message NestedNestedBar { 30 | string sfile_path = 1; 31 | oneof hello { 32 | string file_path = 2; 33 | } 34 | } 35 | string sfile_paths = 1; 36 | } 37 | string file_paths = 1; 38 | map map_file_path = 2; 39 | } 40 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/fieldnamesfilename/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | rules: 4 | remove: 5 | - ENUMS_HAVE_SENTENCE_COMMENTS 6 | - MESSAGES_HAVE_SENTENCE_COMMENTS_EXCEPT_REQUEST_RESPONSE_TYPES 7 | - RPCS_HAVE_SENTENCE_COMMENTS 8 | - SERVICES_HAVE_SENTENCE_COMMENTS 9 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/fieldscomments/foo/v1/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "FooProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | // A one. 14 | enum One { 15 | ONE_INVALID = 0; 16 | } 17 | 18 | // A two. 19 | message Two { 20 | // A three. 21 | message Three { 22 | // A four. 23 | enum Four { 24 | FOUR_INVALID = 0; 25 | } 26 | int64 six = 1; 27 | map seven = 2; 28 | oneof eight { 29 | int64 nine = 3; 30 | } 31 | } 32 | // A five. 33 | enum Five { 34 | FIVE_INVALID = 0; 35 | } 36 | int64 ten = 1; 37 | map eleven = 2; 38 | oneof twelve { 39 | int64 fourteen = 3; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/fieldscomments/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | rules: 4 | add: 5 | - ENUM_FIELDS_HAVE_COMMENTS 6 | - MESSAGE_FIELDS_HAVE_COMMENTS 7 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/fieldssentencecomments/foo/v1/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "FooProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | // A one. 14 | enum One { 15 | ONE_INVALID = 0; 16 | } 17 | 18 | // A two. 19 | message Two { 20 | // A three. 21 | message Three { 22 | // A four. 23 | enum Four { 24 | FOUR_INVALID = 0; 25 | } 26 | int64 six = 1; 27 | map seven = 2; 28 | oneof eight { 29 | int64 nine = 3; 30 | } 31 | } 32 | // A five. 33 | enum Five { 34 | FIVE_INVALID = 0; 35 | } 36 | int64 ten = 1; 37 | map eleven = 2; 38 | oneof twelve { 39 | int64 fourteen = 3; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/fieldssentencecomments/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | rules: 4 | add: 5 | - ENUM_FIELDS_HAVE_SENTENCE_COMMENTS 6 | - MESSAGE_FIELDS_HAVE_SENTENCE_COMMENTS 7 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/fieldstimeduration/hello.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "HelloProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | message Foo { 14 | message NestedFoo { 15 | message NestedNestedFoo { 16 | string stime = 1; 17 | oneof hello { 18 | string time = 2; 19 | } 20 | } 21 | string stimes = 1; 22 | } 23 | string times = 1; 24 | map map_time = 2; 25 | } 26 | 27 | message Bar { 28 | message NestedBar { 29 | message NestedNestedBar { 30 | string sfile_duration = 1; 31 | oneof hello { 32 | string file_duration = 2; 33 | } 34 | } 35 | string sfile_durations = 1; 36 | } 37 | string file_durations = 1; 38 | map map_file_duration = 2; 39 | } 40 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/fieldstimeduration/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | rules: 4 | add: 5 | - MESSAGE_FIELDS_DURATION 6 | - MESSAGE_FIELDS_TIME 7 | remove: 8 | - ENUMS_HAVE_SENTENCE_COMMENTS 9 | - MESSAGES_HAVE_SENTENCE_COMMENTS_EXCEPT_REQUEST_RESPONSE_TYPES 10 | - RPCS_HAVE_SENTENCE_COMMENTS 11 | - SERVICES_HAVE_SENTENCE_COMMENTS 12 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/filename/fileNameInvalid.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "FileNameInvalidProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/filename/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/fileoptions/file_options_incorrect.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "barpb"; 6 | option java_multiple_files = false; 7 | option java_outer_classname = "FileOptionsIncorrect"; 8 | option java_package = "com.bar"; 9 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/fileoptions/prototool.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/cmd/testdata/lint/fileoptions/prototool.yaml -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/fileoptionsjava/file_options_incorrect.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option csharp_namespace = "Foo"; 6 | option go_package = "foopb"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "FileOptionsIncorrectProto"; 9 | option java_package = "com.foo"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo"; 12 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/fileoptionsjava/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | java_package_prefix: au.com 4 | rules: 5 | remove: 6 | - PACKAGE_MAJOR_BETA_VERSIONED 7 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/floats/foo/v1/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "FooProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | message One { 14 | // This is a field we are ok with having floats. 15 | // 16 | // @suppresswarnings floats 17 | float one = 1; 18 | // @suppresswarnings floats 19 | float two = 2; 20 | float three = 3; 21 | float four = 4; 22 | double five = 5; 23 | } 24 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/floats/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | # allow_suppression is an option that is only allowed in tests, this is not exposed as part of the prototool command 4 | allow_suppression: true 5 | rules: 6 | add: 7 | - MESSAGE_FIELDS_NOT_FLOATS 8 | remove: 9 | - ENUMS_HAVE_SENTENCE_COMMENTS 10 | - MESSAGES_HAVE_SENTENCE_COMMENTS_EXCEPT_REQUEST_RESPONSE_TYPES 11 | - RPCS_HAVE_SENTENCE_COMMENTS 12 | - SERVICES_HAVE_SENTENCE_COMMENTS 13 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/floatsnosuppress/foo/v1/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "FooProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | message One { 14 | // This is a field we are ok with having floats. 15 | // 16 | // @suppresswarnings floats 17 | float one = 1; 18 | // @suppresswarnings floats 19 | float two = 2; 20 | float three = 3; 21 | float four = 4; 22 | double five = 5; 23 | } 24 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/floatsnosuppress/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | rules: 4 | add: 5 | - MESSAGE_FIELDS_NOT_FLOATS 6 | remove: 7 | - ENUMS_HAVE_SENTENCE_COMMENTS 8 | - MESSAGES_HAVE_SENTENCE_COMMENTS_EXCEPT_REQUEST_RESPONSE_TYPES 9 | - RPCS_HAVE_SENTENCE_COMMENTS 10 | - SERVICES_HAVE_SENTENCE_COMMENTS 11 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/gogonotimported/gogo/gogo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package gogo; 4 | 5 | option go_package = "gogopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "GogoProto"; 8 | option java_package = "com.gogo"; 9 | 10 | message Gogo {} 11 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/gogonotimported/gogonotimported.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "GogonotimportedProto"; 8 | option java_package = "com.foo"; 9 | 10 | import "gogo/gogo.proto"; 11 | 12 | message Foo { 13 | gogo.Gogo gogo = 1; 14 | } 15 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/gogonotimported/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | rules: 3 | add: 4 | - GOGO_NOT_IMPORTED 5 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/gopackagelongform/gopackagelongform.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "path/to/foo;foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "GopackagelongformProto"; 8 | option java_package = "com.foo"; 9 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/gopackagelongform/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | rules: 3 | remove: 4 | - FILE_OPTIONS_EQUAL_GO_PACKAGE_PB_SUFFIX 5 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/ignoredir/bar/v1/bar.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package bar.v1; 4 | 5 | option csharp_namespace = "Bar.V1"; 6 | option go_package = "barv1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "BarProto"; 9 | option java_package = "com.bar.v1"; 10 | option objc_class_prefix = "BXX"; 11 | option php_namespace = "Bar\\V1"; 12 | 13 | message Bar { 14 | float one = 1; 15 | } 16 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/ignoredir/foo/v1/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "FooProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | message One { 14 | float one = 1; 15 | } 16 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/ignoredir/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | rules: 4 | add: 5 | - MESSAGE_FIELDS_NOT_FLOATS 6 | remove: 7 | - ENUMS_HAVE_SENTENCE_COMMENTS 8 | - MESSAGES_HAVE_SENTENCE_COMMENTS_EXCEPT_REQUEST_RESPONSE_TYPES 9 | - RPCS_HAVE_SENTENCE_COMMENTS 10 | - SERVICES_HAVE_SENTENCE_COMMENTS 11 | ignores: 12 | - id: MESSAGE_FIELDS_NOT_FLOATS 13 | files: 14 | - bar/v1 15 | - foo/v11 16 | 17 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/importsnotpublic/bar/bar.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package bar; 4 | 5 | option go_package = "barpb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "BarProto"; 8 | option java_package = "com.bar"; 9 | 10 | message Bar { 11 | int64 hello = 1; 12 | } 13 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/importsnotpublic/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "FooProto"; 8 | option java_package = "com.foo"; 9 | 10 | import public "bar/bar.proto"; 11 | 12 | message Foo { 13 | int64 hello = 1; 14 | bar.Bar bar = 2; 15 | } 16 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/importsnotpublic/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | rules: 3 | add: 4 | - IMPORTS_NOT_PUBLIC 5 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/importsnotweak/bar/bar.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package bar; 4 | 5 | option go_package = "barpb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "BarProto"; 8 | option java_package = "com.bar"; 9 | 10 | message Bar { 11 | int64 hello = 1; 12 | } 13 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/importsnotweak/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "FooProto"; 8 | option java_package = "com.foo"; 9 | 10 | import weak "bar/bar.proto"; 11 | 12 | message Foo { 13 | int64 hello = 1; 14 | bar.Bar bar = 2; 15 | } 16 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/importsnotweak/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | rules: 3 | add: 4 | - IMPORTS_NOT_WEAK 5 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/inlinecomments/foo/v1/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; // inline comment 2 | 3 | package foo.v1; // inline comment 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; // inline comment 7 | option java_multiple_files = true; 8 | option java_outer_classname = "FooProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | enum FooType { 14 | FOO_TYPE_INVALID = 0; 15 | FOO_TYPE_UNSET = 1; // inline comment 16 | FOO_TYPE_BALLOON = 2; 17 | FOO_TYPE_TREE = 3; 18 | } 19 | 20 | message Foo { 21 | FooType type = 1; // inline comment 22 | sint32 latitude_micros = 3; 23 | sint32 longitude_micros = 4; 24 | string bar_id = 5; 25 | } 26 | 27 | message Bar { 28 | message Nested { 29 | enum Type { 30 | TYPE_INVALID = 0; // inline comment 31 | TYPE_UNSET = 1; 32 | TYPE_REMOTE_CONTROL = 2; 33 | TYPE_FAN = 3; 34 | } 35 | Type type = 1; 36 | string id = 2; // inline comment 37 | repeated string planet_ids = 3; // inline comment 38 | map map_ids = 4; // inline comment 39 | } 40 | enum Type { 41 | TYPE_INVALID = 0; // inline comment 42 | TYPE_UNSET = 1; 43 | TYPE_REMOTE_CONTROL = 2; 44 | TYPE_FAN = 3; 45 | } 46 | Type type = 1; 47 | string id = 2; // inline comment 48 | repeated string planet_ids = 3; // inline comment 49 | map map_ids = 4; // inline comment 50 | } 51 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/inlinecomments/foo/v1/hello_api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "HelloApiProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | import "foo/v1/foo.proto"; // inline comment 14 | 15 | service HelloAPI { 16 | rpc SendFoo(SendFooRequest) returns (SendFooResponse); // inline comment 17 | } 18 | 19 | message SendFooRequest { 20 | Foo foo = 1; 21 | } 22 | 23 | message SendFooResponse {} 24 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/inlinecomments/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | rules: 4 | remove: 5 | - ENUMS_HAVE_SENTENCE_COMMENTS 6 | - MESSAGES_HAVE_SENTENCE_COMMENTS_EXCEPT_REQUEST_RESPONSE_TYPES 7 | - RPCS_HAVE_SENTENCE_COMMENTS 8 | - SERVICES_HAVE_SENTENCE_COMMENTS 9 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/keyword/package_starts_with_keyword.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package group.v1; 4 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/keyword/prototool.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/cmd/testdata/lint/keyword/prototool.yaml -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/lots/bar/dep.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package bar; 4 | 5 | option go_package = "barpb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "BarProto"; 8 | option java_package = "com.bar"; 9 | 10 | // Dep is a dep. 11 | message Dep { 12 | int64 hello = 1; 13 | } 14 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/lots/prototool.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/cmd/testdata/lint/lots/prototool.yaml -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/majorbetaversioned/foo/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "FooProto"; 8 | option java_package = "com.foo"; 9 | 10 | message Bar { 11 | int64 hello = 1; 12 | } 13 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/majorbetaversioned/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | rules: 3 | add: 4 | - PACKAGE_MAJOR_BETA_VERSIONED 5 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/naming/foo/v1/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "FooProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | enum CommonEnum { 14 | COMMON_ENUM_INVALID = 0; 15 | } 16 | 17 | enum DataEnum { 18 | DATA_ENUM_INVALID = 0; 19 | } 20 | 21 | enum UuidEnum { 22 | UUID_ENUM_INVALID = 0; 23 | } 24 | 25 | message Common { 26 | message UUID { 27 | enum HelloUUID { 28 | HELLO_UUID_INVALID = 0; 29 | } 30 | int64 dummy = 1; 31 | } 32 | int64 dummy = 1; 33 | } 34 | 35 | message DataCommon { 36 | int64 dummy = 1; 37 | } 38 | 39 | message UUID { 40 | reserved "foo_data"; 41 | 42 | oneof data { 43 | int64 common = 1; 44 | } 45 | } 46 | 47 | service FooCommonAPI { 48 | rpc Common(Request) returns (Response); 49 | } 50 | 51 | service FooDataAPI { 52 | rpc Common(Request) returns (Response); 53 | } 54 | 55 | service FooUUIDAPI { 56 | rpc Common(Request) returns (Response); 57 | } 58 | 59 | message Request {} 60 | 61 | message Response {} 62 | 63 | message Suppressed { 64 | // @suppresswarnings naming 65 | map common = 1; 66 | } 67 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/naming/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | # allow_suppression is an option that is only allowed in tests, this is not exposed as part of the prototool command 4 | allow_suppression: true 5 | rules: 6 | remove: 7 | - ENUMS_HAVE_SENTENCE_COMMENTS 8 | - FIELDS_NOT_RESERVED 9 | - MESSAGES_HAVE_SENTENCE_COMMENTS_EXCEPT_REQUEST_RESPONSE_TYPES 10 | - REQUEST_RESPONSE_NAMES_MATCH_RPC 11 | - REQUEST_RESPONSE_TYPES_ONLY_IN_FILE 12 | - REQUEST_RESPONSE_TYPES_UNIQUE 13 | - RPCS_HAVE_SENTENCE_COMMENTS 14 | - SERVICES_HAVE_SENTENCE_COMMENTS 15 | - SERVICE_NAMES_MATCH_FILE_NAME 16 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/nodescriptor/foo/v1/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "FooProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | message One { 14 | int64 descriptor = 1; 15 | } 16 | 17 | message Two { 18 | int64 Descriptor = 1; 19 | } 20 | 21 | message Three { 22 | int64 _descriptor = 1; 23 | } 24 | 25 | message Four { 26 | int64 descriptor_ = 1; 27 | } 28 | 29 | message Five { 30 | int64 __descriptor = 1; 31 | } 32 | 33 | message Six { 34 | int64 descriptor__ = 1; 35 | } 36 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/nodescriptor/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | rules: 4 | remove: 5 | - MESSAGES_HAVE_SENTENCE_COMMENTS_EXCEPT_REQUEST_RESPONSE_TYPES 6 | - MESSAGE_FIELD_NAMES_LOWER_SNAKE_CASE 7 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/nogoogleapihttp/google/api/api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package google.api; 4 | 5 | option csharp_namespace = "Google.Api"; 6 | option go_package = "apipb"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "ApiProto"; 9 | option java_package = "com.google.api"; 10 | option objc_class_prefix = "GAX"; 11 | option php_namespace = "Google\\Api"; 12 | 13 | import "google/protobuf/descriptor.proto"; 14 | 15 | extend google.protobuf.MethodOptions { 16 | Http http = 50001; 17 | } 18 | 19 | message Http { 20 | string get = 1; 21 | } 22 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/nogoogleapihttp/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | # allow_suppression is an option that is only allowed in tests, this is not exposed as part of the prototool command 3 | allow_suppression: true 4 | group: uber2 5 | ignores: 6 | - id: PACKAGE_MAJOR_BETA_VERSIONED 7 | files: 8 | - google/api/api.proto 9 | rules: 10 | add: 11 | - RPC_OPTIONS_NO_GOOGLE_API_HTTP 12 | remove: 13 | - ENUMS_HAVE_SENTENCE_COMMENTS 14 | - MESSAGES_HAVE_SENTENCE_COMMENTS_EXCEPT_REQUEST_RESPONSE_TYPES 15 | - RPCS_HAVE_SENTENCE_COMMENTS 16 | - SERVICES_HAVE_SENTENCE_COMMENTS 17 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/nojsonname/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "FooProto"; 8 | option java_package = "com.foo"; 9 | 10 | message Foo { 11 | int64 one = 1 [json_name = "test"]; 12 | repeated int64 two = 2 [json_name = "test"]; 13 | map three = 3 [json_name = "test"]; 14 | oneof oneof_foo { 15 | int64 four = 4 [json_name = "test"]; 16 | int64 five = 5 [json_name = "test"]; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/nojsonname/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | rules: 3 | add: 4 | - MESSAGE_FIELDS_NO_JSON_NAME 5 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/nokeywords/foo/public/public.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.public; 4 | 5 | option go_package = "publicpb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "PublicProto"; 8 | option java_package = "com.foo.public"; 9 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/nokeywords/foo/public/public_suppressed.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | // @suppresswarnings keywords 4 | package foo.public; 5 | 6 | option go_package = "publicpb"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "PublicSuppressedProto"; 9 | option java_package = "com.foo.public"; 10 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/nokeywords/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | # allow_suppression is an option that is only allowed in tests, this is not exposed as part of the prototool command 3 | allow_suppression: true 4 | rules: 5 | add: 6 | - PACKAGE_NO_KEYWORDS 7 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/noplurals/foo/v1/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "FooProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | service TripAPI {} 14 | 15 | service TripsAPI {} 16 | 17 | service FooTripAPI {} 18 | 19 | service FooTripsAPI {} 20 | 21 | service FooTripBarAPI {} 22 | 23 | service FooTripsBarAPI {} 24 | 25 | service FooTripsBarsAPI {} 26 | 27 | // @suppresswarnings plurals 28 | service OperationsAPI {} 29 | 30 | // @suppresswarnings plurals 31 | service FooOperationsAPI {} 32 | 33 | // @suppresswarnings plurals 34 | service FooOperationsBarAPI {} 35 | 36 | // @suppresswarnings plurals 37 | service FooOperationsBarsAPI {} 38 | 39 | service InfoAPI {} 40 | 41 | service FooInfoAPI {} 42 | 43 | service FooInfoBarAPI {} 44 | 45 | service FooInfoBarsAPI {} 46 | 47 | // @suppresswarnings plurals 48 | service BarInfoBarsAPI {} 49 | 50 | service FooInfoBARSAPI {} 51 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/noplurals/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | # allow_suppression is an option that is only allowed in tests, this is not exposed as part of the prototool command 4 | allow_suppression: true 5 | rules: 6 | add: 7 | - SERVICE_NAMES_NO_PLURALS 8 | remove: 9 | - ENUMS_HAVE_SENTENCE_COMMENTS 10 | - MESSAGES_HAVE_SENTENCE_COMMENTS_EXCEPT_REQUEST_RESPONSE_TYPES 11 | - RPCS_HAVE_SENTENCE_COMMENTS 12 | - SERVICES_HAVE_SENTENCE_COMMENTS 13 | - SERVICE_NAMES_MATCH_FILE_NAME 14 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/noreserved/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "FooProto"; 8 | option java_package = "com.foo"; 9 | 10 | message Foo { 11 | reserved 1 to 3, 4; 12 | reserved "bar"; 13 | enum Bar { 14 | reserved 4 to 6, 7; 15 | reserved "foobar", "barfoo"; 16 | FOO_BAR_INVALID = 0; 17 | FOO_BAR_UNSET = 1; 18 | } 19 | message FooFoo { 20 | reserved 1; 21 | } 22 | } -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/noreserved/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | rules: 3 | add: 4 | - FIELDS_NOT_RESERVED 5 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/nostreaming/foo/v1/hello_api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "HelloApiProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | service HelloAPI { 14 | rpc SendFoo(SendFooRequest) returns (SendFooResponse); 15 | rpc SendBar(stream SendBarRequest) returns (SendBarResponse); 16 | rpc SendBaz(SendBazRequest) returns (stream SendBazResponse); 17 | rpc SendBat(stream SendBatRequest) returns (stream SendBatResponse); 18 | } 19 | 20 | message SendFooRequest {} 21 | 22 | message SendFooResponse {} 23 | 24 | message SendBarRequest {} 25 | 26 | message SendBarResponse {} 27 | 28 | message SendBazRequest {} 29 | 30 | message SendBazResponse {} 31 | 32 | message SendBatRequest {} 33 | 34 | message SendBatResponse {} 35 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/nostreaming/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | rules: 4 | add: 5 | - RPCS_NO_STREAMING 6 | remove: 7 | - ENUMS_HAVE_SENTENCE_COMMENTS 8 | - MESSAGES_HAVE_SENTENCE_COMMENTS_EXCEPT_REQUEST_RESPONSE_TYPES 9 | - RPCS_HAVE_SENTENCE_COMMENTS 10 | - SERVICES_HAVE_SENTENCE_COMMENTS 11 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/notempty/foo/v1/hello.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "HelloProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | message Foo { 14 | message NestedFoo { 15 | message NestedNestedFoo {} 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/notempty/foo/v1/hello_api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "HelloApiProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | service HelloAPI { 14 | rpc SendFoo(SendFooRequest) returns (SendFooResponse); 15 | } 16 | 17 | message SendFooRequest {} 18 | 19 | message SendFooResponse {} 20 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/notempty/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | rules: 4 | add: 5 | - MESSAGES_NOT_EMPTY_EXCEPT_REQUEST_RESPONSE_TYPES 6 | remove: 7 | - ENUMS_HAVE_SENTENCE_COMMENTS 8 | - MESSAGES_HAVE_SENTENCE_COMMENTS_EXCEPT_REQUEST_RESPONSE_TYPES 9 | - RPCS_HAVE_SENTENCE_COMMENTS 10 | - SERVICES_HAVE_SENTENCE_COMMENTS 11 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/onlyinfile/foo/v1/hello_api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "HelloApiProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | service HelloAPI { 14 | rpc SendFoo(SendFooRequest) returns (SendFooResponse); 15 | } 16 | 17 | message SendFooRequest { 18 | Foo foo = 1; 19 | } 20 | 21 | message SendFooResponse {} 22 | 23 | message Foo { 24 | message NestedFoo { 25 | int64 dummy = 1; 26 | } 27 | int64 dummy = 1; 28 | } 29 | 30 | enum Bar { 31 | BAR_INVALID = 0; 32 | } 33 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/onlyinfile/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | rules: 4 | remove: 5 | - ENUMS_HAVE_SENTENCE_COMMENTS 6 | - MESSAGES_HAVE_SENTENCE_COMMENTS_EXCEPT_REQUEST_RESPONSE_TYPES 7 | - RPCS_HAVE_SENTENCE_COMMENTS 8 | - SERVICES_HAVE_SENTENCE_COMMENTS 9 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/packagelowercase/foo_bar/v1/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo_bar.v1; 4 | 5 | option csharp_namespace = "Foo_bar.V1"; 6 | option go_package = "foo_barv1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "FooProto"; 9 | option java_package = "com.foo_bar.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo_bar\\V1"; 12 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/packagelowercase/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | rules: 4 | remove: 5 | - ENUMS_HAVE_SENTENCE_COMMENTS 6 | - MESSAGES_HAVE_SENTENCE_COMMENTS_EXCEPT_REQUEST_RESPONSE_TYPES 7 | - RPCS_HAVE_SENTENCE_COMMENTS 8 | - SERVICES_HAVE_SENTENCE_COMMENTS 9 | - SERVICE_NAMES_MATCH_FILE_NAME 10 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/required/file_options_required.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/required/prototool.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/cmd/testdata/lint/required/prototool.yaml -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/samedir/bar1.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package bar; 4 | 5 | option go_package = "barpb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "Bar1Proto"; 8 | option java_package = "com.bar"; 9 | 10 | message Three {} 11 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/samedir/foo1.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "Foo1Proto"; 8 | option java_package = "com.foo"; 9 | 10 | message One {} 11 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/samedir/foo2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "Foo2Proto"; 8 | option java_package = "com.foo"; 9 | 10 | message Two {} 11 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/samedir/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | rules: 3 | remove: 4 | - FILE_OPTIONS_GO_PACKAGE_SAME_IN_DIR 5 | - FILE_OPTIONS_JAVA_PACKAGE_SAME_IN_DIR 6 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/samedirgopkg/bar1.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "barpb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "Bar1Proto"; 8 | option java_package = "com.foo"; 9 | 10 | message Three {} 11 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/samedirgopkg/foo1.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "Foo1Proto"; 8 | option java_package = "com.foo"; 9 | 10 | message One {} 11 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/samedirgopkg/foo2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "Foo2Proto"; 8 | option java_package = "com.foo"; 9 | 10 | message Two {} 11 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/samedirgopkg/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | rules: 3 | remove: 4 | - FILE_OPTIONS_EQUAL_GO_PACKAGE_PB_SUFFIX 5 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/samedirjavapkg/bar1.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "Bar1Proto"; 8 | 9 | message Three {} 10 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/samedirjavapkg/foo1.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "Foo1Proto"; 8 | option java_package = "com.foo"; 9 | 10 | message One {} 11 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/samedirjavapkg/foo2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "Foo2Proto"; 8 | option java_package = "com.foo"; 9 | 10 | message Two {} 11 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/samedirjavapkg/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | rules: 3 | remove: 4 | - FILE_OPTIONS_EQUAL_JAVA_PACKAGE_COM_PREFIX 5 | - FILE_OPTIONS_REQUIRE_JAVA_PACKAGE 6 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/servicenamefilename/foo/v1/another_api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "AnotherApiProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | service AnotherAPI {} 14 | 15 | service EvenAnotherAPI {} 16 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/servicenamefilename/foo/v1/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "FooProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | service HelloAPI {} 14 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/servicenamefilename/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | rules: 4 | remove: 5 | - ENUMS_HAVE_SENTENCE_COMMENTS 6 | - MESSAGES_HAVE_SENTENCE_COMMENTS_EXCEPT_REQUEST_RESPONSE_TYPES 7 | - RPCS_HAVE_SENTENCE_COMMENTS 8 | - SERVICES_HAVE_SENTENCE_COMMENTS 9 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/syntaxproto2/prototool.yaml: -------------------------------------------------------------------------------- 1 | protoc: 2 | includes: 3 | - ../ 4 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/syntaxproto2/syntax_proto2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "SyntaxProto2Proto"; 8 | option java_package = "com.foo"; 9 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/version2/foo/v1/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "FooProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | // FooType is a foo type, and wants to tell you what type of Foo it is. 14 | enum FooType { 15 | FOO_TYPE_INVALID = 0; 16 | FOO_TYPE_UNSET = 1; 17 | FOO_TYPE_BALLOON = 2; 18 | FOO_TYPE_TREE = 3; 19 | } 20 | 21 | // Foo is a foo, it goes around the world and talks to bars. 22 | message Foo { 23 | FooType type = 1; 24 | sint32 latitude_micros = 3; 25 | sint32 longitude_micros = 4; 26 | string bar_id = 5; 27 | } 28 | 29 | // Bar is a bar that a Foo can talk to. 30 | message Bar { 31 | // Type is the type of Bar. 32 | enum Type { 33 | TYPE_INVALID = 0; 34 | TYPE_UNSET = 1; 35 | TYPE_REMOTE_CONTROL = 2; 36 | TYPE_FAN = 3; 37 | } 38 | Type type = 1; 39 | string id = 2; 40 | repeated string planet_ids = 3; 41 | } 42 | 43 | // Planet is a planet. 44 | message Planet { 45 | string id = 1; 46 | string name = 2; 47 | } 48 | 49 | // Galaxy is a galaxy. 50 | message Galaxy { 51 | string id = 1; 52 | string name = 2; 53 | } 54 | 55 | // Quasar is a quasar. 56 | message Quasar { 57 | string id = 1; 58 | string name = 2; 59 | } 60 | 61 | // ShowingOffBuiltInFieldOptions shows off built in field options. 62 | message ShowingOffBuiltInFieldOptions { 63 | string foo = 1 [deprecated = true]; 64 | } 65 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/version2/foo/v1/hello_api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo.v1; 4 | 5 | option csharp_namespace = "Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "HelloApiProto"; 9 | option java_package = "com.foo.v1"; 10 | option objc_class_prefix = "FXX"; 11 | option php_namespace = "Foo\\V1"; 12 | 13 | import "foo/v1/foo.proto"; 14 | 15 | // HelloAPI is the hello API. 16 | service HelloAPI { 17 | // SendFoo sends a foo. 18 | rpc SendFoo(SendFooRequest) returns (SendFooResponse); 19 | // GetPlanet gets a planet. 20 | rpc GetPlanet(GetPlanetRequest) returns (GetPlanetResponse); 21 | // StreamGalaxies streams galaxies. 22 | rpc StreamGalaxies(StreamGalaxiesRequest) returns (stream StreamGalaxiesResponse); 23 | // StreamQuasars streams quasars. 24 | rpc StreamQuasars(stream StreamQuasarsRequest) returns (StreamQuasarsResponse); 25 | } 26 | 27 | message SendFooRequest { 28 | Foo foo = 1; 29 | } 30 | 31 | message SendFooResponse {} 32 | 33 | message GetPlanetRequest { 34 | string planet_id = 1; 35 | } 36 | 37 | message GetPlanetResponse { 38 | Planet planet = 1; 39 | } 40 | 41 | message StreamGalaxiesRequest {} 42 | 43 | message StreamGalaxiesResponse { 44 | Galaxy galaxy = 1; 45 | } 46 | 47 | message StreamQuasarsRequest { 48 | Quasar quasar = 1; 49 | } 50 | 51 | message StreamQuasarsResponse { 52 | repeated Quasar quasars = 1; 53 | } 54 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/version2/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/wktsuffix/foo/foo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package foo; 4 | 5 | option go_package = "foopb"; 6 | option java_multiple_files = true; 7 | option java_outer_classname = "FooProto"; 8 | option java_package = "com.foo"; 9 | 10 | import "google/protobuf/duration.proto"; 11 | import "google/protobuf/timestamp.proto"; 12 | 13 | message Bar { 14 | google.protobuf.Timestamp one = 1; 15 | google.protobuf.Duration two = 2; 16 | oneof test { 17 | google.protobuf.Timestamp three = 3; 18 | google.protobuf.Duration four = 4; 19 | } 20 | // Make sure this is allowed. 21 | google.protobuf.Timestamp time = 5; 22 | } 23 | -------------------------------------------------------------------------------- /internal/cmd/testdata/lint/wktsuffix/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | rules: 3 | add: 4 | - WKT_DURATION_SUFFIX 5 | - WKT_TIMESTAMP_SUFFIX 6 | -------------------------------------------------------------------------------- /internal/create/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "create.go", 7 | "handler.go", 8 | ], 9 | importpath = "github.com/uber/prototool/internal/create", 10 | visibility = ["//:__subpackages__"], 11 | deps = [ 12 | "//internal/protostrs:go_default_library", 13 | "//internal/settings:go_default_library", 14 | "@org_uber_go_zap//:go_default_library", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /internal/desc/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["desc.go"], 6 | importpath = "github.com/uber/prototool/internal/desc", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "@com_github_golang_protobuf//proto:go_default_library", 10 | "@com_github_golang_protobuf//protoc-gen-go/descriptor:go_default_library", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /internal/diff/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["diff.go"], 6 | importpath = "github.com/uber/prototool/internal/diff", 7 | visibility = ["//:__subpackages__"], 8 | ) 9 | 10 | go_test( 11 | name = "go_default_test", 12 | srcs = ["diff_test.go"], 13 | embed = [":go_default_library"], 14 | deps = ["@com_github_stretchr_testify//assert:go_default_library"], 15 | ) 16 | -------------------------------------------------------------------------------- /internal/exec/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "exec.go", 7 | "runner.go", 8 | ], 9 | importpath = "github.com/uber/prototool/internal/exec", 10 | visibility = ["//:__subpackages__"], 11 | deps = [ 12 | "//internal/breaking:go_default_library", 13 | "//internal/cfginit:go_default_library", 14 | "//internal/create:go_default_library", 15 | "//internal/desc:go_default_library", 16 | "//internal/diff:go_default_library", 17 | "//internal/extract:go_default_library", 18 | "//internal/file:go_default_library", 19 | "//internal/format:go_default_library", 20 | "//internal/git:go_default_library", 21 | "//internal/grpc:go_default_library", 22 | "//internal/lint:go_default_library", 23 | "//internal/protoc:go_default_library", 24 | "//internal/reflect:go_default_library", 25 | "//internal/settings:go_default_library", 26 | "//internal/text:go_default_library", 27 | "//internal/vars:go_default_library", 28 | "@com_github_golang_protobuf//jsonpb:go_default_library", 29 | "@com_github_golang_protobuf//proto:go_default_library", 30 | "@com_github_golang_protobuf//protoc-gen-go/descriptor:go_default_library", 31 | "@in_gopkg_yaml_v2//:go_default_library", 32 | "@org_uber_go_multierr//:go_default_library", 33 | "@org_uber_go_zap//:go_default_library", 34 | ], 35 | ) 36 | -------------------------------------------------------------------------------- /internal/extract/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["extract.go"], 6 | importpath = "github.com/uber/prototool/internal/extract", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//internal/protostrs:go_default_library", 10 | "//internal/reflect/gen/uber/proto/reflect/v1:go_default_library", 11 | ], 12 | ) 13 | 14 | go_test( 15 | name = "go_default_test", 16 | srcs = ["extract_test.go"], 17 | data = glob(["testdata/**"]), 18 | embed = [":go_default_library"], 19 | deps = [ 20 | "//internal/reflect:go_default_library", 21 | "//internal/testing:go_default_library", 22 | "@com_github_stretchr_testify//require:go_default_library", 23 | ], 24 | ) 25 | -------------------------------------------------------------------------------- /internal/extract/testdata/one/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | -------------------------------------------------------------------------------- /internal/extract/testdata/one/uber/proto/bar/v1/one.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package uber.proto.bar.v1; 4 | 5 | option csharp_namespace = "Uber.Proto.Bar.V1"; 6 | option go_package = "barv1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "OneProto"; 9 | option java_package = "com.uber.proto.bar.v1"; 10 | option objc_class_prefix = "UPB"; 11 | option php_namespace = "Uber\\Proto\\Bar\\V1"; 12 | 13 | import "uber/proto/bar/v1/two.proto"; 14 | 15 | message OneFoo { 16 | int64 one = 1; 17 | string two = 2; 18 | OneBar one_bar = 3; 19 | } 20 | 21 | message OneBar { 22 | int64 one = 1; 23 | string two = 2; 24 | } 25 | 26 | message OneBaz { 27 | OneFoo one_foo = 1; 28 | OneBar one_bar = 2; 29 | TwoFoo two_foo = 3; 30 | TwoBar two_bar = 4; 31 | } 32 | -------------------------------------------------------------------------------- /internal/extract/testdata/one/uber/proto/bar/v1/two.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package uber.proto.bar.v1; 4 | 5 | option csharp_namespace = "Uber.Proto.Bar.V1"; 6 | option go_package = "barv1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "TwoProto"; 9 | option java_package = "com.uber.proto.bar.v1"; 10 | option objc_class_prefix = "UPB"; 11 | option php_namespace = "Uber\\Proto\\Bar\\V1"; 12 | 13 | message TwoFoo { 14 | int64 one = 1; 15 | string two = 2; 16 | TwoBar two_bar = 3; 17 | } 18 | 19 | message TwoBar { 20 | int64 one = 1; 21 | string two = 2; 22 | } 23 | -------------------------------------------------------------------------------- /internal/extract/testdata/one/uber/proto/foo/v1/one.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package uber.proto.foo.v1; 4 | 5 | option csharp_namespace = "Uber.Proto.Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "OneProto"; 9 | option java_package = "com.uber.proto.foo.v1"; 10 | option objc_class_prefix = "UPF"; 11 | option php_namespace = "Uber\\Proto\\Foo\\V1"; 12 | 13 | import "uber/proto/bar/v1/one.proto"; 14 | import "uber/proto/bar/v1/two.proto"; 15 | import "uber/proto/foo/v1/two.proto"; 16 | 17 | message OneFoo { 18 | int64 one = 1; 19 | string two = 2; 20 | OneBar one_bar = 3; 21 | } 22 | 23 | message OneBar { 24 | int64 one = 1; 25 | string two = 2; 26 | } 27 | 28 | message OneBaz { 29 | OneFoo one_foo = 1; 30 | OneBar one_bar = 2; 31 | TwoFoo two_foo = 3; 32 | TwoBar two_bar = 4; 33 | } 34 | 35 | message OneBat { 36 | bar.v1.OneFoo one_foo = 1; 37 | bar.v1.OneBar one_bar = 2; 38 | uber.proto.bar.v1.TwoFoo two_foo = 3; 39 | uber.proto.bar.v1.TwoBar two_bar = 4; 40 | } 41 | 42 | enum Enum { 43 | ENUM_INVALID = 0; 44 | ENUM_FOO = 1; 45 | ENUM_BAR = 2; 46 | } 47 | 48 | message Simple { 49 | message Nested { 50 | int64 one = 1; 51 | string two = 2; 52 | } 53 | enum NestedEnum { 54 | NESTED_ENUM_INVALID = 0; 55 | NESTED_ENUM_FOO = 1; 56 | NESTED_ENUM_BAR = 2; 57 | } 58 | 59 | int64 one = 1; 60 | string two = 2; 61 | repeated int64 three = 3; 62 | map four = 4; 63 | oneof test_oneof { 64 | int64 five = 5; 65 | OneBat one_bat = 6; 66 | } 67 | } 68 | 69 | message FooRequest { 70 | int64 one = 1; 71 | } 72 | 73 | message FooResponse { 74 | int64 one = 1; 75 | } 76 | 77 | message BarRequest { 78 | int64 one = 1; 79 | } 80 | 81 | message BarResponse { 82 | int64 one = 1; 83 | } 84 | 85 | service SomeAPI { 86 | rpc Foo(FooRequest) returns (FooResponse); 87 | rpc Bar(BarRequest) returns (BarResponse); 88 | } 89 | -------------------------------------------------------------------------------- /internal/extract/testdata/one/uber/proto/foo/v1/two.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package uber.proto.foo.v1; 4 | 5 | option csharp_namespace = "Uber.Proto.Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "TwoProto"; 9 | option java_package = "com.uber.proto.foo.v1"; 10 | option objc_class_prefix = "UPF"; 11 | option php_namespace = "Uber\\Proto\\Foo\\V1"; 12 | 13 | message TwoFoo { 14 | int64 one = 1; 15 | string two = 2; 16 | TwoBar two_bar = 3; 17 | } 18 | 19 | message TwoBar { 20 | int64 one = 1; 21 | string two = 2; 22 | } 23 | -------------------------------------------------------------------------------- /internal/file/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "file.go", 7 | "proto_set_provider.go", 8 | ], 9 | importpath = "github.com/uber/prototool/internal/file", 10 | visibility = ["//:__subpackages__"], 11 | deps = [ 12 | "//internal/settings:go_default_library", 13 | "@org_uber_go_zap//:go_default_library", 14 | ], 15 | ) 16 | 17 | go_test( 18 | name = "go_default_test", 19 | srcs = [ 20 | "file_test.go", 21 | "proto_set_provider_test.go", 22 | ], 23 | data = glob(["testdata/**"]), 24 | embed = [":go_default_library"], 25 | deps = [ 26 | "//internal/settings:go_default_library", 27 | "@com_github_stretchr_testify//assert:go_default_library", 28 | "@com_github_stretchr_testify//require:go_default_library", 29 | "@org_uber_go_zap//:go_default_library", 30 | ], 31 | ) 32 | -------------------------------------------------------------------------------- /internal/file/testdata/invalid/prototool.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/file/testdata/invalid/prototool.json -------------------------------------------------------------------------------- /internal/file/testdata/invalid/prototool.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uber/prototool/a6d064684c011c8482f4218c681a66a64031fb1d/internal/file/testdata/invalid/prototool.yaml -------------------------------------------------------------------------------- /internal/file/testdata/valid/base/a/d/file.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | -------------------------------------------------------------------------------- /internal/file/testdata/valid/base/a/d/file2.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | -------------------------------------------------------------------------------- /internal/file/testdata/valid/base/a/d/file3.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | -------------------------------------------------------------------------------- /internal/file/testdata/valid/base/a/d/prototool.yaml: -------------------------------------------------------------------------------- 1 | excludes: 2 | - file3.proto 3 | protoc: 4 | version: 3.2.0 5 | -------------------------------------------------------------------------------- /internal/file/testdata/valid/base/a/e/file.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | -------------------------------------------------------------------------------- /internal/file/testdata/valid/base/a/f/file.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | -------------------------------------------------------------------------------- /internal/file/testdata/valid/base/a/file.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | -------------------------------------------------------------------------------- /internal/file/testdata/valid/base/b/file.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | -------------------------------------------------------------------------------- /internal/file/testdata/valid/base/b/g/h/file.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | -------------------------------------------------------------------------------- /internal/file/testdata/valid/base/b/prototool.json: -------------------------------------------------------------------------------- 1 | { 2 | "excludes": [ 3 | "g/h" 4 | ], 5 | "protoc": { 6 | "version": "3.3.0" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /internal/file/testdata/valid/base/c/file.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | -------------------------------------------------------------------------------- /internal/file/testdata/valid/base/c/i/file.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | -------------------------------------------------------------------------------- /internal/file/testdata/valid/base/d/file.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | -------------------------------------------------------------------------------- /internal/file/testdata/valid/base/d/g/h/file.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | -------------------------------------------------------------------------------- /internal/file/testdata/valid/base/d/prototool.yaml: -------------------------------------------------------------------------------- 1 | protoc: 2 | version: 3.3.0 3 | -------------------------------------------------------------------------------- /internal/file/testdata/valid/base/prototool.yaml: -------------------------------------------------------------------------------- 1 | excludes: 2 | - c/i 3 | - d 4 | protoc: 5 | version: 3.4.0 6 | -------------------------------------------------------------------------------- /internal/format/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "base_visitor.go", 7 | "first_pass_visitor.go", 8 | "format.go", 9 | "main_visitor.go", 10 | "transformer.go", 11 | ], 12 | importpath = "github.com/uber/prototool/internal/format", 13 | visibility = ["//:__subpackages__"], 14 | deps = [ 15 | "//internal/buf:go_default_library", 16 | "//internal/protostrs:go_default_library", 17 | "//internal/text:go_default_library", 18 | "@com_github_emicklei_proto//:go_default_library", 19 | "@org_uber_go_zap//:go_default_library", 20 | ], 21 | ) 22 | -------------------------------------------------------------------------------- /internal/git/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["git.go"], 6 | importpath = "github.com/uber/prototool/internal/git", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//internal/file:go_default_library", 10 | "@org_uber_go_zap//:go_default_library", 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /internal/grpc/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "grpc.go", 7 | "handler.go", 8 | "invocation_event_handler.go", 9 | ], 10 | importpath = "github.com/uber/prototool/internal/grpc", 11 | visibility = ["//:__subpackages__"], 12 | deps = [ 13 | "//internal/desc:go_default_library", 14 | "@com_github_fullstorydev_grpcurl//:go_default_library", 15 | "@com_github_golang_protobuf//jsonpb:go_default_library", 16 | "@com_github_golang_protobuf//proto:go_default_library", 17 | "@com_github_golang_protobuf//protoc-gen-go/descriptor:go_default_library", 18 | "@com_github_jhump_protoreflect//desc:go_default_library", 19 | "@com_github_jhump_protoreflect//dynamic:go_default_library", 20 | "@org_golang_google_grpc//:go_default_library", 21 | "@org_golang_google_grpc//credentials:go_default_library", 22 | "@org_golang_google_grpc//keepalive:go_default_library", 23 | "@org_golang_google_grpc//metadata:go_default_library", 24 | "@org_golang_google_grpc//status:go_default_library", 25 | "@org_uber_go_zap//:go_default_library", 26 | ], 27 | ) 28 | 29 | go_test( 30 | name = "go_default_test", 31 | srcs = ["handler_test.go"], 32 | embed = [":go_default_library"], 33 | deps = ["@com_github_stretchr_testify//require:go_default_library"], 34 | ) 35 | -------------------------------------------------------------------------------- /internal/lint/check_gogo_not_imported.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package lint 22 | 23 | import ( 24 | "strings" 25 | 26 | "github.com/emicklei/proto" 27 | "github.com/uber/prototool/internal/text" 28 | ) 29 | 30 | var ( 31 | gogoNotImportedLinter = NewLinter( 32 | "GOGO_NOT_IMPORTED", 33 | `Verifies that the "gogo.proto" file from gogo/protobuf is not imported.`, 34 | checkGogoNotImported, 35 | ) 36 | ) 37 | 38 | func checkGogoNotImported(add func(*text.Failure), dirPath string, descriptors []*FileDescriptor) error { 39 | return runVisitor(&gogoNotImportedVisitor{baseAddVisitor: newBaseAddVisitor(add)}, descriptors) 40 | } 41 | 42 | type gogoNotImportedVisitor struct { 43 | baseAddVisitor 44 | } 45 | 46 | func (v gogoNotImportedVisitor) VisitImport(element *proto.Import) { 47 | if strings.HasSuffix(element.Filename, "gogo.proto") { 48 | v.AddFailuref(element.Position, `Importing "gogo.proto" is not allowed.`) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /internal/lint/check_imports_not_public.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package lint 22 | 23 | import ( 24 | "github.com/emicklei/proto" 25 | "github.com/uber/prototool/internal/text" 26 | ) 27 | 28 | var ( 29 | importsNotPublicLinter = NewLinter( 30 | "IMPORTS_NOT_PUBLIC", 31 | `Verifies that there are no public imports.`, 32 | checkImportsNotPublic, 33 | ) 34 | ) 35 | 36 | func checkImportsNotPublic(add func(*text.Failure), dirPath string, descriptors []*FileDescriptor) error { 37 | return runVisitor(&importsNotPublicVisitor{baseAddVisitor: newBaseAddVisitor(add)}, descriptors) 38 | } 39 | 40 | type importsNotPublicVisitor struct { 41 | baseAddVisitor 42 | } 43 | 44 | func (v importsNotPublicVisitor) VisitImport(element *proto.Import) { 45 | if element.Kind == "public" { 46 | v.AddFailuref(element.Position, `Public imports are not allowed.`) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /internal/lint/check_imports_not_weak.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package lint 22 | 23 | import ( 24 | "github.com/emicklei/proto" 25 | "github.com/uber/prototool/internal/text" 26 | ) 27 | 28 | var ( 29 | importsNotWeakLinter = NewLinter( 30 | "IMPORTS_NOT_WEAK", 31 | `Verifies that there are no weak imports.`, 32 | checkImportsNotWeak, 33 | ) 34 | ) 35 | 36 | func checkImportsNotWeak(add func(*text.Failure), dirPath string, descriptors []*FileDescriptor) error { 37 | return runVisitor(&importsNotWeakVisitor{baseAddVisitor: newBaseAddVisitor(add)}, descriptors) 38 | } 39 | 40 | type importsNotWeakVisitor struct { 41 | baseAddVisitor 42 | } 43 | 44 | func (v importsNotWeakVisitor) VisitImport(element *proto.Import) { 45 | if element.Kind == "weak" { 46 | v.AddFailuref(element.Position, `Weak imports are not allowed.`) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /internal/lint/check_rpc_names_camel_case.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package lint 22 | 23 | import ( 24 | "github.com/emicklei/proto" 25 | "github.com/uber/prototool/internal/strs" 26 | "github.com/uber/prototool/internal/text" 27 | ) 28 | 29 | var rpcNamesCamelCaseLinter = NewLinter( 30 | "RPC_NAMES_CAMEL_CASE", 31 | "Verifies that all RPC names are CamelCase.", 32 | checkRPCNamesCamelCase, 33 | ) 34 | 35 | func checkRPCNamesCamelCase(add func(*text.Failure), dirPath string, descriptors []*FileDescriptor) error { 36 | return runVisitor(rpcNamesCamelCaseVisitor{baseAddVisitor: newBaseAddVisitor(add)}, descriptors) 37 | } 38 | 39 | type rpcNamesCamelCaseVisitor struct { 40 | baseAddVisitor 41 | } 42 | 43 | func (v rpcNamesCamelCaseVisitor) VisitService(service *proto.Service) { 44 | for _, child := range service.Elements { 45 | child.Accept(v) 46 | } 47 | } 48 | 49 | func (v rpcNamesCamelCaseVisitor) VisitRPC(rpc *proto.RPC) { 50 | if !strs.IsCamelCase(rpc.Name) { 51 | v.AddFailuref(rpc.Position, "RPC name %q must be CamelCase.", rpc.Name) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /internal/lint/check_rpcs_have_comments.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package lint 22 | 23 | import ( 24 | "github.com/emicklei/proto" 25 | "github.com/uber/prototool/internal/text" 26 | ) 27 | 28 | var rpcsHaveCommentsLinter = NewLinter( 29 | "RPCS_HAVE_COMMENTS", 30 | `Verifies that all rpcs have a comment of the form "// RPCName ...".`, 31 | checkRPCsHaveComments, 32 | ) 33 | 34 | func checkRPCsHaveComments(add func(*text.Failure), dirPath string, descriptors []*FileDescriptor) error { 35 | return runVisitor(rpcsHaveCommentsVisitor{baseAddVisitor: newBaseAddVisitor(add)}, descriptors) 36 | } 37 | 38 | type rpcsHaveCommentsVisitor struct { 39 | baseAddVisitor 40 | } 41 | 42 | func (v rpcsHaveCommentsVisitor) VisitService(service *proto.Service) { 43 | for _, child := range service.Elements { 44 | child.Accept(v) 45 | } 46 | } 47 | 48 | func (v rpcsHaveCommentsVisitor) VisitRPC(rpc *proto.RPC) { 49 | if !hasGolangStyleComment(rpc.Comment, rpc.Name) { 50 | v.AddFailuref(rpc.Position, `RPC %q needs a comment of the form "// %s ..."`, rpc.Name, rpc.Name) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /internal/lint/check_rpcs_no_streaming.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package lint 22 | 23 | import ( 24 | "github.com/emicklei/proto" 25 | "github.com/uber/prototool/internal/text" 26 | ) 27 | 28 | var rpcsNoStreamingLinter = NewLinter( 29 | "RPCS_NO_STREAMING", 30 | `Verifies that all rpcs are unary.`, 31 | checkRPCsNoStreaming, 32 | ) 33 | 34 | func checkRPCsNoStreaming(add func(*text.Failure), dirPath string, descriptors []*FileDescriptor) error { 35 | return runVisitor(rpcsNoStreamingVisitor{baseAddVisitor: newBaseAddVisitor(add)}, descriptors) 36 | } 37 | 38 | type rpcsNoStreamingVisitor struct { 39 | baseAddVisitor 40 | } 41 | 42 | func (v rpcsNoStreamingVisitor) VisitService(service *proto.Service) { 43 | for _, child := range service.Elements { 44 | child.Accept(v) 45 | } 46 | } 47 | 48 | func (v rpcsNoStreamingVisitor) VisitRPC(rpc *proto.RPC) { 49 | if rpc.StreamsRequest || rpc.StreamsReturns { 50 | v.AddFailuref(rpc.Position, `RPC %q is streaming and only unary RPCs are allowed.`, rpc.Name) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /internal/lint/check_service_names_camel_case.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package lint 22 | 23 | import ( 24 | "github.com/emicklei/proto" 25 | "github.com/uber/prototool/internal/strs" 26 | "github.com/uber/prototool/internal/text" 27 | ) 28 | 29 | var serviceNamesCamelCaseLinter = NewLinter( 30 | "SERVICE_NAMES_CAMEL_CASE", 31 | "Verifies that all service names are CamelCase.", 32 | checkServiceNamesCamelCase, 33 | ) 34 | 35 | func checkServiceNamesCamelCase(add func(*text.Failure), dirPath string, descriptors []*FileDescriptor) error { 36 | return runVisitor(serviceNamesCamelCaseVisitor{baseAddVisitor: newBaseAddVisitor(add)}, descriptors) 37 | } 38 | 39 | type serviceNamesCamelCaseVisitor struct { 40 | baseAddVisitor 41 | } 42 | 43 | func (v serviceNamesCamelCaseVisitor) VisitService(service *proto.Service) { 44 | if !strs.IsCamelCase(service.Name) { 45 | v.AddFailuref(service.Position, "Service name %q must be CamelCase.", service.Name) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /internal/lint/check_service_names_capitalized.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package lint 22 | 23 | import ( 24 | "github.com/emicklei/proto" 25 | "github.com/uber/prototool/internal/strs" 26 | "github.com/uber/prototool/internal/text" 27 | ) 28 | 29 | var serviceNamesCapitalizedLinter = NewLinter( 30 | "SERVICE_NAMES_CAPITALIZED", 31 | "Verifies that all service names are Capitalized.", 32 | checkServiceNamesCapitalized, 33 | ) 34 | 35 | func checkServiceNamesCapitalized(add func(*text.Failure), dirPath string, descriptors []*FileDescriptor) error { 36 | return runVisitor(serviceNamesCapitalizedVisitor{baseAddVisitor: newBaseAddVisitor(add)}, descriptors) 37 | } 38 | 39 | type serviceNamesCapitalizedVisitor struct { 40 | baseAddVisitor 41 | } 42 | 43 | func (v serviceNamesCapitalizedVisitor) VisitService(service *proto.Service) { 44 | if !strs.IsCapitalized(service.Name) { 45 | v.AddFailuref(service.Position, "Service name %q must be capitalized.", service.Name) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /internal/lint/check_services_have_comments.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package lint 22 | 23 | import ( 24 | "github.com/emicklei/proto" 25 | "github.com/uber/prototool/internal/text" 26 | ) 27 | 28 | var servicesHaveCommentsLinter = NewLinter( 29 | "SERVICES_HAVE_COMMENTS", 30 | `Verifies that all services have a comment of the form "// ServiceName ...".`, 31 | checkServicesHaveComments, 32 | ) 33 | 34 | func checkServicesHaveComments(add func(*text.Failure), dirPath string, descriptors []*FileDescriptor) error { 35 | return runVisitor(servicesHaveCommentsVisitor{baseAddVisitor: newBaseAddVisitor(add)}, descriptors) 36 | } 37 | 38 | type servicesHaveCommentsVisitor struct { 39 | baseAddVisitor 40 | } 41 | 42 | func (v servicesHaveCommentsVisitor) VisitService(service *proto.Service) { 43 | if !hasGolangStyleComment(service.Comment, service.Name) { 44 | v.AddFailuref(service.Position, `Service %q needs a comment of the form "// %s ..."`, service.Name, service.Name) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /internal/lint/check_services_have_sentence_comments.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package lint 22 | 23 | import ( 24 | "github.com/emicklei/proto" 25 | "github.com/uber/prototool/internal/text" 26 | ) 27 | 28 | var servicesHaveSentenceCommentsLinter = NewLinter( 29 | "SERVICES_HAVE_SENTENCE_COMMENTS", 30 | `Verifies that all services have a comment that contains at least one complete sentence.`, 31 | checkServicesHaveSentenceComments, 32 | ) 33 | 34 | func checkServicesHaveSentenceComments(add func(*text.Failure), dirPath string, descriptors []*FileDescriptor) error { 35 | return runVisitor(servicesHaveSentenceCommentsVisitor{baseAddVisitor: newBaseAddVisitor(add)}, descriptors) 36 | } 37 | 38 | type servicesHaveSentenceCommentsVisitor struct { 39 | baseAddVisitor 40 | } 41 | 42 | func (v servicesHaveSentenceCommentsVisitor) VisitService(service *proto.Service) { 43 | if !hasCompleteSentenceComment(service.Comment) { 44 | v.AddFailuref(service.Position, `Service %q needs a comment with a complete sentence that starts on the first line of the comment.`, service.Name) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /internal/lint/runner.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | package lint 22 | 23 | import ( 24 | "github.com/uber/prototool/internal/file" 25 | "github.com/uber/prototool/internal/text" 26 | "go.uber.org/zap" 27 | ) 28 | 29 | type runner struct { 30 | logger *zap.Logger 31 | } 32 | 33 | func newRunner(options ...RunnerOption) *runner { 34 | runner := &runner{ 35 | logger: zap.NewNop(), 36 | } 37 | for _, option := range options { 38 | option(runner) 39 | } 40 | return runner 41 | } 42 | 43 | func (r *runner) Run(protoSet *file.ProtoSet, absolutePaths bool) ([]*text.Failure, error) { 44 | linters, err := GetLinters(protoSet.Config.Lint) 45 | if err != nil { 46 | return nil, err 47 | } 48 | dirPathToDescriptors, err := GetDirPathToDescriptors(protoSet, absolutePaths) 49 | if err != nil { 50 | return nil, err 51 | } 52 | return CheckMultiple(linters, dirPathToDescriptors, protoSet.Config.Lint.IgnoreIDToFilePaths) 53 | } 54 | -------------------------------------------------------------------------------- /internal/protoc/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "compiler.go", 7 | "downloader.go", 8 | "protoc.go", 9 | ], 10 | importpath = "github.com/uber/prototool/internal/protoc", 11 | visibility = ["//:__subpackages__"], 12 | deps = [ 13 | "//internal/file:go_default_library", 14 | "//internal/settings:go_default_library", 15 | "//internal/text:go_default_library", 16 | "//internal/vars:go_default_library", 17 | "//internal/wkt:go_default_library", 18 | "@com_github_gofrs_flock//:go_default_library", 19 | "@com_github_golang_protobuf//proto:go_default_library", 20 | "@com_github_golang_protobuf//protoc-gen-go/descriptor:go_default_library", 21 | "@org_uber_go_multierr//:go_default_library", 22 | "@org_uber_go_zap//:go_default_library", 23 | ], 24 | ) 25 | 26 | go_test( 27 | name = "go_default_test", 28 | srcs = ["downloader_test.go"], 29 | embed = [":go_default_library"], 30 | deps = [ 31 | "//internal/settings:go_default_library", 32 | "@com_github_stretchr_testify//assert:go_default_library", 33 | "@com_github_stretchr_testify//require:go_default_library", 34 | ], 35 | ) 36 | -------------------------------------------------------------------------------- /internal/protostrs/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["protostrs.go"], 6 | importpath = "github.com/uber/prototool/internal/protostrs", 7 | visibility = ["//:__subpackages__"], 8 | deps = ["//internal/strs:go_default_library"], 9 | ) 10 | 11 | go_test( 12 | name = "go_default_test", 13 | srcs = ["protostrs_test.go"], 14 | embed = [":go_default_library"], 15 | deps = ["@com_github_stretchr_testify//assert:go_default_library"], 16 | ) 17 | -------------------------------------------------------------------------------- /internal/reflect/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["reflect.go"], 6 | importpath = "github.com/uber/prototool/internal/reflect", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//internal/reflect/gen/uber/proto/reflect/v1:go_default_library", 10 | "//internal/strs:go_default_library", 11 | "@com_github_golang_protobuf//proto:go_default_library", 12 | "@com_github_golang_protobuf//protoc-gen-go/descriptor:go_default_library", 13 | ], 14 | ) 15 | 16 | go_test( 17 | name = "go_default_test", 18 | srcs = ["reflect_test.go"], 19 | data = glob(["testdata/**"]), 20 | embed = [":go_default_library"], 21 | deps = [ 22 | "//internal/reflect/gen/uber/proto/reflect/v1:go_default_library", 23 | "//internal/testing:go_default_library", 24 | "@com_github_golang_protobuf//jsonpb:go_default_library", 25 | "@com_github_stretchr_testify//require:go_default_library", 26 | ], 27 | ) 28 | -------------------------------------------------------------------------------- /internal/reflect/gen/uber/proto/reflect/v1/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["reflect.pb.go"], 6 | importpath = "github.com/uber/prototool/internal/reflect/gen/uber/proto/reflect/v1", 7 | visibility = ["//:__subpackages__"], 8 | deps = ["@com_github_golang_protobuf//proto:go_default_library"], 9 | ) 10 | -------------------------------------------------------------------------------- /internal/reflect/proto/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | generate: 4 | go_options: 5 | import_path: github.com/uber/prototool/internal/reflect/proto 6 | plugins: 7 | - name: go 8 | type: go 9 | output: ../gen 10 | -------------------------------------------------------------------------------- /internal/reflect/testdata/one/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | -------------------------------------------------------------------------------- /internal/reflect/testdata/one/uber/proto/bar/v1/one.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package uber.proto.bar.v1; 4 | 5 | option csharp_namespace = "Uber.Proto.Bar.V1"; 6 | option go_package = "barv1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "OneProto"; 9 | option java_package = "com.uber.proto.bar.v1"; 10 | option objc_class_prefix = "UPB"; 11 | option php_namespace = "Uber\\Proto\\Bar\\V1"; 12 | 13 | import "uber/proto/bar/v1/two.proto"; 14 | 15 | message OneFoo { 16 | int64 one = 1; 17 | string two = 2; 18 | OneBar one_bar = 3; 19 | } 20 | 21 | message OneBar { 22 | int64 one = 1; 23 | string two = 2; 24 | } 25 | 26 | message OneBaz { 27 | OneFoo one_foo = 1; 28 | OneBar one_bar = 2; 29 | TwoFoo two_foo = 3; 30 | TwoBar two_bar = 4; 31 | } 32 | -------------------------------------------------------------------------------- /internal/reflect/testdata/one/uber/proto/bar/v1/two.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package uber.proto.bar.v1; 4 | 5 | option csharp_namespace = "Uber.Proto.Bar.V1"; 6 | option go_package = "barv1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "TwoProto"; 9 | option java_package = "com.uber.proto.bar.v1"; 10 | option objc_class_prefix = "UPB"; 11 | option php_namespace = "Uber\\Proto\\Bar\\V1"; 12 | 13 | message TwoFoo { 14 | int64 one = 1; 15 | string two = 2; 16 | TwoBar two_bar = 3; 17 | } 18 | 19 | message TwoBar { 20 | int64 one = 1; 21 | string two = 2; 22 | } 23 | -------------------------------------------------------------------------------- /internal/reflect/testdata/one/uber/proto/foo/v1/one.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package uber.proto.foo.v1; 4 | 5 | option csharp_namespace = "Uber.Proto.Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "OneProto"; 9 | option java_package = "com.uber.proto.foo.v1"; 10 | option objc_class_prefix = "UPF"; 11 | option php_namespace = "Uber\\Proto\\Foo\\V1"; 12 | 13 | import "uber/proto/bar/v1/one.proto"; 14 | import "uber/proto/bar/v1/two.proto"; 15 | import "uber/proto/foo/v1/two.proto"; 16 | 17 | message OneFoo { 18 | int64 one = 1; 19 | string two = 2; 20 | OneBar one_bar = 3; 21 | } 22 | 23 | message OneBar { 24 | int64 one = 1; 25 | string two = 2; 26 | } 27 | 28 | message OneBaz { 29 | OneFoo one_foo = 1; 30 | OneBar one_bar = 2; 31 | TwoFoo two_foo = 3; 32 | TwoBar two_bar = 4; 33 | } 34 | 35 | message OneBat { 36 | bar.v1.OneFoo one_foo = 1; 37 | bar.v1.OneBar one_bar = 2; 38 | uber.proto.bar.v1.TwoFoo two_foo = 3; 39 | uber.proto.bar.v1.TwoBar two_bar = 4; 40 | } 41 | 42 | enum Enum { 43 | ENUM_INVALID = 0; 44 | ENUM_FOO = 1; 45 | ENUM_BAR = 2; 46 | } 47 | 48 | message Simple { 49 | message Nested { 50 | int64 one = 1; 51 | string two = 2; 52 | } 53 | enum NestedEnum { 54 | NESTED_ENUM_INVALID = 0; 55 | NESTED_ENUM_FOO = 1; 56 | NESTED_ENUM_BAR = 2; 57 | } 58 | 59 | int64 one = 1; 60 | string two = 2; 61 | repeated int64 three = 3; 62 | map four = 4; 63 | oneof test_oneof { 64 | int64 five = 5; 65 | OneBat one_bat = 6; 66 | } 67 | } 68 | 69 | message FooRequest { 70 | int64 one = 1; 71 | } 72 | 73 | message FooResponse { 74 | int64 one = 1; 75 | } 76 | 77 | message BarRequest { 78 | int64 one = 1; 79 | } 80 | 81 | message BarResponse { 82 | int64 one = 1; 83 | } 84 | 85 | service SomeAPI { 86 | rpc Foo(FooRequest) returns (FooResponse); 87 | rpc Bar(BarRequest) returns (BarResponse); 88 | } 89 | -------------------------------------------------------------------------------- /internal/reflect/testdata/one/uber/proto/foo/v1/two.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package uber.proto.foo.v1; 4 | 5 | option csharp_namespace = "Uber.Proto.Foo.V1"; 6 | option go_package = "foov1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "TwoProto"; 9 | option java_package = "com.uber.proto.foo.v1"; 10 | option objc_class_prefix = "UPF"; 11 | option php_namespace = "Uber\\Proto\\Foo\\V1"; 12 | 13 | message TwoFoo { 14 | int64 one = 1; 15 | string two = 2; 16 | TwoBar two_bar = 3; 17 | } 18 | 19 | message TwoBar { 20 | int64 one = 1; 21 | string two = 2; 22 | } 23 | -------------------------------------------------------------------------------- /internal/settings/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "config_provider.go", 7 | "settings.go", 8 | ], 9 | importpath = "github.com/uber/prototool/internal/settings", 10 | visibility = ["//:__subpackages__"], 11 | deps = [ 12 | "//internal/strs:go_default_library", 13 | "@in_gopkg_yaml_v2//:go_default_library", 14 | "@org_uber_go_zap//:go_default_library", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /internal/strs/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["strs.go"], 6 | importpath = "github.com/uber/prototool/internal/strs", 7 | visibility = ["//:__subpackages__"], 8 | ) 9 | 10 | go_test( 11 | name = "go_default_test", 12 | srcs = ["strs_test.go"], 13 | embed = [":go_default_library"], 14 | deps = ["@com_github_stretchr_testify//assert:go_default_library"], 15 | ) 16 | -------------------------------------------------------------------------------- /internal/testing/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["testing.go"], 6 | importpath = "github.com/uber/prototool/internal/testing", 7 | visibility = ["//:__subpackages__"], 8 | deps = [ 9 | "//internal/file:go_default_library", 10 | "//internal/protoc:go_default_library", 11 | "//internal/reflect/gen/uber/proto/reflect/v1:go_default_library", 12 | "@com_github_golang_protobuf//jsonpb:go_default_library", 13 | "@com_github_golang_protobuf//protoc-gen-go/descriptor:go_default_library", 14 | "@com_github_stretchr_testify//require:go_default_library", 15 | "@org_uber_go_multierr//:go_default_library", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /internal/text/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["text.go"], 6 | importpath = "github.com/uber/prototool/internal/text", 7 | visibility = ["//:__subpackages__"], 8 | ) 9 | 10 | go_test( 11 | name = "go_default_test", 12 | srcs = ["text_test.go"], 13 | embed = [":go_default_library"], 14 | deps = ["@com_github_stretchr_testify//assert:go_default_library"], 15 | ) 16 | -------------------------------------------------------------------------------- /internal/vars/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["vars.go"], 6 | importpath = "github.com/uber/prototool/internal/vars", 7 | visibility = ["//:__subpackages__"], 8 | ) 9 | -------------------------------------------------------------------------------- /internal/vars/vars.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Uber Technologies, Inc. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | // Package vars contains static variables used in Prototool. 22 | package vars 23 | 24 | const ( 25 | // Version is the current version. 26 | Version = "1.11.0-dev" 27 | 28 | // DefaultProtocVersion is the default version of protoc from 29 | // github.com/protocolbuffers/protobuf to use. 30 | // 31 | // See https://github.com/protocolbuffers/protobuf/releases for the latest release. 32 | DefaultProtocVersion = "3.11.0" 33 | ) 34 | -------------------------------------------------------------------------------- /internal/wkt/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["wkt.go"], 6 | importpath = "github.com/uber/prototool/internal/wkt", 7 | visibility = ["//:__subpackages__"], 8 | ) 9 | -------------------------------------------------------------------------------- /style/prototool.yaml: -------------------------------------------------------------------------------- 1 | lint: 2 | group: uber2 3 | -------------------------------------------------------------------------------- /style/uber/road/v1/road.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package uber.road.v1; 4 | 5 | option csharp_namespace = "Uber.Road.V1"; 6 | option go_package = "roadv1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "RoadProto"; 9 | option java_package = "com.uber.road.v1"; 10 | option objc_class_prefix = "URX"; 11 | option php_namespace = "Uber\\Road\\V1"; 12 | 13 | import "google/protobuf/duration.proto"; 14 | import "google/protobuf/timestamp.proto"; 15 | 16 | // A traffic light color. 17 | enum TrafficLightColor { 18 | TRAFFIC_LIGHT_COLOR_INVALID = 0; 19 | TRAFFIC_LIGHT_COLOR_UNSET = 1; 20 | TRAFFIC_LIGHT_COLOR_GREEN = 2; 21 | TRAFFIC_LIGHT_COLOR_YELLOW = 3; 22 | TRAFFIC_LIGHT_COLOR_RED = 4; 23 | } 24 | 25 | // A traffic light. 26 | message TrafficLight { 27 | string id = 1; 28 | TrafficLightColor current_color = 2; 29 | } 30 | 31 | // Statistics on a traffic light color. 32 | message TrafficLightColorStats { 33 | string traffic_light_id = 1; 34 | TrafficLightColor traffic_light_color = 2; 35 | google.protobuf.Timestamp last_active_time = 3; 36 | google.protobuf.Duration total_duration = 4; 37 | } 38 | -------------------------------------------------------------------------------- /style/uber/trip/v1/trip.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package uber.trip.v1; 4 | 5 | option csharp_namespace = "Uber.Trip.V1"; 6 | option go_package = "tripv1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "TripProto"; 9 | option java_package = "com.uber.trip.v1"; 10 | option objc_class_prefix = "UTX"; 11 | option php_namespace = "Uber\\Trip\\V1"; 12 | 13 | import "uber/user/v1/user.proto"; 14 | import "google/protobuf/timestamp.proto"; 15 | 16 | // A trip taken by a rider. 17 | message Trip { 18 | string id = 1; 19 | user.v1.User user = 2; 20 | google.protobuf.Timestamp start_time = 3; 21 | google.protobuf.Timestamp end_time = 4; 22 | repeated Waypoint waypoints = 5; 23 | } 24 | 25 | // A given waypoint. 26 | message Waypoint { 27 | // In the real world, addresses would be normalized into 28 | // a PostalAddress message or such, but for brevity we simplify 29 | // this to a freeform string. 30 | string postal_address = 1; 31 | // The nickname of this waypoint, if any. 32 | string nickname = 2; 33 | } 34 | -------------------------------------------------------------------------------- /style/uber/trip/v1/trip_api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package uber.trip.v1; 4 | 5 | option csharp_namespace = "Uber.Trip.V1"; 6 | option go_package = "tripv1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "TripApiProto"; 9 | option java_package = "com.uber.trip.v1"; 10 | option objc_class_prefix = "UTX"; 11 | option php_namespace = "Uber\\Trip\\V1"; 12 | 13 | import "uber/trip/v1/trip.proto"; 14 | import "google/protobuf/timestamp.proto"; 15 | 16 | // Handles interaction with trips. 17 | service TripAPI { 18 | // Get the trip specified by the ID. 19 | rpc GetTrip(GetTripRequest) returns (GetTripResponse); 20 | // List the trips for the given user before a given time. 21 | // 22 | // If the start index is beyond the end of the available number 23 | // of trips, an empty list of trips will be returned. 24 | // If the start index plus the size is beyond the available number 25 | // of trips, only the number of available trips will be returned. 26 | rpc ListUserTrips(ListUserTripsRequest) returns (ListUserTripsResponse); 27 | } 28 | 29 | message GetTripRequest { 30 | string id = 1; 31 | } 32 | 33 | message GetTripResponse { 34 | Trip trip = 1; 35 | } 36 | 37 | message ListUserTripsRequest { 38 | string user_id = 1; 39 | google.protobuf.Timestamp before_time = 2; 40 | // The start index for pagination. 41 | uint64 start = 3; 42 | // The maximum number of trips to return. 43 | uint64 max_size = 4; 44 | } 45 | 46 | message ListUserTripsResponse { 47 | repeated Trip trips = 1; 48 | // True if more trips are available. 49 | bool next = 2; 50 | } 51 | -------------------------------------------------------------------------------- /style/uber/user/v1/user.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package uber.user.v1; 4 | 5 | option csharp_namespace = "Uber.User.V1"; 6 | option go_package = "userv1"; 7 | option java_multiple_files = true; 8 | option java_outer_classname = "UserProto"; 9 | option java_package = "com.uber.user.v1"; 10 | option objc_class_prefix = "UUX"; 11 | option php_namespace = "Uber\\User\\V1"; 12 | 13 | // A user. 14 | message User { 15 | string id = 1; 16 | string last_name = 3; 17 | string first_names = 5; 18 | 19 | // Deprecated: use first_names instead. 20 | string first_name = 2 [deprecated = true]; 21 | // Deprecated: use first_names instead. 22 | repeated string middle_names = 4 [deprecated = true]; 23 | } 24 | -------------------------------------------------------------------------------- /vim/prototool/ale_linters/proto/prototool.vim: -------------------------------------------------------------------------------- 1 | " Description: run prototool 2 | " 3 | " Deprecated: use prototool-compile, prototool-lint, or prototool-all instead 4 | 5 | call ale#Set('proto_prototool_command', 'all') 6 | 7 | function! ale_linters#proto#prototool#GetCommand(buffer) abort 8 | let l:command = ale#Var(a:buffer, 'proto_prototool_command') 9 | if l:command is? 'all' 10 | " Compile the file, then do generation, then lint 11 | return 'prototool all --disable-format %s' 12 | elseif l:command is? 'compile' 13 | " Compile the file only, doing no generation 14 | return 'prototool compile %s' 15 | elseif l:command is? 'lint' 16 | " Compile the file and then lint, doing no generation 17 | return 'prototool lint %s' 18 | else 19 | " Sensible default, would be better if we could return error 20 | " Is there a way to return error? 21 | return 'prototool all --disable-format %s' 22 | endif 23 | endfunction 24 | 25 | call ale#linter#Define('proto', { 26 | \ 'name': 'prototool', 27 | \ 'lint_file': 1, 28 | \ 'output_stream': 'stdout', 29 | \ 'executable': 'prototool', 30 | \ 'command_callback': 'ale_linters#proto#prototool#GetCommand', 31 | \ 'callback': 'ale#handlers#unix#HandleAsError', 32 | \}) 33 | -------------------------------------------------------------------------------- /vim/prototool/ale_linters/proto/prototool_all.vim: -------------------------------------------------------------------------------- 1 | " Description: run prototool all 2 | 3 | function! ale_linters#proto#prototool_all#GetCommand(buffer) abort 4 | return 'prototool all --disable-format %s' 5 | endfunction 6 | 7 | call ale#linter#Define('proto', { 8 | \ 'name': 'prototool-all', 9 | \ 'lint_file': 1, 10 | \ 'output_stream': 'stdout', 11 | \ 'executable': 'prototool', 12 | \ 'command_callback': 'ale_linters#proto#prototool_all#GetCommand', 13 | \ 'callback': 'ale#handlers#unix#HandleAsError', 14 | \}) 15 | -------------------------------------------------------------------------------- /vim/prototool/ale_linters/proto/prototool_compile.vim: -------------------------------------------------------------------------------- 1 | " Description: run prototool compile 2 | 3 | function! ale_linters#proto#prototool_compile#GetCommand(buffer) abort 4 | return 'prototool compile %s' 5 | endfunction 6 | 7 | call ale#linter#Define('proto', { 8 | \ 'name': 'prototool-compile', 9 | \ 'lint_file': 1, 10 | \ 'output_stream': 'stdout', 11 | \ 'executable': 'prototool', 12 | \ 'command_callback': 'ale_linters#proto#prototool_compile#GetCommand', 13 | \ 'callback': 'ale#handlers#unix#HandleAsError', 14 | \}) 15 | -------------------------------------------------------------------------------- /vim/prototool/ale_linters/proto/prototool_lint.vim: -------------------------------------------------------------------------------- 1 | " Description: run prototool lint 2 | 3 | function! ale_linters#proto#prototool_lint#GetCommand(buffer) abort 4 | return 'prototool lint %s' 5 | endfunction 6 | 7 | call ale#linter#Define('proto', { 8 | \ 'name': 'prototool-lint', 9 | \ 'lint_file': 1, 10 | \ 'output_stream': 'stdout', 11 | \ 'executable': 'prototool', 12 | \ 'command_callback': 'ale_linters#proto#prototool_lint#GetCommand', 13 | \ 'callback': 'ale#handlers#unix#HandleAsError', 14 | \}) 15 | --------------------------------------------------------------------------------