diff --git a/buf/internal/breaking.bzl b/buf/internal/breaking.bzl index ab4b1d9..43bbf61 100644 --- a/buf/internal/breaking.bzl +++ b/buf/internal/breaking.bzl @@ -27,13 +27,16 @@ _TOOLCHAIN = str(Label("//tools/protoc-gen-buf-breaking:toolchain_type")) def _buf_breaking_test_impl(ctx): proto_infos = [t[ProtoInfo] for t in ctx.attr.targets] - config = json.encode({ + config_map = { "against_input": ctx.file.against.short_path, "limit_to_input_files": ctx.attr.limit_to_input_files, "exclude_imports": ctx.attr.exclude_imports, "input_config": ctx.file.config.short_path, "error_format": ctx.attr.error_format, - }) + } + if ctx.attr.module != "": + config_map["module"] = ctx.attr.module + config = json.encode(config_map) files_to_include = [ctx.file.against] if ctx.file.config != None: files_to_include.append(ctx.file.config) @@ -69,6 +72,10 @@ buf_breaking_test = rule( allow_single_file = True, doc = """The `buf.yaml` file""", ), + "module": attr.string( + default = "", + doc = "The module to use in v2 config", + ), "limit_to_input_files": attr.bool( default = False, doc = """Checks are limited to input files. If a file gets deleted that will not be caught. Please refer to https://docs.buf.build/breaking/protoc-plugin for more details""", diff --git a/buf/internal/lint.bzl b/buf/internal/lint.bzl index ff4a33c..981eecd 100644 --- a/buf/internal/lint.bzl +++ b/buf/internal/lint.bzl @@ -27,10 +27,13 @@ _TOOLCHAIN = str(Label("//tools/protoc-gen-buf-lint:toolchain_type")) def _buf_lint_test_impl(ctx): proto_infos = [t[ProtoInfo] for t in ctx.attr.targets] - config = json.encode({ + config_map = { "input_config": "" if ctx.file.config == None else ctx.file.config.short_path, "error_format": ctx.attr.error_format, - }) + } + if ctx.attr.module != "": + config_map["module"] = ctx.attr.module + config = json.encode(config_map) files_to_include = [] if ctx.file.config != None: files_to_include.append(ctx.file.config) @@ -62,6 +65,10 @@ buf_lint_test = rule( allow_single_file = True, doc = "The `buf.yaml` file", ), + "module": attr.string( + default = "", + doc = "The module to use in v2 config", + ), "error_format": attr.string( default = "", doc = "error-format flag for buf lint: https://buf.build/docs/reference/cli/buf/lint#error-format",