Skip to content

Commit

Permalink
e2e: Pass logr.Logger by value
Browse files Browse the repository at this point in the history
This is the recommended way based on logr docs, probably to make it
easier to use, since you don't need to check if the logger is nil, and
zero value of a logger just discards data. This is also the way logr is
used in ramen, so there is no reason to use it differently in the e2e
code.

Part-of: RamenDR#1597
Signed-off-by: Nir Soffer <[email protected]>
  • Loading branch information
nirs committed Oct 31, 2024
1 parent b4f58e9 commit e94f115
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestMain(m *testing.M) {
TimeEncoder: zapcore.ISO8601TimeEncoder,
}))

util.Ctx, err = util.NewContext(&log, util.ConfigFile)
util.Ctx, err = util.NewContext(log, util.ConfigFile)
if err != nil {
log.Error(err, "unable to create new testing context")

Expand Down
2 changes: 1 addition & 1 deletion e2e/util/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type TestConfig struct {
var config = &TestConfig{}

//nolint:cyclop
func ReadConfig(log *logr.Logger, configFile string) error {
func ReadConfig(log logr.Logger, configFile string) error {
viper.SetDefault("ChannelName", defaultChannelName)
viper.SetDefault("ChannelNamespace", defaultChannelNamespace)
viper.SetDefault("GitURL", defaultGitURL)
Expand Down
4 changes: 2 additions & 2 deletions e2e/util/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Cluster struct {
}

type Context struct {
Log *logr.Logger
Log logr.Logger
Hub Cluster
C1 Cluster
C2 Cluster
Expand Down Expand Up @@ -99,7 +99,7 @@ func setupClient(kubeconfigPath string) (*kubernetes.Clientset, client.Client, e
return k8sClientSet, ctrlClient, nil
}

func NewContext(log *logr.Logger, configFile string) (*Context, error) {
func NewContext(log logr.Logger, configFile string) (*Context, error) {
var err error

ctx := new(Context)
Expand Down

0 comments on commit e94f115

Please sign in to comment.