summaryrefslogtreecommitdiff
path: root/vendor/google.golang.org/protobuf/proto
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2021-05-06 08:07:07 +0000
committerGitHub <noreply@github.com>2021-05-06 08:07:07 +0000
commit3de369fd696e6b98d00259d3c759d9b81df4e84b (patch)
tree7c489ea3aa926cda031d6aaa4a852e9e6e469d14 /vendor/google.golang.org/protobuf/proto
parent9b9bd9e0e7b72c91d8e60103e8da7999cefbc63d (diff)
downloadpodman-3de369fd696e6b98d00259d3c759d9b81df4e84b.tar.gz
podman-3de369fd696e6b98d00259d3c759d9b81df4e84b.tar.bz2
podman-3de369fd696e6b98d00259d3c759d9b81df4e84b.zip
Bump github.com/onsi/gomega from 1.11.0 to 1.12.0
Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.11.0 to 1.12.0. - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/gomega/compare/v1.11.0...v1.12.0) Signed-off-by: dependabot[bot] <support@github.com>
Diffstat (limited to 'vendor/google.golang.org/protobuf/proto')
-rw-r--r--vendor/google.golang.org/protobuf/proto/decode.go18
-rw-r--r--vendor/google.golang.org/protobuf/proto/decode_gen.go128
-rw-r--r--vendor/google.golang.org/protobuf/proto/encode.go55
-rw-r--r--vendor/google.golang.org/protobuf/proto/equal.go25
-rw-r--r--vendor/google.golang.org/protobuf/proto/messageset.go7
-rw-r--r--vendor/google.golang.org/protobuf/proto/proto.go9
6 files changed, 123 insertions, 119 deletions
diff --git a/vendor/google.golang.org/protobuf/proto/decode.go b/vendor/google.golang.org/protobuf/proto/decode.go
index 42fc5195e..49f9b8c88 100644
--- a/vendor/google.golang.org/protobuf/proto/decode.go
+++ b/vendor/google.golang.org/protobuf/proto/decode.go
@@ -45,12 +45,14 @@ type UnmarshalOptions struct {
}
// Unmarshal parses the wire-format message in b and places the result in m.
+// The provided message must be mutable (e.g., a non-nil pointer to a message).
func Unmarshal(b []byte, m Message) error {
_, err := UnmarshalOptions{}.unmarshal(b, m.ProtoReflect())
return err
}
// Unmarshal parses the wire-format message in b and places the result in m.
+// The provided message must be mutable (e.g., a non-nil pointer to a message).
func (o UnmarshalOptions) Unmarshal(b []byte, m Message) error {
_, err := o.unmarshal(b, m.ProtoReflect())
return err
@@ -116,10 +118,10 @@ func (o UnmarshalOptions) unmarshalMessageSlow(b []byte, m protoreflect.Message)
// Parse the tag (field number and wire type).
num, wtyp, tagLen := protowire.ConsumeTag(b)
if tagLen < 0 {
- return protowire.ParseError(tagLen)
+ return errDecode
}
if num > protowire.MaxValidNumber {
- return errors.New("invalid field number")
+ return errDecode
}
// Find the field descriptor for this field number.
@@ -159,7 +161,7 @@ func (o UnmarshalOptions) unmarshalMessageSlow(b []byte, m protoreflect.Message)
}
valLen = protowire.ConsumeFieldValue(num, wtyp, b[tagLen:])
if valLen < 0 {
- return protowire.ParseError(valLen)
+ return errDecode
}
if !o.DiscardUnknown {
m.SetUnknown(append(m.GetUnknown(), b[:tagLen+valLen]...))
@@ -194,7 +196,7 @@ func (o UnmarshalOptions) unmarshalMap(b []byte, wtyp protowire.Type, mapv proto
}
b, n = protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
var (
keyField = fd.MapKey()
@@ -213,10 +215,10 @@ func (o UnmarshalOptions) unmarshalMap(b []byte, wtyp protowire.Type, mapv proto
for len(b) > 0 {
num, wtyp, n := protowire.ConsumeTag(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
if num > protowire.MaxValidNumber {
- return 0, errors.New("invalid field number")
+ return 0, errDecode
}
b = b[n:]
err = errUnknown
@@ -246,7 +248,7 @@ func (o UnmarshalOptions) unmarshalMap(b []byte, wtyp protowire.Type, mapv proto
if err == errUnknown {
n = protowire.ConsumeFieldValue(num, wtyp, b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
} else if err != nil {
return 0, err
@@ -272,3 +274,5 @@ func (o UnmarshalOptions) unmarshalMap(b []byte, wtyp protowire.Type, mapv proto
// to the unknown field set of a message. It is never returned from an exported
// function.
var errUnknown = errors.New("BUG: internal error (unknown)")
+
+var errDecode = errors.New("cannot parse invalid wire-format data")
diff --git a/vendor/google.golang.org/protobuf/proto/decode_gen.go b/vendor/google.golang.org/protobuf/proto/decode_gen.go
index d6dc904dc..301eeb20f 100644
--- a/vendor/google.golang.org/protobuf/proto/decode_gen.go
+++ b/vendor/google.golang.org/protobuf/proto/decode_gen.go
@@ -27,7 +27,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
return protoreflect.ValueOfBool(protowire.DecodeBool(v)), n, nil
case protoreflect.EnumKind:
@@ -36,7 +36,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
return protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)), n, nil
case protoreflect.Int32Kind:
@@ -45,7 +45,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
return protoreflect.ValueOfInt32(int32(v)), n, nil
case protoreflect.Sint32Kind:
@@ -54,7 +54,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
return protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))), n, nil
case protoreflect.Uint32Kind:
@@ -63,7 +63,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
return protoreflect.ValueOfUint32(uint32(v)), n, nil
case protoreflect.Int64Kind:
@@ -72,7 +72,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
return protoreflect.ValueOfInt64(int64(v)), n, nil
case protoreflect.Sint64Kind:
@@ -81,7 +81,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
return protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)), n, nil
case protoreflect.Uint64Kind:
@@ -90,7 +90,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
return protoreflect.ValueOfUint64(v), n, nil
case protoreflect.Sfixed32Kind:
@@ -99,7 +99,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeFixed32(b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
return protoreflect.ValueOfInt32(int32(v)), n, nil
case protoreflect.Fixed32Kind:
@@ -108,7 +108,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeFixed32(b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
return protoreflect.ValueOfUint32(uint32(v)), n, nil
case protoreflect.FloatKind:
@@ -117,7 +117,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeFixed32(b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
return protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))), n, nil
case protoreflect.Sfixed64Kind:
@@ -126,7 +126,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeFixed64(b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
return protoreflect.ValueOfInt64(int64(v)), n, nil
case protoreflect.Fixed64Kind:
@@ -135,7 +135,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeFixed64(b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
return protoreflect.ValueOfUint64(v), n, nil
case protoreflect.DoubleKind:
@@ -144,7 +144,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeFixed64(b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
return protoreflect.ValueOfFloat64(math.Float64frombits(v)), n, nil
case protoreflect.StringKind:
@@ -153,7 +153,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeBytes(b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
if strs.EnforceUTF8(fd) && !utf8.Valid(v) {
return protoreflect.Value{}, 0, errors.InvalidUTF8(string(fd.FullName()))
@@ -165,7 +165,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeBytes(b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
return protoreflect.ValueOfBytes(append(emptyBuf[:], v...)), n, nil
case protoreflect.MessageKind:
@@ -174,7 +174,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeBytes(b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
return protoreflect.ValueOfBytes(v), n, nil
case protoreflect.GroupKind:
@@ -183,7 +183,7 @@ func (o UnmarshalOptions) unmarshalScalar(b []byte, wtyp protowire.Type, fd prot
}
v, n := protowire.ConsumeGroup(fd.Number(), b)
if n < 0 {
- return val, 0, protowire.ParseError(n)
+ return val, 0, errDecode
}
return protoreflect.ValueOfBytes(v), n, nil
default:
@@ -197,12 +197,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
if wtyp == protowire.BytesType {
buf, n := protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
for len(buf) > 0 {
v, n := protowire.ConsumeVarint(buf)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
buf = buf[n:]
list.Append(protoreflect.ValueOfBool(protowire.DecodeBool(v)))
@@ -214,7 +214,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
list.Append(protoreflect.ValueOfBool(protowire.DecodeBool(v)))
return n, nil
@@ -222,12 +222,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
if wtyp == protowire.BytesType {
buf, n := protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
for len(buf) > 0 {
v, n := protowire.ConsumeVarint(buf)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
buf = buf[n:]
list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
@@ -239,7 +239,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
return n, nil
@@ -247,12 +247,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
if wtyp == protowire.BytesType {
buf, n := protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
for len(buf) > 0 {
v, n := protowire.ConsumeVarint(buf)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
buf = buf[n:]
list.Append(protoreflect.ValueOfInt32(int32(v)))
@@ -264,7 +264,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
list.Append(protoreflect.ValueOfInt32(int32(v)))
return n, nil
@@ -272,12 +272,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
if wtyp == protowire.BytesType {
buf, n := protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
for len(buf) > 0 {
v, n := protowire.ConsumeVarint(buf)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
buf = buf[n:]
list.Append(protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))))
@@ -289,7 +289,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
list.Append(protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))))
return n, nil
@@ -297,12 +297,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
if wtyp == protowire.BytesType {
buf, n := protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
for len(buf) > 0 {
v, n := protowire.ConsumeVarint(buf)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
buf = buf[n:]
list.Append(protoreflect.ValueOfUint32(uint32(v)))
@@ -314,7 +314,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
list.Append(protoreflect.ValueOfUint32(uint32(v)))
return n, nil
@@ -322,12 +322,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
if wtyp == protowire.BytesType {
buf, n := protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
for len(buf) > 0 {
v, n := protowire.ConsumeVarint(buf)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
buf = buf[n:]
list.Append(protoreflect.ValueOfInt64(int64(v)))
@@ -339,7 +339,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
list.Append(protoreflect.ValueOfInt64(int64(v)))
return n, nil
@@ -347,12 +347,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
if wtyp == protowire.BytesType {
buf, n := protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
for len(buf) > 0 {
v, n := protowire.ConsumeVarint(buf)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
buf = buf[n:]
list.Append(protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)))
@@ -364,7 +364,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
list.Append(protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)))
return n, nil
@@ -372,12 +372,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
if wtyp == protowire.BytesType {
buf, n := protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
for len(buf) > 0 {
v, n := protowire.ConsumeVarint(buf)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
buf = buf[n:]
list.Append(protoreflect.ValueOfUint64(v))
@@ -389,7 +389,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeVarint(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
list.Append(protoreflect.ValueOfUint64(v))
return n, nil
@@ -397,12 +397,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
if wtyp == protowire.BytesType {
buf, n := protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
for len(buf) > 0 {
v, n := protowire.ConsumeFixed32(buf)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
buf = buf[n:]
list.Append(protoreflect.ValueOfInt32(int32(v)))
@@ -414,7 +414,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeFixed32(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
list.Append(protoreflect.ValueOfInt32(int32(v)))
return n, nil
@@ -422,12 +422,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
if wtyp == protowire.BytesType {
buf, n := protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
for len(buf) > 0 {
v, n := protowire.ConsumeFixed32(buf)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
buf = buf[n:]
list.Append(protoreflect.ValueOfUint32(uint32(v)))
@@ -439,7 +439,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeFixed32(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
list.Append(protoreflect.ValueOfUint32(uint32(v)))
return n, nil
@@ -447,12 +447,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
if wtyp == protowire.BytesType {
buf, n := protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
for len(buf) > 0 {
v, n := protowire.ConsumeFixed32(buf)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
buf = buf[n:]
list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
@@ -464,7 +464,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeFixed32(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
return n, nil
@@ -472,12 +472,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
if wtyp == protowire.BytesType {
buf, n := protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
for len(buf) > 0 {
v, n := protowire.ConsumeFixed64(buf)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
buf = buf[n:]
list.Append(protoreflect.ValueOfInt64(int64(v)))
@@ -489,7 +489,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeFixed64(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
list.Append(protoreflect.ValueOfInt64(int64(v)))
return n, nil
@@ -497,12 +497,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
if wtyp == protowire.BytesType {
buf, n := protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
for len(buf) > 0 {
v, n := protowire.ConsumeFixed64(buf)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
buf = buf[n:]
list.Append(protoreflect.ValueOfUint64(v))
@@ -514,7 +514,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeFixed64(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
list.Append(protoreflect.ValueOfUint64(v))
return n, nil
@@ -522,12 +522,12 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
if wtyp == protowire.BytesType {
buf, n := protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
for len(buf) > 0 {
v, n := protowire.ConsumeFixed64(buf)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
buf = buf[n:]
list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
@@ -539,7 +539,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeFixed64(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
return n, nil
@@ -549,7 +549,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
if strs.EnforceUTF8(fd) && !utf8.Valid(v) {
return 0, errors.InvalidUTF8(string(fd.FullName()))
@@ -562,7 +562,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
list.Append(protoreflect.ValueOfBytes(append(emptyBuf[:], v...)))
return n, nil
@@ -572,7 +572,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeBytes(b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
m := list.NewElement()
if err := o.unmarshalMessage(v, m.Message()); err != nil {
@@ -586,7 +586,7 @@ func (o UnmarshalOptions) unmarshalList(b []byte, wtyp protowire.Type, list prot
}
v, n := protowire.ConsumeGroup(fd.Number(), b)
if n < 0 {
- return 0, protowire.ParseError(n)
+ return 0, errDecode
}
m := list.NewElement()
if err := o.unmarshalMessage(v, m.Message()); err != nil {
diff --git a/vendor/google.golang.org/protobuf/proto/encode.go b/vendor/google.golang.org/protobuf/proto/encode.go
index 7b47a1180..d18239c23 100644
--- a/vendor/google.golang.org/protobuf/proto/encode.go
+++ b/vendor/google.golang.org/protobuf/proto/encode.go
@@ -5,12 +5,9 @@
package proto
import (
- "sort"
-
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/internal/encoding/messageset"
- "google.golang.org/protobuf/internal/fieldsort"
- "google.golang.org/protobuf/internal/mapsort"
+ "google.golang.org/protobuf/internal/order"
"google.golang.org/protobuf/internal/pragma"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/runtime/protoiface"
@@ -211,14 +208,15 @@ func (o MarshalOptions) marshalMessageSlow(b []byte, m protoreflect.Message) ([]
if messageset.IsMessageSet(m.Descriptor()) {
return o.marshalMessageSet(b, m)
}
- // There are many choices for what order we visit fields in. The default one here
- // is chosen for reasonable efficiency and simplicity given the protoreflect API.
- // It is not deterministic, since Message.Range does not return fields in any
- // defined order.
- //
- // When using deterministic serialization, we sort the known fields.
+ fieldOrder := order.AnyFieldOrder
+ if o.Deterministic {
+ // TODO: This should use a more natural ordering like NumberFieldOrder,
+ // but doing so breaks golden tests that make invalid assumption about
+ // output stability of this implementation.
+ fieldOrder = order.LegacyFieldOrder
+ }
var err error
- o.rangeFields(m, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
+ order.RangeFields(m, fieldOrder, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
b, err = o.marshalField(b, fd, v)
return err == nil
})
@@ -229,27 +227,6 @@ func (o MarshalOptions) marshalMessageSlow(b []byte, m protoreflect.Message) ([]
return b, nil
}
-// rangeFields visits fields in a defined order when deterministic serialization is enabled.
-func (o MarshalOptions) rangeFields(m protoreflect.Message, f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
- if !o.Deterministic {
- m.Range(f)
- return
- }
- var fds []protoreflect.FieldDescriptor
- m.Range(func(fd protoreflect.FieldDescriptor, _ protoreflect.Value) bool {
- fds = append(fds, fd)
- return true
- })
- sort.Slice(fds, func(a, b int) bool {
- return fieldsort.Less(fds[a], fds[b])
- })
- for _, fd := range fds {
- if !f(fd, m.Get(fd)) {
- break
- }
- }
-}
-
func (o MarshalOptions) marshalField(b []byte, fd protoreflect.FieldDescriptor, value protoreflect.Value) ([]byte, error) {
switch {
case fd.IsList():
@@ -292,8 +269,12 @@ func (o MarshalOptions) marshalList(b []byte, fd protoreflect.FieldDescriptor, l
func (o MarshalOptions) marshalMap(b []byte, fd protoreflect.FieldDescriptor, mapv protoreflect.Map) ([]byte, error) {
keyf := fd.MapKey()
valf := fd.MapValue()
+ keyOrder := order.AnyKeyOrder
+ if o.Deterministic {
+ keyOrder = order.GenericKeyOrder
+ }
var err error
- o.rangeMap(mapv, keyf.Kind(), func(key protoreflect.MapKey, value protoreflect.Value) bool {
+ order.RangeEntries(mapv, keyOrder, func(key protoreflect.MapKey, value protoreflect.Value) bool {
b = protowire.AppendTag(b, fd.Number(), protowire.BytesType)
var pos int
b, pos = appendSpeculativeLength(b)
@@ -312,14 +293,6 @@ func (o MarshalOptions) marshalMap(b []byte, fd protoreflect.FieldDescriptor, ma
return b, err
}
-func (o MarshalOptions) rangeMap(mapv protoreflect.Map, kind protoreflect.Kind, f func(protoreflect.MapKey, protoreflect.Value) bool) {
- if !o.Deterministic {
- mapv.Range(f)
- return
- }
- mapsort.Range(mapv, kind, f)
-}
-
// When encoding length-prefixed fields, we speculatively set aside some number of bytes
// for the length, encode the data, and then encode the length (shifting the data if necessary
// to make room).
diff --git a/vendor/google.golang.org/protobuf/proto/equal.go b/vendor/google.golang.org/protobuf/proto/equal.go
index 10902bd85..4dba2b969 100644
--- a/vendor/google.golang.org/protobuf/proto/equal.go
+++ b/vendor/google.golang.org/protobuf/proto/equal.go
@@ -111,18 +111,31 @@ func equalList(fd pref.FieldDescriptor, x, y pref.List) bool {
// equalValue compares two singular values.
func equalValue(fd pref.FieldDescriptor, x, y pref.Value) bool {
- switch {
- case fd.Message() != nil:
- return equalMessage(x.Message(), y.Message())
- case fd.Kind() == pref.BytesKind:
- return bytes.Equal(x.Bytes(), y.Bytes())
- case fd.Kind() == pref.FloatKind, fd.Kind() == pref.DoubleKind:
+ switch fd.Kind() {
+ case pref.BoolKind:
+ return x.Bool() == y.Bool()
+ case pref.EnumKind:
+ return x.Enum() == y.Enum()
+ case pref.Int32Kind, pref.Sint32Kind,
+ pref.Int64Kind, pref.Sint64Kind,
+ pref.Sfixed32Kind, pref.Sfixed64Kind:
+ return x.Int() == y.Int()
+ case pref.Uint32Kind, pref.Uint64Kind,
+ pref.Fixed32Kind, pref.Fixed64Kind:
+ return x.Uint() == y.Uint()
+ case pref.FloatKind, pref.DoubleKind:
fx := x.Float()
fy := y.Float()
if math.IsNaN(fx) || math.IsNaN(fy) {
return math.IsNaN(fx) && math.IsNaN(fy)
}
return fx == fy
+ case pref.StringKind:
+ return x.String() == y.String()
+ case pref.BytesKind:
+ return bytes.Equal(x.Bytes(), y.Bytes())
+ case pref.MessageKind, pref.GroupKind:
+ return equalMessage(x.Message(), y.Message())
default:
return x.Interface() == y.Interface()
}
diff --git a/vendor/google.golang.org/protobuf/proto/messageset.go b/vendor/google.golang.org/protobuf/proto/messageset.go
index 1d692c3a8..312d5d45c 100644
--- a/vendor/google.golang.org/protobuf/proto/messageset.go
+++ b/vendor/google.golang.org/protobuf/proto/messageset.go
@@ -9,6 +9,7 @@ import (
"google.golang.org/protobuf/internal/encoding/messageset"
"google.golang.org/protobuf/internal/errors"
"google.golang.org/protobuf/internal/flags"
+ "google.golang.org/protobuf/internal/order"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/reflect/protoregistry"
)
@@ -28,8 +29,12 @@ func (o MarshalOptions) marshalMessageSet(b []byte, m protoreflect.Message) ([]b
if !flags.ProtoLegacy {
return b, errors.New("no support for message_set_wire_format")
}
+ fieldOrder := order.AnyFieldOrder
+ if o.Deterministic {
+ fieldOrder = order.NumberFieldOrder
+ }
var err error
- o.rangeFields(m, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
+ order.RangeFields(m, fieldOrder, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
b, err = o.marshalMessageSetField(b, fd, v)
return err == nil
})
diff --git a/vendor/google.golang.org/protobuf/proto/proto.go b/vendor/google.golang.org/protobuf/proto/proto.go
index ca14b09c3..1f0d183b1 100644
--- a/vendor/google.golang.org/protobuf/proto/proto.go
+++ b/vendor/google.golang.org/protobuf/proto/proto.go
@@ -32,3 +32,12 @@ var Error error
func init() {
Error = errors.Error
}
+
+// MessageName returns the full name of m.
+// If m is nil, it returns an empty string.
+func MessageName(m Message) protoreflect.FullName {
+ if m == nil {
+ return ""
+ }
+ return m.ProtoReflect().Descriptor().FullName()
+}