Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/proto
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-08-30 11:53:49 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-08-30 12:04:25 +0300
commit388ffbf4b7fbdb760169a527af55a2c07f6b8dfc (patch)
tree022957132d95f5f020999fdf5c0a580dcde747ec /proto
parentd52975efc2b4978aef138fb606b81347b82d366c (diff)
protobuf: Migrate to use new pluginpb package
The golang/protobuf dependency in deprecated in favor of google.golang.org/protobuf. Migrate our usage of the plugin package to use the new pluginpb package instead.
Diffstat (limited to 'proto')
-rw-r--r--proto/go/internal/cmd/protoc-gen-gitaly/main.go10
-rw-r--r--proto/go/internal/linter/lint.go8
-rw-r--r--proto/go/internal/linter/lint_test.go4
-rw-r--r--proto/go/internal/linter/method.go6
4 files changed, 14 insertions, 14 deletions
diff --git a/proto/go/internal/cmd/protoc-gen-gitaly/main.go b/proto/go/internal/cmd/protoc-gen-gitaly/main.go
index 16632acec..b16b88b22 100644
--- a/proto/go/internal/cmd/protoc-gen-gitaly/main.go
+++ b/proto/go/internal/cmd/protoc-gen-gitaly/main.go
@@ -62,9 +62,9 @@ import (
"strings"
"text/template"
- plugin "github.com/golang/protobuf/protoc-gen-go/plugin"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/internal/linter"
"google.golang.org/protobuf/proto"
+ "google.golang.org/protobuf/types/pluginpb"
)
const (
@@ -78,7 +78,7 @@ func main() {
log.Fatalf("reading input: %s", err)
}
- req := &plugin.CodeGeneratorRequest{}
+ req := &pluginpb.CodeGeneratorRequest{}
if err := proto.Unmarshal(data, req); err != nil {
log.Fatalf("parsing input proto: %s", err)
@@ -110,7 +110,7 @@ func parseArgs(argString string) (gitalyProtoDir string, gitalypbDir string) {
return gitalyProtoDir, gitalypbDir
}
-func lintProtos(req *plugin.CodeGeneratorRequest) error {
+func lintProtos(req *pluginpb.CodeGeneratorRequest) error {
var errMsgs []string
for _, pf := range req.GetProtoFile() {
errs := linter.LintFile(pf, req)
@@ -119,7 +119,7 @@ func lintProtos(req *plugin.CodeGeneratorRequest) error {
}
}
- resp := &plugin.CodeGeneratorResponse{}
+ resp := &pluginpb.CodeGeneratorResponse{}
if len(errMsgs) > 0 {
errMsg := strings.Join(errMsgs, "\n\t")
@@ -139,7 +139,7 @@ func lintProtos(req *plugin.CodeGeneratorRequest) error {
return nil
}
-func generateProtolistGo(req *plugin.CodeGeneratorRequest) error {
+func generateProtolistGo(req *pluginpb.CodeGeneratorRequest) error {
var err error
gitalyProtoDir, gitalypbDir := parseArgs(req.GetParameter())
diff --git a/proto/go/internal/linter/lint.go b/proto/go/internal/linter/lint.go
index 95a97e2d8..ea84fd34e 100644
--- a/proto/go/internal/linter/lint.go
+++ b/proto/go/internal/linter/lint.go
@@ -4,11 +4,11 @@ import (
"errors"
"fmt"
- 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"
+ "google.golang.org/protobuf/types/pluginpb"
)
// 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 *descriptorpb.FileDescriptorProto, m *descriptorpb.MethodDescriptorProto, req *plugin.CodeGeneratorRequest) error {
+func ensureMethodOpType(fileDesc *descriptorpb.FileDescriptorProto, m *descriptorpb.MethodDescriptorProto, req *pluginpb.CodeGeneratorRequest) error {
opMsg, err := protoutil.GetOpExtension(m)
if err != nil {
if errors.Is(err, protoregistry.NotFound) {
@@ -51,7 +51,7 @@ func ensureMethodOpType(fileDesc *descriptorpb.FileDescriptorProto, m *descripto
}
}
-func validateMethod(file *descriptorpb.FileDescriptorProto, service *descriptorpb.ServiceDescriptorProto, method *descriptorpb.MethodDescriptorProto, req *plugin.CodeGeneratorRequest) error {
+func validateMethod(file *descriptorpb.FileDescriptorProto, service *descriptorpb.ServiceDescriptorProto, method *descriptorpb.MethodDescriptorProto, req *pluginpb.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 *descriptorpb.FileDescriptorProto, service *descriptorp
// 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 *descriptorpb.FileDescriptorProto, req *plugin.CodeGeneratorRequest) []error {
+func LintFile(file *descriptorpb.FileDescriptorProto, req *pluginpb.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 307a1f906..b6631cd0d 100644
--- a/proto/go/internal/linter/lint_test.go
+++ b/proto/go/internal/linter/lint_test.go
@@ -4,12 +4,12 @@ import (
"errors"
"testing"
- 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"
+ "google.golang.org/protobuf/types/pluginpb"
)
func TestLintFile(t *testing.T) {
@@ -46,7 +46,7 @@ func TestLintFile(t *testing.T) {
require.NoError(t, err)
fdToCheck := protodesc.ToFileDescriptorProto(fd)
- req := &plugin.CodeGeneratorRequest{
+ req := &pluginpb.CodeGeneratorRequest{
ProtoFile: []*descriptorpb.FileDescriptorProto{fdToCheck},
}
diff --git a/proto/go/internal/linter/method.go b/proto/go/internal/linter/method.go
index 828769020..11ad03c36 100644
--- a/proto/go/internal/linter/method.go
+++ b/proto/go/internal/linter/method.go
@@ -5,14 +5,14 @@ import (
"fmt"
"strings"
- 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"
+ "google.golang.org/protobuf/types/pluginpb"
)
type methodLinter struct {
- req *plugin.CodeGeneratorRequest
+ req *pluginpb.CodeGeneratorRequest
fileDesc *descriptorpb.FileDescriptorProto
methodDesc *descriptorpb.MethodDescriptorProto
opMsg *gitalypb.OperationMsg
@@ -213,7 +213,7 @@ func findChildMsg(topLevelMsgs map[string]*descriptorpb.DescriptorProto, t *desc
return nil, fmt.Errorf("could not find message type %q", msgName)
}
-func getFileTypes(filename string, req *plugin.CodeGeneratorRequest) ([]*descriptorpb.DescriptorProto, error) {
+func getFileTypes(filename string, req *pluginpb.CodeGeneratorRequest) ([]*descriptorpb.DescriptorProto, error) {
var types []*descriptorpb.DescriptorProto
var protoFile *descriptorpb.FileDescriptorProto
for _, pf := range req.ProtoFile {