Skip to content

Commit

Permalink
tools: Move external packages constant to top level
Browse files Browse the repository at this point in the history
  • Loading branch information
serathius committed Jan 28, 2022
1 parent 3df14fc commit 0c67c5c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tools/proto-annotations/cmd/etcd_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ import (
"google.golang.org/protobuf/reflect/protoregistry"
)

var (
// externalPackages that are not expected to have etcd version annotation.
externalPackages = []string{"io.prometheus.client", "grpc.binarylog.v1", "google.protobuf", "google.rpc", "google.api"}
)

// printEtcdVersion writes etcd_version proto annotation to stdout and returns any errors encountered when reading annotation.
func printEtcdVersion() []error {
var errs []error
Expand Down Expand Up @@ -59,10 +64,11 @@ func printEtcdVersion() []error {
func allEtcdVersionAnnotations() (annotations []etcdVersionAnnotation, err error) {
var fileAnnotations []etcdVersionAnnotation
protoregistry.GlobalFiles.RangeFiles(func(file protoreflect.FileDescriptor) bool {
switch string(file.Package()) {
// Skip external packages that are not expected to have etcd version annotation.
case "io.prometheus.client", "grpc.binarylog.v1", "google.protobuf", "google.rpc", "google.api":
return true
pkg := string(file.Package())
for _, externalPkg := range externalPackages {
if pkg == externalPkg {
return true
}
}
fileAnnotations, err = fileEtcdVersionAnnotations(file)
if err != nil {
Expand Down

0 comments on commit 0c67c5c

Please sign in to comment.