mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-28 06:29:29 +01:00
go mod tidy && go mod vendor
This commit is contained in:
4
vendor/k8s.io/klog/v2/README.md
generated
vendored
4
vendor/k8s.io/klog/v2/README.md
generated
vendored
@@ -36,7 +36,7 @@ How to use klog
|
||||
**NOTE**: please use the newer go versions that support semantic import versioning in modules, ideally go 1.11.4 or greater.
|
||||
|
||||
### Coexisting with glog
|
||||
This package can be used side by side with glog. [This example](examples/coexist_glog/coexist_glog.go) shows how to initialize and syncronize flags from the global `flag.CommandLine` FlagSet. In addition, the example makes use of stderr as combined output by setting `alsologtostderr` (or `logtostderr`) to `true`.
|
||||
This package can be used side by side with glog. [This example](examples/coexist_glog/coexist_glog.go) shows how to initialize and synchronize flags from the global `flag.CommandLine` FlagSet. In addition, the example makes use of stderr as combined output by setting `alsologtostderr` (or `logtostderr`) to `true`.
|
||||
|
||||
## Community, discussion, contribution, and support
|
||||
|
||||
@@ -44,7 +44,7 @@ Learn how to engage with the Kubernetes community on the [community page](http:/
|
||||
|
||||
You can reach the maintainers of this project at:
|
||||
|
||||
- [Slack](https://kubernetes.slack.com/messages/sig-architecture)
|
||||
- [Slack](https://kubernetes.slack.com/messages/klog)
|
||||
- [Mailing List](https://groups.google.com/forum/#!forum/kubernetes-sig-architecture)
|
||||
|
||||
### Code of conduct
|
||||
|
||||
2
vendor/k8s.io/klog/v2/go.mod
generated
vendored
2
vendor/k8s.io/klog/v2/go.mod
generated
vendored
@@ -2,4 +2,4 @@ module k8s.io/klog/v2
|
||||
|
||||
go 1.13
|
||||
|
||||
require github.com/go-logr/logr v0.1.0
|
||||
require github.com/go-logr/logr v0.2.0
|
||||
|
||||
4
vendor/k8s.io/klog/v2/go.sum
generated
vendored
4
vendor/k8s.io/klog/v2/go.sum
generated
vendored
@@ -1,2 +1,2 @@
|
||||
github.com/go-logr/logr v0.1.0 h1:M1Tv3VzNlEHg6uyACnRdtrploV2P7wZqH8BoQMtz0cg=
|
||||
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
|
||||
github.com/go-logr/logr v0.2.0 h1:QvGt2nLcHH0WK9orKa+ppBPAxREcH364nPUedEpK0TY=
|
||||
github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
|
||||
|
||||
87
vendor/k8s.io/klog/v2/klog.go
generated
vendored
87
vendor/k8s.io/klog/v2/klog.go
generated
vendored
@@ -687,7 +687,7 @@ func (buf *buffer) someDigits(i, d int) int {
|
||||
return copy(buf.tmp[i:], buf.tmp[j:])
|
||||
}
|
||||
|
||||
func (l *loggingT) println(s severity, logr logr.InfoLogger, args ...interface{}) {
|
||||
func (l *loggingT) println(s severity, logr logr.Logger, args ...interface{}) {
|
||||
buf, file, line := l.header(s, 0)
|
||||
// if logr is set, we clear the generated header as we rely on the backing
|
||||
// logr implementation to print headers
|
||||
@@ -699,11 +699,11 @@ func (l *loggingT) println(s severity, logr logr.InfoLogger, args ...interface{}
|
||||
l.output(s, logr, buf, file, line, false)
|
||||
}
|
||||
|
||||
func (l *loggingT) print(s severity, logr logr.InfoLogger, args ...interface{}) {
|
||||
func (l *loggingT) print(s severity, logr logr.Logger, args ...interface{}) {
|
||||
l.printDepth(s, logr, 1, args...)
|
||||
}
|
||||
|
||||
func (l *loggingT) printDepth(s severity, logr logr.InfoLogger, depth int, args ...interface{}) {
|
||||
func (l *loggingT) printDepth(s severity, logr logr.Logger, depth int, args ...interface{}) {
|
||||
buf, file, line := l.header(s, depth)
|
||||
// if logr is set, we clear the generated header as we rely on the backing
|
||||
// logr implementation to print headers
|
||||
@@ -718,7 +718,7 @@ func (l *loggingT) printDepth(s severity, logr logr.InfoLogger, depth int, args
|
||||
l.output(s, logr, buf, file, line, false)
|
||||
}
|
||||
|
||||
func (l *loggingT) printf(s severity, logr logr.InfoLogger, format string, args ...interface{}) {
|
||||
func (l *loggingT) printf(s severity, logr logr.Logger, format string, args ...interface{}) {
|
||||
buf, file, line := l.header(s, 0)
|
||||
// if logr is set, we clear the generated header as we rely on the backing
|
||||
// logr implementation to print headers
|
||||
@@ -736,7 +736,7 @@ func (l *loggingT) printf(s severity, logr logr.InfoLogger, format string, args
|
||||
// printWithFileLine behaves like print but uses the provided file and line number. If
|
||||
// alsoLogToStderr is true, the log message always appears on standard error; it
|
||||
// will also appear in the log file unless --logtostderr is set.
|
||||
func (l *loggingT) printWithFileLine(s severity, logr logr.InfoLogger, file string, line int, alsoToStderr bool, args ...interface{}) {
|
||||
func (l *loggingT) printWithFileLine(s severity, logr logr.Logger, file string, line int, alsoToStderr bool, args ...interface{}) {
|
||||
buf := l.formatHeader(s, file, line)
|
||||
// if logr is set, we clear the generated header as we rely on the backing
|
||||
// logr implementation to print headers
|
||||
@@ -751,17 +751,27 @@ func (l *loggingT) printWithFileLine(s severity, logr logr.InfoLogger, file stri
|
||||
l.output(s, logr, buf, file, line, alsoToStderr)
|
||||
}
|
||||
|
||||
// printS if loggr is specified, no need to output with logging module. If
|
||||
// err arguments is specified, will call logr.Error, or output to errorLog severity
|
||||
func (l *loggingT) printS(err error, loggr logr.Logger, msg string, keysAndValues ...interface{}) {
|
||||
// if loggr is specified, will call loggr.Error, otherwise output with logging module.
|
||||
func (l *loggingT) errorS(err error, loggr logr.Logger, msg string, keysAndValues ...interface{}) {
|
||||
if loggr != nil {
|
||||
if err != nil {
|
||||
loggr.Error(err, msg, keysAndValues)
|
||||
} else {
|
||||
loggr.Info(msg, keysAndValues)
|
||||
}
|
||||
loggr.Error(err, msg, keysAndValues)
|
||||
return
|
||||
}
|
||||
l.printS(err, msg, keysAndValues...)
|
||||
}
|
||||
|
||||
// if loggr is specified, will call loggr.Info, otherwise output with logging module.
|
||||
func (l *loggingT) infoS(loggr logr.Logger, msg string, keysAndValues ...interface{}) {
|
||||
if loggr != nil {
|
||||
loggr.Info(msg, keysAndValues)
|
||||
return
|
||||
}
|
||||
l.printS(nil, msg, keysAndValues...)
|
||||
}
|
||||
|
||||
// printS is called from infoS and errorS if loggr is not specified.
|
||||
// if err arguments is specified, will output to errorLog severity
|
||||
func (l *loggingT) printS(err error, msg string, keysAndValues ...interface{}) {
|
||||
b := &bytes.Buffer{}
|
||||
b.WriteString(fmt.Sprintf("%q", msg))
|
||||
if err != nil {
|
||||
@@ -775,7 +785,7 @@ func (l *loggingT) printS(err error, loggr logr.Logger, msg string, keysAndValue
|
||||
} else {
|
||||
s = errorLog
|
||||
}
|
||||
l.printDepth(s, logging.logr, 1, b)
|
||||
l.printDepth(s, logging.logr, 2, b)
|
||||
}
|
||||
|
||||
const missingValue = "(MISSING)"
|
||||
@@ -790,10 +800,16 @@ func kvListFormat(b *bytes.Buffer, keysAndValues ...interface{}) {
|
||||
v = missingValue
|
||||
}
|
||||
b.WriteByte(' ')
|
||||
if _, ok := v.(fmt.Stringer); ok {
|
||||
|
||||
switch v.(type) {
|
||||
case string, error:
|
||||
b.WriteString(fmt.Sprintf("%s=%q", k, v))
|
||||
} else {
|
||||
b.WriteString(fmt.Sprintf("%s=%#v", k, v))
|
||||
default:
|
||||
if _, ok := v.(fmt.Stringer); ok {
|
||||
b.WriteString(fmt.Sprintf("%s=%q", k, v))
|
||||
} else {
|
||||
b.WriteString(fmt.Sprintf("%s=%+v", k, v))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -853,8 +869,16 @@ func SetOutputBySeverity(name string, w io.Writer) {
|
||||
logging.file[sev] = rb
|
||||
}
|
||||
|
||||
// LogToStderr sets whether to log exclusively to stderr, bypassing outputs
|
||||
func LogToStderr(stderr bool) {
|
||||
logging.mu.Lock()
|
||||
defer logging.mu.Unlock()
|
||||
|
||||
logging.toStderr = stderr
|
||||
}
|
||||
|
||||
// output writes the data to the log files and releases the buffer.
|
||||
func (l *loggingT) output(s severity, log logr.InfoLogger, buf *buffer, file string, line int, alsoToStderr bool) {
|
||||
func (l *loggingT) output(s severity, log logr.Logger, buf *buffer, file string, line int, alsoToStderr bool) {
|
||||
l.mu.Lock()
|
||||
if l.traceLocation.isSet() {
|
||||
if l.traceLocation.match(file, line) {
|
||||
@@ -1207,7 +1231,7 @@ func (l *loggingT) setV(pc uintptr) Level {
|
||||
// See the documentation of V for more information.
|
||||
type Verbose struct {
|
||||
enabled bool
|
||||
logr logr.InfoLogger
|
||||
logr logr.Logger
|
||||
}
|
||||
|
||||
func newVerbose(level Level, b bool) Verbose {
|
||||
@@ -1228,9 +1252,10 @@ func newVerbose(level Level, b bool) Verbose {
|
||||
// not evaluate its arguments.
|
||||
//
|
||||
// Whether an individual call to V generates a log record depends on the setting of
|
||||
// the -v and --vmodule flags; both are off by default. If the level in the call to
|
||||
// V is at least the value of -v, or of -vmodule for the source file containing the
|
||||
// call, the V call will log.
|
||||
// the -v and -vmodule flags; both are off by default. The V call will log if its level
|
||||
// is less than or equal to the value of the -v flag, or alternatively if its level is
|
||||
// less than or equal to the value of the -vmodule pattern matching the source file
|
||||
// containing the call.
|
||||
func V(level Level) Verbose {
|
||||
// This function tries hard to be cheap unless there's work to do.
|
||||
// The fast path is two atomic loads and compares.
|
||||
@@ -1295,11 +1320,15 @@ func (v Verbose) Infof(format string, args ...interface{}) {
|
||||
// See the documentation of V for usage.
|
||||
func (v Verbose) InfoS(msg string, keysAndValues ...interface{}) {
|
||||
if v.enabled {
|
||||
if v.logr != nil {
|
||||
v.logr.Info(msg, keysAndValues)
|
||||
return
|
||||
}
|
||||
logging.printS(nil, nil, msg, keysAndValues...)
|
||||
logging.infoS(v.logr, msg, keysAndValues...)
|
||||
}
|
||||
}
|
||||
|
||||
// Error is equivalent to the global Error function, guarded by the value of v.
|
||||
// See the documentation of V for usage.
|
||||
func (v Verbose) Error(err error, msg string, args ...interface{}) {
|
||||
if v.enabled {
|
||||
logging.errorS(err, v.logr, msg, args...)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1336,7 +1365,7 @@ func Infof(format string, args ...interface{}) {
|
||||
// output:
|
||||
// >> I1025 00:15:15.525108 1 controller_utils.go:116] "Pod status updated" pod="kubedns" status="ready"
|
||||
func InfoS(msg string, keysAndValues ...interface{}) {
|
||||
logging.printS(nil, logging.logr, msg, keysAndValues...)
|
||||
logging.infoS(logging.logr, msg, keysAndValues...)
|
||||
}
|
||||
|
||||
// Warning logs to the WARNING and INFO logs.
|
||||
@@ -1397,7 +1426,7 @@ func Errorf(format string, args ...interface{}) {
|
||||
// output:
|
||||
// >> E1025 00:15:15.525108 1 controller_utils.go:114] "Failed to update pod status" err="timeout"
|
||||
func ErrorS(err error, msg string, keysAndValues ...interface{}) {
|
||||
logging.printS(err, logging.logr, msg, keysAndValues...)
|
||||
logging.errorS(err, logging.logr, msg, keysAndValues...)
|
||||
}
|
||||
|
||||
// Fatal logs to the FATAL, ERROR, WARNING, and INFO logs,
|
||||
|
||||
64
vendor/k8s.io/klog/v2/klog_file.go
generated
vendored
64
vendor/k8s.io/klog/v2/klog_file.go
generated
vendored
@@ -44,43 +44,49 @@ func createLogDirs() {
|
||||
}
|
||||
|
||||
var (
|
||||
pid = os.Getpid()
|
||||
program = filepath.Base(os.Args[0])
|
||||
host = "unknownhost"
|
||||
userName = "unknownuser"
|
||||
pid = os.Getpid()
|
||||
program = filepath.Base(os.Args[0])
|
||||
host = "unknownhost"
|
||||
userName = "unknownuser"
|
||||
userNameOnce sync.Once
|
||||
)
|
||||
|
||||
func init() {
|
||||
h, err := os.Hostname()
|
||||
if err == nil {
|
||||
if h, err := os.Hostname(); err == nil {
|
||||
host = shortHostname(h)
|
||||
}
|
||||
}
|
||||
|
||||
// On Windows, the Go 'user' package requires netapi32.dll.
|
||||
// This affects Windows Nano Server:
|
||||
// https://github.com/golang/go/issues/21867
|
||||
// Fallback to using environment variables.
|
||||
if runtime.GOOS == "windows" {
|
||||
u := os.Getenv("USERNAME")
|
||||
if len(u) == 0 {
|
||||
return
|
||||
}
|
||||
// Sanitize the USERNAME since it may contain filepath separators.
|
||||
u = strings.Replace(u, `\`, "_", -1)
|
||||
func getUserName() string {
|
||||
userNameOnce.Do(func() {
|
||||
// On Windows, the Go 'user' package requires netapi32.dll.
|
||||
// This affects Windows Nano Server:
|
||||
// https://github.com/golang/go/issues/21867
|
||||
// Fallback to using environment variables.
|
||||
if runtime.GOOS == "windows" {
|
||||
u := os.Getenv("USERNAME")
|
||||
if len(u) == 0 {
|
||||
return
|
||||
}
|
||||
// Sanitize the USERNAME since it may contain filepath separators.
|
||||
u = strings.Replace(u, `\`, "_", -1)
|
||||
|
||||
// user.Current().Username normally produces something like 'USERDOMAIN\USERNAME'
|
||||
d := os.Getenv("USERDOMAIN")
|
||||
if len(d) != 0 {
|
||||
userName = d + "_" + u
|
||||
// user.Current().Username normally produces something like 'USERDOMAIN\USERNAME'
|
||||
d := os.Getenv("USERDOMAIN")
|
||||
if len(d) != 0 {
|
||||
userName = d + "_" + u
|
||||
} else {
|
||||
userName = u
|
||||
}
|
||||
} else {
|
||||
userName = u
|
||||
current, err := user.Current()
|
||||
if err == nil {
|
||||
userName = current.Username
|
||||
}
|
||||
}
|
||||
} else {
|
||||
current, err := user.Current()
|
||||
if err == nil {
|
||||
userName = current.Username
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return userName
|
||||
}
|
||||
|
||||
// shortHostname returns its argument, truncating at the first period.
|
||||
@@ -98,7 +104,7 @@ func logName(tag string, t time.Time) (name, link string) {
|
||||
name = fmt.Sprintf("%s.%s.%s.log.%s.%04d%02d%02d-%02d%02d%02d.%d",
|
||||
program,
|
||||
host,
|
||||
userName,
|
||||
getUserName(),
|
||||
tag,
|
||||
t.Year(),
|
||||
t.Month(),
|
||||
|
||||
Reference in New Issue
Block a user