mirror of
https://github.com/1Password/onepassword-operator.git
synced 2025-10-23 07:58:04 +00:00
Upgrade Operator SDK to v1.34.1 and update dependencies (#185)
This does the following updates: * Upgrade to Operator SDK v1.34.1. This fixes building multi-arch images from Makefile. Check this MR from operator-framework for details. * Update Go dependencies. This addresses Dependabot alert ["Golang protojson.Unmarshal function infinite loop when unmarshaling certain forms of invalid JSON"](https://github.com/1Password/onepassword-operator/security/dependabot/13). * Update versions of the GitHub Actions used in the pipelines. * Update Kubernetes related tools (such as controller-tools version, and operator-sdk for ci pipelines) By updating dependencies, the pipelines no longer fail due to a panic error when running `make test`.
This commit is contained in:
81
vendor/go.uber.org/zap/logger.go
generated
vendored
81
vendor/go.uber.org/zap/logger.go
generated
vendored
@@ -27,6 +27,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"go.uber.org/zap/internal/bufferpool"
|
||||
"go.uber.org/zap/internal/stacktrace"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
||||
@@ -42,6 +43,7 @@ type Logger struct {
|
||||
|
||||
development bool
|
||||
addCaller bool
|
||||
onPanic zapcore.CheckWriteHook // default is WriteThenPanic
|
||||
onFatal zapcore.CheckWriteHook // default is WriteThenFatal
|
||||
|
||||
name string
|
||||
@@ -173,7 +175,8 @@ func (log *Logger) WithOptions(opts ...Option) *Logger {
|
||||
}
|
||||
|
||||
// With creates a child logger and adds structured context to it. Fields added
|
||||
// to the child don't affect the parent, and vice versa.
|
||||
// to the child don't affect the parent, and vice versa. Any fields that
|
||||
// require evaluation (such as Objects) are evaluated upon invocation of With.
|
||||
func (log *Logger) With(fields ...Field) *Logger {
|
||||
if len(fields) == 0 {
|
||||
return log
|
||||
@@ -183,6 +186,28 @@ func (log *Logger) With(fields ...Field) *Logger {
|
||||
return l
|
||||
}
|
||||
|
||||
// WithLazy creates a child logger and adds structured context to it lazily.
|
||||
//
|
||||
// The fields are evaluated only if the logger is further chained with [With]
|
||||
// or is written to with any of the log level methods.
|
||||
// Until that occurs, the logger may retain references to objects inside the fields,
|
||||
// and logging will reflect the state of an object at the time of logging,
|
||||
// not the time of WithLazy().
|
||||
//
|
||||
// WithLazy provides a worthwhile performance optimization for contextual loggers
|
||||
// when the likelihood of using the child logger is low,
|
||||
// such as error paths and rarely taken branches.
|
||||
//
|
||||
// Similar to [With], fields added to the child don't affect the parent, and vice versa.
|
||||
func (log *Logger) WithLazy(fields ...Field) *Logger {
|
||||
if len(fields) == 0 {
|
||||
return log
|
||||
}
|
||||
return log.WithOptions(WrapCore(func(core zapcore.Core) zapcore.Core {
|
||||
return zapcore.NewLazyWith(core, fields)
|
||||
}))
|
||||
}
|
||||
|
||||
// Level reports the minimum enabled level for this logger.
|
||||
//
|
||||
// For NopLoggers, this is [zapcore.InvalidLevel].
|
||||
@@ -199,6 +224,8 @@ func (log *Logger) Check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
|
||||
|
||||
// Log logs a message at the specified level. The message includes any fields
|
||||
// passed at the log site, as well as any fields accumulated on the logger.
|
||||
// Any Fields that require evaluation (such as Objects) are evaluated upon
|
||||
// invocation of Log.
|
||||
func (log *Logger) Log(lvl zapcore.Level, msg string, fields ...Field) {
|
||||
if ce := log.check(lvl, msg); ce != nil {
|
||||
ce.Write(fields...)
|
||||
@@ -288,8 +315,8 @@ func (log *Logger) Name() string {
|
||||
}
|
||||
|
||||
func (log *Logger) clone() *Logger {
|
||||
copy := *log
|
||||
return ©
|
||||
clone := *log
|
||||
return &clone
|
||||
}
|
||||
|
||||
func (log *Logger) check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
|
||||
@@ -319,27 +346,12 @@ func (log *Logger) check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
|
||||
// Set up any required terminal behavior.
|
||||
switch ent.Level {
|
||||
case zapcore.PanicLevel:
|
||||
ce = ce.After(ent, zapcore.WriteThenPanic)
|
||||
ce = ce.After(ent, terminalHookOverride(zapcore.WriteThenPanic, log.onPanic))
|
||||
case zapcore.FatalLevel:
|
||||
onFatal := log.onFatal
|
||||
// nil or WriteThenNoop will lead to continued execution after
|
||||
// a Fatal log entry, which is unexpected. For example,
|
||||
//
|
||||
// f, err := os.Open(..)
|
||||
// if err != nil {
|
||||
// log.Fatal("cannot open", zap.Error(err))
|
||||
// }
|
||||
// fmt.Println(f.Name())
|
||||
//
|
||||
// The f.Name() will panic if we continue execution after the
|
||||
// log.Fatal.
|
||||
if onFatal == nil || onFatal == zapcore.WriteThenNoop {
|
||||
onFatal = zapcore.WriteThenFatal
|
||||
}
|
||||
ce = ce.After(ent, onFatal)
|
||||
ce = ce.After(ent, terminalHookOverride(zapcore.WriteThenFatal, log.onFatal))
|
||||
case zapcore.DPanicLevel:
|
||||
if log.development {
|
||||
ce = ce.After(ent, zapcore.WriteThenPanic)
|
||||
ce = ce.After(ent, terminalHookOverride(zapcore.WriteThenPanic, log.onPanic))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,17 +372,17 @@ func (log *Logger) check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
|
||||
|
||||
// Adding the caller or stack trace requires capturing the callers of
|
||||
// this function. We'll share information between these two.
|
||||
stackDepth := stacktraceFirst
|
||||
stackDepth := stacktrace.First
|
||||
if addStack {
|
||||
stackDepth = stacktraceFull
|
||||
stackDepth = stacktrace.Full
|
||||
}
|
||||
stack := captureStacktrace(log.callerSkip+callerSkipOffset, stackDepth)
|
||||
stack := stacktrace.Capture(log.callerSkip+callerSkipOffset, stackDepth)
|
||||
defer stack.Free()
|
||||
|
||||
if stack.Count() == 0 {
|
||||
if log.addCaller {
|
||||
fmt.Fprintf(log.errorOutput, "%v Logger.check error: failed to get caller\n", ent.Time.UTC())
|
||||
log.errorOutput.Sync()
|
||||
_ = log.errorOutput.Sync()
|
||||
}
|
||||
return ce
|
||||
}
|
||||
@@ -391,7 +403,7 @@ func (log *Logger) check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
|
||||
buffer := bufferpool.Get()
|
||||
defer buffer.Free()
|
||||
|
||||
stackfmt := newStackFormatter(buffer)
|
||||
stackfmt := stacktrace.NewFormatter(buffer)
|
||||
|
||||
// We've already extracted the first frame, so format that
|
||||
// separately and defer to stackfmt for the rest.
|
||||
@@ -404,3 +416,20 @@ func (log *Logger) check(lvl zapcore.Level, msg string) *zapcore.CheckedEntry {
|
||||
|
||||
return ce
|
||||
}
|
||||
|
||||
func terminalHookOverride(defaultHook, override zapcore.CheckWriteHook) zapcore.CheckWriteHook {
|
||||
// A nil or WriteThenNoop hook will lead to continued execution after
|
||||
// a Panic or Fatal log entry, which is unexpected. For example,
|
||||
//
|
||||
// f, err := os.Open(..)
|
||||
// if err != nil {
|
||||
// log.Fatal("cannot open", zap.Error(err))
|
||||
// }
|
||||
// fmt.Println(f.Name())
|
||||
//
|
||||
// The f.Name() will panic if we continue execution after the log.Fatal.
|
||||
if override == nil || override == zapcore.WriteThenNoop {
|
||||
return defaultHook
|
||||
}
|
||||
return override
|
||||
}
|
||||
|
Reference in New Issue
Block a user