updated dependencies

This commit is contained in:
ston1th 2023-01-15 16:30:08 +01:00
commit e95910d920
148 changed files with 18553 additions and 2442 deletions

86
vendor/k8s.io/klog/v2/klogr/klogr.go generated vendored
View file

@ -6,10 +6,13 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/go-logr/logr"
"k8s.io/klog/v2"
"sort"
"strings"
"github.com/go-logr/logr"
"k8s.io/klog/v2"
"k8s.io/klog/v2/internal/serialize"
)
// Option is a functional option that reconfigures the logger created with New.
@ -70,51 +73,6 @@ func (l *klogger) Init(info logr.RuntimeInfo) {
l.callDepth += info.CallDepth
}
// trimDuplicates will deduplicate elements provided in multiple KV tuple
// slices, whilst maintaining the distinction between where the items are
// contained.
func trimDuplicates(kvLists ...[]interface{}) [][]interface{} {
// maintain a map of all seen keys
seenKeys := map[interface{}]struct{}{}
// build the same number of output slices as inputs
outs := make([][]interface{}, len(kvLists))
// iterate over the input slices backwards, as 'later' kv specifications
// of the same key will take precedence over earlier ones
for i := len(kvLists) - 1; i >= 0; i-- {
// initialise this output slice
outs[i] = []interface{}{}
// obtain a reference to the kvList we are processing
kvList := kvLists[i]
// start iterating at len(kvList) - 2 (i.e. the 2nd last item) for
// slices that have an even number of elements.
// We add (len(kvList) % 2) here to handle the case where there is an
// odd number of elements in a kvList.
// If there is an odd number, then the last element in the slice will
// have the value 'null'.
for i2 := len(kvList) - 2 + (len(kvList) % 2); i2 >= 0; i2 -= 2 {
k := kvList[i2]
// if we have already seen this key, do not include it again
if _, ok := seenKeys[k]; ok {
continue
}
// make a note that we've observed a new key
seenKeys[k] = struct{}{}
// attempt to obtain the value of the key
var v interface{}
// i2+1 should only ever be out of bounds if we handling the first
// iteration over a slice with an odd number of elements
if i2+1 < len(kvList) {
v = kvList[i2+1]
}
// add this KV tuple to the *start* of the output list to maintain
// the original order as we are iterating over the slice backwards
outs[i] = append([]interface{}{k, v}, outs[i]...)
}
}
return outs
}
func flatten(kvList ...interface{}) string {
keys := make([]string, 0, len(kvList))
vals := make(map[string]interface{}, len(kvList))
@ -127,7 +85,11 @@ func flatten(kvList ...interface{}) string {
if i+1 < len(kvList) {
v = kvList[i+1]
}
keys = append(keys, k)
// Only print each key once...
if _, seen := vals[k]; !seen {
keys = append(keys, k)
}
// ... with the latest value.
vals[k] = v
}
sort.Strings(keys)
@ -161,16 +123,15 @@ func (l klogger) Info(level int, msg string, kvList ...interface{}) {
switch l.format {
case FormatSerialize:
msgStr := flatten("msg", msg)
trimmed := trimDuplicates(l.values, kvList)
fixedStr := flatten(trimmed[0]...)
userStr := flatten(trimmed[1]...)
klog.InfoDepth(l.callDepth+1, l.prefix, " ", msgStr, " ", fixedStr, " ", userStr)
merged := serialize.MergeKVs(l.values, kvList)
kvStr := flatten(merged...)
klog.V(klog.Level(level)).InfoDepth(l.callDepth+1, l.prefix, " ", msgStr, " ", kvStr)
case FormatKlog:
trimmed := trimDuplicates(l.values, kvList)
merged := serialize.MergeKVs(l.values, kvList)
if l.prefix != "" {
msg = l.prefix + ": " + msg
}
klog.InfoSDepth(l.callDepth+1, msg, append(trimmed[0], trimmed[1]...)...)
klog.V(klog.Level(level)).InfoSDepth(l.callDepth+1, msg, merged...)
}
}
@ -182,21 +143,20 @@ func (l klogger) Error(err error, msg string, kvList ...interface{}) {
msgStr := flatten("msg", msg)
var loggableErr interface{}
if err != nil {
loggableErr = err.Error()
loggableErr = serialize.ErrorToString(err)
}
switch l.format {
case FormatSerialize:
errStr := flatten("error", loggableErr)
trimmed := trimDuplicates(l.values, kvList)
fixedStr := flatten(trimmed[0]...)
userStr := flatten(trimmed[1]...)
klog.ErrorDepth(l.callDepth+1, l.prefix, " ", msgStr, " ", errStr, " ", fixedStr, " ", userStr)
merged := serialize.MergeKVs(l.values, kvList)
kvStr := flatten(merged...)
klog.ErrorDepth(l.callDepth+1, l.prefix, " ", msgStr, " ", errStr, " ", kvStr)
case FormatKlog:
trimmed := trimDuplicates(l.values, kvList)
merged := serialize.MergeKVs(l.values, kvList)
if l.prefix != "" {
msg = l.prefix + ": " + msg
}
klog.ErrorSDepth(l.callDepth+1, err, msg, append(trimmed[0], trimmed[1]...)...)
klog.ErrorSDepth(l.callDepth+1, err, msg, merged...)
}
}
@ -212,9 +172,7 @@ func (l klogger) WithName(name string) logr.LogSink {
}
func (l klogger) WithValues(kvList ...interface{}) logr.LogSink {
// Three slice args forces a copy.
n := len(l.values)
l.values = append(l.values[:n:n], kvList...)
l.values = serialize.WithValues(l.values, kvList)
return &l
}