tools: Move external packages constant to top level

dependabot/go_modules/go.uber.org/atomic-1.10.0
Marek Siarkowicz 2022-01-28 16:12:00 +01:00
parent 3df14fc24f
commit 0c67c5ca49
1 changed files with 10 additions and 4 deletions

View File

@ -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
@ -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 {