mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
refactor: use generics in client wrappers (#4525)
Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com> Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com>
This commit is contained in:
parent
2c86416900
commit
f0622a8a3b
8 changed files with 145 additions and 156 deletions
|
@ -6,7 +6,6 @@ import (
|
|||
kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1"
|
||||
v1 "github.com/kyverno/kyverno/pkg/client/clientset/versioned/typed/kyverno/v1"
|
||||
"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"
|
||||
|
@ -24,47 +23,38 @@ func wrapClusterPolicies(c v1.ClusterPolicyInterface, m utils.ClientQueryMetric)
|
|||
}
|
||||
}
|
||||
|
||||
func (c *clusterPolicies) Create(ctx context.Context, clusterPolicy *kyvernov1.ClusterPolicy, opts metav1.CreateOptions) (*kyvernov1.ClusterPolicy, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientCreate, metrics.KyvernoClient, "ClusterPolicy", "")
|
||||
return c.inner.Create(ctx, clusterPolicy, opts)
|
||||
func (c *clusterPolicies) Create(ctx context.Context, o *kyvernov1.ClusterPolicy, opts metav1.CreateOptions) (*kyvernov1.ClusterPolicy, error) {
|
||||
return utils.Create(ctx, c.clientQueryMetric, "ClusterPolicy", "", o, opts, c.inner.Create)
|
||||
}
|
||||
|
||||
func (c *clusterPolicies) Update(ctx context.Context, clusterPolicy *kyvernov1.ClusterPolicy, opts metav1.UpdateOptions) (*kyvernov1.ClusterPolicy, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientUpdate, metrics.KyvernoClient, "ClusterPolicy", "")
|
||||
return c.inner.Update(ctx, clusterPolicy, opts)
|
||||
func (c *clusterPolicies) Update(ctx context.Context, o *kyvernov1.ClusterPolicy, opts metav1.UpdateOptions) (*kyvernov1.ClusterPolicy, error) {
|
||||
return utils.Update(ctx, c.clientQueryMetric, "ClusterPolicy", "", o, opts, c.inner.Update)
|
||||
}
|
||||
|
||||
func (c *clusterPolicies) UpdateStatus(ctx context.Context, clusterPolicy *kyvernov1.ClusterPolicy, opts metav1.UpdateOptions) (*kyvernov1.ClusterPolicy, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientUpdateStatus, metrics.KyvernoClient, "ClusterPolicy", "")
|
||||
return c.inner.UpdateStatus(ctx, clusterPolicy, opts)
|
||||
func (c *clusterPolicies) UpdateStatus(ctx context.Context, o *kyvernov1.ClusterPolicy, opts metav1.UpdateOptions) (*kyvernov1.ClusterPolicy, error) {
|
||||
return utils.UpdateStatus(ctx, c.clientQueryMetric, "ClusterPolicy", "", o, opts, c.inner.UpdateStatus)
|
||||
}
|
||||
|
||||
func (c *clusterPolicies) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
|
||||
c.clientQueryMetric.Record(metrics.ClientDelete, metrics.KyvernoClient, "ClusterPolicy", "")
|
||||
return c.inner.Delete(ctx, name, opts)
|
||||
return utils.Delete(ctx, c.clientQueryMetric, "ClusterPolicy", "", name, opts, c.inner.Delete)
|
||||
}
|
||||
|
||||
func (c *clusterPolicies) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
c.clientQueryMetric.Record(metrics.ClientDeleteCollection, metrics.KyvernoClient, "ClusterPolicy", "")
|
||||
return c.inner.DeleteCollection(ctx, opts, listOpts)
|
||||
return utils.DeleteCollection(ctx, c.clientQueryMetric, "ClusterPolicy", "", opts, listOpts, c.inner.DeleteCollection)
|
||||
}
|
||||
|
||||
func (c *clusterPolicies) Get(ctx context.Context, name string, opts metav1.GetOptions) (*kyvernov1.ClusterPolicy, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientGet, metrics.KyvernoClient, "ClusterPolicy", "")
|
||||
return c.inner.Get(ctx, name, opts)
|
||||
return utils.Get(ctx, c.clientQueryMetric, "ClusterPolicy", "", name, opts, c.inner.Get)
|
||||
}
|
||||
|
||||
func (c *clusterPolicies) List(ctx context.Context, opts metav1.ListOptions) (*kyvernov1.ClusterPolicyList, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientList, metrics.KyvernoClient, "ClusterPolicy", "")
|
||||
return c.inner.List(ctx, opts)
|
||||
return utils.List(ctx, c.clientQueryMetric, "ClusterPolicy", "", opts, c.inner.List)
|
||||
}
|
||||
|
||||
func (c *clusterPolicies) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientWatch, metrics.KyvernoClient, "ClusterPolicy", "")
|
||||
return c.inner.Watch(ctx, opts)
|
||||
return utils.Watch(ctx, c.clientQueryMetric, "ClusterPolicy", "", opts, c.inner.Watch)
|
||||
}
|
||||
|
||||
func (c *clusterPolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *kyvernov1.ClusterPolicy, err error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientPatch, metrics.KyvernoClient, "ClusterPolicy", "")
|
||||
return c.inner.Patch(ctx, name, pt, data, opts, subresources...)
|
||||
func (c *clusterPolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*kyvernov1.ClusterPolicy, error) {
|
||||
return utils.Patch(ctx, c.clientQueryMetric, "ClusterPolicy", "", name, pt, data, opts, c.inner.Patch, subresources...)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1"
|
||||
v1 "github.com/kyverno/kyverno/pkg/client/clientset/versioned/typed/kyverno/v1"
|
||||
"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"
|
||||
|
@ -26,47 +25,38 @@ func wrapPolicies(c v1.PolicyInterface, m utils.ClientQueryMetric, namespace str
|
|||
}
|
||||
}
|
||||
|
||||
func (c *policies) Create(ctx context.Context, policy *kyvernov1.Policy, opts metav1.CreateOptions) (*kyvernov1.Policy, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientCreate, metrics.KyvernoClient, "Policy", c.ns)
|
||||
return c.inner.Create(ctx, policy, opts)
|
||||
func (c *policies) Create(ctx context.Context, o *kyvernov1.Policy, opts metav1.CreateOptions) (*kyvernov1.Policy, error) {
|
||||
return utils.Create(ctx, c.clientQueryMetric, "Policy", c.ns, o, opts, c.inner.Create)
|
||||
}
|
||||
|
||||
func (c *policies) Update(ctx context.Context, policy *kyvernov1.Policy, opts metav1.UpdateOptions) (*kyvernov1.Policy, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientUpdate, metrics.KyvernoClient, "Policy", c.ns)
|
||||
return c.inner.Update(ctx, policy, opts)
|
||||
func (c *policies) Update(ctx context.Context, o *kyvernov1.Policy, opts metav1.UpdateOptions) (*kyvernov1.Policy, error) {
|
||||
return utils.Update(ctx, c.clientQueryMetric, "Policy", c.ns, o, opts, c.inner.Update)
|
||||
}
|
||||
|
||||
func (c *policies) UpdateStatus(ctx context.Context, policy *kyvernov1.Policy, opts metav1.UpdateOptions) (*kyvernov1.Policy, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientUpdateStatus, metrics.KyvernoClient, "Policy", c.ns)
|
||||
return c.inner.UpdateStatus(ctx, policy, opts)
|
||||
func (c *policies) UpdateStatus(ctx context.Context, o *kyvernov1.Policy, opts metav1.UpdateOptions) (*kyvernov1.Policy, error) {
|
||||
return utils.UpdateStatus(ctx, c.clientQueryMetric, "Policy", c.ns, o, opts, c.inner.UpdateStatus)
|
||||
}
|
||||
|
||||
func (c *policies) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
|
||||
c.clientQueryMetric.Record(metrics.ClientDelete, metrics.KyvernoClient, "Policy", c.ns)
|
||||
return c.inner.Delete(ctx, name, opts)
|
||||
return utils.Delete(ctx, c.clientQueryMetric, "Policy", c.ns, name, opts, c.inner.Delete)
|
||||
}
|
||||
|
||||
func (c *policies) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
c.clientQueryMetric.Record(metrics.ClientDeleteCollection, metrics.KyvernoClient, "Policy", c.ns)
|
||||
return c.inner.DeleteCollection(ctx, opts, listOpts)
|
||||
return utils.DeleteCollection(ctx, c.clientQueryMetric, "Policy", c.ns, opts, listOpts, c.inner.DeleteCollection)
|
||||
}
|
||||
|
||||
func (c *policies) Get(ctx context.Context, name string, opts metav1.GetOptions) (*kyvernov1.Policy, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientGet, metrics.KyvernoClient, "Policy", c.ns)
|
||||
return c.inner.Get(ctx, name, opts)
|
||||
return utils.Get(ctx, c.clientQueryMetric, "Policy", c.ns, name, opts, c.inner.Get)
|
||||
}
|
||||
|
||||
func (c *policies) List(ctx context.Context, opts metav1.ListOptions) (*kyvernov1.PolicyList, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientList, metrics.KyvernoClient, "Policy", c.ns)
|
||||
return c.inner.List(ctx, opts)
|
||||
return utils.List(ctx, c.clientQueryMetric, "Policy", c.ns, opts, c.inner.List)
|
||||
}
|
||||
|
||||
func (c *policies) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientWatch, metrics.KyvernoClient, "Policy", c.ns)
|
||||
return c.inner.Watch(ctx, opts)
|
||||
return utils.Watch(ctx, c.clientQueryMetric, "Policy", c.ns, opts, c.inner.Watch)
|
||||
}
|
||||
|
||||
func (c *policies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *kyvernov1.Policy, err error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientPatch, metrics.KyvernoClient, "Policy", c.ns)
|
||||
return c.inner.Patch(ctx, name, pt, data, opts, subresources...)
|
||||
func (c *policies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*kyvernov1.Policy, error) {
|
||||
return utils.Patch(ctx, c.clientQueryMetric, "Policy", c.ns, name, pt, data, opts, c.inner.Patch, subresources...)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
kyvernov1alpha2 "github.com/kyverno/kyverno/api/kyverno/v1alpha2"
|
||||
"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"
|
||||
|
@ -24,42 +23,34 @@ func wrapClusterReportChangeRequests(c v1alpha2.ClusterReportChangeRequestInterf
|
|||
}
|
||||
}
|
||||
|
||||
func (c *clusterReportChangeRequest) Create(ctx context.Context, clusterReportChangeRequest *kyvernov1alpha2.ClusterReportChangeRequest, opts metav1.CreateOptions) (*kyvernov1alpha2.ClusterReportChangeRequest, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientCreate, metrics.KyvernoClient, "ClusterReportChangeRequest", "")
|
||||
return c.inner.Create(ctx, clusterReportChangeRequest, opts)
|
||||
func (c *clusterReportChangeRequest) Create(ctx context.Context, o *kyvernov1alpha2.ClusterReportChangeRequest, opts metav1.CreateOptions) (*kyvernov1alpha2.ClusterReportChangeRequest, error) {
|
||||
return utils.Create(ctx, c.clientQueryMetric, "ClusterReportChangeRequest", "", o, opts, c.inner.Create)
|
||||
}
|
||||
|
||||
func (c *clusterReportChangeRequest) Update(ctx context.Context, clusterReportChangeRequest *kyvernov1alpha2.ClusterReportChangeRequest, opts metav1.UpdateOptions) (*kyvernov1alpha2.ClusterReportChangeRequest, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientUpdate, metrics.KyvernoClient, "ClusterReportChangeRequest", "")
|
||||
return c.inner.Update(ctx, clusterReportChangeRequest, opts)
|
||||
func (c *clusterReportChangeRequest) Update(ctx context.Context, o *kyvernov1alpha2.ClusterReportChangeRequest, opts metav1.UpdateOptions) (*kyvernov1alpha2.ClusterReportChangeRequest, error) {
|
||||
return utils.Update(ctx, c.clientQueryMetric, "ClusterReportChangeRequest", "", o, opts, c.inner.Update)
|
||||
}
|
||||
|
||||
func (c *clusterReportChangeRequest) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
|
||||
c.clientQueryMetric.Record(metrics.ClientDelete, metrics.KyvernoClient, "ClusterReportChangeRequest", "")
|
||||
return c.inner.Delete(ctx, name, opts)
|
||||
return utils.Delete(ctx, c.clientQueryMetric, "ClusterReportChangeRequest", "", name, opts, c.inner.Delete)
|
||||
}
|
||||
|
||||
func (c *clusterReportChangeRequest) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
c.clientQueryMetric.Record(metrics.ClientDeleteCollection, metrics.KyvernoClient, "ClusterReportChangeRequest", "")
|
||||
return c.inner.DeleteCollection(ctx, opts, listOpts)
|
||||
return utils.DeleteCollection(ctx, c.clientQueryMetric, "ClusterReportChangeRequest", "", opts, listOpts, c.inner.DeleteCollection)
|
||||
}
|
||||
|
||||
func (c *clusterReportChangeRequest) Get(ctx context.Context, name string, opts metav1.GetOptions) (*kyvernov1alpha2.ClusterReportChangeRequest, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientGet, metrics.KyvernoClient, "ClusterReportChangeRequest", "")
|
||||
return c.inner.Get(ctx, name, opts)
|
||||
return utils.Get(ctx, c.clientQueryMetric, "ClusterReportChangeRequest", "", name, opts, c.inner.Get)
|
||||
}
|
||||
|
||||
func (c *clusterReportChangeRequest) List(ctx context.Context, opts metav1.ListOptions) (*kyvernov1alpha2.ClusterReportChangeRequestList, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientList, metrics.KyvernoClient, "ClusterReportChangeRequest", "")
|
||||
return c.inner.List(ctx, opts)
|
||||
return utils.List(ctx, c.clientQueryMetric, "ClusterReportChangeRequest", "", opts, c.inner.List)
|
||||
}
|
||||
|
||||
func (c *clusterReportChangeRequest) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientWatch, metrics.KyvernoClient, "ClusterReportChangeRequest", "")
|
||||
return c.inner.Watch(ctx, opts)
|
||||
return utils.Watch(ctx, c.clientQueryMetric, "ClusterReportChangeRequest", "", opts, c.inner.Watch)
|
||||
}
|
||||
|
||||
func (c *clusterReportChangeRequest) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *kyvernov1alpha2.ClusterReportChangeRequest, err error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientPatch, metrics.KyvernoClient, "ClusterReportChangeRequest", "")
|
||||
return c.inner.Patch(ctx, name, pt, data, opts, subresources...)
|
||||
func (c *clusterReportChangeRequest) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*kyvernov1alpha2.ClusterReportChangeRequest, error) {
|
||||
return utils.Patch(ctx, c.clientQueryMetric, "ClusterReportChangeRequest", "", name, pt, data, opts, c.inner.Patch, subresources...)
|
||||
}
|
||||
|
|
|
@ -6,62 +6,53 @@ import (
|
|||
kyvernov1alpha2 "github.com/kyverno/kyverno/api/kyverno/v1alpha2"
|
||||
"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"
|
||||
)
|
||||
|
||||
type reportChangeRequestControl struct {
|
||||
type reportChangeRequest struct {
|
||||
inner v1alpha2.ReportChangeRequestInterface
|
||||
clientQueryMetric utils.ClientQueryMetric
|
||||
ns string
|
||||
}
|
||||
|
||||
func wrapReportChangeRequests(c v1alpha2.ReportChangeRequestInterface, m utils.ClientQueryMetric, namespace string) v1alpha2.ReportChangeRequestInterface {
|
||||
return &reportChangeRequestControl{
|
||||
return &reportChangeRequest{
|
||||
inner: c,
|
||||
clientQueryMetric: m,
|
||||
ns: namespace,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *reportChangeRequestControl) Create(ctx context.Context, reportChangeRequest *kyvernov1alpha2.ReportChangeRequest, opts metav1.CreateOptions) (*kyvernov1alpha2.ReportChangeRequest, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientCreate, metrics.KyvernoClient, "ReportChangeRequest", c.ns)
|
||||
return c.inner.Create(ctx, reportChangeRequest, opts)
|
||||
func (c *reportChangeRequest) Create(ctx context.Context, o *kyvernov1alpha2.ReportChangeRequest, opts metav1.CreateOptions) (*kyvernov1alpha2.ReportChangeRequest, error) {
|
||||
return utils.Create(ctx, c.clientQueryMetric, "ReportChangeRequest", c.ns, o, opts, c.inner.Create)
|
||||
}
|
||||
|
||||
func (c *reportChangeRequestControl) Update(ctx context.Context, reportChangeRequest *kyvernov1alpha2.ReportChangeRequest, opts metav1.UpdateOptions) (*kyvernov1alpha2.ReportChangeRequest, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientUpdate, metrics.KyvernoClient, "ReportChangeRequest", c.ns)
|
||||
return c.inner.Update(ctx, reportChangeRequest, opts)
|
||||
func (c *reportChangeRequest) Update(ctx context.Context, o *kyvernov1alpha2.ReportChangeRequest, opts metav1.UpdateOptions) (*kyvernov1alpha2.ReportChangeRequest, error) {
|
||||
return utils.Update(ctx, c.clientQueryMetric, "ReportChangeRequest", c.ns, o, opts, c.inner.Update)
|
||||
}
|
||||
|
||||
func (c *reportChangeRequestControl) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
|
||||
c.clientQueryMetric.Record(metrics.ClientDelete, metrics.KyvernoClient, "ReportChangeRequest", c.ns)
|
||||
return c.inner.Delete(ctx, name, opts)
|
||||
func (c *reportChangeRequest) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
|
||||
return utils.Delete(ctx, c.clientQueryMetric, "ReportChangeRequest", c.ns, name, opts, c.inner.Delete)
|
||||
}
|
||||
|
||||
func (c *reportChangeRequestControl) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
c.clientQueryMetric.Record(metrics.ClientDeleteCollection, metrics.KyvernoClient, "ReportChangeRequest", c.ns)
|
||||
return c.inner.DeleteCollection(ctx, opts, listOpts)
|
||||
func (c *reportChangeRequest) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
return utils.DeleteCollection(ctx, c.clientQueryMetric, "ReportChangeRequest", c.ns, opts, listOpts, c.inner.DeleteCollection)
|
||||
}
|
||||
|
||||
func (c *reportChangeRequestControl) Get(ctx context.Context, name string, opts metav1.GetOptions) (*kyvernov1alpha2.ReportChangeRequest, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientGet, metrics.KyvernoClient, "ReportChangeRequest", c.ns)
|
||||
return c.inner.Get(ctx, name, opts)
|
||||
func (c *reportChangeRequest) Get(ctx context.Context, name string, opts metav1.GetOptions) (*kyvernov1alpha2.ReportChangeRequest, error) {
|
||||
return utils.Get(ctx, c.clientQueryMetric, "ReportChangeRequest", c.ns, name, opts, c.inner.Get)
|
||||
}
|
||||
|
||||
func (c *reportChangeRequestControl) List(ctx context.Context, opts metav1.ListOptions) (*kyvernov1alpha2.ReportChangeRequestList, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientList, metrics.KyvernoClient, "ReportChangeRequest", c.ns)
|
||||
return c.inner.List(ctx, opts)
|
||||
func (c *reportChangeRequest) List(ctx context.Context, opts metav1.ListOptions) (*kyvernov1alpha2.ReportChangeRequestList, error) {
|
||||
return utils.List(ctx, c.clientQueryMetric, "ReportChangeRequest", c.ns, opts, c.inner.List)
|
||||
}
|
||||
|
||||
func (c *reportChangeRequestControl) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientWatch, metrics.KyvernoClient, "ReportChangeRequest", c.ns)
|
||||
return c.inner.Watch(ctx, opts)
|
||||
func (c *reportChangeRequest) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
|
||||
return utils.Watch(ctx, c.clientQueryMetric, "ReportChangeRequest", c.ns, opts, c.inner.Watch)
|
||||
}
|
||||
|
||||
func (c *reportChangeRequestControl) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *kyvernov1alpha2.ReportChangeRequest, err error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientPatch, metrics.KyvernoClient, "ReportChangeRequest", c.ns)
|
||||
return c.inner.Patch(ctx, name, pt, data, opts, subresources...)
|
||||
func (c *reportChangeRequest) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*kyvernov1alpha2.ReportChangeRequest, error) {
|
||||
return utils.Patch(ctx, c.clientQueryMetric, "ReportChangeRequest", c.ns, name, pt, data, opts, c.inner.Patch, subresources...)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
kyvernov1beta1 "github.com/kyverno/kyverno/api/kyverno/v1beta1"
|
||||
"github.com/kyverno/kyverno/pkg/client/clientset/versioned/typed/kyverno/v1beta1"
|
||||
"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"
|
||||
|
@ -26,47 +25,38 @@ func wrapUpdateRequests(c v1beta1.UpdateRequestInterface, m utils.ClientQueryMet
|
|||
}
|
||||
}
|
||||
|
||||
func (c *updateRequests) Create(ctx context.Context, updateRequest *kyvernov1beta1.UpdateRequest, opts metav1.CreateOptions) (*kyvernov1beta1.UpdateRequest, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientCreate, metrics.KyvernoClient, "UpdateRequest", c.ns)
|
||||
return c.inner.Create(ctx, updateRequest, opts)
|
||||
func (c *updateRequests) Create(ctx context.Context, o *kyvernov1beta1.UpdateRequest, opts metav1.CreateOptions) (*kyvernov1beta1.UpdateRequest, error) {
|
||||
return utils.Create(ctx, c.clientQueryMetric, "UpdateRequest", c.ns, o, opts, c.inner.Create)
|
||||
}
|
||||
|
||||
func (c *updateRequests) Update(ctx context.Context, updateRequest *kyvernov1beta1.UpdateRequest, opts metav1.UpdateOptions) (*kyvernov1beta1.UpdateRequest, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientUpdate, metrics.KyvernoClient, "UpdateRequest", c.ns)
|
||||
return c.inner.Update(ctx, updateRequest, opts)
|
||||
func (c *updateRequests) Update(ctx context.Context, o *kyvernov1beta1.UpdateRequest, opts metav1.UpdateOptions) (*kyvernov1beta1.UpdateRequest, error) {
|
||||
return utils.Update(ctx, c.clientQueryMetric, "UpdateRequest", c.ns, o, opts, c.inner.Update)
|
||||
}
|
||||
|
||||
func (c *updateRequests) UpdateStatus(ctx context.Context, updateRequest *kyvernov1beta1.UpdateRequest, opts metav1.UpdateOptions) (*kyvernov1beta1.UpdateRequest, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientUpdateStatus, metrics.KyvernoClient, "UpdateRequest", c.ns)
|
||||
return c.inner.UpdateStatus(ctx, updateRequest, opts)
|
||||
func (c *updateRequests) UpdateStatus(ctx context.Context, o *kyvernov1beta1.UpdateRequest, opts metav1.UpdateOptions) (*kyvernov1beta1.UpdateRequest, error) {
|
||||
return utils.UpdateStatus(ctx, c.clientQueryMetric, "UpdateRequest", c.ns, o, opts, c.inner.UpdateStatus)
|
||||
}
|
||||
|
||||
func (c *updateRequests) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
|
||||
c.clientQueryMetric.Record(metrics.ClientDelete, metrics.KyvernoClient, "UpdateRequest", c.ns)
|
||||
return c.inner.Delete(ctx, name, opts)
|
||||
return utils.Delete(ctx, c.clientQueryMetric, "UpdateRequest", c.ns, name, opts, c.inner.Delete)
|
||||
}
|
||||
|
||||
func (c *updateRequests) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
c.clientQueryMetric.Record(metrics.ClientDeleteCollection, metrics.KyvernoClient, "UpdateRequest", c.ns)
|
||||
return c.inner.DeleteCollection(ctx, opts, listOpts)
|
||||
return utils.DeleteCollection(ctx, c.clientQueryMetric, "UpdateRequest", c.ns, opts, listOpts, c.inner.DeleteCollection)
|
||||
}
|
||||
|
||||
func (c *updateRequests) Get(ctx context.Context, name string, opts metav1.GetOptions) (*kyvernov1beta1.UpdateRequest, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientGet, metrics.KyvernoClient, "UpdateRequest", c.ns)
|
||||
return c.inner.Get(ctx, name, opts)
|
||||
return utils.Get(ctx, c.clientQueryMetric, "UpdateRequest", c.ns, name, opts, c.inner.Get)
|
||||
}
|
||||
|
||||
func (c *updateRequests) List(ctx context.Context, opts metav1.ListOptions) (*kyvernov1beta1.UpdateRequestList, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientCreate, metrics.KyvernoClient, "UpdateRequest", c.ns)
|
||||
return c.inner.List(ctx, opts)
|
||||
return utils.List(ctx, c.clientQueryMetric, "UpdateRequest", c.ns, opts, c.inner.List)
|
||||
}
|
||||
|
||||
func (c *updateRequests) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientWatch, metrics.KyvernoClient, "UpdateRequest", c.ns)
|
||||
return c.inner.Watch(ctx, opts)
|
||||
return utils.Watch(ctx, c.clientQueryMetric, "UpdateRequest", c.ns, opts, c.inner.Watch)
|
||||
}
|
||||
|
||||
func (c *updateRequests) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *kyvernov1beta1.UpdateRequest, err error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientPatch, metrics.KyvernoClient, "UpdateRequest", c.ns)
|
||||
return c.inner.Patch(ctx, name, pt, data, opts, subresources...)
|
||||
func (c *updateRequests) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*kyvernov1beta1.UpdateRequest, error) {
|
||||
return utils.Patch(ctx, c.clientQueryMetric, "UpdateRequest", c.ns, name, pt, data, opts, c.inner.Patch, subresources...)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
policyreportv1alpha2 "github.com/kyverno/kyverno/api/policyreport/v1alpha2"
|
||||
"github.com/kyverno/kyverno/pkg/client/clientset/versioned/typed/policyreport/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"
|
||||
|
@ -24,42 +23,34 @@ func wrapClusterPolicyReports(c v1alpha2.ClusterPolicyReportInterface, m utils.C
|
|||
}
|
||||
}
|
||||
|
||||
func (c *clusterPolicyReports) Create(ctx context.Context, clusterPolicyReport *policyreportv1alpha2.ClusterPolicyReport, opts metav1.CreateOptions) (*policyreportv1alpha2.ClusterPolicyReport, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientCreate, metrics.PolicyReportClient, "ClusterPolicyReport", "")
|
||||
return c.inner.Create(ctx, clusterPolicyReport, opts)
|
||||
func (c *clusterPolicyReports) Create(ctx context.Context, o *policyreportv1alpha2.ClusterPolicyReport, opts metav1.CreateOptions) (*policyreportv1alpha2.ClusterPolicyReport, error) {
|
||||
return utils.Create(ctx, c.clientQueryMetric, "ClusterPolicyReport", "", o, opts, c.inner.Create)
|
||||
}
|
||||
|
||||
func (c *clusterPolicyReports) Update(ctx context.Context, clusterPolicyReport *policyreportv1alpha2.ClusterPolicyReport, opts metav1.UpdateOptions) (*policyreportv1alpha2.ClusterPolicyReport, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientUpdate, metrics.PolicyReportClient, "ClusterPolicyReport", "")
|
||||
return c.inner.Update(ctx, clusterPolicyReport, opts)
|
||||
func (c *clusterPolicyReports) Update(ctx context.Context, o *policyreportv1alpha2.ClusterPolicyReport, opts metav1.UpdateOptions) (*policyreportv1alpha2.ClusterPolicyReport, error) {
|
||||
return utils.Update(ctx, c.clientQueryMetric, "ClusterPolicyReport", "", o, opts, c.inner.Update)
|
||||
}
|
||||
|
||||
func (c *clusterPolicyReports) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
|
||||
c.clientQueryMetric.Record(metrics.ClientDelete, metrics.PolicyReportClient, "ClusterPolicyReport", "")
|
||||
return c.inner.Delete(ctx, name, opts)
|
||||
return utils.Delete(ctx, c.clientQueryMetric, "ClusterPolicyReport", "", name, opts, c.inner.Delete)
|
||||
}
|
||||
|
||||
func (c *clusterPolicyReports) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
c.clientQueryMetric.Record(metrics.ClientDeleteCollection, metrics.PolicyReportClient, "ClusterPolicyReport", "")
|
||||
return c.inner.DeleteCollection(ctx, opts, listOpts)
|
||||
return utils.DeleteCollection(ctx, c.clientQueryMetric, "ClusterPolicyReport", "", opts, listOpts, c.inner.DeleteCollection)
|
||||
}
|
||||
|
||||
func (c *clusterPolicyReports) Get(ctx context.Context, name string, opts metav1.GetOptions) (*policyreportv1alpha2.ClusterPolicyReport, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientGet, metrics.PolicyReportClient, "ClusterPolicyReport", "")
|
||||
return c.inner.Get(ctx, name, opts)
|
||||
return utils.Get(ctx, c.clientQueryMetric, "ClusterPolicyReport", "", name, opts, c.inner.Get)
|
||||
}
|
||||
|
||||
func (c *clusterPolicyReports) List(ctx context.Context, opts metav1.ListOptions) (*policyreportv1alpha2.ClusterPolicyReportList, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientList, metrics.PolicyReportClient, "ClusterPolicyReport", "")
|
||||
return c.inner.List(ctx, opts)
|
||||
return utils.List(ctx, c.clientQueryMetric, "ClusterPolicyReport", "", opts, c.inner.List)
|
||||
}
|
||||
|
||||
func (c *clusterPolicyReports) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientWatch, metrics.PolicyReportClient, "ClusterPolicyReport", "")
|
||||
return c.inner.Watch(ctx, opts)
|
||||
return utils.Watch(ctx, c.clientQueryMetric, "ClusterPolicyReport", "", opts, c.inner.Watch)
|
||||
}
|
||||
|
||||
func (c *clusterPolicyReports) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *policyreportv1alpha2.ClusterPolicyReport, err error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientPatch, metrics.PolicyReportClient, "ClusterPolicyReport", "")
|
||||
return c.inner.Patch(ctx, name, pt, data, opts, subresources...)
|
||||
func (c *clusterPolicyReports) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*policyreportv1alpha2.ClusterPolicyReport, error) {
|
||||
return utils.Patch(ctx, c.clientQueryMetric, "ClusterPolicyReport", "", name, pt, data, opts, c.inner.Patch, subresources...)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
policyreportv1alpha2 "github.com/kyverno/kyverno/api/policyreport/v1alpha2"
|
||||
"github.com/kyverno/kyverno/pkg/client/clientset/versioned/typed/policyreport/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"
|
||||
|
@ -26,42 +25,34 @@ func wrapPolicyReports(c v1alpha2.PolicyReportInterface, m utils.ClientQueryMetr
|
|||
}
|
||||
}
|
||||
|
||||
func (c *policyReports) Create(ctx context.Context, policyReport *policyreportv1alpha2.PolicyReport, opts metav1.CreateOptions) (*policyreportv1alpha2.PolicyReport, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientCreate, metrics.PolicyReportClient, "PolicyReport", c.ns)
|
||||
return c.inner.Create(ctx, policyReport, opts)
|
||||
func (c *policyReports) Create(ctx context.Context, o *policyreportv1alpha2.PolicyReport, opts metav1.CreateOptions) (*policyreportv1alpha2.PolicyReport, error) {
|
||||
return utils.Create(ctx, c.clientQueryMetric, "PolicyReport", c.ns, o, opts, c.inner.Create)
|
||||
}
|
||||
|
||||
func (c *policyReports) Update(ctx context.Context, policyReport *policyreportv1alpha2.PolicyReport, opts metav1.UpdateOptions) (*policyreportv1alpha2.PolicyReport, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientUpdate, metrics.PolicyReportClient, "PolicyReport", c.ns)
|
||||
return c.inner.Update(ctx, policyReport, opts)
|
||||
func (c *policyReports) Update(ctx context.Context, o *policyreportv1alpha2.PolicyReport, opts metav1.UpdateOptions) (*policyreportv1alpha2.PolicyReport, error) {
|
||||
return utils.Update(ctx, c.clientQueryMetric, "PolicyReport", c.ns, o, opts, c.inner.Update)
|
||||
}
|
||||
|
||||
func (c *policyReports) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
|
||||
c.clientQueryMetric.Record(metrics.ClientDelete, metrics.PolicyReportClient, "PolicyReport", c.ns)
|
||||
return c.inner.Delete(ctx, name, opts)
|
||||
return utils.Delete(ctx, c.clientQueryMetric, "PolicyReport", c.ns, name, opts, c.inner.Delete)
|
||||
}
|
||||
|
||||
func (c *policyReports) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error {
|
||||
c.clientQueryMetric.Record(metrics.ClientDeleteCollection, metrics.PolicyReportClient, "PolicyReport", c.ns)
|
||||
return c.inner.DeleteCollection(ctx, opts, listOpts)
|
||||
return utils.DeleteCollection(ctx, c.clientQueryMetric, "PolicyReport", c.ns, opts, listOpts, c.inner.DeleteCollection)
|
||||
}
|
||||
|
||||
func (c *policyReports) Get(ctx context.Context, name string, opts metav1.GetOptions) (*policyreportv1alpha2.PolicyReport, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientGet, metrics.PolicyReportClient, "PolicyReport", c.ns)
|
||||
return c.inner.Get(ctx, name, opts)
|
||||
return utils.Get(ctx, c.clientQueryMetric, "PolicyReport", c.ns, name, opts, c.inner.Get)
|
||||
}
|
||||
|
||||
func (c *policyReports) List(ctx context.Context, opts metav1.ListOptions) (*policyreportv1alpha2.PolicyReportList, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientList, metrics.PolicyReportClient, "PolicyReport", c.ns)
|
||||
return c.inner.List(ctx, opts)
|
||||
return utils.List(ctx, c.clientQueryMetric, "PolicyReport", c.ns, opts, c.inner.List)
|
||||
}
|
||||
|
||||
func (c *policyReports) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientWatch, metrics.PolicyReportClient, "PolicyReport", c.ns)
|
||||
return c.inner.Watch(ctx, opts)
|
||||
return utils.Watch(ctx, c.clientQueryMetric, "PolicyReport", c.ns, opts, c.inner.Watch)
|
||||
}
|
||||
|
||||
func (c *policyReports) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *policyreportv1alpha2.PolicyReport, err error) {
|
||||
c.clientQueryMetric.Record(metrics.ClientPatch, metrics.PolicyReportClient, "PolicyReport", c.ns)
|
||||
return c.inner.Patch(ctx, name, pt, data, opts, subresources...)
|
||||
func (c *policyReports) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*policyreportv1alpha2.PolicyReport, error) {
|
||||
return utils.Patch(ctx, c.clientQueryMetric, "PolicyReport", c.ns, name, pt, data, opts, c.inner.Patch, subresources...)
|
||||
}
|
||||
|
|
55
pkg/clients/wrappers/utils/wrapper.go
Normal file
55
pkg/clients/wrappers/utils/wrapper.go
Normal file
|
@ -0,0 +1,55 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/kyverno/kyverno/pkg/metrics"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
)
|
||||
|
||||
func Create[K any](ctx context.Context, m ClientQueryMetric, kind string, ns string, o *K, opts metav1.CreateOptions, inner func(context.Context, *K, metav1.CreateOptions) (*K, error)) (*K, error) {
|
||||
m.Record(metrics.ClientCreate, metrics.KyvernoClient, kind, ns)
|
||||
return inner(ctx, o, opts)
|
||||
}
|
||||
|
||||
func Update[K any](ctx context.Context, m ClientQueryMetric, kind string, ns string, o *K, opts metav1.UpdateOptions, inner func(context.Context, *K, metav1.UpdateOptions) (*K, error)) (*K, error) {
|
||||
m.Record(metrics.ClientUpdate, metrics.KyvernoClient, kind, ns)
|
||||
return inner(ctx, o, opts)
|
||||
}
|
||||
|
||||
func UpdateStatus[K any](ctx context.Context, m ClientQueryMetric, kind string, ns string, o *K, opts metav1.UpdateOptions, inner func(context.Context, *K, metav1.UpdateOptions) (*K, error)) (*K, error) {
|
||||
m.Record(metrics.ClientUpdateStatus, metrics.KyvernoClient, kind, ns)
|
||||
return inner(ctx, o, opts)
|
||||
}
|
||||
|
||||
func Delete(ctx context.Context, m ClientQueryMetric, kind string, ns string, name string, opts metav1.DeleteOptions, inner func(context.Context, string, metav1.DeleteOptions) error) error {
|
||||
m.Record(metrics.ClientDelete, metrics.KyvernoClient, kind, ns)
|
||||
return inner(ctx, name, opts)
|
||||
}
|
||||
|
||||
func DeleteCollection(ctx context.Context, m ClientQueryMetric, kind string, ns string, opts metav1.DeleteOptions, listOpts metav1.ListOptions, inner func(context.Context, metav1.DeleteOptions, metav1.ListOptions) error) error {
|
||||
m.Record(metrics.ClientDeleteCollection, metrics.KyvernoClient, kind, ns)
|
||||
return inner(ctx, opts, listOpts)
|
||||
}
|
||||
|
||||
func Get[K any](ctx context.Context, m ClientQueryMetric, kind string, ns string, name string, opts metav1.GetOptions, inner func(context.Context, string, metav1.GetOptions) (*K, error)) (*K, error) {
|
||||
m.Record(metrics.ClientGet, metrics.KyvernoClient, kind, ns)
|
||||
return inner(ctx, name, opts)
|
||||
}
|
||||
|
||||
func List[K any](ctx context.Context, m ClientQueryMetric, kind string, ns string, opts metav1.ListOptions, inner func(context.Context, metav1.ListOptions) (*K, error)) (*K, error) {
|
||||
m.Record(metrics.ClientList, metrics.KyvernoClient, kind, ns)
|
||||
return inner(ctx, opts)
|
||||
}
|
||||
|
||||
func Watch(ctx context.Context, m ClientQueryMetric, kind string, ns string, opts metav1.ListOptions, inner func(context.Context, metav1.ListOptions) (watch.Interface, error)) (watch.Interface, error) {
|
||||
m.Record(metrics.ClientWatch, metrics.KyvernoClient, kind, ns)
|
||||
return inner(ctx, opts)
|
||||
}
|
||||
|
||||
func Patch[K any](ctx context.Context, m ClientQueryMetric, kind string, ns string, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, inner func(context.Context, string, types.PatchType, []byte, metav1.PatchOptions, ...string) (*K, error), subresources ...string) (*K, error) {
|
||||
m.Record(metrics.ClientPatch, metrics.KyvernoClient, kind, ns)
|
||||
return inner(ctx, name, pt, data, opts, subresources...)
|
||||
}
|
Loading…
Reference in a new issue