diff options
Diffstat (limited to 'proto')
-rw-r--r-- | proto/go/internal/linter/lint.go | 8 | ||||
-rw-r--r-- | proto/go/internal/linter/lint_test.go | 4 | ||||
-rw-r--r-- | proto/go/internal/linter/method.go | 28 |
3 files changed, 20 insertions, 20 deletions
diff --git a/proto/go/internal/linter/lint.go b/proto/go/internal/linter/lint.go index f7d0fd43c..95a97e2d8 100644 --- a/proto/go/internal/linter/lint.go +++ b/proto/go/internal/linter/lint.go @@ -4,11 +4,11 @@ import ( "errors" "fmt" - "github.com/golang/protobuf/protoc-gen-go/descriptor" plugin "github.com/golang/protobuf/protoc-gen-go/plugin" "gitlab.com/gitlab-org/gitaly/v14/internal/protoutil" "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb" "google.golang.org/protobuf/reflect/protoregistry" + "google.golang.org/protobuf/types/descriptorpb" ) // ensureMethodOpType will ensure that method includes the op_type option. @@ -17,7 +17,7 @@ import ( // rpc ExampleMethod(ExampleMethodRequest) returns (ExampleMethodResponse) { // option (op_type).op = ACCESSOR; // } -func ensureMethodOpType(fileDesc *descriptor.FileDescriptorProto, m *descriptor.MethodDescriptorProto, req *plugin.CodeGeneratorRequest) error { +func ensureMethodOpType(fileDesc *descriptorpb.FileDescriptorProto, m *descriptorpb.MethodDescriptorProto, req *plugin.CodeGeneratorRequest) error { opMsg, err := protoutil.GetOpExtension(m) if err != nil { if errors.Is(err, protoregistry.NotFound) { @@ -51,7 +51,7 @@ func ensureMethodOpType(fileDesc *descriptor.FileDescriptorProto, m *descriptor. } } -func validateMethod(file *descriptor.FileDescriptorProto, service *descriptor.ServiceDescriptorProto, method *descriptor.MethodDescriptorProto, req *plugin.CodeGeneratorRequest) error { +func validateMethod(file *descriptorpb.FileDescriptorProto, service *descriptorpb.ServiceDescriptorProto, method *descriptorpb.MethodDescriptorProto, req *plugin.CodeGeneratorRequest) error { if intercepted, err := protoutil.IsInterceptedService(service); err != nil { return fmt.Errorf("is intercepted service: %w", err) } else if intercepted { @@ -72,7 +72,7 @@ func validateMethod(file *descriptor.FileDescriptorProto, service *descriptor.Se // LintFile ensures the file described meets Gitaly required processes. // Currently, this is limited to validating if request messages contain // a mandatory operation code. -func LintFile(file *descriptor.FileDescriptorProto, req *plugin.CodeGeneratorRequest) []error { +func LintFile(file *descriptorpb.FileDescriptorProto, req *plugin.CodeGeneratorRequest) []error { var errs []error for _, service := range file.GetService() { diff --git a/proto/go/internal/linter/lint_test.go b/proto/go/internal/linter/lint_test.go index 4bf2653a2..307a1f906 100644 --- a/proto/go/internal/linter/lint_test.go +++ b/proto/go/internal/linter/lint_test.go @@ -4,12 +4,12 @@ import ( "errors" "testing" - "github.com/golang/protobuf/protoc-gen-go/descriptor" plugin "github.com/golang/protobuf/protoc-gen-go/plugin" "github.com/stretchr/testify/require" _ "gitlab.com/gitlab-org/gitaly/v14/proto/go/internal/linter/testdata" "google.golang.org/protobuf/reflect/protodesc" protoreg "google.golang.org/protobuf/reflect/protoregistry" + "google.golang.org/protobuf/types/descriptorpb" ) func TestLintFile(t *testing.T) { @@ -47,7 +47,7 @@ func TestLintFile(t *testing.T) { fdToCheck := protodesc.ToFileDescriptorProto(fd) req := &plugin.CodeGeneratorRequest{ - ProtoFile: []*descriptor.FileDescriptorProto{fdToCheck}, + ProtoFile: []*descriptorpb.FileDescriptorProto{fdToCheck}, } for _, protoPath := range []string{ diff --git a/proto/go/internal/linter/method.go b/proto/go/internal/linter/method.go index bf4d56746..828769020 100644 --- a/proto/go/internal/linter/method.go +++ b/proto/go/internal/linter/method.go @@ -5,16 +5,16 @@ import ( "fmt" "strings" - "github.com/golang/protobuf/protoc-gen-go/descriptor" plugin "github.com/golang/protobuf/protoc-gen-go/plugin" "gitlab.com/gitlab-org/gitaly/v14/internal/protoutil" "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb" + "google.golang.org/protobuf/types/descriptorpb" ) type methodLinter struct { req *plugin.CodeGeneratorRequest - fileDesc *descriptor.FileDescriptorProto - methodDesc *descriptor.MethodDescriptorProto + fileDesc *descriptorpb.FileDescriptorProto + methodDesc *descriptorpb.MethodDescriptorProto opMsg *gitalypb.OperationMsg } @@ -128,8 +128,8 @@ func (ml methodLinter) ensureValidTargetRepository(expected int) error { return nil } -func (ml methodLinter) getTopLevelMsgs() (map[string]*descriptor.DescriptorProto, error) { - topLevelMsgs := map[string]*descriptor.DescriptorProto{} +func (ml methodLinter) getTopLevelMsgs() (map[string]*descriptorpb.DescriptorProto, error) { + topLevelMsgs := map[string]*descriptorpb.DescriptorProto{} types, err := getFileTypes(ml.fileDesc.GetName(), ml.req) if err != nil { @@ -142,13 +142,13 @@ func (ml methodLinter) getTopLevelMsgs() (map[string]*descriptor.DescriptorProto } type matcher struct { - match func(*descriptor.FieldDescriptorProto) (bool, error) - subMatch func(*descriptor.FieldDescriptorProto) (bool, error) + match func(*descriptorpb.FieldDescriptorProto) (bool, error) + subMatch func(*descriptorpb.FieldDescriptorProto) (bool, error) expectedType string - topLevelMsgs map[string]*descriptor.DescriptorProto + topLevelMsgs map[string]*descriptorpb.DescriptorProto } -func (m matcher) findMatchingFields(prefix string, t *descriptor.DescriptorProto) ([]string, error) { +func (m matcher) findMatchingFields(prefix string, t *descriptorpb.DescriptorProto) ([]string, error) { var storageFields []string for _, f := range t.GetField() { subMatcher := m @@ -188,8 +188,8 @@ func (m matcher) findMatchingFields(prefix string, t *descriptor.DescriptorProto return storageFields, nil } -func findChildMsg(topLevelMsgs map[string]*descriptor.DescriptorProto, t *descriptor.DescriptorProto, f *descriptor.FieldDescriptorProto) (*descriptor.DescriptorProto, error) { - var childType *descriptor.DescriptorProto +func findChildMsg(topLevelMsgs map[string]*descriptorpb.DescriptorProto, t *descriptorpb.DescriptorProto, f *descriptorpb.FieldDescriptorProto) (*descriptorpb.DescriptorProto, error) { + var childType *descriptorpb.DescriptorProto const msgPrimitive = "TYPE_MESSAGE" if primitive := f.GetType().String(); primitive != msgPrimitive { return nil, nil @@ -213,9 +213,9 @@ func findChildMsg(topLevelMsgs map[string]*descriptor.DescriptorProto, t *descri return nil, fmt.Errorf("could not find message type %q", msgName) } -func getFileTypes(filename string, req *plugin.CodeGeneratorRequest) ([]*descriptor.DescriptorProto, error) { - var types []*descriptor.DescriptorProto - var protoFile *descriptor.FileDescriptorProto +func getFileTypes(filename string, req *plugin.CodeGeneratorRequest) ([]*descriptorpb.DescriptorProto, error) { + var types []*descriptorpb.DescriptorProto + var protoFile *descriptorpb.FileDescriptorProto for _, pf := range req.ProtoFile { if pf.Name != nil && *pf.Name == filename { types = pf.GetMessageType() |