From c76538de4a7ba6adcbfe90768287ba74a449f372 Mon Sep 17 00:00:00 2001 From: "Philip K. Warren" Date: Fri, 2 Oct 2026 11:07:20 -0500 Subject: [PATCH] Include optional module name on file descriptor In some cases, it may be useful to know the BSR module name of a file descriptor in a check plugin. This could be used to enforce package naming constraints matching the module's organization name or name. Update copyright years and buf CLI version to the latest. --- .github/workflows/ci.yaml | 2 +- LICENSE | 2 +- Makefile | 8 ++-- buf/plugin/check/v1/annotation.proto | 2 +- buf/plugin/check/v1/category.proto | 2 +- buf/plugin/check/v1/check.proto | 2 +- buf/plugin/check/v1/check_service.proto | 2 +- buf/plugin/check/v1/rule.proto | 2 +- .../descriptor/v1/file_descriptor.proto | 5 ++- buf/plugin/descriptor/v1/file_location.proto | 2 +- buf/plugin/descriptor/v1/module_name.proto | 43 +++++++++++++++++++ buf/plugin/info/v1/license.proto | 7 +-- buf/plugin/info/v1/plugin_info.proto | 2 +- buf/plugin/info/v1/plugin_info_service.proto | 2 +- buf/plugin/option/v1/option.proto | 2 +- 15 files changed, 65 insertions(+), 20 deletions(-) create mode 100644 buf/plugin/descriptor/v1/module_name.proto diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7b68426..0ce7e0c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,7 +12,7 @@ jobs: - name: install uses: actions/setup-go@v7 with: - go-version: 1.23.x + go-version: 1.27.x cache-dependency-path: Makefile - name: make run: make diff --git a/LICENSE b/LICENSE index 1d56d56..6e9dfef 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2024-2025 Buf Technologies, Inc. + Copyright 2024-2026 Buf Technologies, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Makefile b/Makefile index b6469f4..4fde76e 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,9 @@ BIN := .tmp/bin export PATH := $(BIN):$(PATH) export GOBIN := $(abspath $(BIN)) -BUF_VERSION := v1.42.0 -COPYRIGHT_YEARS := 2024-2025 +BUF_VERSION := v1.73.0 +COPYRIGHT_YEARS := 2024-2026 +LICENSE_IGNORE := -e .github/ -e buf.yaml .PHONY: help help: ## Describe useful make targets @@ -46,7 +47,8 @@ generate: $(BIN)/buf $(BIN)/license-header ## Format and regenerate license head license-header \ --license-type apache \ --copyright-holder "Buf Technologies, Inc." \ - --year-range "$(COPYRIGHT_YEARS)" + --year-range "$(COPYRIGHT_YEARS)" \ + $(LICENSE_IGNORE) buf format -w .PHONY: checkgenerate diff --git a/buf/plugin/check/v1/annotation.proto b/buf/plugin/check/v1/annotation.proto index 7698705..8ca9d7a 100644 --- a/buf/plugin/check/v1/annotation.proto +++ b/buf/plugin/check/v1/annotation.proto @@ -1,4 +1,4 @@ -// Copyright 2024-2025 Buf Technologies, Inc. +// Copyright 2024-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/buf/plugin/check/v1/category.proto b/buf/plugin/check/v1/category.proto index f5a6b9b..ff7c131 100644 --- a/buf/plugin/check/v1/category.proto +++ b/buf/plugin/check/v1/category.proto @@ -1,4 +1,4 @@ -// Copyright 2024-2025 Buf Technologies, Inc. +// Copyright 2024-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/buf/plugin/check/v1/check.proto b/buf/plugin/check/v1/check.proto index 4e789e2..f0286ad 100644 --- a/buf/plugin/check/v1/check.proto +++ b/buf/plugin/check/v1/check.proto @@ -1,4 +1,4 @@ -// Copyright 2024-2025 Buf Technologies, Inc. +// Copyright 2024-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/buf/plugin/check/v1/check_service.proto b/buf/plugin/check/v1/check_service.proto index 041b348..31d47ab 100644 --- a/buf/plugin/check/v1/check_service.proto +++ b/buf/plugin/check/v1/check_service.proto @@ -1,4 +1,4 @@ -// Copyright 2024-2025 Buf Technologies, Inc. +// Copyright 2024-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/buf/plugin/check/v1/rule.proto b/buf/plugin/check/v1/rule.proto index 05055d5..d7dcc63 100644 --- a/buf/plugin/check/v1/rule.proto +++ b/buf/plugin/check/v1/rule.proto @@ -1,4 +1,4 @@ -// Copyright 2024-2025 Buf Technologies, Inc. +// Copyright 2024-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/buf/plugin/descriptor/v1/file_descriptor.proto b/buf/plugin/descriptor/v1/file_descriptor.proto index 425ae2f..ca1196b 100644 --- a/buf/plugin/descriptor/v1/file_descriptor.proto +++ b/buf/plugin/descriptor/v1/file_descriptor.proto @@ -1,4 +1,4 @@ -// Copyright 2024-2025 Buf Technologies, Inc. +// Copyright 2024-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ syntax = "proto3"; package buf.plugin.descriptor.v1; +import "buf/plugin/descriptor/v1/module_name.proto"; import "buf/validate/validate.proto"; import "google/protobuf/descriptor.proto"; @@ -60,4 +61,6 @@ message FileDescriptor { // // This matches the shape of the public_dependency and weak_dependency fields. repeated int32 unused_dependency = 4; + // The name of the module that the file belongs to, if any. + ModuleName module_name = 5; } diff --git a/buf/plugin/descriptor/v1/file_location.proto b/buf/plugin/descriptor/v1/file_location.proto index d132617..bf29dbd 100644 --- a/buf/plugin/descriptor/v1/file_location.proto +++ b/buf/plugin/descriptor/v1/file_location.proto @@ -1,4 +1,4 @@ -// Copyright 2024-2025 Buf Technologies, Inc. +// Copyright 2024-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/buf/plugin/descriptor/v1/module_name.proto b/buf/plugin/descriptor/v1/module_name.proto new file mode 100644 index 0000000..3577402 --- /dev/null +++ b/buf/plugin/descriptor/v1/module_name.proto @@ -0,0 +1,43 @@ +// Copyright 2024-2026 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package buf.plugin.descriptor.v1; + +import "buf/validate/validate.proto"; + +option go_package = "buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go/buf/plugin/descriptor/v1"; + +// The fully-qualified name of a module on the Buf Schema Registry. +message ModuleName { + // The registry hostname of the module. + // + // Required. + string registry = 1 [(buf.validate.field).required = true]; + // The name of the owner of the module, either a user or organization. + // + // Required. + string owner = 2 [ + (buf.validate.field).required = true, + (buf.validate.field).string.max_len = 48 + ]; + // The name of the module. + // + // Required. + string module = 3 [(buf.validate.field).string = { + min_len: 2 + max_len: 100 + }]; +} diff --git a/buf/plugin/info/v1/license.proto b/buf/plugin/info/v1/license.proto index f47416b..36568fa 100644 --- a/buf/plugin/info/v1/license.proto +++ b/buf/plugin/info/v1/license.proto @@ -1,4 +1,4 @@ -// Copyright 2024-2025 Buf Technologies, Inc. +// Copyright 2024-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -37,9 +37,6 @@ message License { // The raw text of the license. string text = 2; // The url that contains the license. - string url = 3 [ - (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, - (buf.validate.field).string.uri = true - ]; + string url = 3 [(buf.validate.field).string.uri = true]; } } diff --git a/buf/plugin/info/v1/plugin_info.proto b/buf/plugin/info/v1/plugin_info.proto index b31d8fc..8f823e7 100644 --- a/buf/plugin/info/v1/plugin_info.proto +++ b/buf/plugin/info/v1/plugin_info.proto @@ -1,4 +1,4 @@ -// Copyright 2024-2025 Buf Technologies, Inc. +// Copyright 2024-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/buf/plugin/info/v1/plugin_info_service.proto b/buf/plugin/info/v1/plugin_info_service.proto index 7e25c68..d4f30f9 100644 --- a/buf/plugin/info/v1/plugin_info_service.proto +++ b/buf/plugin/info/v1/plugin_info_service.proto @@ -1,4 +1,4 @@ -// Copyright 2024-2025 Buf Technologies, Inc. +// Copyright 2024-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/buf/plugin/option/v1/option.proto b/buf/plugin/option/v1/option.proto index df67ab0..e907e3b 100644 --- a/buf/plugin/option/v1/option.proto +++ b/buf/plugin/option/v1/option.proto @@ -1,4 +1,4 @@ -// Copyright 2024-2025 Buf Technologies, Inc. +// Copyright 2024-2026 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.