зеркало из https://github.com/Azure/ARO-RP.git
Merge pull request #3474 from Azure/ARO-6247/revendor-go-cosmosdb
Revendor go-cosmosdb
This commit is contained in:
Коммит
14e3c5a881
4
go.mod
4
go.mod
|
@ -42,7 +42,7 @@ require (
|
|||
github.com/gorilla/sessions v1.2.2
|
||||
github.com/hashicorp/go-multierror v1.1.1
|
||||
github.com/itchyny/gojq v0.12.13
|
||||
github.com/jewzaam/go-cosmosdb v0.0.0-20230924011506-8f8942a01991
|
||||
github.com/jewzaam/go-cosmosdb v0.0.0-20240320220716-88298caebe4a
|
||||
github.com/jongio/azidext/go/azidext v0.5.0
|
||||
github.com/microsoft/kiota-abstractions-go v1.2.0
|
||||
github.com/microsoft/kiota-http-go v1.0.0
|
||||
|
@ -71,7 +71,7 @@ require (
|
|||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/stretchr/testify v1.8.4
|
||||
github.com/tebeka/selenium v0.9.9
|
||||
github.com/ugorji/go/codec v1.2.11
|
||||
github.com/ugorji/go/codec v1.2.12
|
||||
github.com/vincent-petithory/dataurl v1.0.0
|
||||
golang.org/x/crypto v0.21.0
|
||||
golang.org/x/net v0.22.0
|
||||
|
|
10
go.sum
10
go.sum
|
@ -385,8 +385,8 @@ github.com/itchyny/gojq v0.12.13/go.mod h1:JzwzAqenfhrPUuwbmEz3nu3JQmFLlQTQMUcOd
|
|||
github.com/itchyny/timefmt-go v0.1.5 h1:G0INE2la8S6ru/ZI5JecgyzbbJNs5lG1RcBqa7Jm6GE=
|
||||
github.com/itchyny/timefmt-go v0.1.5/go.mod h1:nEP7L+2YmAbT2kZ2HfSs1d8Xtw9LY8D2stDBckWakZ8=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jewzaam/go-cosmosdb v0.0.0-20230924011506-8f8942a01991 h1:koKHzrAEY9tclwxktrMpKrYMkZ4EoaV5wPrx4mP4Rk4=
|
||||
github.com/jewzaam/go-cosmosdb v0.0.0-20230924011506-8f8942a01991/go.mod h1:PjxVF6k8IU/Kt7koUjD/8UfK1ZvoqAznDzh1hK40MjY=
|
||||
github.com/jewzaam/go-cosmosdb v0.0.0-20240320220716-88298caebe4a h1:x8omH/WFc+AYa/2zTNQCLkpPQDxxpSAiYkCpXqRhtUI=
|
||||
github.com/jewzaam/go-cosmosdb v0.0.0-20240320220716-88298caebe4a/go.mod h1:hEk8/SoE/NBT9ofV69Gzs98vbGyF155SaYl1p9bxKb8=
|
||||
github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8=
|
||||
github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
|
||||
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
|
||||
|
@ -654,10 +654,8 @@ github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
|||
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 h1:e/5i7d4oYZ+C1wj2THlRK+oAhjeS/TRQwMfkIuet3w0=
|
||||
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399/go.mod h1:LdwHTNJT99C5fTAzDz0ud328OgXz+gierycbcIx2fRs=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/ugorji/go v1.2.0/go.mod h1:1ny++pKMXhLWrwWV5Nf+CbOuZJhMoaFD+0GMFfd8fEc=
|
||||
github.com/ugorji/go/codec v1.2.0/go.mod h1:dXvG35r7zTX6QImXOSFhGMmKtX+wJ7VTWzGvYQGIjBs=
|
||||
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
|
||||
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
|
||||
github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
|
||||
github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinCts=
|
||||
|
|
|
@ -170,6 +170,8 @@ type PartitionKeyRanges struct {
|
|||
|
||||
// PartitionKeyRange represents a partition key range
|
||||
type PartitionKeyRange struct {
|
||||
MissingFields
|
||||
|
||||
ID string `json:"id,omitempty"`
|
||||
ResourceID string `json:"_rid,omitempty"`
|
||||
Timestamp int `json:"_ts,omitempty"`
|
||||
|
@ -192,6 +194,27 @@ const (
|
|||
PartitionKeyRangeStatusOnline PartitionKeyRangeStatus = "online"
|
||||
)
|
||||
|
||||
// MissingFields retains values that do not map to struct fields during JSON
|
||||
// marshalling/unmarshalling. MissingFields implements
|
||||
// github.com/ugorji/go/codec.MissingFielder.
|
||||
type MissingFields struct {
|
||||
m map[string]interface{}
|
||||
}
|
||||
|
||||
// CodecMissingField is called to set a missing field and value pair
|
||||
func (mf *MissingFields) CodecMissingField(field []byte, value interface{}) bool {
|
||||
if mf.m == nil {
|
||||
mf.m = map[string]interface{}{}
|
||||
}
|
||||
(mf.m)[string(field)] = value
|
||||
return true
|
||||
}
|
||||
|
||||
// CodecMissingFields returns the set of fields which are not struct fields
|
||||
func (mf *MissingFields) CodecMissingFields() map[string]interface{} {
|
||||
return mf.m
|
||||
}
|
||||
|
||||
type collectionClient struct {
|
||||
*databaseClient
|
||||
path string
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -123,6 +123,11 @@ type cborEncDriver struct {
|
|||
encDriverNoopContainerWriter
|
||||
h *CborHandle
|
||||
|
||||
// scratch buffer for: encode time, numbers, etc
|
||||
//
|
||||
// RFC3339Nano uses 35 chars: 2006-01-02T15:04:05.999999999Z07:00
|
||||
b [40]byte
|
||||
|
||||
e Encoder
|
||||
}
|
||||
|
||||
|
@ -204,7 +209,7 @@ func (e *cborEncDriver) EncodeTime(t time.Time) {
|
|||
e.EncodeNil()
|
||||
} else if e.h.TimeRFC3339 {
|
||||
e.encUint(0, cborBaseTag)
|
||||
e.encStringBytesS(cborBaseString, t.Format(time.RFC3339Nano))
|
||||
e.encStringBytesS(cborBaseString, stringView(fmtTime(t, time.RFC3339Nano, e.b[:0])))
|
||||
} else {
|
||||
e.encUint(1, cborBaseTag)
|
||||
t = t.UTC().Round(time.Microsecond)
|
||||
|
@ -427,12 +432,13 @@ func (d *cborDecDriver) decLen() int {
|
|||
return int(d.decUint())
|
||||
}
|
||||
|
||||
func (d *cborDecDriver) decAppendIndefiniteBytes(bs []byte) []byte {
|
||||
func (d *cborDecDriver) decAppendIndefiniteBytes(bs []byte, major byte) []byte {
|
||||
d.bdRead = false
|
||||
for !d.CheckBreak() {
|
||||
if major := d.bd >> 5; major != cborMajorBytes && major != cborMajorString {
|
||||
d.d.errorf("invalid indefinite string/bytes %x (%s); got major %v, expected %v or %v",
|
||||
d.bd, cbordesc(d.bd), major, cborMajorBytes, cborMajorString)
|
||||
chunkMajor := d.bd >> 5
|
||||
if chunkMajor != major {
|
||||
d.d.errorf("malformed indefinite string/bytes %x (%s); contains chunk with major type %v, expected %v",
|
||||
d.bd, cbordesc(d.bd), chunkMajor, major)
|
||||
}
|
||||
n := uint(d.decLen())
|
||||
oldLen := uint(len(bs))
|
||||
|
@ -445,6 +451,9 @@ func (d *cborDecDriver) decAppendIndefiniteBytes(bs []byte) []byte {
|
|||
bs = bs[:newLen]
|
||||
}
|
||||
d.d.decRd.readb(bs[oldLen:newLen])
|
||||
if d.h.ValidateUnicode && major == cborMajorString && !utf8.Valid(bs[oldLen:newLen]) {
|
||||
d.d.errorf("indefinite-length text string contains chunk that is not a valid utf-8 sequence: 0x%x", bs[oldLen:newLen])
|
||||
}
|
||||
d.bdRead = false
|
||||
}
|
||||
d.bdRead = false
|
||||
|
@ -580,9 +589,9 @@ func (d *cborDecDriver) DecodeBytes(bs []byte) (bsOut []byte) {
|
|||
d.bdRead = false
|
||||
if bs == nil {
|
||||
d.d.decByteState = decByteStateReuseBuf
|
||||
return d.decAppendIndefiniteBytes(d.d.b[:0])
|
||||
return d.decAppendIndefiniteBytes(d.d.b[:0], d.bd>>5)
|
||||
}
|
||||
return d.decAppendIndefiniteBytes(bs[:0])
|
||||
return d.decAppendIndefiniteBytes(bs[:0], d.bd>>5)
|
||||
}
|
||||
if d.bd == cborBdIndefiniteArray {
|
||||
d.bdRead = false
|
||||
|
|
|
@ -1399,6 +1399,10 @@ func NewDecoderString(s string, h Handle) *Decoder {
|
|||
return NewDecoderBytes(bytesView(s), h)
|
||||
}
|
||||
|
||||
func (d *Decoder) HandleName() string {
|
||||
return d.hh.Name()
|
||||
}
|
||||
|
||||
func (d *Decoder) r() *decRd {
|
||||
return &d.decRd
|
||||
}
|
||||
|
@ -1580,14 +1584,9 @@ func (d *Decoder) MustDecode(v interface{}) {
|
|||
d.calls--
|
||||
}
|
||||
|
||||
// Release releases shared (pooled) resources.
|
||||
// Release is a no-op.
|
||||
//
|
||||
// It is important to call Release() when done with a Decoder, so those resources
|
||||
// are released instantly for use by subsequently created Decoders.
|
||||
//
|
||||
// By default, Release() is automatically called unless the option ExplicitRelease is set.
|
||||
//
|
||||
// Deprecated: Release is a no-op as pooled resources are not used with an Decoder.
|
||||
// Deprecated: Pooled resources are not used with a Decoder.
|
||||
// This method is kept for compatibility reasons only.
|
||||
func (d *Decoder) Release() {
|
||||
}
|
||||
|
|
|
@ -984,6 +984,10 @@ func NewEncoderBytes(out *[]byte, h Handle) *Encoder {
|
|||
return e
|
||||
}
|
||||
|
||||
func (e *Encoder) HandleName() string {
|
||||
return e.hh.Name()
|
||||
}
|
||||
|
||||
func (e *Encoder) init(h Handle) {
|
||||
initHandle(h)
|
||||
e.err = errEncoderNotInitialized
|
||||
|
@ -1150,12 +1154,9 @@ func (e *Encoder) MustEncode(v interface{}) {
|
|||
}
|
||||
}
|
||||
|
||||
// Release releases shared (pooled) resources.
|
||||
// Release is a no-op.
|
||||
//
|
||||
// It is important to call Release() when done with an Encoder, so those resources
|
||||
// are released instantly for use by subsequently created Encoders.
|
||||
//
|
||||
// Deprecated: Release is a no-op as pooled resources are not used with an Encoder.
|
||||
// Deprecated: Pooled resources are not used with an Encoder.
|
||||
// This method is kept for compatibility reasons only.
|
||||
func (e *Encoder) Release() {
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ package codec
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/base32"
|
||||
"errors"
|
||||
"fmt"
|
||||
"go/format"
|
||||
|
@ -190,7 +190,11 @@ var (
|
|||
errGenExpectArrayOrMap = errors.New("unexpected type - expecting array/map/slice")
|
||||
errGenUnexpectedTypeFastpath = errors.New("fast-path: unexpected type - requires map or slice")
|
||||
|
||||
genBase64enc = base64.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789__")
|
||||
// don't use base64, only 63 characters allowed in valid go identifiers
|
||||
// ie ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_
|
||||
//
|
||||
// don't use numbers, as a valid go identifer must start with a letter.
|
||||
genTypenameEnc = base32.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef")
|
||||
genQNameRegex = regexp.MustCompile(`[A-Za-z_.]+`)
|
||||
)
|
||||
|
||||
|
@ -2303,8 +2307,6 @@ func genMethodNameT(t reflect.Type, tRef reflect.Type) (n string) {
|
|||
}
|
||||
} else {
|
||||
// best way to get the package name inclusive
|
||||
// return ptrPfx + strings.Replace(tstr, ".", "_", 1000)
|
||||
// return ptrPfx + genBase64enc.EncodeToString([]byte(tstr))
|
||||
if t.Name() != "" && genQNameRegex.MatchString(tstr) {
|
||||
return ptrPfx + strings.Replace(tstr, ".", "_", 1000)
|
||||
} else {
|
||||
|
@ -2315,12 +2317,12 @@ func genMethodNameT(t reflect.Type, tRef reflect.Type) (n string) {
|
|||
}
|
||||
}
|
||||
|
||||
// genCustomNameForType base64encodes the t.String() value in such a way
|
||||
// genCustomNameForType base32 encodes the t.String() value in such a way
|
||||
// that it can be used within a function name.
|
||||
func genCustomTypeName(tstr string) string {
|
||||
len2 := genBase64enc.EncodedLen(len(tstr))
|
||||
len2 := genTypenameEnc.EncodedLen(len(tstr))
|
||||
bufx := make([]byte, len2)
|
||||
genBase64enc.Encode(bufx, []byte(tstr))
|
||||
genTypenameEnc.Encode(bufx, []byte(tstr))
|
||||
for i := len2 - 1; i >= 0; i-- {
|
||||
if bufx[i] == '=' {
|
||||
len2--
|
||||
|
|
|
@ -110,8 +110,7 @@ package codec
|
|||
//
|
||||
// ------------------------------------------
|
||||
// Bounds Checking
|
||||
// - Allow bytesDecReader to incur "bounds check error", and
|
||||
// recover that as an io.EOF.
|
||||
// - Allow bytesDecReader to incur "bounds check error", and recover that as an io error.
|
||||
// This allows the bounds check branch to always be taken by the branch predictor,
|
||||
// giving better performance (in theory), while ensuring that the code is shorter.
|
||||
//
|
||||
|
@ -857,26 +856,10 @@ type BasicHandle struct {
|
|||
// Once a Handle has been initialized (used), do not modify this option. It will be ignored.
|
||||
TimeNotBuiltin bool
|
||||
|
||||
// ExplicitRelease configures whether Release() is implicitly called after an encode or
|
||||
// decode call.
|
||||
// ExplicitRelease is ignored and has no effect.
|
||||
//
|
||||
// If you will hold onto an Encoder or Decoder for re-use, by calling Reset(...)
|
||||
// on it or calling (Must)Encode repeatedly into a given []byte or io.Writer,
|
||||
// then you do not want it to be implicitly closed after each Encode/Decode call.
|
||||
// Doing so will unnecessarily return resources to the shared pool, only for you to
|
||||
// grab them right after again to do another Encode/Decode call.
|
||||
//
|
||||
// Instead, you configure ExplicitRelease=true, and you explicitly call Release() when
|
||||
// you are truly done.
|
||||
//
|
||||
// As an alternative, you can explicitly set a finalizer - so its resources
|
||||
// are returned to the shared pool before it is garbage-collected. Do it as below:
|
||||
// runtime.SetFinalizer(e, (*Encoder).Release)
|
||||
// runtime.SetFinalizer(d, (*Decoder).Release)
|
||||
//
|
||||
// Deprecated: This is not longer used as pools are only used for long-lived objects
|
||||
// which are shared across goroutines.
|
||||
// Setting this value has no effect. It is maintained for backward compatibility.
|
||||
// Deprecated: Pools are only used for long-lived objects shared across goroutines.
|
||||
// It is maintained for backward compatibility.
|
||||
ExplicitRelease bool
|
||||
|
||||
// ---- cache line
|
||||
|
@ -2489,7 +2472,7 @@ func panicValToErr(h errDecorator, v interface{}, err *error) {
|
|||
case runtime.Error:
|
||||
d, dok := h.(*Decoder)
|
||||
if dok && d.bytes && isSliceBoundsError(xerr.Error()) {
|
||||
*err = io.EOF
|
||||
*err = io.ErrUnexpectedEOF
|
||||
} else {
|
||||
h.wrapErr(xerr, err)
|
||||
}
|
||||
|
@ -2803,7 +2786,7 @@ func freelistCapacity(length int) (capacity int) {
|
|||
// bytesFreelist is a list of byte buffers, sorted by cap.
|
||||
//
|
||||
// In anecdotal testing (running go test -tsd 1..6), we couldn't get
|
||||
// the length ofthe list > 4 at any time. So we believe a linear search
|
||||
// the length of the list > 4 at any time. So we believe a linear search
|
||||
// without bounds checking is sufficient.
|
||||
//
|
||||
// Typical usage model:
|
||||
|
@ -2821,7 +2804,7 @@ func freelistCapacity(length int) (capacity int) {
|
|||
// v1 := v0
|
||||
// ... use v1 ...
|
||||
// blist.put(v1)
|
||||
// if byteSliceAddr(v0) != byteSliceAddr(v1) {
|
||||
// if !byteSliceSameData(v0, v1) {
|
||||
// blist.put(v0)
|
||||
// }
|
||||
type bytesFreelist [][]byte
|
||||
|
|
|
@ -1301,6 +1301,9 @@ func (d *jsonDecDriver) DecodeNaked() {
|
|||
// Note also that the float values for NaN, +Inf or -Inf are encoded as null,
|
||||
// as suggested by NOTE 4 of the ECMA-262 ECMAScript Language Specification 5.1 edition.
|
||||
// see http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf .
|
||||
//
|
||||
// Note the following behaviour differences vs std-library encoding/json package:
|
||||
// - struct field names matched in case-sensitive manner
|
||||
type JsonHandle struct {
|
||||
textEncodingType
|
||||
BasicHandle
|
||||
|
|
|
@ -1174,7 +1174,7 @@ func (c *msgpackSpecRpcCodec) ReadRequestBody(body interface{}) error {
|
|||
|
||||
func (c *msgpackSpecRpcCodec) parseCustomHeader(expectTypeByte byte, msgid *uint64, methodOrError *string) (err error) {
|
||||
if cls := c.cls.load(); cls.closed {
|
||||
return io.EOF
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
// We read the response header by hand
|
||||
|
|
|
@ -350,9 +350,9 @@ func (z *ioDecReader) unreadn1() {
|
|||
|
||||
// bytesDecReader is a decReader that reads off a byte slice with zero copying
|
||||
//
|
||||
// Note: we do not try to convert index'ing out of bounds to an io.EOF.
|
||||
// Note: we do not try to convert index'ing out of bounds to an io error.
|
||||
// instead, we let it bubble up to the exported Encode/Decode method
|
||||
// and recover it as an io.EOF.
|
||||
// and recover it as an io error.
|
||||
//
|
||||
// Every function here MUST defensively check bounds either explicitly
|
||||
// or via a bounds check.
|
||||
|
|
|
@ -732,8 +732,8 @@ github.com/itchyny/gojq/cli
|
|||
# github.com/itchyny/timefmt-go v0.1.5
|
||||
## explicit; go 1.17
|
||||
github.com/itchyny/timefmt-go
|
||||
# github.com/jewzaam/go-cosmosdb v0.0.0-20230924011506-8f8942a01991
|
||||
## explicit; go 1.14
|
||||
# github.com/jewzaam/go-cosmosdb v0.0.0-20240320220716-88298caebe4a
|
||||
## explicit; go 1.18
|
||||
github.com/jewzaam/go-cosmosdb/cmd/gencosmosdb
|
||||
github.com/jewzaam/go-cosmosdb/pkg/gencosmosdb
|
||||
# github.com/jinzhu/copier v0.4.0
|
||||
|
@ -1240,7 +1240,7 @@ github.com/tebeka/selenium/log
|
|||
# github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399
|
||||
## explicit
|
||||
github.com/titanous/rocacheck
|
||||
# github.com/ugorji/go/codec v1.2.11
|
||||
# github.com/ugorji/go/codec v1.2.12
|
||||
## explicit; go 1.11
|
||||
github.com/ugorji/go/codec
|
||||
# github.com/ulikunitz/xz v0.5.11
|
||||
|
|
Загрузка…
Ссылка в новой задаче