From 416a478cf6e4ea2aaecf5108aade563c9fc3fc53 Mon Sep 17 00:00:00 2001 From: xuzhonghu Date: Wed, 18 Jul 2018 17:35:08 +0800 Subject: [PATCH] Add String method to audit.Backend interface --- staging/src/k8s.io/apiserver/pkg/audit/types.go | 3 +++ staging/src/k8s.io/apiserver/pkg/audit/union_test.go | 4 ++++ staging/src/k8s.io/apiserver/plugin/pkg/audit/fake/fake.go | 4 ++++ test/integration/examples/webhook_test.go | 6 ++++++ 4 files changed, 17 insertions(+) diff --git a/staging/src/k8s.io/apiserver/pkg/audit/types.go b/staging/src/k8s.io/apiserver/pkg/audit/types.go index f1b7cef5457..dbf03b0f51c 100644 --- a/staging/src/k8s.io/apiserver/pkg/audit/types.go +++ b/staging/src/k8s.io/apiserver/pkg/audit/types.go @@ -39,4 +39,7 @@ type Backend interface { // events are delivered. It can be assumed that this method is called after // the stopCh channel passed to the Run method has been closed. Shutdown() + + // Returns the backend PluginName. + String() string } diff --git a/staging/src/k8s.io/apiserver/pkg/audit/union_test.go b/staging/src/k8s.io/apiserver/pkg/audit/union_test.go index 45fd6710035..3d474a4743c 100644 --- a/staging/src/k8s.io/apiserver/pkg/audit/union_test.go +++ b/staging/src/k8s.io/apiserver/pkg/audit/union_test.go @@ -40,6 +40,10 @@ func (f *fakeBackend) Shutdown() { // Nothing to do here. } +func (f *fakeBackend) String() string { + return "" +} + func TestUnion(t *testing.T) { backends := []Backend{ new(fakeBackend), diff --git a/staging/src/k8s.io/apiserver/plugin/pkg/audit/fake/fake.go b/staging/src/k8s.io/apiserver/plugin/pkg/audit/fake/fake.go index 4b8fa3c7c21..a886529ec68 100644 --- a/staging/src/k8s.io/apiserver/plugin/pkg/audit/fake/fake.go +++ b/staging/src/k8s.io/apiserver/plugin/pkg/audit/fake/fake.go @@ -44,3 +44,7 @@ func (b *Backend) ProcessEvents(ev ...*auditinternal.Event) { b.OnRequest(ev) } } + +func (b *Backend) String() string { + return "" +} diff --git a/test/integration/examples/webhook_test.go b/test/integration/examples/webhook_test.go index f756d06d4ce..eb4d04fd30b 100644 --- a/test/integration/examples/webhook_test.go +++ b/test/integration/examples/webhook_test.go @@ -111,8 +111,14 @@ type auditSinkFunc func(events ...*auditinternal.Event) func (f auditSinkFunc) ProcessEvents(events ...*auditinternal.Event) { f(events...) } + func (auditSinkFunc) Run(stopCh <-chan struct{}) error { return nil } + func (auditSinkFunc) Shutdown() { } + +func (auditSinkFunc) String() string { + return "" +}