Update go dependencies (#4322)
This commit is contained in:
parent
28cc3bb5e2
commit
a54ab3341e
507 changed files with 50566 additions and 40414 deletions
19
vendor/k8s.io/utils/io/consistentread.go → vendor/k8s.io/utils/io/read.go
generated
vendored
19
vendor/k8s.io/utils/io/consistentread.go → vendor/k8s.io/utils/io/read.go
generated
vendored
|
|
@ -18,10 +18,15 @@ package io
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
// ErrLimitReached means that the read limit is reached.
|
||||
var ErrLimitReached = errors.New("the read limit is reached")
|
||||
|
||||
// ConsistentRead repeatedly reads a file until it gets the same content twice.
|
||||
// This is useful when reading files in /proc that are larger than page size
|
||||
// and kernel may modify them between individual read() syscalls.
|
||||
|
|
@ -53,3 +58,17 @@ func consistentReadSync(filename string, attempts int, sync func(int)) ([]byte,
|
|||
}
|
||||
return nil, fmt.Errorf("could not get consistent content of %s after %d attempts", filename, attempts)
|
||||
}
|
||||
|
||||
// ReadAtMost reads up to `limit` bytes from `r`, and reports an error
|
||||
// when `limit` bytes are read.
|
||||
func ReadAtMost(r io.Reader, limit int64) ([]byte, error) {
|
||||
limitedReader := &io.LimitedReader{R: r, N: limit}
|
||||
data, err := ioutil.ReadAll(limitedReader)
|
||||
if err != nil {
|
||||
return data, err
|
||||
}
|
||||
if limitedReader.N <= 0 {
|
||||
return data, ErrLimitReached
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
2
vendor/k8s.io/utils/pointer/pointer.go
generated
vendored
2
vendor/k8s.io/utils/pointer/pointer.go
generated
vendored
|
|
@ -56,7 +56,7 @@ func Int64Ptr(i int64) *int64 {
|
|||
return &i
|
||||
}
|
||||
|
||||
// Int32PtrDerefOr dereference the int32 ptr and returns it i not nil,
|
||||
// Int32PtrDerefOr dereference the int32 ptr and returns it if not nil,
|
||||
// else returns def.
|
||||
func Int32PtrDerefOr(ptr *int32, def int32) int32 {
|
||||
if ptr != nil {
|
||||
|
|
|
|||
3
vendor/k8s.io/utils/trace/trace.go
generated
vendored
3
vendor/k8s.io/utils/trace/trace.go
generated
vendored
|
|
@ -43,7 +43,8 @@ func New(name string) *Trace {
|
|||
return &Trace{name, time.Now(), nil}
|
||||
}
|
||||
|
||||
// Step adds a new step with a specific message
|
||||
// Step adds a new step with a specific message. Call this at the end of an
|
||||
// execution step to record how long it took.
|
||||
func (t *Trace) Step(msg string) {
|
||||
if t.steps == nil {
|
||||
// traces almost always have less than 6 steps, do this to avoid more than a single allocation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue