From 7f72f60dd04f5b679cc77e27871640f23f1863c4 Mon Sep 17 00:00:00 2001 From: Alex Leong Date: Thu, 10 Oct 2024 19:18:31 +0000 Subject: [PATCH] Update generated client-go code Signed-off-by: Alex Leong --- .../versioned/fake/clientset_generated.go | 6 +- .../v1beta1/externalworkload.go | 129 ++---------------- .../v1beta1/fake/fake_externalworkload.go | 29 ++-- .../typed/link/v1alpha1/fake/fake_link.go | 29 ++-- .../versioned/typed/link/v1alpha1/link.go | 129 ++---------------- .../policy/v1alpha1/authorizationpolicy.go | 129 ++---------------- .../v1alpha1/fake/fake_authorizationpolicy.go | 29 ++-- .../policy/v1alpha1/fake/fake_httproute.go | 29 ++-- .../fake/fake_meshtlsauthentication.go | 29 ++-- .../fake/fake_networkauthentication.go | 29 ++-- .../typed/policy/v1alpha1/httproute.go | 129 ++---------------- .../policy/v1alpha1/meshtlsauthentication.go | 129 ++---------------- .../policy/v1alpha1/networkauthentication.go | 129 ++---------------- .../policy/v1beta3/fake/fake_httproute.go | 29 ++-- .../typed/policy/v1beta3/httproute.go | 129 ++---------------- .../typed/server/v1beta1/fake/fake_server.go | 29 ++-- .../versioned/typed/server/v1beta1/server.go | 129 ++---------------- .../typed/server/v1beta2/fake/fake_server.go | 29 ++-- .../versioned/typed/server/v1beta2/server.go | 129 ++---------------- .../typed/server/v1beta3/fake/fake_server.go | 29 ++-- .../versioned/typed/server/v1beta3/server.go | 129 ++---------------- .../v1beta1/fake/fake_serverauthorization.go | 29 ++-- .../v1beta1/serverauthorization.go | 129 ++---------------- .../v1alpha2/fake/fake_serviceprofile.go | 29 ++-- .../serviceprofile/v1alpha2/serviceprofile.go | 129 ++---------------- .../informers/externalversions/factory.go | 1 + .../v1beta1/externalworkload.go | 39 +----- .../gen/client/listers/link/v1alpha1/link.go | 39 +----- .../policy/v1alpha1/authorizationpolicy.go | 39 +----- .../listers/policy/v1alpha1/httproute.go | 39 +----- .../policy/v1alpha1/meshtlsauthentication.go | 39 +----- .../policy/v1alpha1/networkauthentication.go | 39 +----- .../listers/policy/v1beta3/httproute.go | 39 +----- .../client/listers/server/v1beta1/server.go | 39 +----- .../client/listers/server/v1beta2/server.go | 39 +----- .../client/listers/server/v1beta3/server.go | 39 +----- .../v1beta1/serverauthorization.go | 39 +----- .../serviceprofile/v1alpha2/serviceprofile.go | 39 +----- 38 files changed, 378 insertions(+), 1993 deletions(-) diff --git a/controller/gen/client/clientset/versioned/fake/clientset_generated.go b/controller/gen/client/clientset/versioned/fake/clientset_generated.go index a0c6afd60d3ad..39db6f01e40fe 100644 --- a/controller/gen/client/clientset/versioned/fake/clientset_generated.go +++ b/controller/gen/client/clientset/versioned/fake/clientset_generated.go @@ -47,8 +47,12 @@ import ( // NewSimpleClientset returns a clientset that will respond with the provided objects. // It's backed by a very simple object tracker that processes creates, updates and deletions as-is, -// without applying any validations and/or defaults. It shouldn't be considered a replacement +// without applying any field management, validations and/or defaults. It shouldn't be considered a replacement // for a real clientset and is mostly useful in simple unit tests. +// +// DEPRECATED: NewClientset replaces this with support for field management, which significantly improves +// server side apply testing. NewClientset is only available when apply configurations are generated (e.g. +// via --with-applyconfig). func NewSimpleClientset(objects ...runtime.Object) *Clientset { o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) for _, obj := range objects { diff --git a/controller/gen/client/clientset/versioned/typed/externalworkload/v1beta1/externalworkload.go b/controller/gen/client/clientset/versioned/typed/externalworkload/v1beta1/externalworkload.go index 74bdfe78d1e65..ebf9823d97fb4 100644 --- a/controller/gen/client/clientset/versioned/typed/externalworkload/v1beta1/externalworkload.go +++ b/controller/gen/client/clientset/versioned/typed/externalworkload/v1beta1/externalworkload.go @@ -20,14 +20,13 @@ package v1beta1 import ( "context" - "time" v1beta1 "github.com/linkerd/linkerd2/controller/gen/apis/externalworkload/v1beta1" scheme "github.com/linkerd/linkerd2/controller/gen/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" + gentype "k8s.io/client-go/gentype" ) // ExternalWorkloadsGetter has a method to return a ExternalWorkloadInterface. @@ -51,128 +50,18 @@ type ExternalWorkloadInterface interface { // externalWorkloads implements ExternalWorkloadInterface type externalWorkloads struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1beta1.ExternalWorkload, *v1beta1.ExternalWorkloadList] } // newExternalWorkloads returns a ExternalWorkloads func newExternalWorkloads(c *ExternalworkloadV1beta1Client, namespace string) *externalWorkloads { return &externalWorkloads{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1beta1.ExternalWorkload, *v1beta1.ExternalWorkloadList]( + "externalworkloads", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1beta1.ExternalWorkload { return &v1beta1.ExternalWorkload{} }, + func() *v1beta1.ExternalWorkloadList { return &v1beta1.ExternalWorkloadList{} }), } } - -// Get takes name of the externalWorkload, and returns the corresponding externalWorkload object, and an error if there is any. -func (c *externalWorkloads) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.ExternalWorkload, err error) { - result = &v1beta1.ExternalWorkload{} - err = c.client.Get(). - Namespace(c.ns). - Resource("externalworkloads"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of ExternalWorkloads that match those selectors. -func (c *externalWorkloads) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ExternalWorkloadList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta1.ExternalWorkloadList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("externalworkloads"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested externalWorkloads. -func (c *externalWorkloads) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("externalworkloads"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a externalWorkload and creates it. Returns the server's representation of the externalWorkload, and an error, if there is any. -func (c *externalWorkloads) Create(ctx context.Context, externalWorkload *v1beta1.ExternalWorkload, opts v1.CreateOptions) (result *v1beta1.ExternalWorkload, err error) { - result = &v1beta1.ExternalWorkload{} - err = c.client.Post(). - Namespace(c.ns). - Resource("externalworkloads"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(externalWorkload). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a externalWorkload and updates it. Returns the server's representation of the externalWorkload, and an error, if there is any. -func (c *externalWorkloads) Update(ctx context.Context, externalWorkload *v1beta1.ExternalWorkload, opts v1.UpdateOptions) (result *v1beta1.ExternalWorkload, err error) { - result = &v1beta1.ExternalWorkload{} - err = c.client.Put(). - Namespace(c.ns). - Resource("externalworkloads"). - Name(externalWorkload.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(externalWorkload). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the externalWorkload and deletes it. Returns an error if one occurs. -func (c *externalWorkloads) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("externalworkloads"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *externalWorkloads) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("externalworkloads"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched externalWorkload. -func (c *externalWorkloads) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ExternalWorkload, err error) { - result = &v1beta1.ExternalWorkload{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("externalworkloads"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/controller/gen/client/clientset/versioned/typed/externalworkload/v1beta1/fake/fake_externalworkload.go b/controller/gen/client/clientset/versioned/typed/externalworkload/v1beta1/fake/fake_externalworkload.go index 7a85624566dc0..fd3403b0e1227 100644 --- a/controller/gen/client/clientset/versioned/typed/externalworkload/v1beta1/fake/fake_externalworkload.go +++ b/controller/gen/client/clientset/versioned/typed/externalworkload/v1beta1/fake/fake_externalworkload.go @@ -41,22 +41,24 @@ var externalworkloadsKind = v1beta1.SchemeGroupVersion.WithKind("ExternalWorkloa // Get takes name of the externalWorkload, and returns the corresponding externalWorkload object, and an error if there is any. func (c *FakeExternalWorkloads) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.ExternalWorkload, err error) { + emptyResult := &v1beta1.ExternalWorkload{} obj, err := c.Fake. - Invokes(testing.NewGetAction(externalworkloadsResource, c.ns, name), &v1beta1.ExternalWorkload{}) + Invokes(testing.NewGetActionWithOptions(externalworkloadsResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.ExternalWorkload), err } // List takes label and field selectors, and returns the list of ExternalWorkloads that match those selectors. func (c *FakeExternalWorkloads) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ExternalWorkloadList, err error) { + emptyResult := &v1beta1.ExternalWorkloadList{} obj, err := c.Fake. - Invokes(testing.NewListAction(externalworkloadsResource, externalworkloadsKind, c.ns, opts), &v1beta1.ExternalWorkloadList{}) + Invokes(testing.NewListActionWithOptions(externalworkloadsResource, externalworkloadsKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeExternalWorkloads) List(ctx context.Context, opts v1.ListOptions) ( // Watch returns a watch.Interface that watches the requested externalWorkloads. func (c *FakeExternalWorkloads) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(externalworkloadsResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(externalworkloadsResource, c.ns, opts)) } // Create takes the representation of a externalWorkload and creates it. Returns the server's representation of the externalWorkload, and an error, if there is any. func (c *FakeExternalWorkloads) Create(ctx context.Context, externalWorkload *v1beta1.ExternalWorkload, opts v1.CreateOptions) (result *v1beta1.ExternalWorkload, err error) { + emptyResult := &v1beta1.ExternalWorkload{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(externalworkloadsResource, c.ns, externalWorkload), &v1beta1.ExternalWorkload{}) + Invokes(testing.NewCreateActionWithOptions(externalworkloadsResource, c.ns, externalWorkload, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.ExternalWorkload), err } // Update takes the representation of a externalWorkload and updates it. Returns the server's representation of the externalWorkload, and an error, if there is any. func (c *FakeExternalWorkloads) Update(ctx context.Context, externalWorkload *v1beta1.ExternalWorkload, opts v1.UpdateOptions) (result *v1beta1.ExternalWorkload, err error) { + emptyResult := &v1beta1.ExternalWorkload{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(externalworkloadsResource, c.ns, externalWorkload), &v1beta1.ExternalWorkload{}) + Invokes(testing.NewUpdateActionWithOptions(externalworkloadsResource, c.ns, externalWorkload, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.ExternalWorkload), err } @@ -111,7 +115,7 @@ func (c *FakeExternalWorkloads) Delete(ctx context.Context, name string, opts v1 // DeleteCollection deletes a collection of objects. func (c *FakeExternalWorkloads) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(externalworkloadsResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(externalworkloadsResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.ExternalWorkloadList{}) return err @@ -119,11 +123,12 @@ func (c *FakeExternalWorkloads) DeleteCollection(ctx context.Context, opts v1.De // Patch applies the patch and returns the patched externalWorkload. func (c *FakeExternalWorkloads) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ExternalWorkload, err error) { + emptyResult := &v1beta1.ExternalWorkload{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(externalworkloadsResource, c.ns, name, pt, data, subresources...), &v1beta1.ExternalWorkload{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(externalworkloadsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.ExternalWorkload), err } diff --git a/controller/gen/client/clientset/versioned/typed/link/v1alpha1/fake/fake_link.go b/controller/gen/client/clientset/versioned/typed/link/v1alpha1/fake/fake_link.go index dd8ea34ba1532..cdfcef7ee2e6d 100644 --- a/controller/gen/client/clientset/versioned/typed/link/v1alpha1/fake/fake_link.go +++ b/controller/gen/client/clientset/versioned/typed/link/v1alpha1/fake/fake_link.go @@ -41,22 +41,24 @@ var linksKind = v1alpha1.SchemeGroupVersion.WithKind("Link") // Get takes name of the link, and returns the corresponding link object, and an error if there is any. func (c *FakeLinks) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Link, err error) { + emptyResult := &v1alpha1.Link{} obj, err := c.Fake. - Invokes(testing.NewGetAction(linksResource, c.ns, name), &v1alpha1.Link{}) + Invokes(testing.NewGetActionWithOptions(linksResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.Link), err } // List takes label and field selectors, and returns the list of Links that match those selectors. func (c *FakeLinks) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.LinkList, err error) { + emptyResult := &v1alpha1.LinkList{} obj, err := c.Fake. - Invokes(testing.NewListAction(linksResource, linksKind, c.ns, opts), &v1alpha1.LinkList{}) + Invokes(testing.NewListActionWithOptions(linksResource, linksKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeLinks) List(ctx context.Context, opts v1.ListOptions) (result *v1al // Watch returns a watch.Interface that watches the requested links. func (c *FakeLinks) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(linksResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(linksResource, c.ns, opts)) } // Create takes the representation of a link and creates it. Returns the server's representation of the link, and an error, if there is any. func (c *FakeLinks) Create(ctx context.Context, link *v1alpha1.Link, opts v1.CreateOptions) (result *v1alpha1.Link, err error) { + emptyResult := &v1alpha1.Link{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(linksResource, c.ns, link), &v1alpha1.Link{}) + Invokes(testing.NewCreateActionWithOptions(linksResource, c.ns, link, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.Link), err } // Update takes the representation of a link and updates it. Returns the server's representation of the link, and an error, if there is any. func (c *FakeLinks) Update(ctx context.Context, link *v1alpha1.Link, opts v1.UpdateOptions) (result *v1alpha1.Link, err error) { + emptyResult := &v1alpha1.Link{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(linksResource, c.ns, link), &v1alpha1.Link{}) + Invokes(testing.NewUpdateActionWithOptions(linksResource, c.ns, link, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.Link), err } @@ -111,7 +115,7 @@ func (c *FakeLinks) Delete(ctx context.Context, name string, opts v1.DeleteOptio // DeleteCollection deletes a collection of objects. func (c *FakeLinks) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(linksResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(linksResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha1.LinkList{}) return err @@ -119,11 +123,12 @@ func (c *FakeLinks) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, // Patch applies the patch and returns the patched link. func (c *FakeLinks) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Link, err error) { + emptyResult := &v1alpha1.Link{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(linksResource, c.ns, name, pt, data, subresources...), &v1alpha1.Link{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(linksResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.Link), err } diff --git a/controller/gen/client/clientset/versioned/typed/link/v1alpha1/link.go b/controller/gen/client/clientset/versioned/typed/link/v1alpha1/link.go index 77ce949cfe6c0..b8348dcb299ca 100644 --- a/controller/gen/client/clientset/versioned/typed/link/v1alpha1/link.go +++ b/controller/gen/client/clientset/versioned/typed/link/v1alpha1/link.go @@ -20,14 +20,13 @@ package v1alpha1 import ( "context" - "time" v1alpha1 "github.com/linkerd/linkerd2/controller/gen/apis/link/v1alpha1" scheme "github.com/linkerd/linkerd2/controller/gen/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" + gentype "k8s.io/client-go/gentype" ) // LinksGetter has a method to return a LinkInterface. @@ -51,128 +50,18 @@ type LinkInterface interface { // links implements LinkInterface type links struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1alpha1.Link, *v1alpha1.LinkList] } // newLinks returns a Links func newLinks(c *LinkV1alpha1Client, namespace string) *links { return &links{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1alpha1.Link, *v1alpha1.LinkList]( + "links", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha1.Link { return &v1alpha1.Link{} }, + func() *v1alpha1.LinkList { return &v1alpha1.LinkList{} }), } } - -// Get takes name of the link, and returns the corresponding link object, and an error if there is any. -func (c *links) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Link, err error) { - result = &v1alpha1.Link{} - err = c.client.Get(). - Namespace(c.ns). - Resource("links"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Links that match those selectors. -func (c *links) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.LinkList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.LinkList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("links"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested links. -func (c *links) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("links"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a link and creates it. Returns the server's representation of the link, and an error, if there is any. -func (c *links) Create(ctx context.Context, link *v1alpha1.Link, opts v1.CreateOptions) (result *v1alpha1.Link, err error) { - result = &v1alpha1.Link{} - err = c.client.Post(). - Namespace(c.ns). - Resource("links"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(link). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a link and updates it. Returns the server's representation of the link, and an error, if there is any. -func (c *links) Update(ctx context.Context, link *v1alpha1.Link, opts v1.UpdateOptions) (result *v1alpha1.Link, err error) { - result = &v1alpha1.Link{} - err = c.client.Put(). - Namespace(c.ns). - Resource("links"). - Name(link.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(link). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the link and deletes it. Returns an error if one occurs. -func (c *links) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("links"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *links) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("links"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched link. -func (c *links) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Link, err error) { - result = &v1alpha1.Link{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("links"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/authorizationpolicy.go b/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/authorizationpolicy.go index 1976592fdf059..aee96f4fbce21 100644 --- a/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/authorizationpolicy.go +++ b/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/authorizationpolicy.go @@ -20,14 +20,13 @@ package v1alpha1 import ( "context" - "time" v1alpha1 "github.com/linkerd/linkerd2/controller/gen/apis/policy/v1alpha1" scheme "github.com/linkerd/linkerd2/controller/gen/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" + gentype "k8s.io/client-go/gentype" ) // AuthorizationPoliciesGetter has a method to return a AuthorizationPolicyInterface. @@ -51,128 +50,18 @@ type AuthorizationPolicyInterface interface { // authorizationPolicies implements AuthorizationPolicyInterface type authorizationPolicies struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1alpha1.AuthorizationPolicy, *v1alpha1.AuthorizationPolicyList] } // newAuthorizationPolicies returns a AuthorizationPolicies func newAuthorizationPolicies(c *PolicyV1alpha1Client, namespace string) *authorizationPolicies { return &authorizationPolicies{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1alpha1.AuthorizationPolicy, *v1alpha1.AuthorizationPolicyList]( + "authorizationpolicies", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha1.AuthorizationPolicy { return &v1alpha1.AuthorizationPolicy{} }, + func() *v1alpha1.AuthorizationPolicyList { return &v1alpha1.AuthorizationPolicyList{} }), } } - -// Get takes name of the authorizationPolicy, and returns the corresponding authorizationPolicy object, and an error if there is any. -func (c *authorizationPolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.AuthorizationPolicy, err error) { - result = &v1alpha1.AuthorizationPolicy{} - err = c.client.Get(). - Namespace(c.ns). - Resource("authorizationpolicies"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of AuthorizationPolicies that match those selectors. -func (c *authorizationPolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.AuthorizationPolicyList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.AuthorizationPolicyList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("authorizationpolicies"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested authorizationPolicies. -func (c *authorizationPolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("authorizationpolicies"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a authorizationPolicy and creates it. Returns the server's representation of the authorizationPolicy, and an error, if there is any. -func (c *authorizationPolicies) Create(ctx context.Context, authorizationPolicy *v1alpha1.AuthorizationPolicy, opts v1.CreateOptions) (result *v1alpha1.AuthorizationPolicy, err error) { - result = &v1alpha1.AuthorizationPolicy{} - err = c.client.Post(). - Namespace(c.ns). - Resource("authorizationpolicies"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(authorizationPolicy). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a authorizationPolicy and updates it. Returns the server's representation of the authorizationPolicy, and an error, if there is any. -func (c *authorizationPolicies) Update(ctx context.Context, authorizationPolicy *v1alpha1.AuthorizationPolicy, opts v1.UpdateOptions) (result *v1alpha1.AuthorizationPolicy, err error) { - result = &v1alpha1.AuthorizationPolicy{} - err = c.client.Put(). - Namespace(c.ns). - Resource("authorizationpolicies"). - Name(authorizationPolicy.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(authorizationPolicy). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the authorizationPolicy and deletes it. Returns an error if one occurs. -func (c *authorizationPolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("authorizationpolicies"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *authorizationPolicies) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("authorizationpolicies"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched authorizationPolicy. -func (c *authorizationPolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.AuthorizationPolicy, err error) { - result = &v1alpha1.AuthorizationPolicy{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("authorizationpolicies"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_authorizationpolicy.go b/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_authorizationpolicy.go index 08a795212b705..daaaae0f4e368 100644 --- a/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_authorizationpolicy.go +++ b/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_authorizationpolicy.go @@ -41,22 +41,24 @@ var authorizationpoliciesKind = v1alpha1.SchemeGroupVersion.WithKind("Authorizat // Get takes name of the authorizationPolicy, and returns the corresponding authorizationPolicy object, and an error if there is any. func (c *FakeAuthorizationPolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.AuthorizationPolicy, err error) { + emptyResult := &v1alpha1.AuthorizationPolicy{} obj, err := c.Fake. - Invokes(testing.NewGetAction(authorizationpoliciesResource, c.ns, name), &v1alpha1.AuthorizationPolicy{}) + Invokes(testing.NewGetActionWithOptions(authorizationpoliciesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.AuthorizationPolicy), err } // List takes label and field selectors, and returns the list of AuthorizationPolicies that match those selectors. func (c *FakeAuthorizationPolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.AuthorizationPolicyList, err error) { + emptyResult := &v1alpha1.AuthorizationPolicyList{} obj, err := c.Fake. - Invokes(testing.NewListAction(authorizationpoliciesResource, authorizationpoliciesKind, c.ns, opts), &v1alpha1.AuthorizationPolicyList{}) + Invokes(testing.NewListActionWithOptions(authorizationpoliciesResource, authorizationpoliciesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeAuthorizationPolicies) List(ctx context.Context, opts v1.ListOption // Watch returns a watch.Interface that watches the requested authorizationPolicies. func (c *FakeAuthorizationPolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(authorizationpoliciesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(authorizationpoliciesResource, c.ns, opts)) } // Create takes the representation of a authorizationPolicy and creates it. Returns the server's representation of the authorizationPolicy, and an error, if there is any. func (c *FakeAuthorizationPolicies) Create(ctx context.Context, authorizationPolicy *v1alpha1.AuthorizationPolicy, opts v1.CreateOptions) (result *v1alpha1.AuthorizationPolicy, err error) { + emptyResult := &v1alpha1.AuthorizationPolicy{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(authorizationpoliciesResource, c.ns, authorizationPolicy), &v1alpha1.AuthorizationPolicy{}) + Invokes(testing.NewCreateActionWithOptions(authorizationpoliciesResource, c.ns, authorizationPolicy, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.AuthorizationPolicy), err } // Update takes the representation of a authorizationPolicy and updates it. Returns the server's representation of the authorizationPolicy, and an error, if there is any. func (c *FakeAuthorizationPolicies) Update(ctx context.Context, authorizationPolicy *v1alpha1.AuthorizationPolicy, opts v1.UpdateOptions) (result *v1alpha1.AuthorizationPolicy, err error) { + emptyResult := &v1alpha1.AuthorizationPolicy{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(authorizationpoliciesResource, c.ns, authorizationPolicy), &v1alpha1.AuthorizationPolicy{}) + Invokes(testing.NewUpdateActionWithOptions(authorizationpoliciesResource, c.ns, authorizationPolicy, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.AuthorizationPolicy), err } @@ -111,7 +115,7 @@ func (c *FakeAuthorizationPolicies) Delete(ctx context.Context, name string, opt // DeleteCollection deletes a collection of objects. func (c *FakeAuthorizationPolicies) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(authorizationpoliciesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(authorizationpoliciesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha1.AuthorizationPolicyList{}) return err @@ -119,11 +123,12 @@ func (c *FakeAuthorizationPolicies) DeleteCollection(ctx context.Context, opts v // Patch applies the patch and returns the patched authorizationPolicy. func (c *FakeAuthorizationPolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.AuthorizationPolicy, err error) { + emptyResult := &v1alpha1.AuthorizationPolicy{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(authorizationpoliciesResource, c.ns, name, pt, data, subresources...), &v1alpha1.AuthorizationPolicy{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(authorizationpoliciesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.AuthorizationPolicy), err } diff --git a/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_httproute.go b/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_httproute.go index d52c528b2ae50..7d1d4e3e0850d 100644 --- a/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_httproute.go +++ b/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_httproute.go @@ -41,22 +41,24 @@ var httproutesKind = v1alpha1.SchemeGroupVersion.WithKind("HTTPRoute") // Get takes name of the hTTPRoute, and returns the corresponding hTTPRoute object, and an error if there is any. func (c *FakeHTTPRoutes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.HTTPRoute, err error) { + emptyResult := &v1alpha1.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewGetAction(httproutesResource, c.ns, name), &v1alpha1.HTTPRoute{}) + Invokes(testing.NewGetActionWithOptions(httproutesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.HTTPRoute), err } // List takes label and field selectors, and returns the list of HTTPRoutes that match those selectors. func (c *FakeHTTPRoutes) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.HTTPRouteList, err error) { + emptyResult := &v1alpha1.HTTPRouteList{} obj, err := c.Fake. - Invokes(testing.NewListAction(httproutesResource, httproutesKind, c.ns, opts), &v1alpha1.HTTPRouteList{}) + Invokes(testing.NewListActionWithOptions(httproutesResource, httproutesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeHTTPRoutes) List(ctx context.Context, opts v1.ListOptions) (result // Watch returns a watch.Interface that watches the requested hTTPRoutes. func (c *FakeHTTPRoutes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(httproutesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(httproutesResource, c.ns, opts)) } // Create takes the representation of a hTTPRoute and creates it. Returns the server's representation of the hTTPRoute, and an error, if there is any. func (c *FakeHTTPRoutes) Create(ctx context.Context, hTTPRoute *v1alpha1.HTTPRoute, opts v1.CreateOptions) (result *v1alpha1.HTTPRoute, err error) { + emptyResult := &v1alpha1.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(httproutesResource, c.ns, hTTPRoute), &v1alpha1.HTTPRoute{}) + Invokes(testing.NewCreateActionWithOptions(httproutesResource, c.ns, hTTPRoute, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.HTTPRoute), err } // Update takes the representation of a hTTPRoute and updates it. Returns the server's representation of the hTTPRoute, and an error, if there is any. func (c *FakeHTTPRoutes) Update(ctx context.Context, hTTPRoute *v1alpha1.HTTPRoute, opts v1.UpdateOptions) (result *v1alpha1.HTTPRoute, err error) { + emptyResult := &v1alpha1.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(httproutesResource, c.ns, hTTPRoute), &v1alpha1.HTTPRoute{}) + Invokes(testing.NewUpdateActionWithOptions(httproutesResource, c.ns, hTTPRoute, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.HTTPRoute), err } @@ -111,7 +115,7 @@ func (c *FakeHTTPRoutes) Delete(ctx context.Context, name string, opts v1.Delete // DeleteCollection deletes a collection of objects. func (c *FakeHTTPRoutes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(httproutesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(httproutesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha1.HTTPRouteList{}) return err @@ -119,11 +123,12 @@ func (c *FakeHTTPRoutes) DeleteCollection(ctx context.Context, opts v1.DeleteOpt // Patch applies the patch and returns the patched hTTPRoute. func (c *FakeHTTPRoutes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.HTTPRoute, err error) { + emptyResult := &v1alpha1.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(httproutesResource, c.ns, name, pt, data, subresources...), &v1alpha1.HTTPRoute{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(httproutesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.HTTPRoute), err } diff --git a/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_meshtlsauthentication.go b/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_meshtlsauthentication.go index 65eb83bdbac3e..1625b06e476b1 100644 --- a/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_meshtlsauthentication.go +++ b/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_meshtlsauthentication.go @@ -41,22 +41,24 @@ var meshtlsauthenticationsKind = v1alpha1.SchemeGroupVersion.WithKind("MeshTLSAu // Get takes name of the meshTLSAuthentication, and returns the corresponding meshTLSAuthentication object, and an error if there is any. func (c *FakeMeshTLSAuthentications) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.MeshTLSAuthentication, err error) { + emptyResult := &v1alpha1.MeshTLSAuthentication{} obj, err := c.Fake. - Invokes(testing.NewGetAction(meshtlsauthenticationsResource, c.ns, name), &v1alpha1.MeshTLSAuthentication{}) + Invokes(testing.NewGetActionWithOptions(meshtlsauthenticationsResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.MeshTLSAuthentication), err } // List takes label and field selectors, and returns the list of MeshTLSAuthentications that match those selectors. func (c *FakeMeshTLSAuthentications) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.MeshTLSAuthenticationList, err error) { + emptyResult := &v1alpha1.MeshTLSAuthenticationList{} obj, err := c.Fake. - Invokes(testing.NewListAction(meshtlsauthenticationsResource, meshtlsauthenticationsKind, c.ns, opts), &v1alpha1.MeshTLSAuthenticationList{}) + Invokes(testing.NewListActionWithOptions(meshtlsauthenticationsResource, meshtlsauthenticationsKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeMeshTLSAuthentications) List(ctx context.Context, opts v1.ListOptio // Watch returns a watch.Interface that watches the requested meshTLSAuthentications. func (c *FakeMeshTLSAuthentications) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(meshtlsauthenticationsResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(meshtlsauthenticationsResource, c.ns, opts)) } // Create takes the representation of a meshTLSAuthentication and creates it. Returns the server's representation of the meshTLSAuthentication, and an error, if there is any. func (c *FakeMeshTLSAuthentications) Create(ctx context.Context, meshTLSAuthentication *v1alpha1.MeshTLSAuthentication, opts v1.CreateOptions) (result *v1alpha1.MeshTLSAuthentication, err error) { + emptyResult := &v1alpha1.MeshTLSAuthentication{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(meshtlsauthenticationsResource, c.ns, meshTLSAuthentication), &v1alpha1.MeshTLSAuthentication{}) + Invokes(testing.NewCreateActionWithOptions(meshtlsauthenticationsResource, c.ns, meshTLSAuthentication, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.MeshTLSAuthentication), err } // Update takes the representation of a meshTLSAuthentication and updates it. Returns the server's representation of the meshTLSAuthentication, and an error, if there is any. func (c *FakeMeshTLSAuthentications) Update(ctx context.Context, meshTLSAuthentication *v1alpha1.MeshTLSAuthentication, opts v1.UpdateOptions) (result *v1alpha1.MeshTLSAuthentication, err error) { + emptyResult := &v1alpha1.MeshTLSAuthentication{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(meshtlsauthenticationsResource, c.ns, meshTLSAuthentication), &v1alpha1.MeshTLSAuthentication{}) + Invokes(testing.NewUpdateActionWithOptions(meshtlsauthenticationsResource, c.ns, meshTLSAuthentication, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.MeshTLSAuthentication), err } @@ -111,7 +115,7 @@ func (c *FakeMeshTLSAuthentications) Delete(ctx context.Context, name string, op // DeleteCollection deletes a collection of objects. func (c *FakeMeshTLSAuthentications) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(meshtlsauthenticationsResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(meshtlsauthenticationsResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha1.MeshTLSAuthenticationList{}) return err @@ -119,11 +123,12 @@ func (c *FakeMeshTLSAuthentications) DeleteCollection(ctx context.Context, opts // Patch applies the patch and returns the patched meshTLSAuthentication. func (c *FakeMeshTLSAuthentications) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.MeshTLSAuthentication, err error) { + emptyResult := &v1alpha1.MeshTLSAuthentication{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(meshtlsauthenticationsResource, c.ns, name, pt, data, subresources...), &v1alpha1.MeshTLSAuthentication{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(meshtlsauthenticationsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.MeshTLSAuthentication), err } diff --git a/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_networkauthentication.go b/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_networkauthentication.go index 5fcde30031306..bda1c37002797 100644 --- a/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_networkauthentication.go +++ b/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_networkauthentication.go @@ -41,22 +41,24 @@ var networkauthenticationsKind = v1alpha1.SchemeGroupVersion.WithKind("NetworkAu // Get takes name of the networkAuthentication, and returns the corresponding networkAuthentication object, and an error if there is any. func (c *FakeNetworkAuthentications) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NetworkAuthentication, err error) { + emptyResult := &v1alpha1.NetworkAuthentication{} obj, err := c.Fake. - Invokes(testing.NewGetAction(networkauthenticationsResource, c.ns, name), &v1alpha1.NetworkAuthentication{}) + Invokes(testing.NewGetActionWithOptions(networkauthenticationsResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.NetworkAuthentication), err } // List takes label and field selectors, and returns the list of NetworkAuthentications that match those selectors. func (c *FakeNetworkAuthentications) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NetworkAuthenticationList, err error) { + emptyResult := &v1alpha1.NetworkAuthenticationList{} obj, err := c.Fake. - Invokes(testing.NewListAction(networkauthenticationsResource, networkauthenticationsKind, c.ns, opts), &v1alpha1.NetworkAuthenticationList{}) + Invokes(testing.NewListActionWithOptions(networkauthenticationsResource, networkauthenticationsKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeNetworkAuthentications) List(ctx context.Context, opts v1.ListOptio // Watch returns a watch.Interface that watches the requested networkAuthentications. func (c *FakeNetworkAuthentications) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(networkauthenticationsResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(networkauthenticationsResource, c.ns, opts)) } // Create takes the representation of a networkAuthentication and creates it. Returns the server's representation of the networkAuthentication, and an error, if there is any. func (c *FakeNetworkAuthentications) Create(ctx context.Context, networkAuthentication *v1alpha1.NetworkAuthentication, opts v1.CreateOptions) (result *v1alpha1.NetworkAuthentication, err error) { + emptyResult := &v1alpha1.NetworkAuthentication{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(networkauthenticationsResource, c.ns, networkAuthentication), &v1alpha1.NetworkAuthentication{}) + Invokes(testing.NewCreateActionWithOptions(networkauthenticationsResource, c.ns, networkAuthentication, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.NetworkAuthentication), err } // Update takes the representation of a networkAuthentication and updates it. Returns the server's representation of the networkAuthentication, and an error, if there is any. func (c *FakeNetworkAuthentications) Update(ctx context.Context, networkAuthentication *v1alpha1.NetworkAuthentication, opts v1.UpdateOptions) (result *v1alpha1.NetworkAuthentication, err error) { + emptyResult := &v1alpha1.NetworkAuthentication{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(networkauthenticationsResource, c.ns, networkAuthentication), &v1alpha1.NetworkAuthentication{}) + Invokes(testing.NewUpdateActionWithOptions(networkauthenticationsResource, c.ns, networkAuthentication, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.NetworkAuthentication), err } @@ -111,7 +115,7 @@ func (c *FakeNetworkAuthentications) Delete(ctx context.Context, name string, op // DeleteCollection deletes a collection of objects. func (c *FakeNetworkAuthentications) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(networkauthenticationsResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(networkauthenticationsResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha1.NetworkAuthenticationList{}) return err @@ -119,11 +123,12 @@ func (c *FakeNetworkAuthentications) DeleteCollection(ctx context.Context, opts // Patch applies the patch and returns the patched networkAuthentication. func (c *FakeNetworkAuthentications) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NetworkAuthentication, err error) { + emptyResult := &v1alpha1.NetworkAuthentication{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(networkauthenticationsResource, c.ns, name, pt, data, subresources...), &v1alpha1.NetworkAuthentication{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(networkauthenticationsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.NetworkAuthentication), err } diff --git a/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/httproute.go b/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/httproute.go index 7ddbbedb47db8..ad6c8655c7640 100644 --- a/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/httproute.go +++ b/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/httproute.go @@ -20,14 +20,13 @@ package v1alpha1 import ( "context" - "time" v1alpha1 "github.com/linkerd/linkerd2/controller/gen/apis/policy/v1alpha1" scheme "github.com/linkerd/linkerd2/controller/gen/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" + gentype "k8s.io/client-go/gentype" ) // HTTPRoutesGetter has a method to return a HTTPRouteInterface. @@ -51,128 +50,18 @@ type HTTPRouteInterface interface { // hTTPRoutes implements HTTPRouteInterface type hTTPRoutes struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1alpha1.HTTPRoute, *v1alpha1.HTTPRouteList] } // newHTTPRoutes returns a HTTPRoutes func newHTTPRoutes(c *PolicyV1alpha1Client, namespace string) *hTTPRoutes { return &hTTPRoutes{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1alpha1.HTTPRoute, *v1alpha1.HTTPRouteList]( + "httproutes", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha1.HTTPRoute { return &v1alpha1.HTTPRoute{} }, + func() *v1alpha1.HTTPRouteList { return &v1alpha1.HTTPRouteList{} }), } } - -// Get takes name of the hTTPRoute, and returns the corresponding hTTPRoute object, and an error if there is any. -func (c *hTTPRoutes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.HTTPRoute, err error) { - result = &v1alpha1.HTTPRoute{} - err = c.client.Get(). - Namespace(c.ns). - Resource("httproutes"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of HTTPRoutes that match those selectors. -func (c *hTTPRoutes) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.HTTPRouteList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.HTTPRouteList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("httproutes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested hTTPRoutes. -func (c *hTTPRoutes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("httproutes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a hTTPRoute and creates it. Returns the server's representation of the hTTPRoute, and an error, if there is any. -func (c *hTTPRoutes) Create(ctx context.Context, hTTPRoute *v1alpha1.HTTPRoute, opts v1.CreateOptions) (result *v1alpha1.HTTPRoute, err error) { - result = &v1alpha1.HTTPRoute{} - err = c.client.Post(). - Namespace(c.ns). - Resource("httproutes"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(hTTPRoute). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a hTTPRoute and updates it. Returns the server's representation of the hTTPRoute, and an error, if there is any. -func (c *hTTPRoutes) Update(ctx context.Context, hTTPRoute *v1alpha1.HTTPRoute, opts v1.UpdateOptions) (result *v1alpha1.HTTPRoute, err error) { - result = &v1alpha1.HTTPRoute{} - err = c.client.Put(). - Namespace(c.ns). - Resource("httproutes"). - Name(hTTPRoute.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(hTTPRoute). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the hTTPRoute and deletes it. Returns an error if one occurs. -func (c *hTTPRoutes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("httproutes"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *hTTPRoutes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("httproutes"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched hTTPRoute. -func (c *hTTPRoutes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.HTTPRoute, err error) { - result = &v1alpha1.HTTPRoute{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("httproutes"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/meshtlsauthentication.go b/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/meshtlsauthentication.go index 3ef852cd88a5f..b69573ce4e465 100644 --- a/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/meshtlsauthentication.go +++ b/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/meshtlsauthentication.go @@ -20,14 +20,13 @@ package v1alpha1 import ( "context" - "time" v1alpha1 "github.com/linkerd/linkerd2/controller/gen/apis/policy/v1alpha1" scheme "github.com/linkerd/linkerd2/controller/gen/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" + gentype "k8s.io/client-go/gentype" ) // MeshTLSAuthenticationsGetter has a method to return a MeshTLSAuthenticationInterface. @@ -51,128 +50,18 @@ type MeshTLSAuthenticationInterface interface { // meshTLSAuthentications implements MeshTLSAuthenticationInterface type meshTLSAuthentications struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1alpha1.MeshTLSAuthentication, *v1alpha1.MeshTLSAuthenticationList] } // newMeshTLSAuthentications returns a MeshTLSAuthentications func newMeshTLSAuthentications(c *PolicyV1alpha1Client, namespace string) *meshTLSAuthentications { return &meshTLSAuthentications{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1alpha1.MeshTLSAuthentication, *v1alpha1.MeshTLSAuthenticationList]( + "meshtlsauthentications", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha1.MeshTLSAuthentication { return &v1alpha1.MeshTLSAuthentication{} }, + func() *v1alpha1.MeshTLSAuthenticationList { return &v1alpha1.MeshTLSAuthenticationList{} }), } } - -// Get takes name of the meshTLSAuthentication, and returns the corresponding meshTLSAuthentication object, and an error if there is any. -func (c *meshTLSAuthentications) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.MeshTLSAuthentication, err error) { - result = &v1alpha1.MeshTLSAuthentication{} - err = c.client.Get(). - Namespace(c.ns). - Resource("meshtlsauthentications"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of MeshTLSAuthentications that match those selectors. -func (c *meshTLSAuthentications) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.MeshTLSAuthenticationList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.MeshTLSAuthenticationList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("meshtlsauthentications"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested meshTLSAuthentications. -func (c *meshTLSAuthentications) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("meshtlsauthentications"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a meshTLSAuthentication and creates it. Returns the server's representation of the meshTLSAuthentication, and an error, if there is any. -func (c *meshTLSAuthentications) Create(ctx context.Context, meshTLSAuthentication *v1alpha1.MeshTLSAuthentication, opts v1.CreateOptions) (result *v1alpha1.MeshTLSAuthentication, err error) { - result = &v1alpha1.MeshTLSAuthentication{} - err = c.client.Post(). - Namespace(c.ns). - Resource("meshtlsauthentications"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(meshTLSAuthentication). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a meshTLSAuthentication and updates it. Returns the server's representation of the meshTLSAuthentication, and an error, if there is any. -func (c *meshTLSAuthentications) Update(ctx context.Context, meshTLSAuthentication *v1alpha1.MeshTLSAuthentication, opts v1.UpdateOptions) (result *v1alpha1.MeshTLSAuthentication, err error) { - result = &v1alpha1.MeshTLSAuthentication{} - err = c.client.Put(). - Namespace(c.ns). - Resource("meshtlsauthentications"). - Name(meshTLSAuthentication.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(meshTLSAuthentication). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the meshTLSAuthentication and deletes it. Returns an error if one occurs. -func (c *meshTLSAuthentications) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("meshtlsauthentications"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *meshTLSAuthentications) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("meshtlsauthentications"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched meshTLSAuthentication. -func (c *meshTLSAuthentications) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.MeshTLSAuthentication, err error) { - result = &v1alpha1.MeshTLSAuthentication{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("meshtlsauthentications"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/networkauthentication.go b/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/networkauthentication.go index efb81d20fc25e..84f5883575619 100644 --- a/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/networkauthentication.go +++ b/controller/gen/client/clientset/versioned/typed/policy/v1alpha1/networkauthentication.go @@ -20,14 +20,13 @@ package v1alpha1 import ( "context" - "time" v1alpha1 "github.com/linkerd/linkerd2/controller/gen/apis/policy/v1alpha1" scheme "github.com/linkerd/linkerd2/controller/gen/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" + gentype "k8s.io/client-go/gentype" ) // NetworkAuthenticationsGetter has a method to return a NetworkAuthenticationInterface. @@ -51,128 +50,18 @@ type NetworkAuthenticationInterface interface { // networkAuthentications implements NetworkAuthenticationInterface type networkAuthentications struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1alpha1.NetworkAuthentication, *v1alpha1.NetworkAuthenticationList] } // newNetworkAuthentications returns a NetworkAuthentications func newNetworkAuthentications(c *PolicyV1alpha1Client, namespace string) *networkAuthentications { return &networkAuthentications{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1alpha1.NetworkAuthentication, *v1alpha1.NetworkAuthenticationList]( + "networkauthentications", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha1.NetworkAuthentication { return &v1alpha1.NetworkAuthentication{} }, + func() *v1alpha1.NetworkAuthenticationList { return &v1alpha1.NetworkAuthenticationList{} }), } } - -// Get takes name of the networkAuthentication, and returns the corresponding networkAuthentication object, and an error if there is any. -func (c *networkAuthentications) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NetworkAuthentication, err error) { - result = &v1alpha1.NetworkAuthentication{} - err = c.client.Get(). - Namespace(c.ns). - Resource("networkauthentications"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of NetworkAuthentications that match those selectors. -func (c *networkAuthentications) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.NetworkAuthenticationList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.NetworkAuthenticationList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("networkauthentications"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested networkAuthentications. -func (c *networkAuthentications) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("networkauthentications"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a networkAuthentication and creates it. Returns the server's representation of the networkAuthentication, and an error, if there is any. -func (c *networkAuthentications) Create(ctx context.Context, networkAuthentication *v1alpha1.NetworkAuthentication, opts v1.CreateOptions) (result *v1alpha1.NetworkAuthentication, err error) { - result = &v1alpha1.NetworkAuthentication{} - err = c.client.Post(). - Namespace(c.ns). - Resource("networkauthentications"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(networkAuthentication). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a networkAuthentication and updates it. Returns the server's representation of the networkAuthentication, and an error, if there is any. -func (c *networkAuthentications) Update(ctx context.Context, networkAuthentication *v1alpha1.NetworkAuthentication, opts v1.UpdateOptions) (result *v1alpha1.NetworkAuthentication, err error) { - result = &v1alpha1.NetworkAuthentication{} - err = c.client.Put(). - Namespace(c.ns). - Resource("networkauthentications"). - Name(networkAuthentication.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(networkAuthentication). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the networkAuthentication and deletes it. Returns an error if one occurs. -func (c *networkAuthentications) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("networkauthentications"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *networkAuthentications) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("networkauthentications"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched networkAuthentication. -func (c *networkAuthentications) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.NetworkAuthentication, err error) { - result = &v1alpha1.NetworkAuthentication{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("networkauthentications"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/controller/gen/client/clientset/versioned/typed/policy/v1beta3/fake/fake_httproute.go b/controller/gen/client/clientset/versioned/typed/policy/v1beta3/fake/fake_httproute.go index 8b77ee43aa68b..8a2d8e541cbff 100644 --- a/controller/gen/client/clientset/versioned/typed/policy/v1beta3/fake/fake_httproute.go +++ b/controller/gen/client/clientset/versioned/typed/policy/v1beta3/fake/fake_httproute.go @@ -41,22 +41,24 @@ var httproutesKind = v1beta3.SchemeGroupVersion.WithKind("HTTPRoute") // Get takes name of the hTTPRoute, and returns the corresponding hTTPRoute object, and an error if there is any. func (c *FakeHTTPRoutes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta3.HTTPRoute, err error) { + emptyResult := &v1beta3.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewGetAction(httproutesResource, c.ns, name), &v1beta3.HTTPRoute{}) + Invokes(testing.NewGetActionWithOptions(httproutesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta3.HTTPRoute), err } // List takes label and field selectors, and returns the list of HTTPRoutes that match those selectors. func (c *FakeHTTPRoutes) List(ctx context.Context, opts v1.ListOptions) (result *v1beta3.HTTPRouteList, err error) { + emptyResult := &v1beta3.HTTPRouteList{} obj, err := c.Fake. - Invokes(testing.NewListAction(httproutesResource, httproutesKind, c.ns, opts), &v1beta3.HTTPRouteList{}) + Invokes(testing.NewListActionWithOptions(httproutesResource, httproutesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeHTTPRoutes) List(ctx context.Context, opts v1.ListOptions) (result // Watch returns a watch.Interface that watches the requested hTTPRoutes. func (c *FakeHTTPRoutes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(httproutesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(httproutesResource, c.ns, opts)) } // Create takes the representation of a hTTPRoute and creates it. Returns the server's representation of the hTTPRoute, and an error, if there is any. func (c *FakeHTTPRoutes) Create(ctx context.Context, hTTPRoute *v1beta3.HTTPRoute, opts v1.CreateOptions) (result *v1beta3.HTTPRoute, err error) { + emptyResult := &v1beta3.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(httproutesResource, c.ns, hTTPRoute), &v1beta3.HTTPRoute{}) + Invokes(testing.NewCreateActionWithOptions(httproutesResource, c.ns, hTTPRoute, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta3.HTTPRoute), err } // Update takes the representation of a hTTPRoute and updates it. Returns the server's representation of the hTTPRoute, and an error, if there is any. func (c *FakeHTTPRoutes) Update(ctx context.Context, hTTPRoute *v1beta3.HTTPRoute, opts v1.UpdateOptions) (result *v1beta3.HTTPRoute, err error) { + emptyResult := &v1beta3.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(httproutesResource, c.ns, hTTPRoute), &v1beta3.HTTPRoute{}) + Invokes(testing.NewUpdateActionWithOptions(httproutesResource, c.ns, hTTPRoute, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta3.HTTPRoute), err } @@ -111,7 +115,7 @@ func (c *FakeHTTPRoutes) Delete(ctx context.Context, name string, opts v1.Delete // DeleteCollection deletes a collection of objects. func (c *FakeHTTPRoutes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(httproutesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(httproutesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1beta3.HTTPRouteList{}) return err @@ -119,11 +123,12 @@ func (c *FakeHTTPRoutes) DeleteCollection(ctx context.Context, opts v1.DeleteOpt // Patch applies the patch and returns the patched hTTPRoute. func (c *FakeHTTPRoutes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta3.HTTPRoute, err error) { + emptyResult := &v1beta3.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(httproutesResource, c.ns, name, pt, data, subresources...), &v1beta3.HTTPRoute{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(httproutesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta3.HTTPRoute), err } diff --git a/controller/gen/client/clientset/versioned/typed/policy/v1beta3/httproute.go b/controller/gen/client/clientset/versioned/typed/policy/v1beta3/httproute.go index 2907ce6187d4c..28cb08a4eaac8 100644 --- a/controller/gen/client/clientset/versioned/typed/policy/v1beta3/httproute.go +++ b/controller/gen/client/clientset/versioned/typed/policy/v1beta3/httproute.go @@ -20,14 +20,13 @@ package v1beta3 import ( "context" - "time" v1beta3 "github.com/linkerd/linkerd2/controller/gen/apis/policy/v1beta3" scheme "github.com/linkerd/linkerd2/controller/gen/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" + gentype "k8s.io/client-go/gentype" ) // HTTPRoutesGetter has a method to return a HTTPRouteInterface. @@ -51,128 +50,18 @@ type HTTPRouteInterface interface { // hTTPRoutes implements HTTPRouteInterface type hTTPRoutes struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1beta3.HTTPRoute, *v1beta3.HTTPRouteList] } // newHTTPRoutes returns a HTTPRoutes func newHTTPRoutes(c *PolicyV1beta3Client, namespace string) *hTTPRoutes { return &hTTPRoutes{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1beta3.HTTPRoute, *v1beta3.HTTPRouteList]( + "httproutes", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1beta3.HTTPRoute { return &v1beta3.HTTPRoute{} }, + func() *v1beta3.HTTPRouteList { return &v1beta3.HTTPRouteList{} }), } } - -// Get takes name of the hTTPRoute, and returns the corresponding hTTPRoute object, and an error if there is any. -func (c *hTTPRoutes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta3.HTTPRoute, err error) { - result = &v1beta3.HTTPRoute{} - err = c.client.Get(). - Namespace(c.ns). - Resource("httproutes"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of HTTPRoutes that match those selectors. -func (c *hTTPRoutes) List(ctx context.Context, opts v1.ListOptions) (result *v1beta3.HTTPRouteList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta3.HTTPRouteList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("httproutes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested hTTPRoutes. -func (c *hTTPRoutes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("httproutes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a hTTPRoute and creates it. Returns the server's representation of the hTTPRoute, and an error, if there is any. -func (c *hTTPRoutes) Create(ctx context.Context, hTTPRoute *v1beta3.HTTPRoute, opts v1.CreateOptions) (result *v1beta3.HTTPRoute, err error) { - result = &v1beta3.HTTPRoute{} - err = c.client.Post(). - Namespace(c.ns). - Resource("httproutes"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(hTTPRoute). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a hTTPRoute and updates it. Returns the server's representation of the hTTPRoute, and an error, if there is any. -func (c *hTTPRoutes) Update(ctx context.Context, hTTPRoute *v1beta3.HTTPRoute, opts v1.UpdateOptions) (result *v1beta3.HTTPRoute, err error) { - result = &v1beta3.HTTPRoute{} - err = c.client.Put(). - Namespace(c.ns). - Resource("httproutes"). - Name(hTTPRoute.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(hTTPRoute). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the hTTPRoute and deletes it. Returns an error if one occurs. -func (c *hTTPRoutes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("httproutes"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *hTTPRoutes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("httproutes"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched hTTPRoute. -func (c *hTTPRoutes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta3.HTTPRoute, err error) { - result = &v1beta3.HTTPRoute{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("httproutes"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/controller/gen/client/clientset/versioned/typed/server/v1beta1/fake/fake_server.go b/controller/gen/client/clientset/versioned/typed/server/v1beta1/fake/fake_server.go index c9199ab1335fc..d00d07ddeefda 100644 --- a/controller/gen/client/clientset/versioned/typed/server/v1beta1/fake/fake_server.go +++ b/controller/gen/client/clientset/versioned/typed/server/v1beta1/fake/fake_server.go @@ -41,22 +41,24 @@ var serversKind = v1beta1.SchemeGroupVersion.WithKind("Server") // Get takes name of the server, and returns the corresponding server object, and an error if there is any. func (c *FakeServers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Server, err error) { + emptyResult := &v1beta1.Server{} obj, err := c.Fake. - Invokes(testing.NewGetAction(serversResource, c.ns, name), &v1beta1.Server{}) + Invokes(testing.NewGetActionWithOptions(serversResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.Server), err } // List takes label and field selectors, and returns the list of Servers that match those selectors. func (c *FakeServers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ServerList, err error) { + emptyResult := &v1beta1.ServerList{} obj, err := c.Fake. - Invokes(testing.NewListAction(serversResource, serversKind, c.ns, opts), &v1beta1.ServerList{}) + Invokes(testing.NewListActionWithOptions(serversResource, serversKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeServers) List(ctx context.Context, opts v1.ListOptions) (result *v1 // Watch returns a watch.Interface that watches the requested servers. func (c *FakeServers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(serversResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(serversResource, c.ns, opts)) } // Create takes the representation of a server and creates it. Returns the server's representation of the server, and an error, if there is any. func (c *FakeServers) Create(ctx context.Context, server *v1beta1.Server, opts v1.CreateOptions) (result *v1beta1.Server, err error) { + emptyResult := &v1beta1.Server{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(serversResource, c.ns, server), &v1beta1.Server{}) + Invokes(testing.NewCreateActionWithOptions(serversResource, c.ns, server, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.Server), err } // Update takes the representation of a server and updates it. Returns the server's representation of the server, and an error, if there is any. func (c *FakeServers) Update(ctx context.Context, server *v1beta1.Server, opts v1.UpdateOptions) (result *v1beta1.Server, err error) { + emptyResult := &v1beta1.Server{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(serversResource, c.ns, server), &v1beta1.Server{}) + Invokes(testing.NewUpdateActionWithOptions(serversResource, c.ns, server, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.Server), err } @@ -111,7 +115,7 @@ func (c *FakeServers) Delete(ctx context.Context, name string, opts v1.DeleteOpt // DeleteCollection deletes a collection of objects. func (c *FakeServers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(serversResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(serversResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.ServerList{}) return err @@ -119,11 +123,12 @@ func (c *FakeServers) DeleteCollection(ctx context.Context, opts v1.DeleteOption // Patch applies the patch and returns the patched server. func (c *FakeServers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Server, err error) { + emptyResult := &v1beta1.Server{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(serversResource, c.ns, name, pt, data, subresources...), &v1beta1.Server{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(serversResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.Server), err } diff --git a/controller/gen/client/clientset/versioned/typed/server/v1beta1/server.go b/controller/gen/client/clientset/versioned/typed/server/v1beta1/server.go index 0296afa779ae6..7838ea2c67d54 100644 --- a/controller/gen/client/clientset/versioned/typed/server/v1beta1/server.go +++ b/controller/gen/client/clientset/versioned/typed/server/v1beta1/server.go @@ -20,14 +20,13 @@ package v1beta1 import ( "context" - "time" v1beta1 "github.com/linkerd/linkerd2/controller/gen/apis/server/v1beta1" scheme "github.com/linkerd/linkerd2/controller/gen/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" + gentype "k8s.io/client-go/gentype" ) // ServersGetter has a method to return a ServerInterface. @@ -51,128 +50,18 @@ type ServerInterface interface { // servers implements ServerInterface type servers struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1beta1.Server, *v1beta1.ServerList] } // newServers returns a Servers func newServers(c *ServerV1beta1Client, namespace string) *servers { return &servers{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1beta1.Server, *v1beta1.ServerList]( + "servers", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1beta1.Server { return &v1beta1.Server{} }, + func() *v1beta1.ServerList { return &v1beta1.ServerList{} }), } } - -// Get takes name of the server, and returns the corresponding server object, and an error if there is any. -func (c *servers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Server, err error) { - result = &v1beta1.Server{} - err = c.client.Get(). - Namespace(c.ns). - Resource("servers"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Servers that match those selectors. -func (c *servers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ServerList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta1.ServerList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("servers"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested servers. -func (c *servers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("servers"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a server and creates it. Returns the server's representation of the server, and an error, if there is any. -func (c *servers) Create(ctx context.Context, server *v1beta1.Server, opts v1.CreateOptions) (result *v1beta1.Server, err error) { - result = &v1beta1.Server{} - err = c.client.Post(). - Namespace(c.ns). - Resource("servers"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(server). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a server and updates it. Returns the server's representation of the server, and an error, if there is any. -func (c *servers) Update(ctx context.Context, server *v1beta1.Server, opts v1.UpdateOptions) (result *v1beta1.Server, err error) { - result = &v1beta1.Server{} - err = c.client.Put(). - Namespace(c.ns). - Resource("servers"). - Name(server.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(server). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the server and deletes it. Returns an error if one occurs. -func (c *servers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("servers"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *servers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("servers"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched server. -func (c *servers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Server, err error) { - result = &v1beta1.Server{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("servers"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/controller/gen/client/clientset/versioned/typed/server/v1beta2/fake/fake_server.go b/controller/gen/client/clientset/versioned/typed/server/v1beta2/fake/fake_server.go index 710bbecb5e084..b772d7381b06d 100644 --- a/controller/gen/client/clientset/versioned/typed/server/v1beta2/fake/fake_server.go +++ b/controller/gen/client/clientset/versioned/typed/server/v1beta2/fake/fake_server.go @@ -41,22 +41,24 @@ var serversKind = v1beta2.SchemeGroupVersion.WithKind("Server") // Get takes name of the server, and returns the corresponding server object, and an error if there is any. func (c *FakeServers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.Server, err error) { + emptyResult := &v1beta2.Server{} obj, err := c.Fake. - Invokes(testing.NewGetAction(serversResource, c.ns, name), &v1beta2.Server{}) + Invokes(testing.NewGetActionWithOptions(serversResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.Server), err } // List takes label and field selectors, and returns the list of Servers that match those selectors. func (c *FakeServers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.ServerList, err error) { + emptyResult := &v1beta2.ServerList{} obj, err := c.Fake. - Invokes(testing.NewListAction(serversResource, serversKind, c.ns, opts), &v1beta2.ServerList{}) + Invokes(testing.NewListActionWithOptions(serversResource, serversKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeServers) List(ctx context.Context, opts v1.ListOptions) (result *v1 // Watch returns a watch.Interface that watches the requested servers. func (c *FakeServers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(serversResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(serversResource, c.ns, opts)) } // Create takes the representation of a server and creates it. Returns the server's representation of the server, and an error, if there is any. func (c *FakeServers) Create(ctx context.Context, server *v1beta2.Server, opts v1.CreateOptions) (result *v1beta2.Server, err error) { + emptyResult := &v1beta2.Server{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(serversResource, c.ns, server), &v1beta2.Server{}) + Invokes(testing.NewCreateActionWithOptions(serversResource, c.ns, server, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.Server), err } // Update takes the representation of a server and updates it. Returns the server's representation of the server, and an error, if there is any. func (c *FakeServers) Update(ctx context.Context, server *v1beta2.Server, opts v1.UpdateOptions) (result *v1beta2.Server, err error) { + emptyResult := &v1beta2.Server{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(serversResource, c.ns, server), &v1beta2.Server{}) + Invokes(testing.NewUpdateActionWithOptions(serversResource, c.ns, server, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.Server), err } @@ -111,7 +115,7 @@ func (c *FakeServers) Delete(ctx context.Context, name string, opts v1.DeleteOpt // DeleteCollection deletes a collection of objects. func (c *FakeServers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(serversResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(serversResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1beta2.ServerList{}) return err @@ -119,11 +123,12 @@ func (c *FakeServers) DeleteCollection(ctx context.Context, opts v1.DeleteOption // Patch applies the patch and returns the patched server. func (c *FakeServers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.Server, err error) { + emptyResult := &v1beta2.Server{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(serversResource, c.ns, name, pt, data, subresources...), &v1beta2.Server{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(serversResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.Server), err } diff --git a/controller/gen/client/clientset/versioned/typed/server/v1beta2/server.go b/controller/gen/client/clientset/versioned/typed/server/v1beta2/server.go index d16fb85cb714f..f6e350f380500 100644 --- a/controller/gen/client/clientset/versioned/typed/server/v1beta2/server.go +++ b/controller/gen/client/clientset/versioned/typed/server/v1beta2/server.go @@ -20,14 +20,13 @@ package v1beta2 import ( "context" - "time" v1beta2 "github.com/linkerd/linkerd2/controller/gen/apis/server/v1beta2" scheme "github.com/linkerd/linkerd2/controller/gen/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" + gentype "k8s.io/client-go/gentype" ) // ServersGetter has a method to return a ServerInterface. @@ -51,128 +50,18 @@ type ServerInterface interface { // servers implements ServerInterface type servers struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1beta2.Server, *v1beta2.ServerList] } // newServers returns a Servers func newServers(c *ServerV1beta2Client, namespace string) *servers { return &servers{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1beta2.Server, *v1beta2.ServerList]( + "servers", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1beta2.Server { return &v1beta2.Server{} }, + func() *v1beta2.ServerList { return &v1beta2.ServerList{} }), } } - -// Get takes name of the server, and returns the corresponding server object, and an error if there is any. -func (c *servers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.Server, err error) { - result = &v1beta2.Server{} - err = c.client.Get(). - Namespace(c.ns). - Resource("servers"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Servers that match those selectors. -func (c *servers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.ServerList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta2.ServerList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("servers"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested servers. -func (c *servers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("servers"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a server and creates it. Returns the server's representation of the server, and an error, if there is any. -func (c *servers) Create(ctx context.Context, server *v1beta2.Server, opts v1.CreateOptions) (result *v1beta2.Server, err error) { - result = &v1beta2.Server{} - err = c.client.Post(). - Namespace(c.ns). - Resource("servers"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(server). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a server and updates it. Returns the server's representation of the server, and an error, if there is any. -func (c *servers) Update(ctx context.Context, server *v1beta2.Server, opts v1.UpdateOptions) (result *v1beta2.Server, err error) { - result = &v1beta2.Server{} - err = c.client.Put(). - Namespace(c.ns). - Resource("servers"). - Name(server.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(server). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the server and deletes it. Returns an error if one occurs. -func (c *servers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("servers"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *servers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("servers"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched server. -func (c *servers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.Server, err error) { - result = &v1beta2.Server{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("servers"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/controller/gen/client/clientset/versioned/typed/server/v1beta3/fake/fake_server.go b/controller/gen/client/clientset/versioned/typed/server/v1beta3/fake/fake_server.go index 1c95745f363b8..fff7322dbb7be 100644 --- a/controller/gen/client/clientset/versioned/typed/server/v1beta3/fake/fake_server.go +++ b/controller/gen/client/clientset/versioned/typed/server/v1beta3/fake/fake_server.go @@ -41,22 +41,24 @@ var serversKind = v1beta3.SchemeGroupVersion.WithKind("Server") // Get takes name of the server, and returns the corresponding server object, and an error if there is any. func (c *FakeServers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta3.Server, err error) { + emptyResult := &v1beta3.Server{} obj, err := c.Fake. - Invokes(testing.NewGetAction(serversResource, c.ns, name), &v1beta3.Server{}) + Invokes(testing.NewGetActionWithOptions(serversResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta3.Server), err } // List takes label and field selectors, and returns the list of Servers that match those selectors. func (c *FakeServers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta3.ServerList, err error) { + emptyResult := &v1beta3.ServerList{} obj, err := c.Fake. - Invokes(testing.NewListAction(serversResource, serversKind, c.ns, opts), &v1beta3.ServerList{}) + Invokes(testing.NewListActionWithOptions(serversResource, serversKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeServers) List(ctx context.Context, opts v1.ListOptions) (result *v1 // Watch returns a watch.Interface that watches the requested servers. func (c *FakeServers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(serversResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(serversResource, c.ns, opts)) } // Create takes the representation of a server and creates it. Returns the server's representation of the server, and an error, if there is any. func (c *FakeServers) Create(ctx context.Context, server *v1beta3.Server, opts v1.CreateOptions) (result *v1beta3.Server, err error) { + emptyResult := &v1beta3.Server{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(serversResource, c.ns, server), &v1beta3.Server{}) + Invokes(testing.NewCreateActionWithOptions(serversResource, c.ns, server, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta3.Server), err } // Update takes the representation of a server and updates it. Returns the server's representation of the server, and an error, if there is any. func (c *FakeServers) Update(ctx context.Context, server *v1beta3.Server, opts v1.UpdateOptions) (result *v1beta3.Server, err error) { + emptyResult := &v1beta3.Server{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(serversResource, c.ns, server), &v1beta3.Server{}) + Invokes(testing.NewUpdateActionWithOptions(serversResource, c.ns, server, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta3.Server), err } @@ -111,7 +115,7 @@ func (c *FakeServers) Delete(ctx context.Context, name string, opts v1.DeleteOpt // DeleteCollection deletes a collection of objects. func (c *FakeServers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(serversResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(serversResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1beta3.ServerList{}) return err @@ -119,11 +123,12 @@ func (c *FakeServers) DeleteCollection(ctx context.Context, opts v1.DeleteOption // Patch applies the patch and returns the patched server. func (c *FakeServers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta3.Server, err error) { + emptyResult := &v1beta3.Server{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(serversResource, c.ns, name, pt, data, subresources...), &v1beta3.Server{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(serversResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta3.Server), err } diff --git a/controller/gen/client/clientset/versioned/typed/server/v1beta3/server.go b/controller/gen/client/clientset/versioned/typed/server/v1beta3/server.go index 19d5dee01605b..e28271467f999 100644 --- a/controller/gen/client/clientset/versioned/typed/server/v1beta3/server.go +++ b/controller/gen/client/clientset/versioned/typed/server/v1beta3/server.go @@ -20,14 +20,13 @@ package v1beta3 import ( "context" - "time" v1beta3 "github.com/linkerd/linkerd2/controller/gen/apis/server/v1beta3" scheme "github.com/linkerd/linkerd2/controller/gen/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" + gentype "k8s.io/client-go/gentype" ) // ServersGetter has a method to return a ServerInterface. @@ -51,128 +50,18 @@ type ServerInterface interface { // servers implements ServerInterface type servers struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1beta3.Server, *v1beta3.ServerList] } // newServers returns a Servers func newServers(c *ServerV1beta3Client, namespace string) *servers { return &servers{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1beta3.Server, *v1beta3.ServerList]( + "servers", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1beta3.Server { return &v1beta3.Server{} }, + func() *v1beta3.ServerList { return &v1beta3.ServerList{} }), } } - -// Get takes name of the server, and returns the corresponding server object, and an error if there is any. -func (c *servers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta3.Server, err error) { - result = &v1beta3.Server{} - err = c.client.Get(). - Namespace(c.ns). - Resource("servers"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Servers that match those selectors. -func (c *servers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta3.ServerList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta3.ServerList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("servers"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested servers. -func (c *servers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("servers"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a server and creates it. Returns the server's representation of the server, and an error, if there is any. -func (c *servers) Create(ctx context.Context, server *v1beta3.Server, opts v1.CreateOptions) (result *v1beta3.Server, err error) { - result = &v1beta3.Server{} - err = c.client.Post(). - Namespace(c.ns). - Resource("servers"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(server). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a server and updates it. Returns the server's representation of the server, and an error, if there is any. -func (c *servers) Update(ctx context.Context, server *v1beta3.Server, opts v1.UpdateOptions) (result *v1beta3.Server, err error) { - result = &v1beta3.Server{} - err = c.client.Put(). - Namespace(c.ns). - Resource("servers"). - Name(server.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(server). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the server and deletes it. Returns an error if one occurs. -func (c *servers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("servers"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *servers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("servers"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched server. -func (c *servers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta3.Server, err error) { - result = &v1beta3.Server{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("servers"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/controller/gen/client/clientset/versioned/typed/serverauthorization/v1beta1/fake/fake_serverauthorization.go b/controller/gen/client/clientset/versioned/typed/serverauthorization/v1beta1/fake/fake_serverauthorization.go index 59e7f6dc047ad..ff4821114141b 100644 --- a/controller/gen/client/clientset/versioned/typed/serverauthorization/v1beta1/fake/fake_serverauthorization.go +++ b/controller/gen/client/clientset/versioned/typed/serverauthorization/v1beta1/fake/fake_serverauthorization.go @@ -41,22 +41,24 @@ var serverauthorizationsKind = v1beta1.SchemeGroupVersion.WithKind("ServerAuthor // Get takes name of the serverAuthorization, and returns the corresponding serverAuthorization object, and an error if there is any. func (c *FakeServerAuthorizations) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.ServerAuthorization, err error) { + emptyResult := &v1beta1.ServerAuthorization{} obj, err := c.Fake. - Invokes(testing.NewGetAction(serverauthorizationsResource, c.ns, name), &v1beta1.ServerAuthorization{}) + Invokes(testing.NewGetActionWithOptions(serverauthorizationsResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.ServerAuthorization), err } // List takes label and field selectors, and returns the list of ServerAuthorizations that match those selectors. func (c *FakeServerAuthorizations) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ServerAuthorizationList, err error) { + emptyResult := &v1beta1.ServerAuthorizationList{} obj, err := c.Fake. - Invokes(testing.NewListAction(serverauthorizationsResource, serverauthorizationsKind, c.ns, opts), &v1beta1.ServerAuthorizationList{}) + Invokes(testing.NewListActionWithOptions(serverauthorizationsResource, serverauthorizationsKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeServerAuthorizations) List(ctx context.Context, opts v1.ListOptions // Watch returns a watch.Interface that watches the requested serverAuthorizations. func (c *FakeServerAuthorizations) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(serverauthorizationsResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(serverauthorizationsResource, c.ns, opts)) } // Create takes the representation of a serverAuthorization and creates it. Returns the server's representation of the serverAuthorization, and an error, if there is any. func (c *FakeServerAuthorizations) Create(ctx context.Context, serverAuthorization *v1beta1.ServerAuthorization, opts v1.CreateOptions) (result *v1beta1.ServerAuthorization, err error) { + emptyResult := &v1beta1.ServerAuthorization{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(serverauthorizationsResource, c.ns, serverAuthorization), &v1beta1.ServerAuthorization{}) + Invokes(testing.NewCreateActionWithOptions(serverauthorizationsResource, c.ns, serverAuthorization, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.ServerAuthorization), err } // Update takes the representation of a serverAuthorization and updates it. Returns the server's representation of the serverAuthorization, and an error, if there is any. func (c *FakeServerAuthorizations) Update(ctx context.Context, serverAuthorization *v1beta1.ServerAuthorization, opts v1.UpdateOptions) (result *v1beta1.ServerAuthorization, err error) { + emptyResult := &v1beta1.ServerAuthorization{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(serverauthorizationsResource, c.ns, serverAuthorization), &v1beta1.ServerAuthorization{}) + Invokes(testing.NewUpdateActionWithOptions(serverauthorizationsResource, c.ns, serverAuthorization, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.ServerAuthorization), err } @@ -111,7 +115,7 @@ func (c *FakeServerAuthorizations) Delete(ctx context.Context, name string, opts // DeleteCollection deletes a collection of objects. func (c *FakeServerAuthorizations) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(serverauthorizationsResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(serverauthorizationsResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.ServerAuthorizationList{}) return err @@ -119,11 +123,12 @@ func (c *FakeServerAuthorizations) DeleteCollection(ctx context.Context, opts v1 // Patch applies the patch and returns the patched serverAuthorization. func (c *FakeServerAuthorizations) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ServerAuthorization, err error) { + emptyResult := &v1beta1.ServerAuthorization{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(serverauthorizationsResource, c.ns, name, pt, data, subresources...), &v1beta1.ServerAuthorization{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(serverauthorizationsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.ServerAuthorization), err } diff --git a/controller/gen/client/clientset/versioned/typed/serverauthorization/v1beta1/serverauthorization.go b/controller/gen/client/clientset/versioned/typed/serverauthorization/v1beta1/serverauthorization.go index fd75467a8435f..c64798a02071e 100644 --- a/controller/gen/client/clientset/versioned/typed/serverauthorization/v1beta1/serverauthorization.go +++ b/controller/gen/client/clientset/versioned/typed/serverauthorization/v1beta1/serverauthorization.go @@ -20,14 +20,13 @@ package v1beta1 import ( "context" - "time" v1beta1 "github.com/linkerd/linkerd2/controller/gen/apis/serverauthorization/v1beta1" scheme "github.com/linkerd/linkerd2/controller/gen/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" + gentype "k8s.io/client-go/gentype" ) // ServerAuthorizationsGetter has a method to return a ServerAuthorizationInterface. @@ -51,128 +50,18 @@ type ServerAuthorizationInterface interface { // serverAuthorizations implements ServerAuthorizationInterface type serverAuthorizations struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1beta1.ServerAuthorization, *v1beta1.ServerAuthorizationList] } // newServerAuthorizations returns a ServerAuthorizations func newServerAuthorizations(c *ServerauthorizationV1beta1Client, namespace string) *serverAuthorizations { return &serverAuthorizations{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1beta1.ServerAuthorization, *v1beta1.ServerAuthorizationList]( + "serverauthorizations", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1beta1.ServerAuthorization { return &v1beta1.ServerAuthorization{} }, + func() *v1beta1.ServerAuthorizationList { return &v1beta1.ServerAuthorizationList{} }), } } - -// Get takes name of the serverAuthorization, and returns the corresponding serverAuthorization object, and an error if there is any. -func (c *serverAuthorizations) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.ServerAuthorization, err error) { - result = &v1beta1.ServerAuthorization{} - err = c.client.Get(). - Namespace(c.ns). - Resource("serverauthorizations"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of ServerAuthorizations that match those selectors. -func (c *serverAuthorizations) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ServerAuthorizationList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta1.ServerAuthorizationList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("serverauthorizations"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested serverAuthorizations. -func (c *serverAuthorizations) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("serverauthorizations"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a serverAuthorization and creates it. Returns the server's representation of the serverAuthorization, and an error, if there is any. -func (c *serverAuthorizations) Create(ctx context.Context, serverAuthorization *v1beta1.ServerAuthorization, opts v1.CreateOptions) (result *v1beta1.ServerAuthorization, err error) { - result = &v1beta1.ServerAuthorization{} - err = c.client.Post(). - Namespace(c.ns). - Resource("serverauthorizations"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(serverAuthorization). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a serverAuthorization and updates it. Returns the server's representation of the serverAuthorization, and an error, if there is any. -func (c *serverAuthorizations) Update(ctx context.Context, serverAuthorization *v1beta1.ServerAuthorization, opts v1.UpdateOptions) (result *v1beta1.ServerAuthorization, err error) { - result = &v1beta1.ServerAuthorization{} - err = c.client.Put(). - Namespace(c.ns). - Resource("serverauthorizations"). - Name(serverAuthorization.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(serverAuthorization). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the serverAuthorization and deletes it. Returns an error if one occurs. -func (c *serverAuthorizations) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("serverauthorizations"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *serverAuthorizations) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("serverauthorizations"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched serverAuthorization. -func (c *serverAuthorizations) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ServerAuthorization, err error) { - result = &v1beta1.ServerAuthorization{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("serverauthorizations"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/controller/gen/client/clientset/versioned/typed/serviceprofile/v1alpha2/fake/fake_serviceprofile.go b/controller/gen/client/clientset/versioned/typed/serviceprofile/v1alpha2/fake/fake_serviceprofile.go index 2c92761323840..d67fe87cd997e 100644 --- a/controller/gen/client/clientset/versioned/typed/serviceprofile/v1alpha2/fake/fake_serviceprofile.go +++ b/controller/gen/client/clientset/versioned/typed/serviceprofile/v1alpha2/fake/fake_serviceprofile.go @@ -41,22 +41,24 @@ var serviceprofilesKind = v1alpha2.SchemeGroupVersion.WithKind("ServiceProfile") // Get takes name of the serviceProfile, and returns the corresponding serviceProfile object, and an error if there is any. func (c *FakeServiceProfiles) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.ServiceProfile, err error) { + emptyResult := &v1alpha2.ServiceProfile{} obj, err := c.Fake. - Invokes(testing.NewGetAction(serviceprofilesResource, c.ns, name), &v1alpha2.ServiceProfile{}) + Invokes(testing.NewGetActionWithOptions(serviceprofilesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha2.ServiceProfile), err } // List takes label and field selectors, and returns the list of ServiceProfiles that match those selectors. func (c *FakeServiceProfiles) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ServiceProfileList, err error) { + emptyResult := &v1alpha2.ServiceProfileList{} obj, err := c.Fake. - Invokes(testing.NewListAction(serviceprofilesResource, serviceprofilesKind, c.ns, opts), &v1alpha2.ServiceProfileList{}) + Invokes(testing.NewListActionWithOptions(serviceprofilesResource, serviceprofilesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeServiceProfiles) List(ctx context.Context, opts v1.ListOptions) (re // Watch returns a watch.Interface that watches the requested serviceProfiles. func (c *FakeServiceProfiles) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(serviceprofilesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(serviceprofilesResource, c.ns, opts)) } // Create takes the representation of a serviceProfile and creates it. Returns the server's representation of the serviceProfile, and an error, if there is any. func (c *FakeServiceProfiles) Create(ctx context.Context, serviceProfile *v1alpha2.ServiceProfile, opts v1.CreateOptions) (result *v1alpha2.ServiceProfile, err error) { + emptyResult := &v1alpha2.ServiceProfile{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(serviceprofilesResource, c.ns, serviceProfile), &v1alpha2.ServiceProfile{}) + Invokes(testing.NewCreateActionWithOptions(serviceprofilesResource, c.ns, serviceProfile, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha2.ServiceProfile), err } // Update takes the representation of a serviceProfile and updates it. Returns the server's representation of the serviceProfile, and an error, if there is any. func (c *FakeServiceProfiles) Update(ctx context.Context, serviceProfile *v1alpha2.ServiceProfile, opts v1.UpdateOptions) (result *v1alpha2.ServiceProfile, err error) { + emptyResult := &v1alpha2.ServiceProfile{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(serviceprofilesResource, c.ns, serviceProfile), &v1alpha2.ServiceProfile{}) + Invokes(testing.NewUpdateActionWithOptions(serviceprofilesResource, c.ns, serviceProfile, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha2.ServiceProfile), err } @@ -111,7 +115,7 @@ func (c *FakeServiceProfiles) Delete(ctx context.Context, name string, opts v1.D // DeleteCollection deletes a collection of objects. func (c *FakeServiceProfiles) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(serviceprofilesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(serviceprofilesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha2.ServiceProfileList{}) return err @@ -119,11 +123,12 @@ func (c *FakeServiceProfiles) DeleteCollection(ctx context.Context, opts v1.Dele // Patch applies the patch and returns the patched serviceProfile. func (c *FakeServiceProfiles) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.ServiceProfile, err error) { + emptyResult := &v1alpha2.ServiceProfile{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(serviceprofilesResource, c.ns, name, pt, data, subresources...), &v1alpha2.ServiceProfile{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(serviceprofilesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha2.ServiceProfile), err } diff --git a/controller/gen/client/clientset/versioned/typed/serviceprofile/v1alpha2/serviceprofile.go b/controller/gen/client/clientset/versioned/typed/serviceprofile/v1alpha2/serviceprofile.go index 0b04e59d78092..b3c6a479778cb 100644 --- a/controller/gen/client/clientset/versioned/typed/serviceprofile/v1alpha2/serviceprofile.go +++ b/controller/gen/client/clientset/versioned/typed/serviceprofile/v1alpha2/serviceprofile.go @@ -20,14 +20,13 @@ package v1alpha2 import ( "context" - "time" v1alpha2 "github.com/linkerd/linkerd2/controller/gen/apis/serviceprofile/v1alpha2" scheme "github.com/linkerd/linkerd2/controller/gen/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" + gentype "k8s.io/client-go/gentype" ) // ServiceProfilesGetter has a method to return a ServiceProfileInterface. @@ -51,128 +50,18 @@ type ServiceProfileInterface interface { // serviceProfiles implements ServiceProfileInterface type serviceProfiles struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1alpha2.ServiceProfile, *v1alpha2.ServiceProfileList] } // newServiceProfiles returns a ServiceProfiles func newServiceProfiles(c *LinkerdV1alpha2Client, namespace string) *serviceProfiles { return &serviceProfiles{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1alpha2.ServiceProfile, *v1alpha2.ServiceProfileList]( + "serviceprofiles", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha2.ServiceProfile { return &v1alpha2.ServiceProfile{} }, + func() *v1alpha2.ServiceProfileList { return &v1alpha2.ServiceProfileList{} }), } } - -// Get takes name of the serviceProfile, and returns the corresponding serviceProfile object, and an error if there is any. -func (c *serviceProfiles) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.ServiceProfile, err error) { - result = &v1alpha2.ServiceProfile{} - err = c.client.Get(). - Namespace(c.ns). - Resource("serviceprofiles"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of ServiceProfiles that match those selectors. -func (c *serviceProfiles) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ServiceProfileList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha2.ServiceProfileList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("serviceprofiles"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested serviceProfiles. -func (c *serviceProfiles) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("serviceprofiles"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a serviceProfile and creates it. Returns the server's representation of the serviceProfile, and an error, if there is any. -func (c *serviceProfiles) Create(ctx context.Context, serviceProfile *v1alpha2.ServiceProfile, opts v1.CreateOptions) (result *v1alpha2.ServiceProfile, err error) { - result = &v1alpha2.ServiceProfile{} - err = c.client.Post(). - Namespace(c.ns). - Resource("serviceprofiles"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(serviceProfile). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a serviceProfile and updates it. Returns the server's representation of the serviceProfile, and an error, if there is any. -func (c *serviceProfiles) Update(ctx context.Context, serviceProfile *v1alpha2.ServiceProfile, opts v1.UpdateOptions) (result *v1alpha2.ServiceProfile, err error) { - result = &v1alpha2.ServiceProfile{} - err = c.client.Put(). - Namespace(c.ns). - Resource("serviceprofiles"). - Name(serviceProfile.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(serviceProfile). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the serviceProfile and deletes it. Returns an error if one occurs. -func (c *serviceProfiles) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("serviceprofiles"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *serviceProfiles) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("serviceprofiles"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched serviceProfile. -func (c *serviceProfiles) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.ServiceProfile, err error) { - result = &v1alpha2.ServiceProfile{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("serviceprofiles"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/controller/gen/client/informers/externalversions/factory.go b/controller/gen/client/informers/externalversions/factory.go index 2cdf7b777115e..aefb07e037aa1 100644 --- a/controller/gen/client/informers/externalversions/factory.go +++ b/controller/gen/client/informers/externalversions/factory.go @@ -233,6 +233,7 @@ type SharedInformerFactory interface { // Start initializes all requested informers. They are handled in goroutines // which run until the stop channel gets closed. + // Warning: Start does not block. When run in a go-routine, it will race with a later WaitForCacheSync. Start(stopCh <-chan struct{}) // Shutdown marks a factory as shutting down. At that point no new diff --git a/controller/gen/client/listers/externalworkload/v1beta1/externalworkload.go b/controller/gen/client/listers/externalworkload/v1beta1/externalworkload.go index f3c8600776a99..d700459aa20fe 100644 --- a/controller/gen/client/listers/externalworkload/v1beta1/externalworkload.go +++ b/controller/gen/client/listers/externalworkload/v1beta1/externalworkload.go @@ -20,8 +20,8 @@ package v1beta1 import ( v1beta1 "github.com/linkerd/linkerd2/controller/gen/apis/externalworkload/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -38,25 +38,17 @@ type ExternalWorkloadLister interface { // externalWorkloadLister implements the ExternalWorkloadLister interface. type externalWorkloadLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta1.ExternalWorkload] } // NewExternalWorkloadLister returns a new ExternalWorkloadLister. func NewExternalWorkloadLister(indexer cache.Indexer) ExternalWorkloadLister { - return &externalWorkloadLister{indexer: indexer} -} - -// List lists all ExternalWorkloads in the indexer. -func (s *externalWorkloadLister) List(selector labels.Selector) (ret []*v1beta1.ExternalWorkload, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.ExternalWorkload)) - }) - return ret, err + return &externalWorkloadLister{listers.New[*v1beta1.ExternalWorkload](indexer, v1beta1.Resource("externalworkload"))} } // ExternalWorkloads returns an object that can list and get ExternalWorkloads. func (s *externalWorkloadLister) ExternalWorkloads(namespace string) ExternalWorkloadNamespaceLister { - return externalWorkloadNamespaceLister{indexer: s.indexer, namespace: namespace} + return externalWorkloadNamespaceLister{listers.NewNamespaced[*v1beta1.ExternalWorkload](s.ResourceIndexer, namespace)} } // ExternalWorkloadNamespaceLister helps list and get ExternalWorkloads. @@ -74,26 +66,5 @@ type ExternalWorkloadNamespaceLister interface { // externalWorkloadNamespaceLister implements the ExternalWorkloadNamespaceLister // interface. type externalWorkloadNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all ExternalWorkloads in the indexer for a given namespace. -func (s externalWorkloadNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.ExternalWorkload, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.ExternalWorkload)) - }) - return ret, err -} - -// Get retrieves the ExternalWorkload from the indexer for a given namespace and name. -func (s externalWorkloadNamespaceLister) Get(name string) (*v1beta1.ExternalWorkload, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("externalworkload"), name) - } - return obj.(*v1beta1.ExternalWorkload), nil + listers.ResourceIndexer[*v1beta1.ExternalWorkload] } diff --git a/controller/gen/client/listers/link/v1alpha1/link.go b/controller/gen/client/listers/link/v1alpha1/link.go index b0c98342139bc..f544c52d9c0eb 100644 --- a/controller/gen/client/listers/link/v1alpha1/link.go +++ b/controller/gen/client/listers/link/v1alpha1/link.go @@ -20,8 +20,8 @@ package v1alpha1 import ( v1alpha1 "github.com/linkerd/linkerd2/controller/gen/apis/link/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -38,25 +38,17 @@ type LinkLister interface { // linkLister implements the LinkLister interface. type linkLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1alpha1.Link] } // NewLinkLister returns a new LinkLister. func NewLinkLister(indexer cache.Indexer) LinkLister { - return &linkLister{indexer: indexer} -} - -// List lists all Links in the indexer. -func (s *linkLister) List(selector labels.Selector) (ret []*v1alpha1.Link, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.Link)) - }) - return ret, err + return &linkLister{listers.New[*v1alpha1.Link](indexer, v1alpha1.Resource("link"))} } // Links returns an object that can list and get Links. func (s *linkLister) Links(namespace string) LinkNamespaceLister { - return linkNamespaceLister{indexer: s.indexer, namespace: namespace} + return linkNamespaceLister{listers.NewNamespaced[*v1alpha1.Link](s.ResourceIndexer, namespace)} } // LinkNamespaceLister helps list and get Links. @@ -74,26 +66,5 @@ type LinkNamespaceLister interface { // linkNamespaceLister implements the LinkNamespaceLister // interface. type linkNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all Links in the indexer for a given namespace. -func (s linkNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Link, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.Link)) - }) - return ret, err -} - -// Get retrieves the Link from the indexer for a given namespace and name. -func (s linkNamespaceLister) Get(name string) (*v1alpha1.Link, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("link"), name) - } - return obj.(*v1alpha1.Link), nil + listers.ResourceIndexer[*v1alpha1.Link] } diff --git a/controller/gen/client/listers/policy/v1alpha1/authorizationpolicy.go b/controller/gen/client/listers/policy/v1alpha1/authorizationpolicy.go index 11bd906afb43c..bfab309fae365 100644 --- a/controller/gen/client/listers/policy/v1alpha1/authorizationpolicy.go +++ b/controller/gen/client/listers/policy/v1alpha1/authorizationpolicy.go @@ -20,8 +20,8 @@ package v1alpha1 import ( v1alpha1 "github.com/linkerd/linkerd2/controller/gen/apis/policy/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -38,25 +38,17 @@ type AuthorizationPolicyLister interface { // authorizationPolicyLister implements the AuthorizationPolicyLister interface. type authorizationPolicyLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1alpha1.AuthorizationPolicy] } // NewAuthorizationPolicyLister returns a new AuthorizationPolicyLister. func NewAuthorizationPolicyLister(indexer cache.Indexer) AuthorizationPolicyLister { - return &authorizationPolicyLister{indexer: indexer} -} - -// List lists all AuthorizationPolicies in the indexer. -func (s *authorizationPolicyLister) List(selector labels.Selector) (ret []*v1alpha1.AuthorizationPolicy, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.AuthorizationPolicy)) - }) - return ret, err + return &authorizationPolicyLister{listers.New[*v1alpha1.AuthorizationPolicy](indexer, v1alpha1.Resource("authorizationpolicy"))} } // AuthorizationPolicies returns an object that can list and get AuthorizationPolicies. func (s *authorizationPolicyLister) AuthorizationPolicies(namespace string) AuthorizationPolicyNamespaceLister { - return authorizationPolicyNamespaceLister{indexer: s.indexer, namespace: namespace} + return authorizationPolicyNamespaceLister{listers.NewNamespaced[*v1alpha1.AuthorizationPolicy](s.ResourceIndexer, namespace)} } // AuthorizationPolicyNamespaceLister helps list and get AuthorizationPolicies. @@ -74,26 +66,5 @@ type AuthorizationPolicyNamespaceLister interface { // authorizationPolicyNamespaceLister implements the AuthorizationPolicyNamespaceLister // interface. type authorizationPolicyNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all AuthorizationPolicies in the indexer for a given namespace. -func (s authorizationPolicyNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.AuthorizationPolicy, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.AuthorizationPolicy)) - }) - return ret, err -} - -// Get retrieves the AuthorizationPolicy from the indexer for a given namespace and name. -func (s authorizationPolicyNamespaceLister) Get(name string) (*v1alpha1.AuthorizationPolicy, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("authorizationpolicy"), name) - } - return obj.(*v1alpha1.AuthorizationPolicy), nil + listers.ResourceIndexer[*v1alpha1.AuthorizationPolicy] } diff --git a/controller/gen/client/listers/policy/v1alpha1/httproute.go b/controller/gen/client/listers/policy/v1alpha1/httproute.go index b9b6916072816..6df7392c9dd95 100644 --- a/controller/gen/client/listers/policy/v1alpha1/httproute.go +++ b/controller/gen/client/listers/policy/v1alpha1/httproute.go @@ -20,8 +20,8 @@ package v1alpha1 import ( v1alpha1 "github.com/linkerd/linkerd2/controller/gen/apis/policy/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -38,25 +38,17 @@ type HTTPRouteLister interface { // hTTPRouteLister implements the HTTPRouteLister interface. type hTTPRouteLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1alpha1.HTTPRoute] } // NewHTTPRouteLister returns a new HTTPRouteLister. func NewHTTPRouteLister(indexer cache.Indexer) HTTPRouteLister { - return &hTTPRouteLister{indexer: indexer} -} - -// List lists all HTTPRoutes in the indexer. -func (s *hTTPRouteLister) List(selector labels.Selector) (ret []*v1alpha1.HTTPRoute, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.HTTPRoute)) - }) - return ret, err + return &hTTPRouteLister{listers.New[*v1alpha1.HTTPRoute](indexer, v1alpha1.Resource("httproute"))} } // HTTPRoutes returns an object that can list and get HTTPRoutes. func (s *hTTPRouteLister) HTTPRoutes(namespace string) HTTPRouteNamespaceLister { - return hTTPRouteNamespaceLister{indexer: s.indexer, namespace: namespace} + return hTTPRouteNamespaceLister{listers.NewNamespaced[*v1alpha1.HTTPRoute](s.ResourceIndexer, namespace)} } // HTTPRouteNamespaceLister helps list and get HTTPRoutes. @@ -74,26 +66,5 @@ type HTTPRouteNamespaceLister interface { // hTTPRouteNamespaceLister implements the HTTPRouteNamespaceLister // interface. type hTTPRouteNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all HTTPRoutes in the indexer for a given namespace. -func (s hTTPRouteNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.HTTPRoute, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.HTTPRoute)) - }) - return ret, err -} - -// Get retrieves the HTTPRoute from the indexer for a given namespace and name. -func (s hTTPRouteNamespaceLister) Get(name string) (*v1alpha1.HTTPRoute, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("httproute"), name) - } - return obj.(*v1alpha1.HTTPRoute), nil + listers.ResourceIndexer[*v1alpha1.HTTPRoute] } diff --git a/controller/gen/client/listers/policy/v1alpha1/meshtlsauthentication.go b/controller/gen/client/listers/policy/v1alpha1/meshtlsauthentication.go index 0d701f0a92530..8960cb7a3549a 100644 --- a/controller/gen/client/listers/policy/v1alpha1/meshtlsauthentication.go +++ b/controller/gen/client/listers/policy/v1alpha1/meshtlsauthentication.go @@ -20,8 +20,8 @@ package v1alpha1 import ( v1alpha1 "github.com/linkerd/linkerd2/controller/gen/apis/policy/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -38,25 +38,17 @@ type MeshTLSAuthenticationLister interface { // meshTLSAuthenticationLister implements the MeshTLSAuthenticationLister interface. type meshTLSAuthenticationLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1alpha1.MeshTLSAuthentication] } // NewMeshTLSAuthenticationLister returns a new MeshTLSAuthenticationLister. func NewMeshTLSAuthenticationLister(indexer cache.Indexer) MeshTLSAuthenticationLister { - return &meshTLSAuthenticationLister{indexer: indexer} -} - -// List lists all MeshTLSAuthentications in the indexer. -func (s *meshTLSAuthenticationLister) List(selector labels.Selector) (ret []*v1alpha1.MeshTLSAuthentication, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.MeshTLSAuthentication)) - }) - return ret, err + return &meshTLSAuthenticationLister{listers.New[*v1alpha1.MeshTLSAuthentication](indexer, v1alpha1.Resource("meshtlsauthentication"))} } // MeshTLSAuthentications returns an object that can list and get MeshTLSAuthentications. func (s *meshTLSAuthenticationLister) MeshTLSAuthentications(namespace string) MeshTLSAuthenticationNamespaceLister { - return meshTLSAuthenticationNamespaceLister{indexer: s.indexer, namespace: namespace} + return meshTLSAuthenticationNamespaceLister{listers.NewNamespaced[*v1alpha1.MeshTLSAuthentication](s.ResourceIndexer, namespace)} } // MeshTLSAuthenticationNamespaceLister helps list and get MeshTLSAuthentications. @@ -74,26 +66,5 @@ type MeshTLSAuthenticationNamespaceLister interface { // meshTLSAuthenticationNamespaceLister implements the MeshTLSAuthenticationNamespaceLister // interface. type meshTLSAuthenticationNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all MeshTLSAuthentications in the indexer for a given namespace. -func (s meshTLSAuthenticationNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.MeshTLSAuthentication, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.MeshTLSAuthentication)) - }) - return ret, err -} - -// Get retrieves the MeshTLSAuthentication from the indexer for a given namespace and name. -func (s meshTLSAuthenticationNamespaceLister) Get(name string) (*v1alpha1.MeshTLSAuthentication, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("meshtlsauthentication"), name) - } - return obj.(*v1alpha1.MeshTLSAuthentication), nil + listers.ResourceIndexer[*v1alpha1.MeshTLSAuthentication] } diff --git a/controller/gen/client/listers/policy/v1alpha1/networkauthentication.go b/controller/gen/client/listers/policy/v1alpha1/networkauthentication.go index 9908c11df88ca..02f84ff036696 100644 --- a/controller/gen/client/listers/policy/v1alpha1/networkauthentication.go +++ b/controller/gen/client/listers/policy/v1alpha1/networkauthentication.go @@ -20,8 +20,8 @@ package v1alpha1 import ( v1alpha1 "github.com/linkerd/linkerd2/controller/gen/apis/policy/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -38,25 +38,17 @@ type NetworkAuthenticationLister interface { // networkAuthenticationLister implements the NetworkAuthenticationLister interface. type networkAuthenticationLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1alpha1.NetworkAuthentication] } // NewNetworkAuthenticationLister returns a new NetworkAuthenticationLister. func NewNetworkAuthenticationLister(indexer cache.Indexer) NetworkAuthenticationLister { - return &networkAuthenticationLister{indexer: indexer} -} - -// List lists all NetworkAuthentications in the indexer. -func (s *networkAuthenticationLister) List(selector labels.Selector) (ret []*v1alpha1.NetworkAuthentication, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.NetworkAuthentication)) - }) - return ret, err + return &networkAuthenticationLister{listers.New[*v1alpha1.NetworkAuthentication](indexer, v1alpha1.Resource("networkauthentication"))} } // NetworkAuthentications returns an object that can list and get NetworkAuthentications. func (s *networkAuthenticationLister) NetworkAuthentications(namespace string) NetworkAuthenticationNamespaceLister { - return networkAuthenticationNamespaceLister{indexer: s.indexer, namespace: namespace} + return networkAuthenticationNamespaceLister{listers.NewNamespaced[*v1alpha1.NetworkAuthentication](s.ResourceIndexer, namespace)} } // NetworkAuthenticationNamespaceLister helps list and get NetworkAuthentications. @@ -74,26 +66,5 @@ type NetworkAuthenticationNamespaceLister interface { // networkAuthenticationNamespaceLister implements the NetworkAuthenticationNamespaceLister // interface. type networkAuthenticationNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all NetworkAuthentications in the indexer for a given namespace. -func (s networkAuthenticationNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.NetworkAuthentication, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.NetworkAuthentication)) - }) - return ret, err -} - -// Get retrieves the NetworkAuthentication from the indexer for a given namespace and name. -func (s networkAuthenticationNamespaceLister) Get(name string) (*v1alpha1.NetworkAuthentication, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("networkauthentication"), name) - } - return obj.(*v1alpha1.NetworkAuthentication), nil + listers.ResourceIndexer[*v1alpha1.NetworkAuthentication] } diff --git a/controller/gen/client/listers/policy/v1beta3/httproute.go b/controller/gen/client/listers/policy/v1beta3/httproute.go index be2cdf82127fa..9365e71c35fce 100644 --- a/controller/gen/client/listers/policy/v1beta3/httproute.go +++ b/controller/gen/client/listers/policy/v1beta3/httproute.go @@ -20,8 +20,8 @@ package v1beta3 import ( v1beta3 "github.com/linkerd/linkerd2/controller/gen/apis/policy/v1beta3" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -38,25 +38,17 @@ type HTTPRouteLister interface { // hTTPRouteLister implements the HTTPRouteLister interface. type hTTPRouteLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta3.HTTPRoute] } // NewHTTPRouteLister returns a new HTTPRouteLister. func NewHTTPRouteLister(indexer cache.Indexer) HTTPRouteLister { - return &hTTPRouteLister{indexer: indexer} -} - -// List lists all HTTPRoutes in the indexer. -func (s *hTTPRouteLister) List(selector labels.Selector) (ret []*v1beta3.HTTPRoute, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta3.HTTPRoute)) - }) - return ret, err + return &hTTPRouteLister{listers.New[*v1beta3.HTTPRoute](indexer, v1beta3.Resource("httproute"))} } // HTTPRoutes returns an object that can list and get HTTPRoutes. func (s *hTTPRouteLister) HTTPRoutes(namespace string) HTTPRouteNamespaceLister { - return hTTPRouteNamespaceLister{indexer: s.indexer, namespace: namespace} + return hTTPRouteNamespaceLister{listers.NewNamespaced[*v1beta3.HTTPRoute](s.ResourceIndexer, namespace)} } // HTTPRouteNamespaceLister helps list and get HTTPRoutes. @@ -74,26 +66,5 @@ type HTTPRouteNamespaceLister interface { // hTTPRouteNamespaceLister implements the HTTPRouteNamespaceLister // interface. type hTTPRouteNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all HTTPRoutes in the indexer for a given namespace. -func (s hTTPRouteNamespaceLister) List(selector labels.Selector) (ret []*v1beta3.HTTPRoute, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta3.HTTPRoute)) - }) - return ret, err -} - -// Get retrieves the HTTPRoute from the indexer for a given namespace and name. -func (s hTTPRouteNamespaceLister) Get(name string) (*v1beta3.HTTPRoute, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta3.Resource("httproute"), name) - } - return obj.(*v1beta3.HTTPRoute), nil + listers.ResourceIndexer[*v1beta3.HTTPRoute] } diff --git a/controller/gen/client/listers/server/v1beta1/server.go b/controller/gen/client/listers/server/v1beta1/server.go index c2486f96b9677..2805432ef8247 100644 --- a/controller/gen/client/listers/server/v1beta1/server.go +++ b/controller/gen/client/listers/server/v1beta1/server.go @@ -20,8 +20,8 @@ package v1beta1 import ( v1beta1 "github.com/linkerd/linkerd2/controller/gen/apis/server/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -38,25 +38,17 @@ type ServerLister interface { // serverLister implements the ServerLister interface. type serverLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta1.Server] } // NewServerLister returns a new ServerLister. func NewServerLister(indexer cache.Indexer) ServerLister { - return &serverLister{indexer: indexer} -} - -// List lists all Servers in the indexer. -func (s *serverLister) List(selector labels.Selector) (ret []*v1beta1.Server, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.Server)) - }) - return ret, err + return &serverLister{listers.New[*v1beta1.Server](indexer, v1beta1.Resource("server"))} } // Servers returns an object that can list and get Servers. func (s *serverLister) Servers(namespace string) ServerNamespaceLister { - return serverNamespaceLister{indexer: s.indexer, namespace: namespace} + return serverNamespaceLister{listers.NewNamespaced[*v1beta1.Server](s.ResourceIndexer, namespace)} } // ServerNamespaceLister helps list and get Servers. @@ -74,26 +66,5 @@ type ServerNamespaceLister interface { // serverNamespaceLister implements the ServerNamespaceLister // interface. type serverNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all Servers in the indexer for a given namespace. -func (s serverNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Server, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.Server)) - }) - return ret, err -} - -// Get retrieves the Server from the indexer for a given namespace and name. -func (s serverNamespaceLister) Get(name string) (*v1beta1.Server, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("server"), name) - } - return obj.(*v1beta1.Server), nil + listers.ResourceIndexer[*v1beta1.Server] } diff --git a/controller/gen/client/listers/server/v1beta2/server.go b/controller/gen/client/listers/server/v1beta2/server.go index ede3535cf65e5..3b5e3ffe24d30 100644 --- a/controller/gen/client/listers/server/v1beta2/server.go +++ b/controller/gen/client/listers/server/v1beta2/server.go @@ -20,8 +20,8 @@ package v1beta2 import ( v1beta2 "github.com/linkerd/linkerd2/controller/gen/apis/server/v1beta2" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -38,25 +38,17 @@ type ServerLister interface { // serverLister implements the ServerLister interface. type serverLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta2.Server] } // NewServerLister returns a new ServerLister. func NewServerLister(indexer cache.Indexer) ServerLister { - return &serverLister{indexer: indexer} -} - -// List lists all Servers in the indexer. -func (s *serverLister) List(selector labels.Selector) (ret []*v1beta2.Server, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta2.Server)) - }) - return ret, err + return &serverLister{listers.New[*v1beta2.Server](indexer, v1beta2.Resource("server"))} } // Servers returns an object that can list and get Servers. func (s *serverLister) Servers(namespace string) ServerNamespaceLister { - return serverNamespaceLister{indexer: s.indexer, namespace: namespace} + return serverNamespaceLister{listers.NewNamespaced[*v1beta2.Server](s.ResourceIndexer, namespace)} } // ServerNamespaceLister helps list and get Servers. @@ -74,26 +66,5 @@ type ServerNamespaceLister interface { // serverNamespaceLister implements the ServerNamespaceLister // interface. type serverNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all Servers in the indexer for a given namespace. -func (s serverNamespaceLister) List(selector labels.Selector) (ret []*v1beta2.Server, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta2.Server)) - }) - return ret, err -} - -// Get retrieves the Server from the indexer for a given namespace and name. -func (s serverNamespaceLister) Get(name string) (*v1beta2.Server, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta2.Resource("server"), name) - } - return obj.(*v1beta2.Server), nil + listers.ResourceIndexer[*v1beta2.Server] } diff --git a/controller/gen/client/listers/server/v1beta3/server.go b/controller/gen/client/listers/server/v1beta3/server.go index a794c4d19e72c..e2714fa0f1972 100644 --- a/controller/gen/client/listers/server/v1beta3/server.go +++ b/controller/gen/client/listers/server/v1beta3/server.go @@ -20,8 +20,8 @@ package v1beta3 import ( v1beta3 "github.com/linkerd/linkerd2/controller/gen/apis/server/v1beta3" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -38,25 +38,17 @@ type ServerLister interface { // serverLister implements the ServerLister interface. type serverLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta3.Server] } // NewServerLister returns a new ServerLister. func NewServerLister(indexer cache.Indexer) ServerLister { - return &serverLister{indexer: indexer} -} - -// List lists all Servers in the indexer. -func (s *serverLister) List(selector labels.Selector) (ret []*v1beta3.Server, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta3.Server)) - }) - return ret, err + return &serverLister{listers.New[*v1beta3.Server](indexer, v1beta3.Resource("server"))} } // Servers returns an object that can list and get Servers. func (s *serverLister) Servers(namespace string) ServerNamespaceLister { - return serverNamespaceLister{indexer: s.indexer, namespace: namespace} + return serverNamespaceLister{listers.NewNamespaced[*v1beta3.Server](s.ResourceIndexer, namespace)} } // ServerNamespaceLister helps list and get Servers. @@ -74,26 +66,5 @@ type ServerNamespaceLister interface { // serverNamespaceLister implements the ServerNamespaceLister // interface. type serverNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all Servers in the indexer for a given namespace. -func (s serverNamespaceLister) List(selector labels.Selector) (ret []*v1beta3.Server, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta3.Server)) - }) - return ret, err -} - -// Get retrieves the Server from the indexer for a given namespace and name. -func (s serverNamespaceLister) Get(name string) (*v1beta3.Server, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta3.Resource("server"), name) - } - return obj.(*v1beta3.Server), nil + listers.ResourceIndexer[*v1beta3.Server] } diff --git a/controller/gen/client/listers/serverauthorization/v1beta1/serverauthorization.go b/controller/gen/client/listers/serverauthorization/v1beta1/serverauthorization.go index 8f35be7e8c090..96b01872955ba 100644 --- a/controller/gen/client/listers/serverauthorization/v1beta1/serverauthorization.go +++ b/controller/gen/client/listers/serverauthorization/v1beta1/serverauthorization.go @@ -20,8 +20,8 @@ package v1beta1 import ( v1beta1 "github.com/linkerd/linkerd2/controller/gen/apis/serverauthorization/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -38,25 +38,17 @@ type ServerAuthorizationLister interface { // serverAuthorizationLister implements the ServerAuthorizationLister interface. type serverAuthorizationLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta1.ServerAuthorization] } // NewServerAuthorizationLister returns a new ServerAuthorizationLister. func NewServerAuthorizationLister(indexer cache.Indexer) ServerAuthorizationLister { - return &serverAuthorizationLister{indexer: indexer} -} - -// List lists all ServerAuthorizations in the indexer. -func (s *serverAuthorizationLister) List(selector labels.Selector) (ret []*v1beta1.ServerAuthorization, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.ServerAuthorization)) - }) - return ret, err + return &serverAuthorizationLister{listers.New[*v1beta1.ServerAuthorization](indexer, v1beta1.Resource("serverauthorization"))} } // ServerAuthorizations returns an object that can list and get ServerAuthorizations. func (s *serverAuthorizationLister) ServerAuthorizations(namespace string) ServerAuthorizationNamespaceLister { - return serverAuthorizationNamespaceLister{indexer: s.indexer, namespace: namespace} + return serverAuthorizationNamespaceLister{listers.NewNamespaced[*v1beta1.ServerAuthorization](s.ResourceIndexer, namespace)} } // ServerAuthorizationNamespaceLister helps list and get ServerAuthorizations. @@ -74,26 +66,5 @@ type ServerAuthorizationNamespaceLister interface { // serverAuthorizationNamespaceLister implements the ServerAuthorizationNamespaceLister // interface. type serverAuthorizationNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all ServerAuthorizations in the indexer for a given namespace. -func (s serverAuthorizationNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.ServerAuthorization, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.ServerAuthorization)) - }) - return ret, err -} - -// Get retrieves the ServerAuthorization from the indexer for a given namespace and name. -func (s serverAuthorizationNamespaceLister) Get(name string) (*v1beta1.ServerAuthorization, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("serverauthorization"), name) - } - return obj.(*v1beta1.ServerAuthorization), nil + listers.ResourceIndexer[*v1beta1.ServerAuthorization] } diff --git a/controller/gen/client/listers/serviceprofile/v1alpha2/serviceprofile.go b/controller/gen/client/listers/serviceprofile/v1alpha2/serviceprofile.go index f747c59acb42a..d2952ff25651a 100644 --- a/controller/gen/client/listers/serviceprofile/v1alpha2/serviceprofile.go +++ b/controller/gen/client/listers/serviceprofile/v1alpha2/serviceprofile.go @@ -20,8 +20,8 @@ package v1alpha2 import ( v1alpha2 "github.com/linkerd/linkerd2/controller/gen/apis/serviceprofile/v1alpha2" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -38,25 +38,17 @@ type ServiceProfileLister interface { // serviceProfileLister implements the ServiceProfileLister interface. type serviceProfileLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1alpha2.ServiceProfile] } // NewServiceProfileLister returns a new ServiceProfileLister. func NewServiceProfileLister(indexer cache.Indexer) ServiceProfileLister { - return &serviceProfileLister{indexer: indexer} -} - -// List lists all ServiceProfiles in the indexer. -func (s *serviceProfileLister) List(selector labels.Selector) (ret []*v1alpha2.ServiceProfile, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha2.ServiceProfile)) - }) - return ret, err + return &serviceProfileLister{listers.New[*v1alpha2.ServiceProfile](indexer, v1alpha2.Resource("serviceprofile"))} } // ServiceProfiles returns an object that can list and get ServiceProfiles. func (s *serviceProfileLister) ServiceProfiles(namespace string) ServiceProfileNamespaceLister { - return serviceProfileNamespaceLister{indexer: s.indexer, namespace: namespace} + return serviceProfileNamespaceLister{listers.NewNamespaced[*v1alpha2.ServiceProfile](s.ResourceIndexer, namespace)} } // ServiceProfileNamespaceLister helps list and get ServiceProfiles. @@ -74,26 +66,5 @@ type ServiceProfileNamespaceLister interface { // serviceProfileNamespaceLister implements the ServiceProfileNamespaceLister // interface. type serviceProfileNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all ServiceProfiles in the indexer for a given namespace. -func (s serviceProfileNamespaceLister) List(selector labels.Selector) (ret []*v1alpha2.ServiceProfile, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha2.ServiceProfile)) - }) - return ret, err -} - -// Get retrieves the ServiceProfile from the indexer for a given namespace and name. -func (s serviceProfileNamespaceLister) Get(name string) (*v1alpha2.ServiceProfile, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha2.Resource("serviceprofile"), name) - } - return obj.(*v1alpha2.ServiceProfile), nil + listers.ResourceIndexer[*v1alpha2.ServiceProfile] }