mirror of
https://github.com/kyverno/kyverno.git
synced 2025-04-13 15:57:31 +00:00
* Add metric "kyverno_kube_client_queries_total" Signed-off-by: ShutingZhao <shuting@nirmata.com> * publish metric for missing queries Signed-off-by: ShutingZhao <shuting@nirmata.com> * Refactor the way Kyverno registers QPS metric Signed-off-by: ShutingZhao <shuting@nirmata.com> * Move clientsets to a dedicated folder Signed-off-by: ShutingZhao <shuting@nirmata.com> * Wrap Kyverno client and policyreport client to register client query metric Signed-off-by: ShutingZhao <shuting@nirmata.com> * address linter comments Signed-off-by: ShutingZhao <shuting@nirmata.com> * address linter comments Signed-off-by: ShutingZhao <shuting@nirmata.com> * Switch to use wrapper clients Signed-off-by: ShutingZhao <shuting@nirmata.com> Signed-off-by: ShutingZhao <shuting@nirmata.com> Co-authored-by: Vyankatesh Kudtarkar <vyankateshkd@gmail.com>
83 lines
4.8 KiB
Go
83 lines
4.8 KiB
Go
package v1alpha2
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/kyverno/kyverno/api/kyverno/v1alpha2"
|
|
kyvernov1alpha2 "github.com/kyverno/kyverno/pkg/client/clientset/versioned/typed/kyverno/v1alpha2"
|
|
"github.com/kyverno/kyverno/pkg/clients/wrappers/utils"
|
|
"github.com/kyverno/kyverno/pkg/metrics"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/apimachinery/pkg/types"
|
|
"k8s.io/apimachinery/pkg/watch"
|
|
"k8s.io/client-go/rest"
|
|
)
|
|
|
|
type ClusterReportChangeRequestsGetter interface {
|
|
ClusterReportChangeRequests() ClusterReportChangeRequestControlInterface
|
|
}
|
|
|
|
type ClusterReportChangeRequestControlInterface interface {
|
|
Create(ctx context.Context, clusterReportChangeRequest *v1alpha2.ClusterReportChangeRequest, opts metav1.CreateOptions) (*v1alpha2.ClusterReportChangeRequest, error)
|
|
Update(ctx context.Context, clusterReportChangeRequest *v1alpha2.ClusterReportChangeRequest, opts metav1.UpdateOptions) (*v1alpha2.ClusterReportChangeRequest, error)
|
|
Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
|
|
DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error
|
|
Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1alpha2.ClusterReportChangeRequest, error)
|
|
List(ctx context.Context, opts metav1.ListOptions) (*v1alpha2.ClusterReportChangeRequestList, error)
|
|
Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
|
|
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1alpha2.ClusterReportChangeRequest, err error)
|
|
}
|
|
|
|
type clusterReportChangeRequestControl struct {
|
|
client rest.Interface
|
|
crcrClient kyvernov1alpha2.ClusterReportChangeRequestsGetter
|
|
clientQueryMetric utils.ClientQueryMetric
|
|
}
|
|
|
|
func newClusterReportChangeRequests(c *KyvernoV1alpha2Client) *clusterReportChangeRequestControl {
|
|
return &clusterReportChangeRequestControl{
|
|
client: c.RESTClient(),
|
|
crcrClient: c.kyvernov1alpha2Interface,
|
|
clientQueryMetric: c.clientQueryMetric,
|
|
}
|
|
}
|
|
|
|
func (c *clusterReportChangeRequestControl) Create(ctx context.Context, clusterReportChangeRequest *v1alpha2.ClusterReportChangeRequest, opts metav1.CreateOptions) (*v1alpha2.ClusterReportChangeRequest, error) {
|
|
c.clientQueryMetric.Record(metrics.ClientCreate, metrics.KyvernoClient, "ClusterReportChangeRequest", "")
|
|
return c.crcrClient.ClusterReportChangeRequests().Create(ctx, clusterReportChangeRequest, opts)
|
|
}
|
|
|
|
func (c *clusterReportChangeRequestControl) Update(ctx context.Context, clusterReportChangeRequest *v1alpha2.ClusterReportChangeRequest, opts metav1.UpdateOptions) (*v1alpha2.ClusterReportChangeRequest, error) {
|
|
c.clientQueryMetric.Record(metrics.ClientUpdate, metrics.KyvernoClient, "ClusterReportChangeRequest", "")
|
|
return c.crcrClient.ClusterReportChangeRequests().Update(ctx, clusterReportChangeRequest, opts)
|
|
}
|
|
|
|
func (c *clusterReportChangeRequestControl) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
|
|
c.clientQueryMetric.Record(metrics.ClientDelete, metrics.KyvernoClient, "ClusterReportChangeRequest", "")
|
|
return c.crcrClient.ClusterReportChangeRequests().Delete(ctx, name, opts)
|
|
}
|
|
|
|
func (c *clusterReportChangeRequestControl) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
|
c.clientQueryMetric.Record(metrics.ClientDeleteCollection, metrics.KyvernoClient, "ClusterReportChangeRequest", "")
|
|
return c.crcrClient.ClusterReportChangeRequests().DeleteCollection(ctx, opts, listOpts)
|
|
}
|
|
|
|
func (c *clusterReportChangeRequestControl) Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1alpha2.ClusterReportChangeRequest, error) {
|
|
c.clientQueryMetric.Record(metrics.ClientGet, metrics.KyvernoClient, "ClusterReportChangeRequest", "")
|
|
return c.crcrClient.ClusterReportChangeRequests().Get(ctx, name, opts)
|
|
}
|
|
|
|
func (c *clusterReportChangeRequestControl) List(ctx context.Context, opts metav1.ListOptions) (*v1alpha2.ClusterReportChangeRequestList, error) {
|
|
c.clientQueryMetric.Record(metrics.ClientList, metrics.KyvernoClient, "ClusterReportChangeRequest", "")
|
|
return c.crcrClient.ClusterReportChangeRequests().List(ctx, opts)
|
|
}
|
|
|
|
func (c *clusterReportChangeRequestControl) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
|
|
c.clientQueryMetric.Record(metrics.ClientWatch, metrics.KyvernoClient, "ClusterReportChangeRequest", "")
|
|
return c.crcrClient.ClusterReportChangeRequests().Watch(ctx, opts)
|
|
}
|
|
|
|
func (c *clusterReportChangeRequestControl) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1alpha2.ClusterReportChangeRequest, err error) {
|
|
c.clientQueryMetric.Record(metrics.ClientPatch, metrics.KyvernoClient, "ClusterReportChangeRequest", "")
|
|
return c.crcrClient.ClusterReportChangeRequests().Patch(ctx, name, pt, data, opts, subresources...)
|
|
}
|