rebase: bump github.com/onsi/gomega from 1.27.6 to 1.27.7

Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.27.6 to 1.27.7.
- [Release notes](https://github.com/onsi/gomega/releases)
- [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md)
- [Commits](https://github.com/onsi/gomega/compare/v1.27.6...v1.27.7)

---
updated-dependencies:
- dependency-name: github.com/onsi/gomega
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot] 2023-05-24 11:17:29 +00:00 committed by mergify[bot]
parent a610bc4d76
commit 4da4b73d7c
10 changed files with 154 additions and 113 deletions

6
go.mod
View File

@ -22,8 +22,8 @@ require (
github.com/kubernetes-csi/csi-lib-utils v0.13.0 github.com/kubernetes-csi/csi-lib-utils v0.13.0
github.com/kubernetes-csi/external-snapshotter/client/v6 v6.2.0 github.com/kubernetes-csi/external-snapshotter/client/v6 v6.2.0
github.com/libopenstorage/secrets v0.0.0-20210908194121-a1d19aa9713a github.com/libopenstorage/secrets v0.0.0-20210908194121-a1d19aa9713a
github.com/onsi/ginkgo/v2 v2.9.2 github.com/onsi/ginkgo/v2 v2.9.5
github.com/onsi/gomega v1.27.6 github.com/onsi/gomega v1.27.7
github.com/pkg/xattr v0.4.9 github.com/pkg/xattr v0.4.9
github.com/prometheus/client_golang v1.15.1 github.com/prometheus/client_golang v1.15.1
github.com/stretchr/testify v1.8.3 github.com/stretchr/testify v1.8.3
@ -72,7 +72,7 @@ require (
github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gemalto/flume v0.13.0 // indirect github.com/gemalto/flume v0.13.0 // indirect
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 // indirect github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 // indirect
github.com/go-logr/logr v1.2.3 // indirect github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect github.com/go-openapi/jsonreference v0.20.0 // indirect

7
go.sum
View File

@ -357,8 +357,9 @@ github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7
github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-logr/zapr v0.1.0/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk= github.com/go-logr/zapr v0.1.0/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk=
@ -899,8 +900,8 @@ github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
github.com/onsi/gomega v1.22.1/go.mod h1:x6n7VNe4hw0vkyYUM4mjIXx3JbLiPaBPNgB7PRQ1tuM= github.com/onsi/gomega v1.22.1/go.mod h1:x6n7VNe4hw0vkyYUM4mjIXx3JbLiPaBPNgB7PRQ1tuM=
github.com/onsi/gomega v1.23.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg= github.com/onsi/gomega v1.23.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg=
github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= github.com/onsi/gomega v1.27.7 h1:fVih9JD6ogIiHUN6ePK7HJidyEDpWGVB5mzM7cWNXoU=
github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= github.com/onsi/gomega v1.27.7/go.mod h1:1p8OOlwo2iUUDsHnOrjE5UKYJ+e3W8eQ3qSlRahPmr4=
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=

View File

@ -6,7 +6,6 @@ linters:
disable-all: true disable-all: true
enable: enable:
- asciicheck - asciicheck
- deadcode
- errcheck - errcheck
- forcetypeassert - forcetypeassert
- gocritic - gocritic
@ -18,10 +17,8 @@ linters:
- misspell - misspell
- revive - revive
- staticcheck - staticcheck
- structcheck
- typecheck - typecheck
- unused - unused
- varcheck
issues: issues:
exclude-use-default: false exclude-use-default: false

View File

@ -20,35 +20,5 @@ package logr
// used whenever the caller is not interested in the logs. Logger instances // used whenever the caller is not interested in the logs. Logger instances
// produced by this function always compare as equal. // produced by this function always compare as equal.
func Discard() Logger { func Discard() Logger {
return Logger{ return New(nil)
level: 0,
sink: discardLogSink{},
}
}
// discardLogSink is a LogSink that discards all messages.
type discardLogSink struct{}
// Verify that it actually implements the interface
var _ LogSink = discardLogSink{}
func (l discardLogSink) Init(RuntimeInfo) {
}
func (l discardLogSink) Enabled(int) bool {
return false
}
func (l discardLogSink) Info(int, string, ...interface{}) {
}
func (l discardLogSink) Error(error, string, ...interface{}) {
}
func (l discardLogSink) WithValues(...interface{}) LogSink {
return l
}
func (l discardLogSink) WithName(string) LogSink {
return l
} }

View File

@ -21,13 +21,13 @@ limitations under the License.
// github.com/go-logr/logr.LogSink with output through an arbitrary // github.com/go-logr/logr.LogSink with output through an arbitrary
// "write" function. See New and NewJSON for details. // "write" function. See New and NewJSON for details.
// //
// Custom LogSinks // # Custom LogSinks
// //
// For users who need more control, a funcr.Formatter can be embedded inside // For users who need more control, a funcr.Formatter can be embedded inside
// your own custom LogSink implementation. This is useful when the LogSink // your own custom LogSink implementation. This is useful when the LogSink
// needs to implement additional methods, for example. // needs to implement additional methods, for example.
// //
// Formatting // # Formatting
// //
// This will respect logr.Marshaler, fmt.Stringer, and error interfaces for // This will respect logr.Marshaler, fmt.Stringer, and error interfaces for
// values which are being logged. When rendering a struct, funcr will use Go's // values which are being logged. When rendering a struct, funcr will use Go's
@ -37,6 +37,7 @@ package funcr
import ( import (
"bytes" "bytes"
"encoding" "encoding"
"encoding/json"
"fmt" "fmt"
"path/filepath" "path/filepath"
"reflect" "reflect"
@ -217,7 +218,7 @@ func newFormatter(opts Options, outfmt outputFormat) Formatter {
prefix: "", prefix: "",
values: nil, values: nil,
depth: 0, depth: 0,
opts: opts, opts: &opts,
} }
return f return f
} }
@ -231,7 +232,7 @@ type Formatter struct {
values []interface{} values []interface{}
valuesStr string valuesStr string
depth int depth int
opts Options opts *Options
} }
// outputFormat indicates which outputFormat to use. // outputFormat indicates which outputFormat to use.
@ -447,6 +448,7 @@ func (f Formatter) prettyWithFlags(value interface{}, flags uint32, depth int) s
if flags&flagRawStruct == 0 { if flags&flagRawStruct == 0 {
buf.WriteByte('{') buf.WriteByte('{')
} }
printComma := false // testing i>0 is not enough because of JSON omitted fields
for i := 0; i < t.NumField(); i++ { for i := 0; i < t.NumField(); i++ {
fld := t.Field(i) fld := t.Field(i)
if fld.PkgPath != "" { if fld.PkgPath != "" {
@ -478,9 +480,10 @@ func (f Formatter) prettyWithFlags(value interface{}, flags uint32, depth int) s
if omitempty && isEmpty(v.Field(i)) { if omitempty && isEmpty(v.Field(i)) {
continue continue
} }
if i > 0 { if printComma {
buf.WriteByte(',') buf.WriteByte(',')
} }
printComma = true // if we got here, we are rendering a field
if fld.Anonymous && fld.Type.Kind() == reflect.Struct && name == "" { if fld.Anonymous && fld.Type.Kind() == reflect.Struct && name == "" {
buf.WriteString(f.prettyWithFlags(v.Field(i).Interface(), flags|flagRawStruct, depth+1)) buf.WriteString(f.prettyWithFlags(v.Field(i).Interface(), flags|flagRawStruct, depth+1))
continue continue
@ -500,6 +503,20 @@ func (f Formatter) prettyWithFlags(value interface{}, flags uint32, depth int) s
} }
return buf.String() return buf.String()
case reflect.Slice, reflect.Array: case reflect.Slice, reflect.Array:
// If this is outputing as JSON make sure this isn't really a json.RawMessage.
// If so just emit "as-is" and don't pretty it as that will just print
// it as [X,Y,Z,...] which isn't terribly useful vs the string form you really want.
if f.outputFormat == outputJSON {
if rm, ok := value.(json.RawMessage); ok {
// If it's empty make sure we emit an empty value as the array style would below.
if len(rm) > 0 {
buf.Write(rm)
} else {
buf.WriteString("null")
}
return buf.String()
}
}
buf.WriteByte('[') buf.WriteByte('[')
for i := 0; i < v.Len(); i++ { for i := 0; i < v.Len(); i++ {
if i > 0 { if i > 0 {

View File

@ -21,7 +21,7 @@ limitations under the License.
// to back that API. Packages in the Go ecosystem can depend on this package, // to back that API. Packages in the Go ecosystem can depend on this package,
// while callers can implement logging with whatever backend is appropriate. // while callers can implement logging with whatever backend is appropriate.
// //
// Usage // # Usage
// //
// Logging is done using a Logger instance. Logger is a concrete type with // Logging is done using a Logger instance. Logger is a concrete type with
// methods, which defers the actual logging to a LogSink interface. The main // methods, which defers the actual logging to a LogSink interface. The main
@ -30,16 +30,20 @@ limitations under the License.
// "structured logging". // "structured logging".
// //
// With Go's standard log package, we might write: // With Go's standard log package, we might write:
// log.Printf("setting target value %s", targetValue) //
// log.Printf("setting target value %s", targetValue)
// //
// With logr's structured logging, we'd write: // With logr's structured logging, we'd write:
// logger.Info("setting target", "value", targetValue) //
// logger.Info("setting target", "value", targetValue)
// //
// Errors are much the same. Instead of: // Errors are much the same. Instead of:
// log.Printf("failed to open the pod bay door for user %s: %v", user, err) //
// log.Printf("failed to open the pod bay door for user %s: %v", user, err)
// //
// We'd write: // We'd write:
// logger.Error(err, "failed to open the pod bay door", "user", user) //
// logger.Error(err, "failed to open the pod bay door", "user", user)
// //
// Info() and Error() are very similar, but they are separate methods so that // Info() and Error() are very similar, but they are separate methods so that
// LogSink implementations can choose to do things like attach additional // LogSink implementations can choose to do things like attach additional
@ -47,7 +51,7 @@ limitations under the License.
// always logged, regardless of the current verbosity. If there is no error // always logged, regardless of the current verbosity. If there is no error
// instance available, passing nil is valid. // instance available, passing nil is valid.
// //
// Verbosity // # Verbosity
// //
// Often we want to log information only when the application in "verbose // Often we want to log information only when the application in "verbose
// mode". To write log lines that are more verbose, Logger has a V() method. // mode". To write log lines that are more verbose, Logger has a V() method.
@ -58,20 +62,22 @@ limitations under the License.
// Error messages do not have a verbosity level and are always logged. // Error messages do not have a verbosity level and are always logged.
// //
// Where we might have written: // Where we might have written:
// if flVerbose >= 2 { //
// log.Printf("an unusual thing happened") // if flVerbose >= 2 {
// } // log.Printf("an unusual thing happened")
// }
// //
// We can write: // We can write:
// logger.V(2).Info("an unusual thing happened")
// //
// Logger Names // logger.V(2).Info("an unusual thing happened")
//
// # Logger Names
// //
// Logger instances can have name strings so that all messages logged through // Logger instances can have name strings so that all messages logged through
// that instance have additional context. For example, you might want to add // that instance have additional context. For example, you might want to add
// a subsystem name: // a subsystem name:
// //
// logger.WithName("compactor").Info("started", "time", time.Now()) // logger.WithName("compactor").Info("started", "time", time.Now())
// //
// The WithName() method returns a new Logger, which can be passed to // The WithName() method returns a new Logger, which can be passed to
// constructors or other functions for further use. Repeated use of WithName() // constructors or other functions for further use. Repeated use of WithName()
@ -82,25 +88,27 @@ limitations under the License.
// joining operation (e.g. whitespace, commas, periods, slashes, brackets, // joining operation (e.g. whitespace, commas, periods, slashes, brackets,
// quotes, etc). // quotes, etc).
// //
// Saved Values // # Saved Values
// //
// Logger instances can store any number of key/value pairs, which will be // Logger instances can store any number of key/value pairs, which will be
// logged alongside all messages logged through that instance. For example, // logged alongside all messages logged through that instance. For example,
// you might want to create a Logger instance per managed object: // you might want to create a Logger instance per managed object:
// //
// With the standard log package, we might write: // With the standard log package, we might write:
// log.Printf("decided to set field foo to value %q for object %s/%s", //
// targetValue, object.Namespace, object.Name) // log.Printf("decided to set field foo to value %q for object %s/%s",
// targetValue, object.Namespace, object.Name)
// //
// With logr we'd write: // With logr we'd write:
// // Elsewhere: set up the logger to log the object name.
// obj.logger = mainLogger.WithValues(
// "name", obj.name, "namespace", obj.namespace)
// //
// // later on... // // Elsewhere: set up the logger to log the object name.
// obj.logger.Info("setting foo", "value", targetValue) // obj.logger = mainLogger.WithValues(
// "name", obj.name, "namespace", obj.namespace)
// //
// Best Practices // // later on...
// obj.logger.Info("setting foo", "value", targetValue)
//
// # Best Practices
// //
// Logger has very few hard rules, with the goal that LogSink implementations // Logger has very few hard rules, with the goal that LogSink implementations
// might have a lot of freedom to differentiate. There are, however, some // might have a lot of freedom to differentiate. There are, however, some
@ -124,15 +132,15 @@ limitations under the License.
// around. For cases where passing a logger is optional, a pointer to Logger // around. For cases where passing a logger is optional, a pointer to Logger
// should be used. // should be used.
// //
// Key Naming Conventions // # Key Naming Conventions
// //
// Keys are not strictly required to conform to any specification or regex, but // Keys are not strictly required to conform to any specification or regex, but
// it is recommended that they: // it is recommended that they:
// * be human-readable and meaningful (not auto-generated or simple ordinals) // - be human-readable and meaningful (not auto-generated or simple ordinals)
// * be constant (not dependent on input data) // - be constant (not dependent on input data)
// * contain only printable characters // - contain only printable characters
// * not contain whitespace or punctuation // - not contain whitespace or punctuation
// * use lower case for simple keys and lowerCamelCase for more complex ones // - use lower case for simple keys and lowerCamelCase for more complex ones
// //
// These guidelines help ensure that log data is processed properly regardless // These guidelines help ensure that log data is processed properly regardless
// of the log implementation. For example, log implementations will try to // of the log implementation. For example, log implementations will try to
@ -141,51 +149,54 @@ limitations under the License.
// While users are generally free to use key names of their choice, it's // While users are generally free to use key names of their choice, it's
// generally best to avoid using the following keys, as they're frequently used // generally best to avoid using the following keys, as they're frequently used
// by implementations: // by implementations:
// * "caller": the calling information (file/line) of a particular log line // - "caller": the calling information (file/line) of a particular log line
// * "error": the underlying error value in the `Error` method // - "error": the underlying error value in the `Error` method
// * "level": the log level // - "level": the log level
// * "logger": the name of the associated logger // - "logger": the name of the associated logger
// * "msg": the log message // - "msg": the log message
// * "stacktrace": the stack trace associated with a particular log line or // - "stacktrace": the stack trace associated with a particular log line or
// error (often from the `Error` message) // error (often from the `Error` message)
// * "ts": the timestamp for a log line // - "ts": the timestamp for a log line
// //
// Implementations are encouraged to make use of these keys to represent the // Implementations are encouraged to make use of these keys to represent the
// above concepts, when necessary (for example, in a pure-JSON output form, it // above concepts, when necessary (for example, in a pure-JSON output form, it
// would be necessary to represent at least message and timestamp as ordinary // would be necessary to represent at least message and timestamp as ordinary
// named values). // named values).
// //
// Break Glass // # Break Glass
// //
// Implementations may choose to give callers access to the underlying // Implementations may choose to give callers access to the underlying
// logging implementation. The recommended pattern for this is: // logging implementation. The recommended pattern for this is:
// // Underlier exposes access to the underlying logging implementation. //
// // Since callers only have a logr.Logger, they have to know which // // Underlier exposes access to the underlying logging implementation.
// // implementation is in use, so this interface is less of an abstraction // // Since callers only have a logr.Logger, they have to know which
// // and more of way to test type conversion. // // implementation is in use, so this interface is less of an abstraction
// type Underlier interface { // // and more of way to test type conversion.
// GetUnderlying() <underlying-type> // type Underlier interface {
// } // GetUnderlying() <underlying-type>
// }
// //
// Logger grants access to the sink to enable type assertions like this: // Logger grants access to the sink to enable type assertions like this:
// func DoSomethingWithImpl(log logr.Logger) { //
// if underlier, ok := log.GetSink()(impl.Underlier) { // func DoSomethingWithImpl(log logr.Logger) {
// implLogger := underlier.GetUnderlying() // if underlier, ok := log.GetSink().(impl.Underlier); ok {
// ... // implLogger := underlier.GetUnderlying()
// } // ...
// } // }
// }
// //
// Custom `With*` functions can be implemented by copying the complete // Custom `With*` functions can be implemented by copying the complete
// Logger struct and replacing the sink in the copy: // Logger struct and replacing the sink in the copy:
// // WithFooBar changes the foobar parameter in the log sink and returns a //
// // new logger with that modified sink. It does nothing for loggers where // // WithFooBar changes the foobar parameter in the log sink and returns a
// // the sink doesn't support that parameter. // // new logger with that modified sink. It does nothing for loggers where
// func WithFoobar(log logr.Logger, foobar int) logr.Logger { // // the sink doesn't support that parameter.
// if foobarLogSink, ok := log.GetSink()(FoobarSink); ok { // func WithFoobar(log logr.Logger, foobar int) logr.Logger {
// log = log.WithSink(foobarLogSink.WithFooBar(foobar)) // if foobarLogSink, ok := log.GetSink().(FoobarSink); ok {
// } // log = log.WithSink(foobarLogSink.WithFooBar(foobar))
// return log // }
// } // return log
// }
// //
// Don't use New to construct a new Logger with a LogSink retrieved from an // Don't use New to construct a new Logger with a LogSink retrieved from an
// existing Logger. Source code attribution might not work correctly and // existing Logger. Source code attribution might not work correctly and
@ -201,11 +212,14 @@ import (
) )
// New returns a new Logger instance. This is primarily used by libraries // New returns a new Logger instance. This is primarily used by libraries
// implementing LogSink, rather than end users. // implementing LogSink, rather than end users. Passing a nil sink will create
// a Logger which discards all log lines.
func New(sink LogSink) Logger { func New(sink LogSink) Logger {
logger := Logger{} logger := Logger{}
logger.setSink(sink) logger.setSink(sink)
sink.Init(runtimeInfo) if sink != nil {
sink.Init(runtimeInfo)
}
return logger return logger
} }
@ -244,7 +258,7 @@ type Logger struct {
// Enabled tests whether this Logger is enabled. For example, commandline // Enabled tests whether this Logger is enabled. For example, commandline
// flags might be used to set the logging verbosity and disable some info logs. // flags might be used to set the logging verbosity and disable some info logs.
func (l Logger) Enabled() bool { func (l Logger) Enabled() bool {
return l.sink.Enabled(l.level) return l.sink != nil && l.sink.Enabled(l.level)
} }
// Info logs a non-error message with the given key/value pairs as context. // Info logs a non-error message with the given key/value pairs as context.
@ -254,6 +268,9 @@ func (l Logger) Enabled() bool {
// information. The key/value pairs must alternate string keys and arbitrary // information. The key/value pairs must alternate string keys and arbitrary
// values. // values.
func (l Logger) Info(msg string, keysAndValues ...interface{}) { func (l Logger) Info(msg string, keysAndValues ...interface{}) {
if l.sink == nil {
return
}
if l.Enabled() { if l.Enabled() {
if withHelper, ok := l.sink.(CallStackHelperLogSink); ok { if withHelper, ok := l.sink.(CallStackHelperLogSink); ok {
withHelper.GetCallStackHelper()() withHelper.GetCallStackHelper()()
@ -273,6 +290,9 @@ func (l Logger) Info(msg string, keysAndValues ...interface{}) {
// triggered this log line, if present. The err parameter is optional // triggered this log line, if present. The err parameter is optional
// and nil may be passed instead of an error instance. // and nil may be passed instead of an error instance.
func (l Logger) Error(err error, msg string, keysAndValues ...interface{}) { func (l Logger) Error(err error, msg string, keysAndValues ...interface{}) {
if l.sink == nil {
return
}
if withHelper, ok := l.sink.(CallStackHelperLogSink); ok { if withHelper, ok := l.sink.(CallStackHelperLogSink); ok {
withHelper.GetCallStackHelper()() withHelper.GetCallStackHelper()()
} }
@ -284,6 +304,9 @@ func (l Logger) Error(err error, msg string, keysAndValues ...interface{}) {
// level means a log message is less important. Negative V-levels are treated // level means a log message is less important. Negative V-levels are treated
// as 0. // as 0.
func (l Logger) V(level int) Logger { func (l Logger) V(level int) Logger {
if l.sink == nil {
return l
}
if level < 0 { if level < 0 {
level = 0 level = 0
} }
@ -294,6 +317,9 @@ func (l Logger) V(level int) Logger {
// WithValues returns a new Logger instance with additional key/value pairs. // WithValues returns a new Logger instance with additional key/value pairs.
// See Info for documentation on how key/value pairs work. // See Info for documentation on how key/value pairs work.
func (l Logger) WithValues(keysAndValues ...interface{}) Logger { func (l Logger) WithValues(keysAndValues ...interface{}) Logger {
if l.sink == nil {
return l
}
l.setSink(l.sink.WithValues(keysAndValues...)) l.setSink(l.sink.WithValues(keysAndValues...))
return l return l
} }
@ -304,6 +330,9 @@ func (l Logger) WithValues(keysAndValues ...interface{}) Logger {
// contain only letters, digits, and hyphens (see the package documentation for // contain only letters, digits, and hyphens (see the package documentation for
// more information). // more information).
func (l Logger) WithName(name string) Logger { func (l Logger) WithName(name string) Logger {
if l.sink == nil {
return l
}
l.setSink(l.sink.WithName(name)) l.setSink(l.sink.WithName(name))
return l return l
} }
@ -324,6 +353,9 @@ func (l Logger) WithName(name string) Logger {
// WithCallDepth(1) because it works with implementions that support the // WithCallDepth(1) because it works with implementions that support the
// CallDepthLogSink and/or CallStackHelperLogSink interfaces. // CallDepthLogSink and/or CallStackHelperLogSink interfaces.
func (l Logger) WithCallDepth(depth int) Logger { func (l Logger) WithCallDepth(depth int) Logger {
if l.sink == nil {
return l
}
if withCallDepth, ok := l.sink.(CallDepthLogSink); ok { if withCallDepth, ok := l.sink.(CallDepthLogSink); ok {
l.setSink(withCallDepth.WithCallDepth(depth)) l.setSink(withCallDepth.WithCallDepth(depth))
} }
@ -345,6 +377,9 @@ func (l Logger) WithCallDepth(depth int) Logger {
// implementation does not support either of these, the original Logger will be // implementation does not support either of these, the original Logger will be
// returned. // returned.
func (l Logger) WithCallStackHelper() (func(), Logger) { func (l Logger) WithCallStackHelper() (func(), Logger) {
if l.sink == nil {
return func() {}, l
}
var helper func() var helper func()
if withCallDepth, ok := l.sink.(CallDepthLogSink); ok { if withCallDepth, ok := l.sink.(CallDepthLogSink); ok {
l.setSink(withCallDepth.WithCallDepth(1)) l.setSink(withCallDepth.WithCallDepth(1))
@ -357,6 +392,11 @@ func (l Logger) WithCallStackHelper() (func(), Logger) {
return helper, l return helper, l
} }
// IsZero returns true if this logger is an uninitialized zero value
func (l Logger) IsZero() bool {
return l.sink == nil
}
// contextKey is how we find Loggers in a context.Context. // contextKey is how we find Loggers in a context.Context.
type contextKey struct{} type contextKey struct{}
@ -442,7 +482,7 @@ type LogSink interface {
WithName(name string) LogSink WithName(name string) LogSink
} }
// CallDepthLogSink represents a Logger that knows how to climb the call stack // CallDepthLogSink represents a LogSink that knows how to climb the call stack
// to identify the original call site and can offset the depth by a specified // to identify the original call site and can offset the depth by a specified
// number of frames. This is useful for users who have helper functions // number of frames. This is useful for users who have helper functions
// between the "real" call site and the actual calls to Logger methods. // between the "real" call site and the actual calls to Logger methods.
@ -467,7 +507,7 @@ type CallDepthLogSink interface {
WithCallDepth(depth int) LogSink WithCallDepth(depth int) LogSink
} }
// CallStackHelperLogSink represents a Logger that knows how to climb // CallStackHelperLogSink represents a LogSink that knows how to climb
// the call stack to identify the original call site and can skip // the call stack to identify the original call site and can skip
// intermediate helper functions if they mark themselves as // intermediate helper functions if they mark themselves as
// helper. Go's testing package uses that approach. // helper. Go's testing package uses that approach.

View File

@ -3,5 +3,5 @@
. .
.idea .idea
gomega.iml gomega.iml
TODO.md TODO
.vscode .vscode

View File

@ -1,3 +1,19 @@
## 1.27.7
### Fixes
- fix: gcustom.MakeMatcher accepts nil as actual value (#666) [57054d5]
### Maintenance
- update gitignore [05c1bc6]
- Bump github.com/onsi/ginkgo/v2 from 2.9.4 to 2.9.5 (#663) [7cadcf6]
- Bump golang.org/x/net from 0.9.0 to 0.10.0 (#662) [b524839]
- Bump github.com/onsi/ginkgo/v2 from 2.9.2 to 2.9.4 (#661) [5f44694]
- Bump commonmarker from 0.23.8 to 0.23.9 in /docs (#657) [05dc99a]
- Bump nokogiri from 1.14.1 to 1.14.3 in /docs (#658) [3a033d1]
- Replace deprecated NewGomegaWithT with NewWithT (#659) [a19238f]
- Bump golang.org/x/net from 0.8.0 to 0.9.0 (#656) [29ed041]
- Bump actions/setup-go from 3 to 4 (#651) [11b2080]
## 1.27.6 ## 1.27.6
### Fixes ### Fixes

View File

@ -22,7 +22,7 @@ import (
"github.com/onsi/gomega/types" "github.com/onsi/gomega/types"
) )
const GOMEGA_VERSION = "1.27.6" const GOMEGA_VERSION = "1.27.7"
const nilGomegaPanic = `You are trying to make an assertion, but haven't registered Gomega's fail handler. const nilGomegaPanic = `You are trying to make an assertion, but haven't registered Gomega's fail handler.
If you're using Ginkgo then you probably forgot to put your assertion in an It(). If you're using Ginkgo then you probably forgot to put your assertion in an It().

6
vendor/modules.txt vendored
View File

@ -194,7 +194,7 @@ github.com/gemalto/kmip-go/ttlv
# github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 # github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
## explicit ## explicit
github.com/ghodss/yaml github.com/ghodss/yaml
# github.com/go-logr/logr v1.2.3 # github.com/go-logr/logr v1.2.4
## explicit; go 1.16 ## explicit; go 1.16
github.com/go-logr/logr github.com/go-logr/logr
github.com/go-logr/logr/funcr github.com/go-logr/logr/funcr
@ -398,7 +398,7 @@ github.com/modern-go/reflect2
# github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 # github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822
## explicit ## explicit
github.com/munnerz/goautoneg github.com/munnerz/goautoneg
# github.com/onsi/ginkgo/v2 v2.9.2 => github.com/onsi/ginkgo/v2 v2.4.0 # github.com/onsi/ginkgo/v2 v2.9.5 => github.com/onsi/ginkgo/v2 v2.4.0
## explicit; go 1.18 ## explicit; go 1.18
github.com/onsi/ginkgo/v2 github.com/onsi/ginkgo/v2
github.com/onsi/ginkgo/v2/config github.com/onsi/ginkgo/v2/config
@ -410,7 +410,7 @@ github.com/onsi/ginkgo/v2/internal/parallel_support
github.com/onsi/ginkgo/v2/internal/testingtproxy github.com/onsi/ginkgo/v2/internal/testingtproxy
github.com/onsi/ginkgo/v2/reporters github.com/onsi/ginkgo/v2/reporters
github.com/onsi/ginkgo/v2/types github.com/onsi/ginkgo/v2/types
# github.com/onsi/gomega v1.27.6 # github.com/onsi/gomega v1.27.7
## explicit; go 1.18 ## explicit; go 1.18
github.com/onsi/gomega github.com/onsi/gomega
github.com/onsi/gomega/format github.com/onsi/gomega/format