mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
chore: remove obsolete metrics client code (#5401)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
parent
447360c1f3
commit
2765ab166d
2 changed files with 0 additions and 103 deletions
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
Loading…
Add table
Reference in a new issue