mirror of
https://github.com/containers/skopeo.git
synced 2025-09-16 15:00:14 +00:00
fix(deps): update github.com/containers/image/v5 digest to faa4f4f
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
7
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/array_codec.go
generated
vendored
7
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/array_codec.go
generated
vendored
@@ -15,16 +15,15 @@ import (
|
||||
|
||||
// ArrayCodec is the Codec used for bsoncore.Array values.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// ArrayCodec registered.
|
||||
// Deprecated: ArrayCodec will not be directly accessible in Go Driver 2.0.
|
||||
type ArrayCodec struct{}
|
||||
|
||||
var defaultArrayCodec = NewArrayCodec()
|
||||
|
||||
// NewArrayCodec returns an ArrayCodec.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// ArrayCodec registered.
|
||||
// Deprecated: NewArrayCodec will not be available in Go Driver 2.0. See
|
||||
// [ArrayCodec] for more details.
|
||||
func NewArrayCodec() *ArrayCodec {
|
||||
return &ArrayCodec{}
|
||||
}
|
||||
|
25
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/byte_slice_codec.go
generated
vendored
25
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/byte_slice_codec.go
generated
vendored
@@ -17,13 +17,28 @@ import (
|
||||
|
||||
// ByteSliceCodec is the Codec used for []byte values.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// ByteSliceCodec registered.
|
||||
// Deprecated: ByteSliceCodec will not be directly configurable in Go Driver
|
||||
// 2.0. To configure the byte slice encode and decode behavior, use the
|
||||
// configuration methods on a [go.mongodb.org/mongo-driver/bson.Encoder] or
|
||||
// [go.mongodb.org/mongo-driver/bson.Decoder]. To configure the byte slice
|
||||
// encode and decode behavior for a mongo.Client, use
|
||||
// [go.mongodb.org/mongo-driver/mongo/options.ClientOptions.SetBSONOptions].
|
||||
//
|
||||
// For example, to configure a mongo.Client to encode nil byte slices as empty
|
||||
// BSON binary values, use:
|
||||
//
|
||||
// opt := options.Client().SetBSONOptions(&options.BSONOptions{
|
||||
// NilByteSliceAsEmpty: true,
|
||||
// })
|
||||
//
|
||||
// See the deprecation notice for each field in ByteSliceCodec for the
|
||||
// corresponding settings.
|
||||
type ByteSliceCodec struct {
|
||||
// EncodeNilAsEmpty causes EncodeValue to marshal nil Go byte slices as empty BSON binary values
|
||||
// instead of BSON null.
|
||||
//
|
||||
// Deprecated: Use bson.Encoder.NilByteSliceAsEmpty instead.
|
||||
// Deprecated: Use bson.Encoder.NilByteSliceAsEmpty or options.BSONOptions.NilByteSliceAsEmpty
|
||||
// instead.
|
||||
EncodeNilAsEmpty bool
|
||||
}
|
||||
|
||||
@@ -38,8 +53,8 @@ var (
|
||||
|
||||
// NewByteSliceCodec returns a ByteSliceCodec with options opts.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// ByteSliceCodec registered.
|
||||
// Deprecated: NewByteSliceCodec will not be available in Go Driver 2.0. See
|
||||
// [ByteSliceCodec] for more details.
|
||||
func NewByteSliceCodec(opts ...*bsonoptions.ByteSliceCodecOptions) *ByteSliceCodec {
|
||||
byteSliceOpt := bsonoptions.MergeByteSliceCodecOptions(opts...)
|
||||
codec := ByteSliceCodec{}
|
||||
|
10
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go
generated
vendored
10
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go
generated
vendored
@@ -41,7 +41,7 @@ func newDefaultStructCodec() *StructCodec {
|
||||
if err != nil {
|
||||
// This function is called from the codec registration path, so errors can't be propagated. If there's an error
|
||||
// constructing the StructCodec, we panic to avoid losing it.
|
||||
panic(fmt.Errorf("error creating default StructCodec: %v", err))
|
||||
panic(fmt.Errorf("error creating default StructCodec: %w", err))
|
||||
}
|
||||
return codec
|
||||
}
|
||||
@@ -178,7 +178,7 @@ func (dvd DefaultValueDecoders) DDecodeValue(dc DecodeContext, vr bsonrw.ValueRe
|
||||
|
||||
for {
|
||||
key, elemVr, err := dr.ReadElement()
|
||||
if err == bsonrw.ErrEOD {
|
||||
if errors.Is(err, bsonrw.ErrEOD) {
|
||||
break
|
||||
} else if err != nil {
|
||||
return err
|
||||
@@ -1379,7 +1379,7 @@ func (dvd DefaultValueDecoders) MapDecodeValue(dc DecodeContext, vr bsonrw.Value
|
||||
keyType := val.Type().Key()
|
||||
for {
|
||||
key, vr, err := dr.ReadElement()
|
||||
if err == bsonrw.ErrEOD {
|
||||
if errors.Is(err, bsonrw.ErrEOD) {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
@@ -1675,7 +1675,7 @@ func (dvd DefaultValueDecoders) decodeDefault(dc DecodeContext, vr bsonrw.ValueR
|
||||
idx := 0
|
||||
for {
|
||||
vr, err := ar.ReadValue()
|
||||
if err == bsonrw.ErrEOA {
|
||||
if errors.Is(err, bsonrw.ErrEOA) {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
@@ -1787,7 +1787,7 @@ func (DefaultValueDecoders) decodeElemsFromDocumentReader(dc DecodeContext, dr b
|
||||
elems := make([]reflect.Value, 0)
|
||||
for {
|
||||
key, vr, err := dr.ReadElement()
|
||||
if err == bsonrw.ErrEOD {
|
||||
if errors.Is(err, bsonrw.ErrEOD) {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
|
12
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders.go
generated
vendored
12
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders.go
generated
vendored
@@ -343,7 +343,7 @@ func (dve DefaultValueEncoders) mapEncodeValue(ec EncodeContext, dw bsonrw.Docum
|
||||
}
|
||||
|
||||
currEncoder, currVal, lookupErr := dve.lookupElementEncoder(ec, encoder, val.MapIndex(key))
|
||||
if lookupErr != nil && lookupErr != errInvalidValue {
|
||||
if lookupErr != nil && !errors.Is(lookupErr, errInvalidValue) {
|
||||
return lookupErr
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ func (dve DefaultValueEncoders) mapEncodeValue(ec EncodeContext, dw bsonrw.Docum
|
||||
return err
|
||||
}
|
||||
|
||||
if lookupErr == errInvalidValue {
|
||||
if errors.Is(lookupErr, errInvalidValue) {
|
||||
err = vw.WriteNull()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -418,7 +418,7 @@ func (dve DefaultValueEncoders) ArrayEncodeValue(ec EncodeContext, vw bsonrw.Val
|
||||
|
||||
for idx := 0; idx < val.Len(); idx++ {
|
||||
currEncoder, currVal, lookupErr := dve.lookupElementEncoder(ec, encoder, val.Index(idx))
|
||||
if lookupErr != nil && lookupErr != errInvalidValue {
|
||||
if lookupErr != nil && !errors.Is(lookupErr, errInvalidValue) {
|
||||
return lookupErr
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ func (dve DefaultValueEncoders) ArrayEncodeValue(ec EncodeContext, vw bsonrw.Val
|
||||
return err
|
||||
}
|
||||
|
||||
if lookupErr == errInvalidValue {
|
||||
if errors.Is(lookupErr, errInvalidValue) {
|
||||
err = vw.WriteNull()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -487,7 +487,7 @@ func (dve DefaultValueEncoders) SliceEncodeValue(ec EncodeContext, vw bsonrw.Val
|
||||
|
||||
for idx := 0; idx < val.Len(); idx++ {
|
||||
currEncoder, currVal, lookupErr := dve.lookupElementEncoder(ec, encoder, val.Index(idx))
|
||||
if lookupErr != nil && lookupErr != errInvalidValue {
|
||||
if lookupErr != nil && !errors.Is(lookupErr, errInvalidValue) {
|
||||
return lookupErr
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ func (dve DefaultValueEncoders) SliceEncodeValue(ec EncodeContext, vw bsonrw.Val
|
||||
return err
|
||||
}
|
||||
|
||||
if lookupErr == errInvalidValue {
|
||||
if errors.Is(lookupErr, errInvalidValue) {
|
||||
err = vw.WriteNull()
|
||||
if err != nil {
|
||||
return err
|
||||
|
24
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/empty_interface_codec.go
generated
vendored
24
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/empty_interface_codec.go
generated
vendored
@@ -17,13 +17,27 @@ import (
|
||||
|
||||
// EmptyInterfaceCodec is the Codec used for interface{} values.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// EmptyInterfaceCodec registered.
|
||||
// Deprecated: EmptyInterfaceCodec will not be directly configurable in Go
|
||||
// Driver 2.0. To configure the empty interface encode and decode behavior, use
|
||||
// the configuration methods on a [go.mongodb.org/mongo-driver/bson.Encoder] or
|
||||
// [go.mongodb.org/mongo-driver/bson.Decoder]. To configure the empty interface
|
||||
// encode and decode behavior for a mongo.Client, use
|
||||
// [go.mongodb.org/mongo-driver/mongo/options.ClientOptions.SetBSONOptions].
|
||||
//
|
||||
// For example, to configure a mongo.Client to unmarshal BSON binary field
|
||||
// values as a Go byte slice, use:
|
||||
//
|
||||
// opt := options.Client().SetBSONOptions(&options.BSONOptions{
|
||||
// BinaryAsSlice: true,
|
||||
// })
|
||||
//
|
||||
// See the deprecation notice for each field in EmptyInterfaceCodec for the
|
||||
// corresponding settings.
|
||||
type EmptyInterfaceCodec struct {
|
||||
// DecodeBinaryAsSlice causes DecodeValue to unmarshal BSON binary field values that are the
|
||||
// "Generic" or "Old" BSON binary subtype as a Go byte slice instead of a primitive.Binary.
|
||||
//
|
||||
// Deprecated: Use bson.Decoder.BinaryAsSlice instead.
|
||||
// Deprecated: Use bson.Decoder.BinaryAsSlice or options.BSONOptions.BinaryAsSlice instead.
|
||||
DecodeBinaryAsSlice bool
|
||||
}
|
||||
|
||||
@@ -38,8 +52,8 @@ var (
|
||||
|
||||
// NewEmptyInterfaceCodec returns a EmptyInterfaceCodec with options opts.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// EmptyInterfaceCodec registered.
|
||||
// Deprecated: NewEmptyInterfaceCodec will not be available in Go Driver 2.0. See
|
||||
// [EmptyInterfaceCodec] for more details.
|
||||
func NewEmptyInterfaceCodec(opts ...*bsonoptions.EmptyInterfaceCodecOptions) *EmptyInterfaceCodec {
|
||||
interfaceOpt := bsonoptions.MergeEmptyInterfaceCodecOptions(opts...)
|
||||
|
||||
|
38
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/map_codec.go
generated
vendored
38
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/map_codec.go
generated
vendored
@@ -8,6 +8,7 @@ package bsoncodec
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
@@ -21,25 +22,40 @@ var defaultMapCodec = NewMapCodec()
|
||||
|
||||
// MapCodec is the Codec used for map values.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// MapCodec registered.
|
||||
// Deprecated: MapCodec will not be directly configurable in Go Driver 2.0. To
|
||||
// configure the map encode and decode behavior, use the configuration methods
|
||||
// on a [go.mongodb.org/mongo-driver/bson.Encoder] or
|
||||
// [go.mongodb.org/mongo-driver/bson.Decoder]. To configure the map encode and
|
||||
// decode behavior for a mongo.Client, use
|
||||
// [go.mongodb.org/mongo-driver/mongo/options.ClientOptions.SetBSONOptions].
|
||||
//
|
||||
// For example, to configure a mongo.Client to marshal nil Go maps as empty BSON
|
||||
// documents, use:
|
||||
//
|
||||
// opt := options.Client().SetBSONOptions(&options.BSONOptions{
|
||||
// NilMapAsEmpty: true,
|
||||
// })
|
||||
//
|
||||
// See the deprecation notice for each field in MapCodec for the corresponding
|
||||
// settings.
|
||||
type MapCodec struct {
|
||||
// DecodeZerosMap causes DecodeValue to delete any existing values from Go maps in the destination
|
||||
// value passed to Decode before unmarshaling BSON documents into them.
|
||||
//
|
||||
// Deprecated: Use bson.Decoder.ZeroMaps instead.
|
||||
// Deprecated: Use bson.Decoder.ZeroMaps or options.BSONOptions.ZeroMaps instead.
|
||||
DecodeZerosMap bool
|
||||
|
||||
// EncodeNilAsEmpty causes EncodeValue to marshal nil Go maps as empty BSON documents instead of
|
||||
// BSON null.
|
||||
//
|
||||
// Deprecated: Use bson.Encoder.NilMapAsEmpty instead.
|
||||
// Deprecated: Use bson.Encoder.NilMapAsEmpty or options.BSONOptions.NilMapAsEmpty instead.
|
||||
EncodeNilAsEmpty bool
|
||||
|
||||
// EncodeKeysWithStringer causes the Encoder to convert Go map keys to BSON document field name
|
||||
// strings using fmt.Sprintf() instead of the default string conversion logic.
|
||||
//
|
||||
// Deprecated: Use bson.Encoder.StringifyMapKeysWithFmt instead.
|
||||
// Deprecated: Use bson.Encoder.StringifyMapKeysWithFmt or
|
||||
// options.BSONOptions.StringifyMapKeysWithFmt instead.
|
||||
EncodeKeysWithStringer bool
|
||||
}
|
||||
|
||||
@@ -61,8 +77,8 @@ type KeyUnmarshaler interface {
|
||||
|
||||
// NewMapCodec returns a MapCodec with options opts.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// MapCodec registered.
|
||||
// Deprecated: NewMapCodec will not be available in Go Driver 2.0. See
|
||||
// [MapCodec] for more details.
|
||||
func NewMapCodec(opts ...*bsonoptions.MapCodecOptions) *MapCodec {
|
||||
mapOpt := bsonoptions.MergeMapCodecOptions(opts...)
|
||||
|
||||
@@ -128,7 +144,7 @@ func (mc *MapCodec) mapEncodeValue(ec EncodeContext, dw bsonrw.DocumentWriter, v
|
||||
}
|
||||
|
||||
currEncoder, currVal, lookupErr := defaultValueEncoders.lookupElementEncoder(ec, encoder, val.MapIndex(key))
|
||||
if lookupErr != nil && lookupErr != errInvalidValue {
|
||||
if lookupErr != nil && !errors.Is(lookupErr, errInvalidValue) {
|
||||
return lookupErr
|
||||
}
|
||||
|
||||
@@ -137,7 +153,7 @@ func (mc *MapCodec) mapEncodeValue(ec EncodeContext, dw bsonrw.DocumentWriter, v
|
||||
return err
|
||||
}
|
||||
|
||||
if lookupErr == errInvalidValue {
|
||||
if errors.Is(lookupErr, errInvalidValue) {
|
||||
err = vw.WriteNull()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -200,7 +216,7 @@ func (mc *MapCodec) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val ref
|
||||
|
||||
for {
|
||||
key, vr, err := dr.ReadElement()
|
||||
if err == bsonrw.ErrEOD {
|
||||
if errors.Is(err, bsonrw.ErrEOD) {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
@@ -313,7 +329,7 @@ func (mc *MapCodec) decodeKey(key string, keyType reflect.Type) (reflect.Value,
|
||||
if mc.EncodeKeysWithStringer {
|
||||
parsed, err := strconv.ParseFloat(key, 64)
|
||||
if err != nil {
|
||||
return keyVal, fmt.Errorf("Map key is defined to be a decimal type (%v) but got error %v", keyType.Kind(), err)
|
||||
return keyVal, fmt.Errorf("Map key is defined to be a decimal type (%v) but got error %w", keyType.Kind(), err)
|
||||
}
|
||||
keyVal = reflect.ValueOf(parsed)
|
||||
break
|
||||
|
16
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/pointer_codec.go
generated
vendored
16
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/pointer_codec.go
generated
vendored
@@ -18,8 +18,16 @@ var _ ValueDecoder = &PointerCodec{}
|
||||
|
||||
// PointerCodec is the Codec used for pointers.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// PointerCodec registered.
|
||||
// Deprecated: PointerCodec will not be directly accessible in Go Driver 2.0. To
|
||||
// override the default pointer encode and decode behavior, create a new registry
|
||||
// with [go.mongodb.org/mongo-driver/bson.NewRegistry] and register a new
|
||||
// encoder and decoder for pointers.
|
||||
//
|
||||
// For example,
|
||||
//
|
||||
// reg := bson.NewRegistry()
|
||||
// reg.RegisterKindEncoder(reflect.Ptr, myPointerEncoder)
|
||||
// reg.RegisterKindDecoder(reflect.Ptr, myPointerDecoder)
|
||||
type PointerCodec struct {
|
||||
ecache typeEncoderCache
|
||||
dcache typeDecoderCache
|
||||
@@ -27,8 +35,8 @@ type PointerCodec struct {
|
||||
|
||||
// NewPointerCodec returns a PointerCodec that has been initialized.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// PointerCodec registered.
|
||||
// Deprecated: NewPointerCodec will not be available in Go Driver 2.0. See
|
||||
// [PointerCodec] for more details.
|
||||
func NewPointerCodec() *PointerCodec {
|
||||
return &PointerCodec{}
|
||||
}
|
||||
|
27
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/slice_codec.go
generated
vendored
27
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/slice_codec.go
generated
vendored
@@ -7,6 +7,7 @@
|
||||
package bsoncodec
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
@@ -20,8 +21,22 @@ var defaultSliceCodec = NewSliceCodec()
|
||||
|
||||
// SliceCodec is the Codec used for slice values.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// SliceCodec registered.
|
||||
// Deprecated: SliceCodec will not be directly configurable in Go Driver 2.0. To
|
||||
// configure the slice encode and decode behavior, use the configuration methods
|
||||
// on a [go.mongodb.org/mongo-driver/bson.Encoder] or
|
||||
// [go.mongodb.org/mongo-driver/bson.Decoder]. To configure the slice encode and
|
||||
// decode behavior for a mongo.Client, use
|
||||
// [go.mongodb.org/mongo-driver/mongo/options.ClientOptions.SetBSONOptions].
|
||||
//
|
||||
// For example, to configure a mongo.Client to marshal nil Go slices as empty
|
||||
// BSON arrays, use:
|
||||
//
|
||||
// opt := options.Client().SetBSONOptions(&options.BSONOptions{
|
||||
// NilSliceAsEmpty: true,
|
||||
// })
|
||||
//
|
||||
// See the deprecation notice for each field in SliceCodec for the corresponding
|
||||
// settings.
|
||||
type SliceCodec struct {
|
||||
// EncodeNilAsEmpty causes EncodeValue to marshal nil Go slices as empty BSON arrays instead of
|
||||
// BSON null.
|
||||
@@ -32,8 +47,8 @@ type SliceCodec struct {
|
||||
|
||||
// NewSliceCodec returns a MapCodec with options opts.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// SliceCodec registered.
|
||||
// Deprecated: NewSliceCodec will not be available in Go Driver 2.0. See
|
||||
// [SliceCodec] for more details.
|
||||
func NewSliceCodec(opts ...*bsonoptions.SliceCodecOptions) *SliceCodec {
|
||||
sliceOpt := bsonoptions.MergeSliceCodecOptions(opts...)
|
||||
|
||||
@@ -93,7 +108,7 @@ func (sc SliceCodec) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val re
|
||||
|
||||
for idx := 0; idx < val.Len(); idx++ {
|
||||
currEncoder, currVal, lookupErr := defaultValueEncoders.lookupElementEncoder(ec, encoder, val.Index(idx))
|
||||
if lookupErr != nil && lookupErr != errInvalidValue {
|
||||
if lookupErr != nil && !errors.Is(lookupErr, errInvalidValue) {
|
||||
return lookupErr
|
||||
}
|
||||
|
||||
@@ -102,7 +117,7 @@ func (sc SliceCodec) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val re
|
||||
return err
|
||||
}
|
||||
|
||||
if lookupErr == errInvalidValue {
|
||||
if errors.Is(lookupErr, errInvalidValue) {
|
||||
err = vw.WriteNull()
|
||||
if err != nil {
|
||||
return err
|
||||
|
16
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/string_codec.go
generated
vendored
16
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/string_codec.go
generated
vendored
@@ -17,8 +17,16 @@ import (
|
||||
|
||||
// StringCodec is the Codec used for string values.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// StringCodec registered.
|
||||
// Deprecated: StringCodec will not be directly accessible in Go Driver 2.0. To
|
||||
// override the default string encode and decode behavior, create a new registry
|
||||
// with [go.mongodb.org/mongo-driver/bson.NewRegistry] and register a new
|
||||
// encoder and decoder for strings.
|
||||
//
|
||||
// For example,
|
||||
//
|
||||
// reg := bson.NewRegistry()
|
||||
// reg.RegisterKindEncoder(reflect.String, myStringEncoder)
|
||||
// reg.RegisterKindDecoder(reflect.String, myStringDecoder)
|
||||
type StringCodec struct {
|
||||
// DecodeObjectIDAsHex specifies if object IDs should be decoded as their hex representation.
|
||||
// If false, a string made from the raw object ID bytes will be used. Defaults to true.
|
||||
@@ -38,8 +46,8 @@ var (
|
||||
|
||||
// NewStringCodec returns a StringCodec with options opts.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// StringCodec registered.
|
||||
// Deprecated: NewStringCodec will not be available in Go Driver 2.0. See
|
||||
// [StringCodec] for more details.
|
||||
func NewStringCodec(opts ...*bsonoptions.StringCodecOptions) *StringCodec {
|
||||
stringOpt := bsonoptions.MergeStringCodecOptions(opts...)
|
||||
return &StringCodec{*stringOpt.DecodeObjectIDAsHex}
|
||||
|
62
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_codec.go
generated
vendored
62
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_codec.go
generated
vendored
@@ -60,8 +60,22 @@ type Zeroer interface {
|
||||
|
||||
// StructCodec is the Codec used for struct values.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// StructCodec registered.
|
||||
// Deprecated: StructCodec will not be directly configurable in Go Driver 2.0.
|
||||
// To configure the struct encode and decode behavior, use the configuration
|
||||
// methods on a [go.mongodb.org/mongo-driver/bson.Encoder] or
|
||||
// [go.mongodb.org/mongo-driver/bson.Decoder]. To configure the struct encode
|
||||
// and decode behavior for a mongo.Client, use
|
||||
// [go.mongodb.org/mongo-driver/mongo/options.ClientOptions.SetBSONOptions].
|
||||
//
|
||||
// For example, to configure a mongo.Client to omit zero-value structs when
|
||||
// using the "omitempty" struct tag, use:
|
||||
//
|
||||
// opt := options.Client().SetBSONOptions(&options.BSONOptions{
|
||||
// OmitZeroStruct: true,
|
||||
// })
|
||||
//
|
||||
// See the deprecation notice for each field in StructCodec for the corresponding
|
||||
// settings.
|
||||
type StructCodec struct {
|
||||
cache sync.Map // map[reflect.Type]*structDescription
|
||||
parser StructTagParser
|
||||
@@ -69,7 +83,7 @@ type StructCodec struct {
|
||||
// DecodeZeroStruct causes DecodeValue to delete any existing values from Go structs in the
|
||||
// destination value passed to Decode before unmarshaling BSON documents into them.
|
||||
//
|
||||
// Deprecated: Use bson.Decoder.ZeroStructs instead.
|
||||
// Deprecated: Use bson.Decoder.ZeroStructs or options.BSONOptions.ZeroStructs instead.
|
||||
DecodeZeroStruct bool
|
||||
|
||||
// DecodeDeepZeroInline causes DecodeValue to delete any existing values from Go structs in the
|
||||
@@ -82,7 +96,7 @@ type StructCodec struct {
|
||||
// MyStruct{}) as empty and omit it from the marshaled BSON when the "omitempty" struct tag
|
||||
// option is set.
|
||||
//
|
||||
// Deprecated: Use bson.Encoder.OmitZeroStruct instead.
|
||||
// Deprecated: Use bson.Encoder.OmitZeroStruct or options.BSONOptions.OmitZeroStruct instead.
|
||||
EncodeOmitDefaultStruct bool
|
||||
|
||||
// AllowUnexportedFields allows encoding and decoding values from un-exported struct fields.
|
||||
@@ -95,7 +109,8 @@ type StructCodec struct {
|
||||
// a duplicate field in the marshaled BSON when the "inline" struct tag option is set. The
|
||||
// default value is true.
|
||||
//
|
||||
// Deprecated: Use bson.Encoder.ErrorOnInlineDuplicates instead.
|
||||
// Deprecated: Use bson.Encoder.ErrorOnInlineDuplicates or
|
||||
// options.BSONOptions.ErrorOnInlineDuplicates instead.
|
||||
OverwriteDuplicatedInlinedFields bool
|
||||
}
|
||||
|
||||
@@ -104,8 +119,8 @@ var _ ValueDecoder = &StructCodec{}
|
||||
|
||||
// NewStructCodec returns a StructCodec that uses p for struct tag parsing.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// StructCodec registered.
|
||||
// Deprecated: NewStructCodec will not be available in Go Driver 2.0. See
|
||||
// [StructCodec] for more details.
|
||||
func NewStructCodec(p StructTagParser, opts ...*bsonoptions.StructCodecOptions) (*StructCodec, error) {
|
||||
if p == nil {
|
||||
return nil, errors.New("a StructTagParser must be provided to NewStructCodec")
|
||||
@@ -164,11 +179,11 @@ func (sc *StructCodec) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val
|
||||
|
||||
desc.encoder, rv, err = defaultValueEncoders.lookupElementEncoder(ec, desc.encoder, rv)
|
||||
|
||||
if err != nil && err != errInvalidValue {
|
||||
if err != nil && !errors.Is(err, errInvalidValue) {
|
||||
return err
|
||||
}
|
||||
|
||||
if err == errInvalidValue {
|
||||
if errors.Is(err, errInvalidValue) {
|
||||
if desc.omitEmpty {
|
||||
continue
|
||||
}
|
||||
@@ -189,17 +204,17 @@ func (sc *StructCodec) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val
|
||||
|
||||
encoder := desc.encoder
|
||||
|
||||
var zero bool
|
||||
var empty bool
|
||||
if cz, ok := encoder.(CodecZeroer); ok {
|
||||
zero = cz.IsTypeZero(rv.Interface())
|
||||
empty = cz.IsTypeZero(rv.Interface())
|
||||
} else if rv.Kind() == reflect.Interface {
|
||||
// isZero will not treat an interface rv as an interface, so we need to check for the
|
||||
// zero interface separately.
|
||||
zero = rv.IsNil()
|
||||
// isEmpty will not treat an interface rv as an interface, so we need to check for the
|
||||
// nil interface separately.
|
||||
empty = rv.IsNil()
|
||||
} else {
|
||||
zero = isZero(rv, sc.EncodeOmitDefaultStruct || ec.omitZeroStruct)
|
||||
empty = isEmpty(rv, sc.EncodeOmitDefaultStruct || ec.omitZeroStruct)
|
||||
}
|
||||
if desc.omitEmpty && zero {
|
||||
if desc.omitEmpty && empty {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -239,8 +254,8 @@ func (sc *StructCodec) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val
|
||||
}
|
||||
|
||||
func newDecodeError(key string, original error) error {
|
||||
de, ok := original.(*DecodeError)
|
||||
if !ok {
|
||||
var de *DecodeError
|
||||
if !errors.As(original, &de) {
|
||||
return &DecodeError{
|
||||
keys: []string{key},
|
||||
wrapped: original,
|
||||
@@ -308,7 +323,7 @@ func (sc *StructCodec) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val
|
||||
|
||||
for {
|
||||
name, vr, err := dr.ReadElement()
|
||||
if err == bsonrw.ErrEOD {
|
||||
if errors.Is(err, bsonrw.ErrEOD) {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
@@ -391,12 +406,15 @@ func (sc *StructCodec) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val
|
||||
return nil
|
||||
}
|
||||
|
||||
func isZero(v reflect.Value, omitZeroStruct bool) bool {
|
||||
func isEmpty(v reflect.Value, omitZeroStruct bool) bool {
|
||||
kind := v.Kind()
|
||||
if (kind != reflect.Ptr || !v.IsNil()) && v.Type().Implements(tZeroer) {
|
||||
return v.Interface().(Zeroer).IsZero()
|
||||
}
|
||||
if kind == reflect.Struct {
|
||||
switch kind {
|
||||
case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
|
||||
return v.Len() == 0
|
||||
case reflect.Struct:
|
||||
if !omitZeroStruct {
|
||||
return false
|
||||
}
|
||||
@@ -410,7 +428,7 @@ func isZero(v reflect.Value, omitZeroStruct bool) bool {
|
||||
if ff.PkgPath != "" && !ff.Anonymous {
|
||||
continue // Private field
|
||||
}
|
||||
if !isZero(v.Field(i), omitZeroStruct) {
|
||||
if !isEmpty(v.Field(i), omitZeroStruct) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
24
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/time_codec.go
generated
vendored
24
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/time_codec.go
generated
vendored
@@ -23,12 +23,26 @@ const (
|
||||
|
||||
// TimeCodec is the Codec used for time.Time values.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// TimeCodec registered.
|
||||
// Deprecated: TimeCodec will not be directly configurable in Go Driver 2.0.
|
||||
// To configure the time.Time encode and decode behavior, use the configuration
|
||||
// methods on a [go.mongodb.org/mongo-driver/bson.Encoder] or
|
||||
// [go.mongodb.org/mongo-driver/bson.Decoder]. To configure the time.Time encode
|
||||
// and decode behavior for a mongo.Client, use
|
||||
// [go.mongodb.org/mongo-driver/mongo/options.ClientOptions.SetBSONOptions].
|
||||
//
|
||||
// For example, to configure a mongo.Client to ..., use:
|
||||
//
|
||||
// opt := options.Client().SetBSONOptions(&options.BSONOptions{
|
||||
// UseLocalTimeZone: true,
|
||||
// })
|
||||
//
|
||||
// See the deprecation notice for each field in TimeCodec for the corresponding
|
||||
// settings.
|
||||
type TimeCodec struct {
|
||||
// UseLocalTimeZone specifies if we should decode into the local time zone. Defaults to false.
|
||||
//
|
||||
// Deprecated: Use bson.Decoder.UseLocalTimeZone instead.
|
||||
// Deprecated: Use bson.Decoder.UseLocalTimeZone or options.BSONOptions.UseLocalTimeZone
|
||||
// instead.
|
||||
UseLocalTimeZone bool
|
||||
}
|
||||
|
||||
@@ -42,8 +56,8 @@ var (
|
||||
|
||||
// NewTimeCodec returns a TimeCodec with options opts.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// TimeCodec registered.
|
||||
// Deprecated: NewTimeCodec will not be available in Go Driver 2.0. See
|
||||
// [TimeCodec] for more details.
|
||||
func NewTimeCodec(opts ...*bsonoptions.TimeCodecOptions) *TimeCodec {
|
||||
timeOpt := bsonoptions.MergeTimeCodecOptions(opts...)
|
||||
|
||||
|
24
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/uint_codec.go
generated
vendored
24
vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/uint_codec.go
generated
vendored
@@ -18,13 +18,27 @@ import (
|
||||
|
||||
// UIntCodec is the Codec used for uint values.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// UIntCodec registered.
|
||||
// Deprecated: UIntCodec will not be directly configurable in Go Driver 2.0. To
|
||||
// configure the uint encode and decode behavior, use the configuration methods
|
||||
// on a [go.mongodb.org/mongo-driver/bson.Encoder] or
|
||||
// [go.mongodb.org/mongo-driver/bson.Decoder]. To configure the uint encode and
|
||||
// decode behavior for a mongo.Client, use
|
||||
// [go.mongodb.org/mongo-driver/mongo/options.ClientOptions.SetBSONOptions].
|
||||
//
|
||||
// For example, to configure a mongo.Client to marshal Go uint values as the
|
||||
// minimum BSON int size that can represent the value, use:
|
||||
//
|
||||
// opt := options.Client().SetBSONOptions(&options.BSONOptions{
|
||||
// IntMinSize: true,
|
||||
// })
|
||||
//
|
||||
// See the deprecation notice for each field in UIntCodec for the corresponding
|
||||
// settings.
|
||||
type UIntCodec struct {
|
||||
// EncodeToMinSize causes EncodeValue to marshal Go uint values (excluding uint64) as the
|
||||
// minimum BSON int size (either 32-bit or 64-bit) that can represent the integer value.
|
||||
//
|
||||
// Deprecated: Use bson.Encoder.IntMinSize instead.
|
||||
// Deprecated: Use bson.Encoder.IntMinSize or options.BSONOptions.IntMinSize instead.
|
||||
EncodeToMinSize bool
|
||||
}
|
||||
|
||||
@@ -38,8 +52,8 @@ var (
|
||||
|
||||
// NewUIntCodec returns a UIntCodec with options opts.
|
||||
//
|
||||
// Deprecated: Use [go.mongodb.org/mongo-driver/bson.NewRegistry] to get a registry with the
|
||||
// UIntCodec registered.
|
||||
// Deprecated: NewUIntCodec will not be available in Go Driver 2.0. See
|
||||
// [UIntCodec] for more details.
|
||||
func NewUIntCodec(opts ...*bsonoptions.UIntCodecOptions) *UIntCodec {
|
||||
uintOpt := bsonoptions.MergeUIntCodecOptions(opts...)
|
||||
|
||||
|
Reference in New Issue
Block a user