Skip to content

Commit 277e4a6

Browse files
committed
Refactor to use new logr.Logger struct
Signed-off-by: Richard Wall <[email protected]>
1 parent a21f27d commit 277e4a6

File tree

4 files changed

+8
-73
lines changed

4 files changed

+8
-73
lines changed

example/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func main() {
112112
Client: cmclient.NewForConfigOrDie(restConfig),
113113
MetadataReader: store,
114114
Clock: clock.RealClock{},
115-
Log: log,
115+
Log: &log,
116116
NodeID: *nodeID,
117117
GeneratePrivateKey: (&keygen{store: store}).generatePrivateKey,
118118
GenerateRequest: generateRequest,

manager/manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ type Options struct {
6565
Clock clock.Clock
6666

6767
// Logger used to write log messages
68-
Log logr.Logger
68+
Log *logr.Logger
6969

7070
// Maximum number of CertificateRequests that should exist for each
7171
// volume mounted into a pod.
@@ -150,7 +150,7 @@ func NewManager(opts Options) (*Manager, error) {
150150
lister: lister,
151151
metadataReader: opts.MetadataReader,
152152
clock: opts.Clock,
153-
log: opts.Log,
153+
log: *opts.Log,
154154

155155
generatePrivateKey: opts.GeneratePrivateKey,
156156
generateRequest: opts.GenerateRequest,

test/log/test_logr.go

Lines changed: 0 additions & 66 deletions
This file was deleted.

test/util/testutil.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727

2828
"github.com/container-storage-interface/spec/lib/go/csi"
2929
"github.com/go-logr/logr"
30+
logrtesting "github.com/go-logr/logr/testing"
3031
cmapi "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
3132
cmmeta "github.com/jetstack/cert-manager/pkg/apis/meta/v1"
3233
cmclient "github.com/jetstack/cert-manager/pkg/client/clientset/versioned"
@@ -41,13 +42,12 @@ import (
4142
"github.com/cert-manager/csi-lib/manager"
4243
"github.com/cert-manager/csi-lib/metadata"
4344
"github.com/cert-manager/csi-lib/storage"
44-
testlogr "github.com/cert-manager/csi-lib/test/log"
4545
)
4646

4747
type DriverOptions struct {
4848
Clock clock.Clock
4949
Store storage.Interface
50-
Log logr.Logger
50+
Log *logr.Logger
5151
Client cmclient.Interface
5252
Mounter mount.Interface
5353

@@ -62,7 +62,8 @@ type DriverOptions struct {
6262

6363
func RunTestDriver(t *testing.T, opts DriverOptions) (DriverOptions, csi.NodeClient, func()) {
6464
if opts.Log == nil {
65-
opts.Log = testlogr.TestLogger{T: t}
65+
logger := logrtesting.NewTestLogger(t)
66+
opts.Log = &logger
6667
}
6768
if opts.Clock == nil {
6869
opts.Clock = &clock.RealClock{}
@@ -118,7 +119,7 @@ func RunTestDriver(t *testing.T, opts DriverOptions) (DriverOptions, csi.NodeCli
118119
WriteKeypair: opts.WriteKeypair,
119120
})
120121

121-
d := driver.NewWithListener(lis, opts.Log, driver.Options{
122+
d := driver.NewWithListener(lis, *opts.Log, driver.Options{
122123
DriverName: "driver-name",
123124
DriverVersion: "v0.0.1",
124125
NodeID: opts.NodeID,

0 commit comments

Comments
 (0)