From 2765ab166d97e18e3497a8bf031b52b982a27fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Tue, 22 Nov 2022 12:44:06 +0100 Subject: [PATCH] chore: remove obsolete metrics client code (#5401) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché Signed-off-by: Charles-Edouard Brétéché --- pkg/metrics/client.go | 91 ------------------------------------------- pkg/metrics/log.go | 12 ------ 2 files changed, 103 deletions(-) delete mode 100644 pkg/metrics/log.go diff --git a/pkg/metrics/client.go b/pkg/metrics/client.go index e959be57ca..724c7da925 100644 --- a/pkg/metrics/client.go +++ b/pkg/metrics/client.go @@ -1,14 +1,5 @@ package metrics -import ( - "context" - - controllerutils "github.com/kyverno/kyverno/pkg/utils/controller" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" - "k8s.io/apimachinery/pkg/watch" -) - type Recorder interface { Record(clientQueryOperation ClientQueryOperation) } @@ -40,85 +31,3 @@ func ClusteredClientQueryRecorder(m MetricsConfigManager, kind string, client Cl func (r *clientQueryRecorder) Record(clientQueryOperation ClientQueryOperation) { r.manager.RecordClientQueries(clientQueryOperation, r.client, r.kind, r.ns) } - -type objectClient[T metav1.Object] struct { - recorder Recorder - inner controllerutils.ObjectClient[T] -} - -func (c *objectClient[T]) Create(ctx context.Context, obj T, opts metav1.CreateOptions) (T, error) { - defer c.recorder.Record(ClientCreate) - return c.inner.Create(ctx, obj, opts) -} - -func (c *objectClient[T]) Update(ctx context.Context, obj T, opts metav1.UpdateOptions) (T, error) { - defer c.recorder.Record(ClientUpdate) - return c.inner.Update(ctx, obj, opts) -} - -func (c *objectClient[T]) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - defer c.recorder.Record(ClientDelete) - return c.inner.Delete(ctx, name, opts) -} - -func (c *objectClient[T]) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - defer c.recorder.Record(ClientDeleteCollection) - return c.inner.DeleteCollection(ctx, opts, listOpts) -} - -func (c *objectClient[T]) Get(ctx context.Context, name string, opts metav1.GetOptions) (T, error) { - defer c.recorder.Record(ClientGet) - return c.inner.Get(ctx, name, opts) -} - -func (c *objectClient[T]) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - defer c.recorder.Record(ClientUpdate) - return c.inner.Watch(ctx, opts) -} - -func (c *objectClient[T]) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (T, error) { - defer c.recorder.Record(ClientPatch) - return c.inner.Patch(ctx, name, pt, data, opts, subresources...) -} - -type listClient[T any] struct { - recorder Recorder - inner controllerutils.ListClient[T] -} - -func (c *listClient[T]) List(ctx context.Context, opts metav1.ListOptions) (T, error) { - defer c.recorder.Record(ClientList) - return c.inner.List(ctx, opts) -} - -type statusClient[T metav1.Object] struct { - recorder Recorder - inner controllerutils.StatusClient[T] -} - -func (c *statusClient[T]) UpdateStatus(ctx context.Context, obj T, opts metav1.UpdateOptions) (T, error) { - defer c.recorder.Record(ClientUpdateStatus) - return c.inner.UpdateStatus(ctx, obj, opts) -} - -func ObjectClient[T metav1.Object](recorder Recorder, inner controllerutils.ObjectClient[T], -) controllerutils.ObjectClient[T] { - return &objectClient[T]{ - recorder: recorder, - inner: inner, - } -} - -func StatusClient[T metav1.Object](recorder Recorder, inner controllerutils.StatusClient[T]) controllerutils.StatusClient[T] { - return &statusClient[T]{ - recorder: recorder, - inner: inner, - } -} - -func ListClient[T any](recorder Recorder, inner controllerutils.ListClient[T]) controllerutils.ListClient[T] { - return &listClient[T]{ - recorder: recorder, - inner: inner, - } -} diff --git a/pkg/metrics/log.go b/pkg/metrics/log.go deleted file mode 100644 index 04b5981651..0000000000 --- a/pkg/metrics/log.go +++ /dev/null @@ -1,12 +0,0 @@ -package metrics - -import ( - "github.com/go-logr/logr" - "github.com/kyverno/kyverno/pkg/logging" -) - -var logger = logging.WithName("metrics") - -func Logger() logr.Logger { - return logger -}