Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(737)

Unified Diff: grpc/cmd/rpc/printer.go

Issue 2219023003: Update APIs to use new Google cloud paths. (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: grpc/cmd/rpc/printer.go
diff --git a/grpc/cmd/rpc/printer.go b/grpc/cmd/rpc/printer.go
index 0adcb46e07625dcc41e5f8e9390a0f49c49c0709..f1c4f598e84b369e362c45d22f6dfa730f3b266e 100644
--- a/grpc/cmd/rpc/printer.go
+++ b/grpc/cmd/rpc/printer.go
@@ -9,8 +9,10 @@ import (
"io"
"strings"
+ "github.com/luci/luci-go/common/proto/google/descutil"
+
"github.com/luci/luci-go/common/data/text/indented"
- "github.com/luci/luci-go/common/proto/google/descriptor"
+ "google.golang.org/genproto/protobuf"
)
// printer prints a proto3 definition from a description.
@@ -64,7 +66,7 @@ func (p *printer) MaybeLeadingComments(path []int) {
return
}
- loc := p.File.SourceCodeInfo.FindLocation(path)
+ loc := descutil.FindLocation(p.File.SourceCodeInfo, path)
if loc == nil {
return
}
@@ -101,7 +103,7 @@ func (p *printer) shorten(name string) string {
func (p *printer) Service(service *descriptor.ServiceDescriptorProto, serviceIndex, methodIndex int) {
var path []int
if serviceIndex != -1 {
- path = []int{descriptor.NumberFileDescriptorProto_Service, serviceIndex}
+ path = []int{descutil.FileDescriptorProtoServiceTag, serviceIndex}
p.MaybeLeadingComments(path)
}
defer p.open("service %s", service.GetName())()
@@ -109,7 +111,7 @@ func (p *printer) Service(service *descriptor.ServiceDescriptorProto, serviceInd
printMethod := func(i int) {
var methodPath []int
if path != nil {
- methodPath = append(path, descriptor.NumberServiceDescriptorProto_Method, i)
+ methodPath = append(path, descutil.ServiceDescriptorProtoMethodTag, i)
}
p.Method(service.Method[i], methodPath)
}
@@ -166,7 +168,7 @@ var fieldTypeName = map[descriptor.FieldDescriptorProto_Type]string{
// common/proto/google/descriptor/descriptor.proto.
func (p *printer) Field(field *descriptor.FieldDescriptorProto, path []int) {
p.MaybeLeadingComments(path)
- if field.Repeated() {
+ if descutil.Repeated(field) {
p.Printf("repeated ")
}
@@ -197,7 +199,7 @@ func (p *printer) Message(msg *descriptor.DescriptorProto, path []int) {
if f.OneofIndex == nil {
var fieldPath []int
if len(path) > 0 {
- fieldPath = append(path, descriptor.NumberDescriptorProto_Field, i)
+ fieldPath = append(path, descutil.DescriptorProtoFieldTag, i)
}
p.Field(msg.Field[i], fieldPath)
}
@@ -212,7 +214,7 @@ func (p *printer) Message(msg *descriptor.DescriptorProto, path []int) {
func (p *printer) OneOf(msg *descriptor.DescriptorProto, oneOfIndex int, msgPath []int) {
of := msg.GetOneofDecl()[oneOfIndex]
if len(msgPath) > 0 {
- p.MaybeLeadingComments(append(msgPath, descriptor.NumberDescriptorProto_OneOf, oneOfIndex))
+ p.MaybeLeadingComments(append(msgPath, descutil.DescriptorProtoOneOfTag, oneOfIndex))
}
defer p.open("oneof %s", of.GetName())()
@@ -220,7 +222,7 @@ func (p *printer) OneOf(msg *descriptor.DescriptorProto, oneOfIndex int, msgPath
if f.OneofIndex != nil && int(f.GetOneofIndex()) == oneOfIndex {
var fieldPath []int
if len(msgPath) > 0 {
- fieldPath = append(msgPath, descriptor.NumberDescriptorProto_Field, i)
+ fieldPath = append(msgPath, descutil.DescriptorProtoFieldTag, i)
}
p.Field(msg.Field[i], fieldPath)
}
@@ -239,7 +241,7 @@ func (p *printer) Enum(enum *descriptor.EnumDescriptorProto, path []int) {
for i, v := range enum.Value {
var valuePath []int
if len(path) > 0 {
- valuePath = append(path, descriptor.NumberEnumDescriptorProto_Value, i)
+ valuePath = append(path, descutil.EnumDescriptorProtoValueTag, i)
}
p.EnumValue(v, valuePath)
}

Powered by Google App Engine
This is Rietveld 408576698