1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-15 17:51:20 +00:00
kyverno/pkg/clients/kube/coordinationv1/client.generated.go
Charles-Edouard Brétéché ecbdaae292
feat: add logging support to instrumented clients (#5438)
* feat: add discovery support in instrumented clients

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix tracing

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* feat: add logging support to instrumented clients

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com>
2022-11-22 15:12:30 +00:00

59 lines
2.4 KiB
Go

package client
import (
"github.com/go-logr/logr"
leases "github.com/kyverno/kyverno/pkg/clients/kube/coordinationv1/leases"
"github.com/kyverno/kyverno/pkg/metrics"
k8s_io_client_go_kubernetes_typed_coordination_v1 "k8s.io/client-go/kubernetes/typed/coordination/v1"
"k8s.io/client-go/rest"
)
func WithMetrics(inner k8s_io_client_go_kubernetes_typed_coordination_v1.CoordinationV1Interface, metrics metrics.MetricsConfigManager, clientType metrics.ClientType) k8s_io_client_go_kubernetes_typed_coordination_v1.CoordinationV1Interface {
return &withMetrics{inner, metrics, clientType}
}
func WithTracing(inner k8s_io_client_go_kubernetes_typed_coordination_v1.CoordinationV1Interface, client string) k8s_io_client_go_kubernetes_typed_coordination_v1.CoordinationV1Interface {
return &withTracing{inner, client}
}
func WithLogging(inner k8s_io_client_go_kubernetes_typed_coordination_v1.CoordinationV1Interface, logger logr.Logger) k8s_io_client_go_kubernetes_typed_coordination_v1.CoordinationV1Interface {
return &withLogging{inner, logger}
}
type withMetrics struct {
inner k8s_io_client_go_kubernetes_typed_coordination_v1.CoordinationV1Interface
metrics metrics.MetricsConfigManager
clientType metrics.ClientType
}
func (c *withMetrics) RESTClient() rest.Interface {
return c.inner.RESTClient()
}
func (c *withMetrics) Leases(namespace string) k8s_io_client_go_kubernetes_typed_coordination_v1.LeaseInterface {
recorder := metrics.NamespacedClientQueryRecorder(c.metrics, namespace, "Lease", c.clientType)
return leases.WithMetrics(c.inner.Leases(namespace), recorder)
}
type withTracing struct {
inner k8s_io_client_go_kubernetes_typed_coordination_v1.CoordinationV1Interface
client string
}
func (c *withTracing) RESTClient() rest.Interface {
return c.inner.RESTClient()
}
func (c *withTracing) Leases(namespace string) k8s_io_client_go_kubernetes_typed_coordination_v1.LeaseInterface {
return leases.WithTracing(c.inner.Leases(namespace), c.client, "Lease")
}
type withLogging struct {
inner k8s_io_client_go_kubernetes_typed_coordination_v1.CoordinationV1Interface
logger logr.Logger
}
func (c *withLogging) RESTClient() rest.Interface {
return c.inner.RESTClient()
}
func (c *withLogging) Leases(namespace string) k8s_io_client_go_kubernetes_typed_coordination_v1.LeaseInterface {
return leases.WithLogging(c.inner.Leases(namespace), c.logger.WithValues("resource", "Leases").WithValues("namespace", namespace))
}