vendor: update gogo/protobuf dependency
Updates to the gogo/protobuf dependency are required to correctly generate time types. We also remove an unused windows dependency. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
57
vendor/github.com/gogo/protobuf/plugin/gostring/gostring.go
generated
vendored
57
vendor/github.com/gogo/protobuf/plugin/gostring/gostring.go
generated
vendored
@@ -97,8 +97,10 @@ not print their values, while the generated GoString method will always print al
|
||||
package gostring
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogo/protobuf/gogoproto"
|
||||
"github.com/gogo/protobuf/protoc-gen-gogo/generator"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
@@ -145,6 +147,7 @@ func (p *gostring) Generate(file *generator.FileDescriptor) {
|
||||
reflectPkg := p.NewImport("reflect")
|
||||
sortKeysPkg := p.NewImport("github.com/gogo/protobuf/sortkeys")
|
||||
|
||||
extensionToGoStringUsed := false
|
||||
for _, message := range file.Messages() {
|
||||
if !p.overwrite && !gogoproto.HasGoString(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
continue
|
||||
@@ -221,7 +224,7 @@ func (p *gostring) Generate(file *generator.FileDescriptor) {
|
||||
p.P(`s = append(s, "`, fieldname, `: " + `, mapName, `+ ",\n")`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if field.IsMessage() || p.IsGroup(field) {
|
||||
} else if (field.IsMessage() && !gogoproto.IsCustomType(field) && !gogoproto.IsStdTime(field) && !gogoproto.IsStdDuration(field)) || p.IsGroup(field) {
|
||||
if nullable || repeated {
|
||||
p.P(`if this.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
@@ -264,6 +267,7 @@ func (p *gostring) Generate(file *generator.FileDescriptor) {
|
||||
if message.DescriptorProto.HasExtension() {
|
||||
if gogoproto.HasExtensionsMap(file.FileDescriptorProto, message.DescriptorProto) {
|
||||
p.P(`s = append(s, "XXX_InternalExtensions: " + extensionToGoString`, p.localName, `(this) + ",\n")`)
|
||||
extensionToGoStringUsed = true
|
||||
} else {
|
||||
p.P(`if this.XXX_extensions != nil {`)
|
||||
p.In()
|
||||
@@ -338,29 +342,34 @@ func (p *gostring) Generate(file *generator.FileDescriptor) {
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
|
||||
p.P(`func extensionToGoString`, p.localName, `(m `, protoPkg.Use(), `.Message) string {`)
|
||||
p.In()
|
||||
p.P(`e := `, protoPkg.Use(), `.GetUnsafeExtensionsMap(m)`)
|
||||
p.P(`if e == nil { return "nil" }`)
|
||||
p.P(`s := "proto.NewUnsafeXXX_InternalExtensions(map[int32]proto.Extension{"`)
|
||||
p.P(`keys := make([]int, 0, len(e))`)
|
||||
p.P(`for k := range e {`)
|
||||
p.In()
|
||||
p.P(`keys = append(keys, int(k))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(sortPkg.Use(), `.Ints(keys)`)
|
||||
p.P(`ss := []string{}`)
|
||||
p.P(`for _, k := range keys {`)
|
||||
p.In()
|
||||
p.P(`ss = append(ss, `, strconvPkg.Use(), `.Itoa(k) + ": " + e[int32(k)].GoString())`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`s+=`, stringsPkg.Use(), `.Join(ss, ",") + "})"`)
|
||||
p.P(`return s`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
|
||||
if extensionToGoStringUsed {
|
||||
if !gogoproto.ImportsGoGoProto(file.FileDescriptorProto) {
|
||||
fmt.Fprintf(os.Stderr, "The GoString plugin for messages with extensions requires importing gogoprotobuf. Please see file %s", file.GetName())
|
||||
os.Exit(1)
|
||||
}
|
||||
p.P(`func extensionToGoString`, p.localName, `(m `, protoPkg.Use(), `.Message) string {`)
|
||||
p.In()
|
||||
p.P(`e := `, protoPkg.Use(), `.GetUnsafeExtensionsMap(m)`)
|
||||
p.P(`if e == nil { return "nil" }`)
|
||||
p.P(`s := "proto.NewUnsafeXXX_InternalExtensions(map[int32]proto.Extension{"`)
|
||||
p.P(`keys := make([]int, 0, len(e))`)
|
||||
p.P(`for k := range e {`)
|
||||
p.In()
|
||||
p.P(`keys = append(keys, int(k))`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(sortPkg.Use(), `.Ints(keys)`)
|
||||
p.P(`ss := []string{}`)
|
||||
p.P(`for _, k := range keys {`)
|
||||
p.In()
|
||||
p.P(`ss = append(ss, `, strconvPkg.Use(), `.Itoa(k) + ": " + e[int32(k)].GoString())`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.P(`s+=`, stringsPkg.Use(), `.Join(ss, ",") + "})"`)
|
||||
p.P(`return s`)
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
2
vendor/github.com/gogo/protobuf/plugin/marshalto/marshalto.go
generated
vendored
2
vendor/github.com/gogo/protobuf/plugin/marshalto/marshalto.go
generated
vendored
@@ -420,7 +420,7 @@ func (p *marshalto) generateField(proto3 bool, numGen NumGen, file *generator.Fi
|
||||
p.P(`if m.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
}
|
||||
packed := field.IsPacked() || (proto3 && field.IsRepeated() && generator.IsScalar(field))
|
||||
packed := field.IsPacked() || (proto3 && field.IsPacked3())
|
||||
wireType := field.WireType()
|
||||
fieldNumber := field.GetNumber()
|
||||
if packed {
|
||||
|
||||
35
vendor/github.com/gogo/protobuf/plugin/populate/populate.go
generated
vendored
35
vendor/github.com/gogo/protobuf/plugin/populate/populate.go
generated
vendored
@@ -194,7 +194,6 @@ func (p *plugin) getFuncName(goTypName string) string {
|
||||
case "time.NewPopulatedTime":
|
||||
funcName = p.typesPkg.Use() + ".NewPopulatedStdTime"
|
||||
case "time.NewPopulatedDuration":
|
||||
p.typesPkg.Use()
|
||||
funcName = p.typesPkg.Use() + ".NewPopulatedStdDuration"
|
||||
}
|
||||
return funcName
|
||||
@@ -305,6 +304,23 @@ func (p *plugin) GenerateField(file *generator.FileDescriptor, message *generato
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if gogoproto.IsCustomType(field) {
|
||||
funcCall := p.getCustomFuncCall(goTypName)
|
||||
if field.IsRepeated() {
|
||||
p.P(p.varGen.Next(), ` := r.Intn(10)`)
|
||||
p.P(`this.`, fieldname, ` = make(`, goTyp, `, `, p.varGen.Current(), `)`)
|
||||
p.P(`for i := 0; i < `, p.varGen.Current(), `; i++ {`)
|
||||
p.In()
|
||||
p.P(p.varGen.Next(), `:= `, funcCall)
|
||||
p.P(`this.`, fieldname, `[i] = *`, p.varGen.Current())
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if gogoproto.IsNullable(field) {
|
||||
p.P(`this.`, fieldname, ` = `, funcCall)
|
||||
} else {
|
||||
p.P(p.varGen.Next(), `:= `, funcCall)
|
||||
p.P(`this.`, fieldname, ` = *`, p.varGen.Current())
|
||||
}
|
||||
} else if field.IsMessage() || p.IsGroup(field) {
|
||||
funcCall := p.getFuncCall(goTypName)
|
||||
if field.IsRepeated() {
|
||||
@@ -345,23 +361,6 @@ func (p *plugin) GenerateField(file *generator.FileDescriptor, message *generato
|
||||
p.P(p.varGen.Next(), ` := `, val)
|
||||
p.P(`this.`, fieldname, ` = &`, p.varGen.Current())
|
||||
}
|
||||
} else if gogoproto.IsCustomType(field) {
|
||||
funcCall := p.getCustomFuncCall(goTypName)
|
||||
if field.IsRepeated() {
|
||||
p.P(p.varGen.Next(), ` := r.Intn(10)`)
|
||||
p.P(`this.`, fieldname, ` = make(`, goTyp, `, `, p.varGen.Current(), `)`)
|
||||
p.P(`for i := 0; i < `, p.varGen.Current(), `; i++ {`)
|
||||
p.In()
|
||||
p.P(p.varGen.Next(), `:= `, funcCall)
|
||||
p.P(`this.`, fieldname, `[i] = *`, p.varGen.Current())
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
} else if gogoproto.IsNullable(field) {
|
||||
p.P(`this.`, fieldname, ` = `, funcCall)
|
||||
} else {
|
||||
p.P(p.varGen.Next(), `:= `, funcCall)
|
||||
p.P(`this.`, fieldname, ` = *`, p.varGen.Current())
|
||||
}
|
||||
} else if field.IsBytes() {
|
||||
if field.IsRepeated() {
|
||||
p.P(p.varGen.Next(), ` := r.Intn(10)`)
|
||||
|
||||
2
vendor/github.com/gogo/protobuf/plugin/size/size.go
generated
vendored
2
vendor/github.com/gogo/protobuf/plugin/size/size.go
generated
vendored
@@ -230,7 +230,7 @@ func (p *size) generateField(proto3 bool, file *generator.FileDescriptor, messag
|
||||
p.P(`if m.`, fieldname, ` != nil {`)
|
||||
p.In()
|
||||
}
|
||||
packed := field.IsPacked() || (proto3 && field.IsRepeated() && generator.IsScalar(field))
|
||||
packed := field.IsPacked() || (proto3 && field.IsPacked3())
|
||||
_, wire := p.GoType(message, field)
|
||||
wireType := wireToType(wire)
|
||||
fieldNumber := field.GetNumber()
|
||||
|
||||
2
vendor/github.com/gogo/protobuf/plugin/stringer/stringer.go
generated
vendored
2
vendor/github.com/gogo/protobuf/plugin/stringer/stringer.go
generated
vendored
@@ -203,7 +203,7 @@ func (p *stringer) Generate(file *generator.FileDescriptor) {
|
||||
} else if p.IsMap(field) {
|
||||
mapName := `mapStringFor` + fieldname
|
||||
p.P("`", fieldname, ":`", ` + `, mapName, " + `,", "`,")
|
||||
} else if field.IsMessage() || p.IsGroup(field) {
|
||||
} else if (field.IsMessage() && !gogoproto.IsCustomType(field)) || p.IsGroup(field) {
|
||||
desc := p.ObjectNamed(field.GetTypeName())
|
||||
msgname := p.TypeName(desc)
|
||||
msgnames := strings.Split(msgname, ".")
|
||||
|
||||
26
vendor/github.com/gogo/protobuf/plugin/unmarshal/unmarshal.go
generated
vendored
26
vendor/github.com/gogo/protobuf/plugin/unmarshal/unmarshal.go
generated
vendored
@@ -806,10 +806,13 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip
|
||||
} else {
|
||||
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, time.Duration(0))`)
|
||||
}
|
||||
} else if nullable {
|
||||
} else if nullable && !gogoproto.IsCustomType(field) {
|
||||
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, &`, msgname, `{})`)
|
||||
} else {
|
||||
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, `, msgname, `{})`)
|
||||
goType, _ := p.GoType(nil, field)
|
||||
// remove the slice from the type, i.e. []*T -> *T
|
||||
goType = goType[2:]
|
||||
p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, `, goType, `{})`)
|
||||
}
|
||||
varName := `m.` + fieldname + `[len(m.` + fieldname + `)-1]`
|
||||
buf := `dAtA[iNdEx:postIndex]`
|
||||
@@ -840,7 +843,9 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip
|
||||
} else if gogoproto.IsStdDuration(field) {
|
||||
p.P(`m.`, fieldname, ` = new(time.Duration)`)
|
||||
} else {
|
||||
p.P(`m.`, fieldname, ` = &`, msgname, `{}`)
|
||||
goType, _ := p.GoType(nil, field)
|
||||
// remove the star from the type
|
||||
p.P(`m.`, fieldname, ` = &`, goType[1:], `{}`)
|
||||
}
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
@@ -869,6 +874,7 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip
|
||||
p.P(`}`)
|
||||
}
|
||||
p.P(`iNdEx = postIndex`)
|
||||
|
||||
case descriptor.FieldDescriptorProto_TYPE_BYTES:
|
||||
p.P(`var byteLen int`)
|
||||
p.decodeVarint("byteLen", "int")
|
||||
@@ -1164,12 +1170,16 @@ func (p *unmarshal) Generate(file *generator.FileDescriptor) {
|
||||
if field.OneofIndex != nil {
|
||||
errFieldname = p.GetOneOfFieldName(message, field)
|
||||
}
|
||||
packed := field.IsPacked() || (proto3 && field.IsRepeated() && generator.IsScalar(field))
|
||||
possiblyPacked := field.IsScalar() && field.IsRepeated()
|
||||
p.P(`case `, strconv.Itoa(int(field.GetNumber())), `:`)
|
||||
p.In()
|
||||
wireType := field.WireType()
|
||||
if packed {
|
||||
p.P(`if wireType == `, strconv.Itoa(proto.WireBytes), `{`)
|
||||
if possiblyPacked {
|
||||
p.P(`if wireType == `, strconv.Itoa(wireType), `{`)
|
||||
p.In()
|
||||
p.field(file, message, field, fieldname, false)
|
||||
p.Out()
|
||||
p.P(`} else if wireType == `, strconv.Itoa(proto.WireBytes), `{`)
|
||||
p.In()
|
||||
p.P(`var packedLen int`)
|
||||
p.decodeVarint("packedLen", "int")
|
||||
@@ -1190,10 +1200,6 @@ func (p *unmarshal) Generate(file *generator.FileDescriptor) {
|
||||
p.Out()
|
||||
p.P(`}`)
|
||||
p.Out()
|
||||
p.P(`} else if wireType == `, strconv.Itoa(wireType), `{`)
|
||||
p.In()
|
||||
p.field(file, message, field, fieldname, false)
|
||||
p.Out()
|
||||
p.P(`} else {`)
|
||||
p.In()
|
||||
p.P(`return ` + fmtPkg.Use() + `.Errorf("proto: wrong wireType = %d for field ` + errFieldname + `", wireType)`)
|
||||
|
||||
Reference in New Issue
Block a user