diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index 518bdf0c1..a28c20436 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -61,8 +61,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/pkg/client/clientset/versioned/typed/apisix/v2/apisixroute.go b/pkg/client/clientset/versioned/typed/apisix/v2/apisixroute.go index bc463592b..78ffe03c4 100644 --- a/pkg/client/clientset/versioned/typed/apisix/v2/apisixroute.go +++ b/pkg/client/clientset/versioned/typed/apisix/v2/apisixroute.go @@ -20,14 +20,13 @@ package v2 import ( "context" - "time" v2 "github.com/fluxcd/flagger/pkg/apis/apisix/v2" scheme "github.com/fluxcd/flagger/pkg/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" ) // ApisixRoutesGetter has a method to return a ApisixRouteInterface. @@ -40,6 +39,7 @@ type ApisixRoutesGetter interface { type ApisixRouteInterface interface { Create(ctx context.Context, apisixRoute *v2.ApisixRoute, opts v1.CreateOptions) (*v2.ApisixRoute, error) Update(ctx context.Context, apisixRoute *v2.ApisixRoute, opts v1.UpdateOptions) (*v2.ApisixRoute, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, apisixRoute *v2.ApisixRoute, opts v1.UpdateOptions) (*v2.ApisixRoute, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error @@ -52,144 +52,18 @@ type ApisixRouteInterface interface { // apisixRoutes implements ApisixRouteInterface type apisixRoutes struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v2.ApisixRoute, *v2.ApisixRouteList] } // newApisixRoutes returns a ApisixRoutes func newApisixRoutes(c *ApisixV2Client, namespace string) *apisixRoutes { return &apisixRoutes{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v2.ApisixRoute, *v2.ApisixRouteList]( + "apisixroutes", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v2.ApisixRoute { return &v2.ApisixRoute{} }, + func() *v2.ApisixRouteList { return &v2.ApisixRouteList{} }), } } - -// Get takes name of the apisixRoute, and returns the corresponding apisixRoute object, and an error if there is any. -func (c *apisixRoutes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2.ApisixRoute, err error) { - result = &v2.ApisixRoute{} - err = c.client.Get(). - Namespace(c.ns). - Resource("apisixroutes"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of ApisixRoutes that match those selectors. -func (c *apisixRoutes) List(ctx context.Context, opts v1.ListOptions) (result *v2.ApisixRouteList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v2.ApisixRouteList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("apisixroutes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested apisixRoutes. -func (c *apisixRoutes) 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("apisixroutes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a apisixRoute and creates it. Returns the server's representation of the apisixRoute, and an error, if there is any. -func (c *apisixRoutes) Create(ctx context.Context, apisixRoute *v2.ApisixRoute, opts v1.CreateOptions) (result *v2.ApisixRoute, err error) { - result = &v2.ApisixRoute{} - err = c.client.Post(). - Namespace(c.ns). - Resource("apisixroutes"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(apisixRoute). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a apisixRoute and updates it. Returns the server's representation of the apisixRoute, and an error, if there is any. -func (c *apisixRoutes) Update(ctx context.Context, apisixRoute *v2.ApisixRoute, opts v1.UpdateOptions) (result *v2.ApisixRoute, err error) { - result = &v2.ApisixRoute{} - err = c.client.Put(). - Namespace(c.ns). - Resource("apisixroutes"). - Name(apisixRoute.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(apisixRoute). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *apisixRoutes) UpdateStatus(ctx context.Context, apisixRoute *v2.ApisixRoute, opts v1.UpdateOptions) (result *v2.ApisixRoute, err error) { - result = &v2.ApisixRoute{} - err = c.client.Put(). - Namespace(c.ns). - Resource("apisixroutes"). - Name(apisixRoute.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(apisixRoute). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the apisixRoute and deletes it. Returns an error if one occurs. -func (c *apisixRoutes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("apisixroutes"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *apisixRoutes) 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("apisixroutes"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched apisixRoute. -func (c *apisixRoutes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2.ApisixRoute, err error) { - result = &v2.ApisixRoute{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("apisixroutes"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/apisix/v2/fake/fake_apisixroute.go b/pkg/client/clientset/versioned/typed/apisix/v2/fake/fake_apisixroute.go index 0689e3fc9..7e1dfb169 100644 --- a/pkg/client/clientset/versioned/typed/apisix/v2/fake/fake_apisixroute.go +++ b/pkg/client/clientset/versioned/typed/apisix/v2/fake/fake_apisixroute.go @@ -41,22 +41,24 @@ var apisixroutesKind = v2.SchemeGroupVersion.WithKind("ApisixRoute") // Get takes name of the apisixRoute, and returns the corresponding apisixRoute object, and an error if there is any. func (c *FakeApisixRoutes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v2.ApisixRoute, err error) { + emptyResult := &v2.ApisixRoute{} obj, err := c.Fake. - Invokes(testing.NewGetAction(apisixroutesResource, c.ns, name), &v2.ApisixRoute{}) + Invokes(testing.NewGetActionWithOptions(apisixroutesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v2.ApisixRoute), err } // List takes label and field selectors, and returns the list of ApisixRoutes that match those selectors. func (c *FakeApisixRoutes) List(ctx context.Context, opts v1.ListOptions) (result *v2.ApisixRouteList, err error) { + emptyResult := &v2.ApisixRouteList{} obj, err := c.Fake. - Invokes(testing.NewListAction(apisixroutesResource, apisixroutesKind, c.ns, opts), &v2.ApisixRouteList{}) + Invokes(testing.NewListActionWithOptions(apisixroutesResource, apisixroutesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,40 +77,43 @@ func (c *FakeApisixRoutes) List(ctx context.Context, opts v1.ListOptions) (resul // Watch returns a watch.Interface that watches the requested apisixRoutes. func (c *FakeApisixRoutes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(apisixroutesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(apisixroutesResource, c.ns, opts)) } // Create takes the representation of a apisixRoute and creates it. Returns the server's representation of the apisixRoute, and an error, if there is any. func (c *FakeApisixRoutes) Create(ctx context.Context, apisixRoute *v2.ApisixRoute, opts v1.CreateOptions) (result *v2.ApisixRoute, err error) { + emptyResult := &v2.ApisixRoute{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(apisixroutesResource, c.ns, apisixRoute), &v2.ApisixRoute{}) + Invokes(testing.NewCreateActionWithOptions(apisixroutesResource, c.ns, apisixRoute, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v2.ApisixRoute), err } // Update takes the representation of a apisixRoute and updates it. Returns the server's representation of the apisixRoute, and an error, if there is any. func (c *FakeApisixRoutes) Update(ctx context.Context, apisixRoute *v2.ApisixRoute, opts v1.UpdateOptions) (result *v2.ApisixRoute, err error) { + emptyResult := &v2.ApisixRoute{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(apisixroutesResource, c.ns, apisixRoute), &v2.ApisixRoute{}) + Invokes(testing.NewUpdateActionWithOptions(apisixroutesResource, c.ns, apisixRoute, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v2.ApisixRoute), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeApisixRoutes) UpdateStatus(ctx context.Context, apisixRoute *v2.ApisixRoute, opts v1.UpdateOptions) (*v2.ApisixRoute, error) { +func (c *FakeApisixRoutes) UpdateStatus(ctx context.Context, apisixRoute *v2.ApisixRoute, opts v1.UpdateOptions) (result *v2.ApisixRoute, err error) { + emptyResult := &v2.ApisixRoute{} obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(apisixroutesResource, "status", c.ns, apisixRoute), &v2.ApisixRoute{}) + Invokes(testing.NewUpdateSubresourceActionWithOptions(apisixroutesResource, "status", c.ns, apisixRoute, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v2.ApisixRoute), err } @@ -123,7 +128,7 @@ func (c *FakeApisixRoutes) Delete(ctx context.Context, name string, opts v1.Dele // DeleteCollection deletes a collection of objects. func (c *FakeApisixRoutes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(apisixroutesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(apisixroutesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v2.ApisixRouteList{}) return err @@ -131,11 +136,12 @@ func (c *FakeApisixRoutes) DeleteCollection(ctx context.Context, opts v1.DeleteO // Patch applies the patch and returns the patched apisixRoute. func (c *FakeApisixRoutes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v2.ApisixRoute, err error) { + emptyResult := &v2.ApisixRoute{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(apisixroutesResource, c.ns, name, pt, data, subresources...), &v2.ApisixRoute{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(apisixroutesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v2.ApisixRoute), err } diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_mesh.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_mesh.go index 82bb676b0..e4770aa2d 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_mesh.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_mesh.go @@ -40,20 +40,22 @@ var meshesKind = v1beta1.SchemeGroupVersion.WithKind("Mesh") // Get takes name of the mesh, and returns the corresponding mesh object, and an error if there is any. func (c *FakeMeshes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Mesh, err error) { + emptyResult := &v1beta1.Mesh{} obj, err := c.Fake. - Invokes(testing.NewRootGetAction(meshesResource, name), &v1beta1.Mesh{}) + Invokes(testing.NewRootGetActionWithOptions(meshesResource, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.Mesh), err } // List takes label and field selectors, and returns the list of Meshes that match those selectors. func (c *FakeMeshes) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.MeshList, err error) { + emptyResult := &v1beta1.MeshList{} obj, err := c.Fake. - Invokes(testing.NewRootListAction(meshesResource, meshesKind, opts), &v1beta1.MeshList{}) + Invokes(testing.NewRootListActionWithOptions(meshesResource, meshesKind, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -72,36 +74,39 @@ func (c *FakeMeshes) List(ctx context.Context, opts v1.ListOptions) (result *v1b // Watch returns a watch.Interface that watches the requested meshes. func (c *FakeMeshes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchAction(meshesResource, opts)) + InvokesWatch(testing.NewRootWatchActionWithOptions(meshesResource, opts)) } // Create takes the representation of a mesh and creates it. Returns the server's representation of the mesh, and an error, if there is any. func (c *FakeMeshes) Create(ctx context.Context, mesh *v1beta1.Mesh, opts v1.CreateOptions) (result *v1beta1.Mesh, err error) { + emptyResult := &v1beta1.Mesh{} obj, err := c.Fake. - Invokes(testing.NewRootCreateAction(meshesResource, mesh), &v1beta1.Mesh{}) + Invokes(testing.NewRootCreateActionWithOptions(meshesResource, mesh, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.Mesh), err } // Update takes the representation of a mesh and updates it. Returns the server's representation of the mesh, and an error, if there is any. func (c *FakeMeshes) Update(ctx context.Context, mesh *v1beta1.Mesh, opts v1.UpdateOptions) (result *v1beta1.Mesh, err error) { + emptyResult := &v1beta1.Mesh{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateAction(meshesResource, mesh), &v1beta1.Mesh{}) + Invokes(testing.NewRootUpdateActionWithOptions(meshesResource, mesh, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.Mesh), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeMeshes) UpdateStatus(ctx context.Context, mesh *v1beta1.Mesh, opts v1.UpdateOptions) (*v1beta1.Mesh, error) { +func (c *FakeMeshes) UpdateStatus(ctx context.Context, mesh *v1beta1.Mesh, opts v1.UpdateOptions) (result *v1beta1.Mesh, err error) { + emptyResult := &v1beta1.Mesh{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceAction(meshesResource, "status", mesh), &v1beta1.Mesh{}) + Invokes(testing.NewRootUpdateSubresourceActionWithOptions(meshesResource, "status", mesh, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.Mesh), err } @@ -115,7 +120,7 @@ func (c *FakeMeshes) Delete(ctx context.Context, name string, opts v1.DeleteOpti // DeleteCollection deletes a collection of objects. func (c *FakeMeshes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewRootDeleteCollectionAction(meshesResource, listOpts) + action := testing.NewRootDeleteCollectionActionWithOptions(meshesResource, opts, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.MeshList{}) return err @@ -123,10 +128,11 @@ func (c *FakeMeshes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions // Patch applies the patch and returns the patched mesh. func (c *FakeMeshes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Mesh, err error) { + emptyResult := &v1beta1.Mesh{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(meshesResource, name, pt, data, subresources...), &v1beta1.Mesh{}) + Invokes(testing.NewRootPatchSubresourceActionWithOptions(meshesResource, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.Mesh), err } diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_virtualnode.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_virtualnode.go index 54cf584a7..8df3ddecd 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_virtualnode.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_virtualnode.go @@ -41,22 +41,24 @@ var virtualnodesKind = v1beta1.SchemeGroupVersion.WithKind("VirtualNode") // Get takes name of the virtualNode, and returns the corresponding virtualNode object, and an error if there is any. func (c *FakeVirtualNodes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.VirtualNode, err error) { + emptyResult := &v1beta1.VirtualNode{} obj, err := c.Fake. - Invokes(testing.NewGetAction(virtualnodesResource, c.ns, name), &v1beta1.VirtualNode{}) + Invokes(testing.NewGetActionWithOptions(virtualnodesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.VirtualNode), err } // List takes label and field selectors, and returns the list of VirtualNodes that match those selectors. func (c *FakeVirtualNodes) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.VirtualNodeList, err error) { + emptyResult := &v1beta1.VirtualNodeList{} obj, err := c.Fake. - Invokes(testing.NewListAction(virtualnodesResource, virtualnodesKind, c.ns, opts), &v1beta1.VirtualNodeList{}) + Invokes(testing.NewListActionWithOptions(virtualnodesResource, virtualnodesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,40 +77,43 @@ func (c *FakeVirtualNodes) List(ctx context.Context, opts v1.ListOptions) (resul // Watch returns a watch.Interface that watches the requested virtualNodes. func (c *FakeVirtualNodes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(virtualnodesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(virtualnodesResource, c.ns, opts)) } // Create takes the representation of a virtualNode and creates it. Returns the server's representation of the virtualNode, and an error, if there is any. func (c *FakeVirtualNodes) Create(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.CreateOptions) (result *v1beta1.VirtualNode, err error) { + emptyResult := &v1beta1.VirtualNode{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(virtualnodesResource, c.ns, virtualNode), &v1beta1.VirtualNode{}) + Invokes(testing.NewCreateActionWithOptions(virtualnodesResource, c.ns, virtualNode, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.VirtualNode), err } // Update takes the representation of a virtualNode and updates it. Returns the server's representation of the virtualNode, and an error, if there is any. func (c *FakeVirtualNodes) Update(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.UpdateOptions) (result *v1beta1.VirtualNode, err error) { + emptyResult := &v1beta1.VirtualNode{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(virtualnodesResource, c.ns, virtualNode), &v1beta1.VirtualNode{}) + Invokes(testing.NewUpdateActionWithOptions(virtualnodesResource, c.ns, virtualNode, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.VirtualNode), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeVirtualNodes) UpdateStatus(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.UpdateOptions) (*v1beta1.VirtualNode, error) { +func (c *FakeVirtualNodes) UpdateStatus(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.UpdateOptions) (result *v1beta1.VirtualNode, err error) { + emptyResult := &v1beta1.VirtualNode{} obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(virtualnodesResource, "status", c.ns, virtualNode), &v1beta1.VirtualNode{}) + Invokes(testing.NewUpdateSubresourceActionWithOptions(virtualnodesResource, "status", c.ns, virtualNode, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.VirtualNode), err } @@ -123,7 +128,7 @@ func (c *FakeVirtualNodes) Delete(ctx context.Context, name string, opts v1.Dele // DeleteCollection deletes a collection of objects. func (c *FakeVirtualNodes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(virtualnodesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(virtualnodesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.VirtualNodeList{}) return err @@ -131,11 +136,12 @@ func (c *FakeVirtualNodes) DeleteCollection(ctx context.Context, opts v1.DeleteO // Patch applies the patch and returns the patched virtualNode. func (c *FakeVirtualNodes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.VirtualNode, err error) { + emptyResult := &v1beta1.VirtualNode{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(virtualnodesResource, c.ns, name, pt, data, subresources...), &v1beta1.VirtualNode{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(virtualnodesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.VirtualNode), err } diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_virtualservice.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_virtualservice.go index 47668b01d..5e0f5b9da 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_virtualservice.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/fake/fake_virtualservice.go @@ -41,22 +41,24 @@ var virtualservicesKind = v1beta1.SchemeGroupVersion.WithKind("VirtualService") // Get takes name of the virtualService, and returns the corresponding virtualService object, and an error if there is any. func (c *FakeVirtualServices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.VirtualService, err error) { + emptyResult := &v1beta1.VirtualService{} obj, err := c.Fake. - Invokes(testing.NewGetAction(virtualservicesResource, c.ns, name), &v1beta1.VirtualService{}) + Invokes(testing.NewGetActionWithOptions(virtualservicesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.VirtualService), err } // List takes label and field selectors, and returns the list of VirtualServices that match those selectors. func (c *FakeVirtualServices) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.VirtualServiceList, err error) { + emptyResult := &v1beta1.VirtualServiceList{} obj, err := c.Fake. - Invokes(testing.NewListAction(virtualservicesResource, virtualservicesKind, c.ns, opts), &v1beta1.VirtualServiceList{}) + Invokes(testing.NewListActionWithOptions(virtualservicesResource, virtualservicesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,40 +77,43 @@ func (c *FakeVirtualServices) List(ctx context.Context, opts v1.ListOptions) (re // Watch returns a watch.Interface that watches the requested virtualServices. func (c *FakeVirtualServices) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(virtualservicesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(virtualservicesResource, c.ns, opts)) } // Create takes the representation of a virtualService and creates it. Returns the server's representation of the virtualService, and an error, if there is any. func (c *FakeVirtualServices) Create(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.CreateOptions) (result *v1beta1.VirtualService, err error) { + emptyResult := &v1beta1.VirtualService{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(virtualservicesResource, c.ns, virtualService), &v1beta1.VirtualService{}) + Invokes(testing.NewCreateActionWithOptions(virtualservicesResource, c.ns, virtualService, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.VirtualService), err } // Update takes the representation of a virtualService and updates it. Returns the server's representation of the virtualService, and an error, if there is any. func (c *FakeVirtualServices) Update(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.UpdateOptions) (result *v1beta1.VirtualService, err error) { + emptyResult := &v1beta1.VirtualService{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(virtualservicesResource, c.ns, virtualService), &v1beta1.VirtualService{}) + Invokes(testing.NewUpdateActionWithOptions(virtualservicesResource, c.ns, virtualService, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.VirtualService), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeVirtualServices) UpdateStatus(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.UpdateOptions) (*v1beta1.VirtualService, error) { +func (c *FakeVirtualServices) UpdateStatus(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.UpdateOptions) (result *v1beta1.VirtualService, err error) { + emptyResult := &v1beta1.VirtualService{} obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(virtualservicesResource, "status", c.ns, virtualService), &v1beta1.VirtualService{}) + Invokes(testing.NewUpdateSubresourceActionWithOptions(virtualservicesResource, "status", c.ns, virtualService, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.VirtualService), err } @@ -123,7 +128,7 @@ func (c *FakeVirtualServices) Delete(ctx context.Context, name string, opts v1.D // DeleteCollection deletes a collection of objects. func (c *FakeVirtualServices) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(virtualservicesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(virtualservicesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.VirtualServiceList{}) return err @@ -131,11 +136,12 @@ func (c *FakeVirtualServices) DeleteCollection(ctx context.Context, opts v1.Dele // Patch applies the patch and returns the patched virtualService. func (c *FakeVirtualServices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.VirtualService, err error) { + emptyResult := &v1beta1.VirtualService{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(virtualservicesResource, c.ns, name, pt, data, subresources...), &v1beta1.VirtualService{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(virtualservicesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.VirtualService), err } diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/mesh.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/mesh.go index ef48a7702..3c6a89b61 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/mesh.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/mesh.go @@ -20,14 +20,13 @@ package v1beta1 import ( "context" - "time" v1beta1 "github.com/fluxcd/flagger/pkg/apis/appmesh/v1beta1" scheme "github.com/fluxcd/flagger/pkg/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" ) // MeshesGetter has a method to return a MeshInterface. @@ -40,6 +39,7 @@ type MeshesGetter interface { type MeshInterface interface { Create(ctx context.Context, mesh *v1beta1.Mesh, opts v1.CreateOptions) (*v1beta1.Mesh, error) Update(ctx context.Context, mesh *v1beta1.Mesh, opts v1.UpdateOptions) (*v1beta1.Mesh, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, mesh *v1beta1.Mesh, opts v1.UpdateOptions) (*v1beta1.Mesh, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error @@ -52,133 +52,18 @@ type MeshInterface interface { // meshes implements MeshInterface type meshes struct { - client rest.Interface + *gentype.ClientWithList[*v1beta1.Mesh, *v1beta1.MeshList] } // newMeshes returns a Meshes func newMeshes(c *AppmeshV1beta1Client) *meshes { return &meshes{ - client: c.RESTClient(), + gentype.NewClientWithList[*v1beta1.Mesh, *v1beta1.MeshList]( + "meshes", + c.RESTClient(), + scheme.ParameterCodec, + "", + func() *v1beta1.Mesh { return &v1beta1.Mesh{} }, + func() *v1beta1.MeshList { return &v1beta1.MeshList{} }), } } - -// Get takes name of the mesh, and returns the corresponding mesh object, and an error if there is any. -func (c *meshes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Mesh, err error) { - result = &v1beta1.Mesh{} - err = c.client.Get(). - Resource("meshes"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Meshes that match those selectors. -func (c *meshes) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.MeshList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta1.MeshList{} - err = c.client.Get(). - Resource("meshes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested meshes. -func (c *meshes) 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(). - Resource("meshes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a mesh and creates it. Returns the server's representation of the mesh, and an error, if there is any. -func (c *meshes) Create(ctx context.Context, mesh *v1beta1.Mesh, opts v1.CreateOptions) (result *v1beta1.Mesh, err error) { - result = &v1beta1.Mesh{} - err = c.client.Post(). - Resource("meshes"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(mesh). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a mesh and updates it. Returns the server's representation of the mesh, and an error, if there is any. -func (c *meshes) Update(ctx context.Context, mesh *v1beta1.Mesh, opts v1.UpdateOptions) (result *v1beta1.Mesh, err error) { - result = &v1beta1.Mesh{} - err = c.client.Put(). - Resource("meshes"). - Name(mesh.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(mesh). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *meshes) UpdateStatus(ctx context.Context, mesh *v1beta1.Mesh, opts v1.UpdateOptions) (result *v1beta1.Mesh, err error) { - result = &v1beta1.Mesh{} - err = c.client.Put(). - Resource("meshes"). - Name(mesh.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(mesh). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the mesh and deletes it. Returns an error if one occurs. -func (c *meshes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Resource("meshes"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *meshes) 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(). - Resource("meshes"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched mesh. -func (c *meshes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Mesh, err error) { - result = &v1beta1.Mesh{} - err = c.client.Patch(pt). - Resource("meshes"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/virtualnode.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/virtualnode.go index 4f2f36e2b..486e20945 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/virtualnode.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/virtualnode.go @@ -20,14 +20,13 @@ package v1beta1 import ( "context" - "time" v1beta1 "github.com/fluxcd/flagger/pkg/apis/appmesh/v1beta1" scheme "github.com/fluxcd/flagger/pkg/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" ) // VirtualNodesGetter has a method to return a VirtualNodeInterface. @@ -40,6 +39,7 @@ type VirtualNodesGetter interface { type VirtualNodeInterface interface { Create(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.CreateOptions) (*v1beta1.VirtualNode, error) Update(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.UpdateOptions) (*v1beta1.VirtualNode, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.UpdateOptions) (*v1beta1.VirtualNode, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error @@ -52,144 +52,18 @@ type VirtualNodeInterface interface { // virtualNodes implements VirtualNodeInterface type virtualNodes struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1beta1.VirtualNode, *v1beta1.VirtualNodeList] } // newVirtualNodes returns a VirtualNodes func newVirtualNodes(c *AppmeshV1beta1Client, namespace string) *virtualNodes { return &virtualNodes{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1beta1.VirtualNode, *v1beta1.VirtualNodeList]( + "virtualnodes", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1beta1.VirtualNode { return &v1beta1.VirtualNode{} }, + func() *v1beta1.VirtualNodeList { return &v1beta1.VirtualNodeList{} }), } } - -// Get takes name of the virtualNode, and returns the corresponding virtualNode object, and an error if there is any. -func (c *virtualNodes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.VirtualNode, err error) { - result = &v1beta1.VirtualNode{} - err = c.client.Get(). - Namespace(c.ns). - Resource("virtualnodes"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of VirtualNodes that match those selectors. -func (c *virtualNodes) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.VirtualNodeList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta1.VirtualNodeList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("virtualnodes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested virtualNodes. -func (c *virtualNodes) 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("virtualnodes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a virtualNode and creates it. Returns the server's representation of the virtualNode, and an error, if there is any. -func (c *virtualNodes) Create(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.CreateOptions) (result *v1beta1.VirtualNode, err error) { - result = &v1beta1.VirtualNode{} - err = c.client.Post(). - Namespace(c.ns). - Resource("virtualnodes"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(virtualNode). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a virtualNode and updates it. Returns the server's representation of the virtualNode, and an error, if there is any. -func (c *virtualNodes) Update(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.UpdateOptions) (result *v1beta1.VirtualNode, err error) { - result = &v1beta1.VirtualNode{} - err = c.client.Put(). - Namespace(c.ns). - Resource("virtualnodes"). - Name(virtualNode.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(virtualNode). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *virtualNodes) UpdateStatus(ctx context.Context, virtualNode *v1beta1.VirtualNode, opts v1.UpdateOptions) (result *v1beta1.VirtualNode, err error) { - result = &v1beta1.VirtualNode{} - err = c.client.Put(). - Namespace(c.ns). - Resource("virtualnodes"). - Name(virtualNode.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(virtualNode). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the virtualNode and deletes it. Returns an error if one occurs. -func (c *virtualNodes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("virtualnodes"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *virtualNodes) 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("virtualnodes"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched virtualNode. -func (c *virtualNodes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.VirtualNode, err error) { - result = &v1beta1.VirtualNode{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("virtualnodes"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/virtualservice.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/virtualservice.go index 4e42f17a7..cf71788eb 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta1/virtualservice.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta1/virtualservice.go @@ -20,14 +20,13 @@ package v1beta1 import ( "context" - "time" v1beta1 "github.com/fluxcd/flagger/pkg/apis/appmesh/v1beta1" scheme "github.com/fluxcd/flagger/pkg/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" ) // VirtualServicesGetter has a method to return a VirtualServiceInterface. @@ -40,6 +39,7 @@ type VirtualServicesGetter interface { type VirtualServiceInterface interface { Create(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.CreateOptions) (*v1beta1.VirtualService, error) Update(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.UpdateOptions) (*v1beta1.VirtualService, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.UpdateOptions) (*v1beta1.VirtualService, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error @@ -52,144 +52,18 @@ type VirtualServiceInterface interface { // virtualServices implements VirtualServiceInterface type virtualServices struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1beta1.VirtualService, *v1beta1.VirtualServiceList] } // newVirtualServices returns a VirtualServices func newVirtualServices(c *AppmeshV1beta1Client, namespace string) *virtualServices { return &virtualServices{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1beta1.VirtualService, *v1beta1.VirtualServiceList]( + "virtualservices", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1beta1.VirtualService { return &v1beta1.VirtualService{} }, + func() *v1beta1.VirtualServiceList { return &v1beta1.VirtualServiceList{} }), } } - -// Get takes name of the virtualService, and returns the corresponding virtualService object, and an error if there is any. -func (c *virtualServices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.VirtualService, err error) { - result = &v1beta1.VirtualService{} - err = c.client.Get(). - Namespace(c.ns). - Resource("virtualservices"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of VirtualServices that match those selectors. -func (c *virtualServices) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.VirtualServiceList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta1.VirtualServiceList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("virtualservices"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested virtualServices. -func (c *virtualServices) 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("virtualservices"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a virtualService and creates it. Returns the server's representation of the virtualService, and an error, if there is any. -func (c *virtualServices) Create(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.CreateOptions) (result *v1beta1.VirtualService, err error) { - result = &v1beta1.VirtualService{} - err = c.client.Post(). - Namespace(c.ns). - Resource("virtualservices"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(virtualService). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a virtualService and updates it. Returns the server's representation of the virtualService, and an error, if there is any. -func (c *virtualServices) Update(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.UpdateOptions) (result *v1beta1.VirtualService, err error) { - result = &v1beta1.VirtualService{} - err = c.client.Put(). - Namespace(c.ns). - Resource("virtualservices"). - Name(virtualService.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(virtualService). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *virtualServices) UpdateStatus(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.UpdateOptions) (result *v1beta1.VirtualService, err error) { - result = &v1beta1.VirtualService{} - err = c.client.Put(). - Namespace(c.ns). - Resource("virtualservices"). - Name(virtualService.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(virtualService). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the virtualService and deletes it. Returns an error if one occurs. -func (c *virtualServices) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("virtualservices"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *virtualServices) 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("virtualservices"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched virtualService. -func (c *virtualServices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.VirtualService, err error) { - result = &v1beta1.VirtualService{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("virtualservices"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta2/fake/fake_virtualnode.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta2/fake/fake_virtualnode.go index 202fc035d..8442b1aee 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta2/fake/fake_virtualnode.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta2/fake/fake_virtualnode.go @@ -41,22 +41,24 @@ var virtualnodesKind = v1beta2.SchemeGroupVersion.WithKind("VirtualNode") // Get takes name of the virtualNode, and returns the corresponding virtualNode object, and an error if there is any. func (c *FakeVirtualNodes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.VirtualNode, err error) { + emptyResult := &v1beta2.VirtualNode{} obj, err := c.Fake. - Invokes(testing.NewGetAction(virtualnodesResource, c.ns, name), &v1beta2.VirtualNode{}) + Invokes(testing.NewGetActionWithOptions(virtualnodesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.VirtualNode), err } // List takes label and field selectors, and returns the list of VirtualNodes that match those selectors. func (c *FakeVirtualNodes) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.VirtualNodeList, err error) { + emptyResult := &v1beta2.VirtualNodeList{} obj, err := c.Fake. - Invokes(testing.NewListAction(virtualnodesResource, virtualnodesKind, c.ns, opts), &v1beta2.VirtualNodeList{}) + Invokes(testing.NewListActionWithOptions(virtualnodesResource, virtualnodesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,40 +77,43 @@ func (c *FakeVirtualNodes) List(ctx context.Context, opts v1.ListOptions) (resul // Watch returns a watch.Interface that watches the requested virtualNodes. func (c *FakeVirtualNodes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(virtualnodesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(virtualnodesResource, c.ns, opts)) } // Create takes the representation of a virtualNode and creates it. Returns the server's representation of the virtualNode, and an error, if there is any. func (c *FakeVirtualNodes) Create(ctx context.Context, virtualNode *v1beta2.VirtualNode, opts v1.CreateOptions) (result *v1beta2.VirtualNode, err error) { + emptyResult := &v1beta2.VirtualNode{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(virtualnodesResource, c.ns, virtualNode), &v1beta2.VirtualNode{}) + Invokes(testing.NewCreateActionWithOptions(virtualnodesResource, c.ns, virtualNode, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.VirtualNode), err } // Update takes the representation of a virtualNode and updates it. Returns the server's representation of the virtualNode, and an error, if there is any. func (c *FakeVirtualNodes) Update(ctx context.Context, virtualNode *v1beta2.VirtualNode, opts v1.UpdateOptions) (result *v1beta2.VirtualNode, err error) { + emptyResult := &v1beta2.VirtualNode{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(virtualnodesResource, c.ns, virtualNode), &v1beta2.VirtualNode{}) + Invokes(testing.NewUpdateActionWithOptions(virtualnodesResource, c.ns, virtualNode, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.VirtualNode), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeVirtualNodes) UpdateStatus(ctx context.Context, virtualNode *v1beta2.VirtualNode, opts v1.UpdateOptions) (*v1beta2.VirtualNode, error) { +func (c *FakeVirtualNodes) UpdateStatus(ctx context.Context, virtualNode *v1beta2.VirtualNode, opts v1.UpdateOptions) (result *v1beta2.VirtualNode, err error) { + emptyResult := &v1beta2.VirtualNode{} obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(virtualnodesResource, "status", c.ns, virtualNode), &v1beta2.VirtualNode{}) + Invokes(testing.NewUpdateSubresourceActionWithOptions(virtualnodesResource, "status", c.ns, virtualNode, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.VirtualNode), err } @@ -123,7 +128,7 @@ func (c *FakeVirtualNodes) Delete(ctx context.Context, name string, opts v1.Dele // DeleteCollection deletes a collection of objects. func (c *FakeVirtualNodes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(virtualnodesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(virtualnodesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1beta2.VirtualNodeList{}) return err @@ -131,11 +136,12 @@ func (c *FakeVirtualNodes) DeleteCollection(ctx context.Context, opts v1.DeleteO // Patch applies the patch and returns the patched virtualNode. func (c *FakeVirtualNodes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.VirtualNode, err error) { + emptyResult := &v1beta2.VirtualNode{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(virtualnodesResource, c.ns, name, pt, data, subresources...), &v1beta2.VirtualNode{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(virtualnodesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.VirtualNode), err } diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta2/fake/fake_virtualrouter.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta2/fake/fake_virtualrouter.go index 5a5092a94..88e66f0a8 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta2/fake/fake_virtualrouter.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta2/fake/fake_virtualrouter.go @@ -41,22 +41,24 @@ var virtualroutersKind = v1beta2.SchemeGroupVersion.WithKind("VirtualRouter") // Get takes name of the virtualRouter, and returns the corresponding virtualRouter object, and an error if there is any. func (c *FakeVirtualRouters) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.VirtualRouter, err error) { + emptyResult := &v1beta2.VirtualRouter{} obj, err := c.Fake. - Invokes(testing.NewGetAction(virtualroutersResource, c.ns, name), &v1beta2.VirtualRouter{}) + Invokes(testing.NewGetActionWithOptions(virtualroutersResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.VirtualRouter), err } // List takes label and field selectors, and returns the list of VirtualRouters that match those selectors. func (c *FakeVirtualRouters) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.VirtualRouterList, err error) { + emptyResult := &v1beta2.VirtualRouterList{} obj, err := c.Fake. - Invokes(testing.NewListAction(virtualroutersResource, virtualroutersKind, c.ns, opts), &v1beta2.VirtualRouterList{}) + Invokes(testing.NewListActionWithOptions(virtualroutersResource, virtualroutersKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,40 +77,43 @@ func (c *FakeVirtualRouters) List(ctx context.Context, opts v1.ListOptions) (res // Watch returns a watch.Interface that watches the requested virtualRouters. func (c *FakeVirtualRouters) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(virtualroutersResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(virtualroutersResource, c.ns, opts)) } // Create takes the representation of a virtualRouter and creates it. Returns the server's representation of the virtualRouter, and an error, if there is any. func (c *FakeVirtualRouters) Create(ctx context.Context, virtualRouter *v1beta2.VirtualRouter, opts v1.CreateOptions) (result *v1beta2.VirtualRouter, err error) { + emptyResult := &v1beta2.VirtualRouter{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(virtualroutersResource, c.ns, virtualRouter), &v1beta2.VirtualRouter{}) + Invokes(testing.NewCreateActionWithOptions(virtualroutersResource, c.ns, virtualRouter, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.VirtualRouter), err } // Update takes the representation of a virtualRouter and updates it. Returns the server's representation of the virtualRouter, and an error, if there is any. func (c *FakeVirtualRouters) Update(ctx context.Context, virtualRouter *v1beta2.VirtualRouter, opts v1.UpdateOptions) (result *v1beta2.VirtualRouter, err error) { + emptyResult := &v1beta2.VirtualRouter{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(virtualroutersResource, c.ns, virtualRouter), &v1beta2.VirtualRouter{}) + Invokes(testing.NewUpdateActionWithOptions(virtualroutersResource, c.ns, virtualRouter, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.VirtualRouter), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeVirtualRouters) UpdateStatus(ctx context.Context, virtualRouter *v1beta2.VirtualRouter, opts v1.UpdateOptions) (*v1beta2.VirtualRouter, error) { +func (c *FakeVirtualRouters) UpdateStatus(ctx context.Context, virtualRouter *v1beta2.VirtualRouter, opts v1.UpdateOptions) (result *v1beta2.VirtualRouter, err error) { + emptyResult := &v1beta2.VirtualRouter{} obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(virtualroutersResource, "status", c.ns, virtualRouter), &v1beta2.VirtualRouter{}) + Invokes(testing.NewUpdateSubresourceActionWithOptions(virtualroutersResource, "status", c.ns, virtualRouter, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.VirtualRouter), err } @@ -123,7 +128,7 @@ func (c *FakeVirtualRouters) Delete(ctx context.Context, name string, opts v1.De // DeleteCollection deletes a collection of objects. func (c *FakeVirtualRouters) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(virtualroutersResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(virtualroutersResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1beta2.VirtualRouterList{}) return err @@ -131,11 +136,12 @@ func (c *FakeVirtualRouters) DeleteCollection(ctx context.Context, opts v1.Delet // Patch applies the patch and returns the patched virtualRouter. func (c *FakeVirtualRouters) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.VirtualRouter, err error) { + emptyResult := &v1beta2.VirtualRouter{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(virtualroutersResource, c.ns, name, pt, data, subresources...), &v1beta2.VirtualRouter{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(virtualroutersResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.VirtualRouter), err } diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta2/fake/fake_virtualservice.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta2/fake/fake_virtualservice.go index 167dafe0f..cb4f72633 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta2/fake/fake_virtualservice.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta2/fake/fake_virtualservice.go @@ -41,22 +41,24 @@ var virtualservicesKind = v1beta2.SchemeGroupVersion.WithKind("VirtualService") // Get takes name of the virtualService, and returns the corresponding virtualService object, and an error if there is any. func (c *FakeVirtualServices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.VirtualService, err error) { + emptyResult := &v1beta2.VirtualService{} obj, err := c.Fake. - Invokes(testing.NewGetAction(virtualservicesResource, c.ns, name), &v1beta2.VirtualService{}) + Invokes(testing.NewGetActionWithOptions(virtualservicesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.VirtualService), err } // List takes label and field selectors, and returns the list of VirtualServices that match those selectors. func (c *FakeVirtualServices) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.VirtualServiceList, err error) { + emptyResult := &v1beta2.VirtualServiceList{} obj, err := c.Fake. - Invokes(testing.NewListAction(virtualservicesResource, virtualservicesKind, c.ns, opts), &v1beta2.VirtualServiceList{}) + Invokes(testing.NewListActionWithOptions(virtualservicesResource, virtualservicesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,40 +77,43 @@ func (c *FakeVirtualServices) List(ctx context.Context, opts v1.ListOptions) (re // Watch returns a watch.Interface that watches the requested virtualServices. func (c *FakeVirtualServices) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(virtualservicesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(virtualservicesResource, c.ns, opts)) } // Create takes the representation of a virtualService and creates it. Returns the server's representation of the virtualService, and an error, if there is any. func (c *FakeVirtualServices) Create(ctx context.Context, virtualService *v1beta2.VirtualService, opts v1.CreateOptions) (result *v1beta2.VirtualService, err error) { + emptyResult := &v1beta2.VirtualService{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(virtualservicesResource, c.ns, virtualService), &v1beta2.VirtualService{}) + Invokes(testing.NewCreateActionWithOptions(virtualservicesResource, c.ns, virtualService, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.VirtualService), err } // Update takes the representation of a virtualService and updates it. Returns the server's representation of the virtualService, and an error, if there is any. func (c *FakeVirtualServices) Update(ctx context.Context, virtualService *v1beta2.VirtualService, opts v1.UpdateOptions) (result *v1beta2.VirtualService, err error) { + emptyResult := &v1beta2.VirtualService{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(virtualservicesResource, c.ns, virtualService), &v1beta2.VirtualService{}) + Invokes(testing.NewUpdateActionWithOptions(virtualservicesResource, c.ns, virtualService, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.VirtualService), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeVirtualServices) UpdateStatus(ctx context.Context, virtualService *v1beta2.VirtualService, opts v1.UpdateOptions) (*v1beta2.VirtualService, error) { +func (c *FakeVirtualServices) UpdateStatus(ctx context.Context, virtualService *v1beta2.VirtualService, opts v1.UpdateOptions) (result *v1beta2.VirtualService, err error) { + emptyResult := &v1beta2.VirtualService{} obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(virtualservicesResource, "status", c.ns, virtualService), &v1beta2.VirtualService{}) + Invokes(testing.NewUpdateSubresourceActionWithOptions(virtualservicesResource, "status", c.ns, virtualService, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.VirtualService), err } @@ -123,7 +128,7 @@ func (c *FakeVirtualServices) Delete(ctx context.Context, name string, opts v1.D // DeleteCollection deletes a collection of objects. func (c *FakeVirtualServices) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(virtualservicesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(virtualservicesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1beta2.VirtualServiceList{}) return err @@ -131,11 +136,12 @@ func (c *FakeVirtualServices) DeleteCollection(ctx context.Context, opts v1.Dele // Patch applies the patch and returns the patched virtualService. func (c *FakeVirtualServices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.VirtualService, err error) { + emptyResult := &v1beta2.VirtualService{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(virtualservicesResource, c.ns, name, pt, data, subresources...), &v1beta2.VirtualService{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(virtualservicesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta2.VirtualService), err } diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta2/virtualnode.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta2/virtualnode.go index 2ca0f710f..047cf749a 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta2/virtualnode.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta2/virtualnode.go @@ -20,14 +20,13 @@ package v1beta2 import ( "context" - "time" v1beta2 "github.com/fluxcd/flagger/pkg/apis/appmesh/v1beta2" scheme "github.com/fluxcd/flagger/pkg/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" ) // VirtualNodesGetter has a method to return a VirtualNodeInterface. @@ -40,6 +39,7 @@ type VirtualNodesGetter interface { type VirtualNodeInterface interface { Create(ctx context.Context, virtualNode *v1beta2.VirtualNode, opts v1.CreateOptions) (*v1beta2.VirtualNode, error) Update(ctx context.Context, virtualNode *v1beta2.VirtualNode, opts v1.UpdateOptions) (*v1beta2.VirtualNode, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, virtualNode *v1beta2.VirtualNode, opts v1.UpdateOptions) (*v1beta2.VirtualNode, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error @@ -52,144 +52,18 @@ type VirtualNodeInterface interface { // virtualNodes implements VirtualNodeInterface type virtualNodes struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1beta2.VirtualNode, *v1beta2.VirtualNodeList] } // newVirtualNodes returns a VirtualNodes func newVirtualNodes(c *AppmeshV1beta2Client, namespace string) *virtualNodes { return &virtualNodes{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1beta2.VirtualNode, *v1beta2.VirtualNodeList]( + "virtualnodes", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1beta2.VirtualNode { return &v1beta2.VirtualNode{} }, + func() *v1beta2.VirtualNodeList { return &v1beta2.VirtualNodeList{} }), } } - -// Get takes name of the virtualNode, and returns the corresponding virtualNode object, and an error if there is any. -func (c *virtualNodes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.VirtualNode, err error) { - result = &v1beta2.VirtualNode{} - err = c.client.Get(). - Namespace(c.ns). - Resource("virtualnodes"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of VirtualNodes that match those selectors. -func (c *virtualNodes) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.VirtualNodeList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta2.VirtualNodeList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("virtualnodes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested virtualNodes. -func (c *virtualNodes) 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("virtualnodes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a virtualNode and creates it. Returns the server's representation of the virtualNode, and an error, if there is any. -func (c *virtualNodes) Create(ctx context.Context, virtualNode *v1beta2.VirtualNode, opts v1.CreateOptions) (result *v1beta2.VirtualNode, err error) { - result = &v1beta2.VirtualNode{} - err = c.client.Post(). - Namespace(c.ns). - Resource("virtualnodes"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(virtualNode). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a virtualNode and updates it. Returns the server's representation of the virtualNode, and an error, if there is any. -func (c *virtualNodes) Update(ctx context.Context, virtualNode *v1beta2.VirtualNode, opts v1.UpdateOptions) (result *v1beta2.VirtualNode, err error) { - result = &v1beta2.VirtualNode{} - err = c.client.Put(). - Namespace(c.ns). - Resource("virtualnodes"). - Name(virtualNode.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(virtualNode). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *virtualNodes) UpdateStatus(ctx context.Context, virtualNode *v1beta2.VirtualNode, opts v1.UpdateOptions) (result *v1beta2.VirtualNode, err error) { - result = &v1beta2.VirtualNode{} - err = c.client.Put(). - Namespace(c.ns). - Resource("virtualnodes"). - Name(virtualNode.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(virtualNode). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the virtualNode and deletes it. Returns an error if one occurs. -func (c *virtualNodes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("virtualnodes"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *virtualNodes) 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("virtualnodes"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched virtualNode. -func (c *virtualNodes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.VirtualNode, err error) { - result = &v1beta2.VirtualNode{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("virtualnodes"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta2/virtualrouter.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta2/virtualrouter.go index bd2daad19..34602c10f 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta2/virtualrouter.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta2/virtualrouter.go @@ -20,14 +20,13 @@ package v1beta2 import ( "context" - "time" v1beta2 "github.com/fluxcd/flagger/pkg/apis/appmesh/v1beta2" scheme "github.com/fluxcd/flagger/pkg/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" ) // VirtualRoutersGetter has a method to return a VirtualRouterInterface. @@ -40,6 +39,7 @@ type VirtualRoutersGetter interface { type VirtualRouterInterface interface { Create(ctx context.Context, virtualRouter *v1beta2.VirtualRouter, opts v1.CreateOptions) (*v1beta2.VirtualRouter, error) Update(ctx context.Context, virtualRouter *v1beta2.VirtualRouter, opts v1.UpdateOptions) (*v1beta2.VirtualRouter, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, virtualRouter *v1beta2.VirtualRouter, opts v1.UpdateOptions) (*v1beta2.VirtualRouter, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error @@ -52,144 +52,18 @@ type VirtualRouterInterface interface { // virtualRouters implements VirtualRouterInterface type virtualRouters struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1beta2.VirtualRouter, *v1beta2.VirtualRouterList] } // newVirtualRouters returns a VirtualRouters func newVirtualRouters(c *AppmeshV1beta2Client, namespace string) *virtualRouters { return &virtualRouters{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1beta2.VirtualRouter, *v1beta2.VirtualRouterList]( + "virtualrouters", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1beta2.VirtualRouter { return &v1beta2.VirtualRouter{} }, + func() *v1beta2.VirtualRouterList { return &v1beta2.VirtualRouterList{} }), } } - -// Get takes name of the virtualRouter, and returns the corresponding virtualRouter object, and an error if there is any. -func (c *virtualRouters) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.VirtualRouter, err error) { - result = &v1beta2.VirtualRouter{} - err = c.client.Get(). - Namespace(c.ns). - Resource("virtualrouters"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of VirtualRouters that match those selectors. -func (c *virtualRouters) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.VirtualRouterList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta2.VirtualRouterList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("virtualrouters"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested virtualRouters. -func (c *virtualRouters) 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("virtualrouters"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a virtualRouter and creates it. Returns the server's representation of the virtualRouter, and an error, if there is any. -func (c *virtualRouters) Create(ctx context.Context, virtualRouter *v1beta2.VirtualRouter, opts v1.CreateOptions) (result *v1beta2.VirtualRouter, err error) { - result = &v1beta2.VirtualRouter{} - err = c.client.Post(). - Namespace(c.ns). - Resource("virtualrouters"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(virtualRouter). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a virtualRouter and updates it. Returns the server's representation of the virtualRouter, and an error, if there is any. -func (c *virtualRouters) Update(ctx context.Context, virtualRouter *v1beta2.VirtualRouter, opts v1.UpdateOptions) (result *v1beta2.VirtualRouter, err error) { - result = &v1beta2.VirtualRouter{} - err = c.client.Put(). - Namespace(c.ns). - Resource("virtualrouters"). - Name(virtualRouter.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(virtualRouter). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *virtualRouters) UpdateStatus(ctx context.Context, virtualRouter *v1beta2.VirtualRouter, opts v1.UpdateOptions) (result *v1beta2.VirtualRouter, err error) { - result = &v1beta2.VirtualRouter{} - err = c.client.Put(). - Namespace(c.ns). - Resource("virtualrouters"). - Name(virtualRouter.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(virtualRouter). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the virtualRouter and deletes it. Returns an error if one occurs. -func (c *virtualRouters) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("virtualrouters"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *virtualRouters) 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("virtualrouters"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched virtualRouter. -func (c *virtualRouters) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.VirtualRouter, err error) { - result = &v1beta2.VirtualRouter{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("virtualrouters"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/appmesh/v1beta2/virtualservice.go b/pkg/client/clientset/versioned/typed/appmesh/v1beta2/virtualservice.go index caa79fbfd..b9925e7be 100644 --- a/pkg/client/clientset/versioned/typed/appmesh/v1beta2/virtualservice.go +++ b/pkg/client/clientset/versioned/typed/appmesh/v1beta2/virtualservice.go @@ -20,14 +20,13 @@ package v1beta2 import ( "context" - "time" v1beta2 "github.com/fluxcd/flagger/pkg/apis/appmesh/v1beta2" scheme "github.com/fluxcd/flagger/pkg/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" ) // VirtualServicesGetter has a method to return a VirtualServiceInterface. @@ -40,6 +39,7 @@ type VirtualServicesGetter interface { type VirtualServiceInterface interface { Create(ctx context.Context, virtualService *v1beta2.VirtualService, opts v1.CreateOptions) (*v1beta2.VirtualService, error) Update(ctx context.Context, virtualService *v1beta2.VirtualService, opts v1.UpdateOptions) (*v1beta2.VirtualService, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, virtualService *v1beta2.VirtualService, opts v1.UpdateOptions) (*v1beta2.VirtualService, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error @@ -52,144 +52,18 @@ type VirtualServiceInterface interface { // virtualServices implements VirtualServiceInterface type virtualServices struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1beta2.VirtualService, *v1beta2.VirtualServiceList] } // newVirtualServices returns a VirtualServices func newVirtualServices(c *AppmeshV1beta2Client, namespace string) *virtualServices { return &virtualServices{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1beta2.VirtualService, *v1beta2.VirtualServiceList]( + "virtualservices", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1beta2.VirtualService { return &v1beta2.VirtualService{} }, + func() *v1beta2.VirtualServiceList { return &v1beta2.VirtualServiceList{} }), } } - -// Get takes name of the virtualService, and returns the corresponding virtualService object, and an error if there is any. -func (c *virtualServices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta2.VirtualService, err error) { - result = &v1beta2.VirtualService{} - err = c.client.Get(). - Namespace(c.ns). - Resource("virtualservices"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of VirtualServices that match those selectors. -func (c *virtualServices) List(ctx context.Context, opts v1.ListOptions) (result *v1beta2.VirtualServiceList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta2.VirtualServiceList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("virtualservices"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested virtualServices. -func (c *virtualServices) 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("virtualservices"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a virtualService and creates it. Returns the server's representation of the virtualService, and an error, if there is any. -func (c *virtualServices) Create(ctx context.Context, virtualService *v1beta2.VirtualService, opts v1.CreateOptions) (result *v1beta2.VirtualService, err error) { - result = &v1beta2.VirtualService{} - err = c.client.Post(). - Namespace(c.ns). - Resource("virtualservices"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(virtualService). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a virtualService and updates it. Returns the server's representation of the virtualService, and an error, if there is any. -func (c *virtualServices) Update(ctx context.Context, virtualService *v1beta2.VirtualService, opts v1.UpdateOptions) (result *v1beta2.VirtualService, err error) { - result = &v1beta2.VirtualService{} - err = c.client.Put(). - Namespace(c.ns). - Resource("virtualservices"). - Name(virtualService.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(virtualService). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *virtualServices) UpdateStatus(ctx context.Context, virtualService *v1beta2.VirtualService, opts v1.UpdateOptions) (result *v1beta2.VirtualService, err error) { - result = &v1beta2.VirtualService{} - err = c.client.Put(). - Namespace(c.ns). - Resource("virtualservices"). - Name(virtualService.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(virtualService). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the virtualService and deletes it. Returns an error if one occurs. -func (c *virtualServices) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("virtualservices"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *virtualServices) 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("virtualservices"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched virtualService. -func (c *virtualServices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta2.VirtualService, err error) { - result = &v1beta2.VirtualService{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("virtualservices"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/flagger/v1beta1/alertprovider.go b/pkg/client/clientset/versioned/typed/flagger/v1beta1/alertprovider.go index 8210838b9..93ab94e38 100644 --- a/pkg/client/clientset/versioned/typed/flagger/v1beta1/alertprovider.go +++ b/pkg/client/clientset/versioned/typed/flagger/v1beta1/alertprovider.go @@ -20,14 +20,13 @@ package v1beta1 import ( "context" - "time" v1beta1 "github.com/fluxcd/flagger/pkg/apis/flagger/v1beta1" scheme "github.com/fluxcd/flagger/pkg/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" ) // AlertProvidersGetter has a method to return a AlertProviderInterface. @@ -40,6 +39,7 @@ type AlertProvidersGetter interface { type AlertProviderInterface interface { Create(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.CreateOptions) (*v1beta1.AlertProvider, error) Update(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.UpdateOptions) (*v1beta1.AlertProvider, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.UpdateOptions) (*v1beta1.AlertProvider, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error @@ -52,144 +52,18 @@ type AlertProviderInterface interface { // alertProviders implements AlertProviderInterface type alertProviders struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1beta1.AlertProvider, *v1beta1.AlertProviderList] } // newAlertProviders returns a AlertProviders func newAlertProviders(c *FlaggerV1beta1Client, namespace string) *alertProviders { return &alertProviders{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1beta1.AlertProvider, *v1beta1.AlertProviderList]( + "alertproviders", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1beta1.AlertProvider { return &v1beta1.AlertProvider{} }, + func() *v1beta1.AlertProviderList { return &v1beta1.AlertProviderList{} }), } } - -// Get takes name of the alertProvider, and returns the corresponding alertProvider object, and an error if there is any. -func (c *alertProviders) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.AlertProvider, err error) { - result = &v1beta1.AlertProvider{} - err = c.client.Get(). - Namespace(c.ns). - Resource("alertproviders"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of AlertProviders that match those selectors. -func (c *alertProviders) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.AlertProviderList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta1.AlertProviderList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("alertproviders"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested alertProviders. -func (c *alertProviders) 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("alertproviders"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a alertProvider and creates it. Returns the server's representation of the alertProvider, and an error, if there is any. -func (c *alertProviders) Create(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.CreateOptions) (result *v1beta1.AlertProvider, err error) { - result = &v1beta1.AlertProvider{} - err = c.client.Post(). - Namespace(c.ns). - Resource("alertproviders"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(alertProvider). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a alertProvider and updates it. Returns the server's representation of the alertProvider, and an error, if there is any. -func (c *alertProviders) Update(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.UpdateOptions) (result *v1beta1.AlertProvider, err error) { - result = &v1beta1.AlertProvider{} - err = c.client.Put(). - Namespace(c.ns). - Resource("alertproviders"). - Name(alertProvider.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(alertProvider). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *alertProviders) UpdateStatus(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.UpdateOptions) (result *v1beta1.AlertProvider, err error) { - result = &v1beta1.AlertProvider{} - err = c.client.Put(). - Namespace(c.ns). - Resource("alertproviders"). - Name(alertProvider.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(alertProvider). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the alertProvider and deletes it. Returns an error if one occurs. -func (c *alertProviders) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("alertproviders"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *alertProviders) 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("alertproviders"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched alertProvider. -func (c *alertProviders) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.AlertProvider, err error) { - result = &v1beta1.AlertProvider{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("alertproviders"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/flagger/v1beta1/canary.go b/pkg/client/clientset/versioned/typed/flagger/v1beta1/canary.go index 18a332c13..612db0d2e 100644 --- a/pkg/client/clientset/versioned/typed/flagger/v1beta1/canary.go +++ b/pkg/client/clientset/versioned/typed/flagger/v1beta1/canary.go @@ -20,14 +20,13 @@ package v1beta1 import ( "context" - "time" v1beta1 "github.com/fluxcd/flagger/pkg/apis/flagger/v1beta1" scheme "github.com/fluxcd/flagger/pkg/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" ) // CanariesGetter has a method to return a CanaryInterface. @@ -40,6 +39,7 @@ type CanariesGetter interface { type CanaryInterface interface { Create(ctx context.Context, canary *v1beta1.Canary, opts v1.CreateOptions) (*v1beta1.Canary, error) Update(ctx context.Context, canary *v1beta1.Canary, opts v1.UpdateOptions) (*v1beta1.Canary, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, canary *v1beta1.Canary, opts v1.UpdateOptions) (*v1beta1.Canary, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error @@ -52,144 +52,18 @@ type CanaryInterface interface { // canaries implements CanaryInterface type canaries struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1beta1.Canary, *v1beta1.CanaryList] } // newCanaries returns a Canaries func newCanaries(c *FlaggerV1beta1Client, namespace string) *canaries { return &canaries{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1beta1.Canary, *v1beta1.CanaryList]( + "canaries", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1beta1.Canary { return &v1beta1.Canary{} }, + func() *v1beta1.CanaryList { return &v1beta1.CanaryList{} }), } } - -// Get takes name of the canary, and returns the corresponding canary object, and an error if there is any. -func (c *canaries) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Canary, err error) { - result = &v1beta1.Canary{} - err = c.client.Get(). - Namespace(c.ns). - Resource("canaries"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Canaries that match those selectors. -func (c *canaries) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CanaryList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta1.CanaryList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("canaries"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested canaries. -func (c *canaries) 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("canaries"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a canary and creates it. Returns the server's representation of the canary, and an error, if there is any. -func (c *canaries) Create(ctx context.Context, canary *v1beta1.Canary, opts v1.CreateOptions) (result *v1beta1.Canary, err error) { - result = &v1beta1.Canary{} - err = c.client.Post(). - Namespace(c.ns). - Resource("canaries"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(canary). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a canary and updates it. Returns the server's representation of the canary, and an error, if there is any. -func (c *canaries) Update(ctx context.Context, canary *v1beta1.Canary, opts v1.UpdateOptions) (result *v1beta1.Canary, err error) { - result = &v1beta1.Canary{} - err = c.client.Put(). - Namespace(c.ns). - Resource("canaries"). - Name(canary.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(canary). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *canaries) UpdateStatus(ctx context.Context, canary *v1beta1.Canary, opts v1.UpdateOptions) (result *v1beta1.Canary, err error) { - result = &v1beta1.Canary{} - err = c.client.Put(). - Namespace(c.ns). - Resource("canaries"). - Name(canary.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(canary). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the canary and deletes it. Returns an error if one occurs. -func (c *canaries) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("canaries"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *canaries) 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("canaries"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched canary. -func (c *canaries) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Canary, err error) { - result = &v1beta1.Canary{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("canaries"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_alertprovider.go b/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_alertprovider.go index 701329438..3b2b7391f 100644 --- a/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_alertprovider.go +++ b/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_alertprovider.go @@ -41,22 +41,24 @@ var alertprovidersKind = v1beta1.SchemeGroupVersion.WithKind("AlertProvider") // Get takes name of the alertProvider, and returns the corresponding alertProvider object, and an error if there is any. func (c *FakeAlertProviders) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.AlertProvider, err error) { + emptyResult := &v1beta1.AlertProvider{} obj, err := c.Fake. - Invokes(testing.NewGetAction(alertprovidersResource, c.ns, name), &v1beta1.AlertProvider{}) + Invokes(testing.NewGetActionWithOptions(alertprovidersResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.AlertProvider), err } // List takes label and field selectors, and returns the list of AlertProviders that match those selectors. func (c *FakeAlertProviders) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.AlertProviderList, err error) { + emptyResult := &v1beta1.AlertProviderList{} obj, err := c.Fake. - Invokes(testing.NewListAction(alertprovidersResource, alertprovidersKind, c.ns, opts), &v1beta1.AlertProviderList{}) + Invokes(testing.NewListActionWithOptions(alertprovidersResource, alertprovidersKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,40 +77,43 @@ func (c *FakeAlertProviders) List(ctx context.Context, opts v1.ListOptions) (res // Watch returns a watch.Interface that watches the requested alertProviders. func (c *FakeAlertProviders) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(alertprovidersResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(alertprovidersResource, c.ns, opts)) } // Create takes the representation of a alertProvider and creates it. Returns the server's representation of the alertProvider, and an error, if there is any. func (c *FakeAlertProviders) Create(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.CreateOptions) (result *v1beta1.AlertProvider, err error) { + emptyResult := &v1beta1.AlertProvider{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(alertprovidersResource, c.ns, alertProvider), &v1beta1.AlertProvider{}) + Invokes(testing.NewCreateActionWithOptions(alertprovidersResource, c.ns, alertProvider, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.AlertProvider), err } // Update takes the representation of a alertProvider and updates it. Returns the server's representation of the alertProvider, and an error, if there is any. func (c *FakeAlertProviders) Update(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.UpdateOptions) (result *v1beta1.AlertProvider, err error) { + emptyResult := &v1beta1.AlertProvider{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(alertprovidersResource, c.ns, alertProvider), &v1beta1.AlertProvider{}) + Invokes(testing.NewUpdateActionWithOptions(alertprovidersResource, c.ns, alertProvider, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.AlertProvider), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeAlertProviders) UpdateStatus(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.UpdateOptions) (*v1beta1.AlertProvider, error) { +func (c *FakeAlertProviders) UpdateStatus(ctx context.Context, alertProvider *v1beta1.AlertProvider, opts v1.UpdateOptions) (result *v1beta1.AlertProvider, err error) { + emptyResult := &v1beta1.AlertProvider{} obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(alertprovidersResource, "status", c.ns, alertProvider), &v1beta1.AlertProvider{}) + Invokes(testing.NewUpdateSubresourceActionWithOptions(alertprovidersResource, "status", c.ns, alertProvider, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.AlertProvider), err } @@ -123,7 +128,7 @@ func (c *FakeAlertProviders) Delete(ctx context.Context, name string, opts v1.De // DeleteCollection deletes a collection of objects. func (c *FakeAlertProviders) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(alertprovidersResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(alertprovidersResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.AlertProviderList{}) return err @@ -131,11 +136,12 @@ func (c *FakeAlertProviders) DeleteCollection(ctx context.Context, opts v1.Delet // Patch applies the patch and returns the patched alertProvider. func (c *FakeAlertProviders) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.AlertProvider, err error) { + emptyResult := &v1beta1.AlertProvider{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(alertprovidersResource, c.ns, name, pt, data, subresources...), &v1beta1.AlertProvider{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(alertprovidersResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.AlertProvider), err } diff --git a/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_canary.go b/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_canary.go index 7f66ee02b..2767fba7a 100644 --- a/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_canary.go +++ b/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_canary.go @@ -41,22 +41,24 @@ var canariesKind = v1beta1.SchemeGroupVersion.WithKind("Canary") // Get takes name of the canary, and returns the corresponding canary object, and an error if there is any. func (c *FakeCanaries) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.Canary, err error) { + emptyResult := &v1beta1.Canary{} obj, err := c.Fake. - Invokes(testing.NewGetAction(canariesResource, c.ns, name), &v1beta1.Canary{}) + Invokes(testing.NewGetActionWithOptions(canariesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.Canary), err } // List takes label and field selectors, and returns the list of Canaries that match those selectors. func (c *FakeCanaries) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.CanaryList, err error) { + emptyResult := &v1beta1.CanaryList{} obj, err := c.Fake. - Invokes(testing.NewListAction(canariesResource, canariesKind, c.ns, opts), &v1beta1.CanaryList{}) + Invokes(testing.NewListActionWithOptions(canariesResource, canariesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,40 +77,43 @@ func (c *FakeCanaries) List(ctx context.Context, opts v1.ListOptions) (result *v // Watch returns a watch.Interface that watches the requested canaries. func (c *FakeCanaries) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(canariesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(canariesResource, c.ns, opts)) } // Create takes the representation of a canary and creates it. Returns the server's representation of the canary, and an error, if there is any. func (c *FakeCanaries) Create(ctx context.Context, canary *v1beta1.Canary, opts v1.CreateOptions) (result *v1beta1.Canary, err error) { + emptyResult := &v1beta1.Canary{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(canariesResource, c.ns, canary), &v1beta1.Canary{}) + Invokes(testing.NewCreateActionWithOptions(canariesResource, c.ns, canary, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.Canary), err } // Update takes the representation of a canary and updates it. Returns the server's representation of the canary, and an error, if there is any. func (c *FakeCanaries) Update(ctx context.Context, canary *v1beta1.Canary, opts v1.UpdateOptions) (result *v1beta1.Canary, err error) { + emptyResult := &v1beta1.Canary{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(canariesResource, c.ns, canary), &v1beta1.Canary{}) + Invokes(testing.NewUpdateActionWithOptions(canariesResource, c.ns, canary, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.Canary), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeCanaries) UpdateStatus(ctx context.Context, canary *v1beta1.Canary, opts v1.UpdateOptions) (*v1beta1.Canary, error) { +func (c *FakeCanaries) UpdateStatus(ctx context.Context, canary *v1beta1.Canary, opts v1.UpdateOptions) (result *v1beta1.Canary, err error) { + emptyResult := &v1beta1.Canary{} obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(canariesResource, "status", c.ns, canary), &v1beta1.Canary{}) + Invokes(testing.NewUpdateSubresourceActionWithOptions(canariesResource, "status", c.ns, canary, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.Canary), err } @@ -123,7 +128,7 @@ func (c *FakeCanaries) Delete(ctx context.Context, name string, opts v1.DeleteOp // DeleteCollection deletes a collection of objects. func (c *FakeCanaries) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(canariesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(canariesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.CanaryList{}) return err @@ -131,11 +136,12 @@ func (c *FakeCanaries) DeleteCollection(ctx context.Context, opts v1.DeleteOptio // Patch applies the patch and returns the patched canary. func (c *FakeCanaries) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.Canary, err error) { + emptyResult := &v1beta1.Canary{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(canariesResource, c.ns, name, pt, data, subresources...), &v1beta1.Canary{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(canariesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.Canary), err } diff --git a/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_metrictemplate.go b/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_metrictemplate.go index 33e417e2a..da6b10615 100644 --- a/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_metrictemplate.go +++ b/pkg/client/clientset/versioned/typed/flagger/v1beta1/fake/fake_metrictemplate.go @@ -41,22 +41,24 @@ var metrictemplatesKind = v1beta1.SchemeGroupVersion.WithKind("MetricTemplate") // Get takes name of the metricTemplate, and returns the corresponding metricTemplate object, and an error if there is any. func (c *FakeMetricTemplates) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.MetricTemplate, err error) { + emptyResult := &v1beta1.MetricTemplate{} obj, err := c.Fake. - Invokes(testing.NewGetAction(metrictemplatesResource, c.ns, name), &v1beta1.MetricTemplate{}) + Invokes(testing.NewGetActionWithOptions(metrictemplatesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.MetricTemplate), err } // List takes label and field selectors, and returns the list of MetricTemplates that match those selectors. func (c *FakeMetricTemplates) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.MetricTemplateList, err error) { + emptyResult := &v1beta1.MetricTemplateList{} obj, err := c.Fake. - Invokes(testing.NewListAction(metrictemplatesResource, metrictemplatesKind, c.ns, opts), &v1beta1.MetricTemplateList{}) + Invokes(testing.NewListActionWithOptions(metrictemplatesResource, metrictemplatesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,40 +77,43 @@ func (c *FakeMetricTemplates) List(ctx context.Context, opts v1.ListOptions) (re // Watch returns a watch.Interface that watches the requested metricTemplates. func (c *FakeMetricTemplates) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(metrictemplatesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(metrictemplatesResource, c.ns, opts)) } // Create takes the representation of a metricTemplate and creates it. Returns the server's representation of the metricTemplate, and an error, if there is any. func (c *FakeMetricTemplates) Create(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.CreateOptions) (result *v1beta1.MetricTemplate, err error) { + emptyResult := &v1beta1.MetricTemplate{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(metrictemplatesResource, c.ns, metricTemplate), &v1beta1.MetricTemplate{}) + Invokes(testing.NewCreateActionWithOptions(metrictemplatesResource, c.ns, metricTemplate, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.MetricTemplate), err } // Update takes the representation of a metricTemplate and updates it. Returns the server's representation of the metricTemplate, and an error, if there is any. func (c *FakeMetricTemplates) Update(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.UpdateOptions) (result *v1beta1.MetricTemplate, err error) { + emptyResult := &v1beta1.MetricTemplate{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(metrictemplatesResource, c.ns, metricTemplate), &v1beta1.MetricTemplate{}) + Invokes(testing.NewUpdateActionWithOptions(metrictemplatesResource, c.ns, metricTemplate, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.MetricTemplate), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeMetricTemplates) UpdateStatus(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.UpdateOptions) (*v1beta1.MetricTemplate, error) { +func (c *FakeMetricTemplates) UpdateStatus(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.UpdateOptions) (result *v1beta1.MetricTemplate, err error) { + emptyResult := &v1beta1.MetricTemplate{} obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(metrictemplatesResource, "status", c.ns, metricTemplate), &v1beta1.MetricTemplate{}) + Invokes(testing.NewUpdateSubresourceActionWithOptions(metrictemplatesResource, "status", c.ns, metricTemplate, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.MetricTemplate), err } @@ -123,7 +128,7 @@ func (c *FakeMetricTemplates) Delete(ctx context.Context, name string, opts v1.D // DeleteCollection deletes a collection of objects. func (c *FakeMetricTemplates) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(metrictemplatesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(metrictemplatesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.MetricTemplateList{}) return err @@ -131,11 +136,12 @@ func (c *FakeMetricTemplates) DeleteCollection(ctx context.Context, opts v1.Dele // Patch applies the patch and returns the patched metricTemplate. func (c *FakeMetricTemplates) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.MetricTemplate, err error) { + emptyResult := &v1beta1.MetricTemplate{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(metrictemplatesResource, c.ns, name, pt, data, subresources...), &v1beta1.MetricTemplate{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(metrictemplatesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.MetricTemplate), err } diff --git a/pkg/client/clientset/versioned/typed/flagger/v1beta1/metrictemplate.go b/pkg/client/clientset/versioned/typed/flagger/v1beta1/metrictemplate.go index 071cc254d..8809e07ce 100644 --- a/pkg/client/clientset/versioned/typed/flagger/v1beta1/metrictemplate.go +++ b/pkg/client/clientset/versioned/typed/flagger/v1beta1/metrictemplate.go @@ -20,14 +20,13 @@ package v1beta1 import ( "context" - "time" v1beta1 "github.com/fluxcd/flagger/pkg/apis/flagger/v1beta1" scheme "github.com/fluxcd/flagger/pkg/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" ) // MetricTemplatesGetter has a method to return a MetricTemplateInterface. @@ -40,6 +39,7 @@ type MetricTemplatesGetter interface { type MetricTemplateInterface interface { Create(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.CreateOptions) (*v1beta1.MetricTemplate, error) Update(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.UpdateOptions) (*v1beta1.MetricTemplate, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.UpdateOptions) (*v1beta1.MetricTemplate, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error @@ -52,144 +52,18 @@ type MetricTemplateInterface interface { // metricTemplates implements MetricTemplateInterface type metricTemplates struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1beta1.MetricTemplate, *v1beta1.MetricTemplateList] } // newMetricTemplates returns a MetricTemplates func newMetricTemplates(c *FlaggerV1beta1Client, namespace string) *metricTemplates { return &metricTemplates{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1beta1.MetricTemplate, *v1beta1.MetricTemplateList]( + "metrictemplates", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1beta1.MetricTemplate { return &v1beta1.MetricTemplate{} }, + func() *v1beta1.MetricTemplateList { return &v1beta1.MetricTemplateList{} }), } } - -// Get takes name of the metricTemplate, and returns the corresponding metricTemplate object, and an error if there is any. -func (c *metricTemplates) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.MetricTemplate, err error) { - result = &v1beta1.MetricTemplate{} - err = c.client.Get(). - Namespace(c.ns). - Resource("metrictemplates"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of MetricTemplates that match those selectors. -func (c *metricTemplates) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.MetricTemplateList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta1.MetricTemplateList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("metrictemplates"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested metricTemplates. -func (c *metricTemplates) 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("metrictemplates"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a metricTemplate and creates it. Returns the server's representation of the metricTemplate, and an error, if there is any. -func (c *metricTemplates) Create(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.CreateOptions) (result *v1beta1.MetricTemplate, err error) { - result = &v1beta1.MetricTemplate{} - err = c.client.Post(). - Namespace(c.ns). - Resource("metrictemplates"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(metricTemplate). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a metricTemplate and updates it. Returns the server's representation of the metricTemplate, and an error, if there is any. -func (c *metricTemplates) Update(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.UpdateOptions) (result *v1beta1.MetricTemplate, err error) { - result = &v1beta1.MetricTemplate{} - err = c.client.Put(). - Namespace(c.ns). - Resource("metrictemplates"). - Name(metricTemplate.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(metricTemplate). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *metricTemplates) UpdateStatus(ctx context.Context, metricTemplate *v1beta1.MetricTemplate, opts v1.UpdateOptions) (result *v1beta1.MetricTemplate, err error) { - result = &v1beta1.MetricTemplate{} - err = c.client.Put(). - Namespace(c.ns). - Resource("metrictemplates"). - Name(metricTemplate.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(metricTemplate). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the metricTemplate and deletes it. Returns an error if one occurs. -func (c *metricTemplates) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("metrictemplates"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *metricTemplates) 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("metrictemplates"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched metricTemplate. -func (c *metricTemplates) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.MetricTemplate, err error) { - result = &v1beta1.MetricTemplate{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("metrictemplates"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/gatewayapi/v1/fake/fake_httproute.go b/pkg/client/clientset/versioned/typed/gatewayapi/v1/fake/fake_httproute.go index 7d622c7f7..ba4a1457e 100644 --- a/pkg/client/clientset/versioned/typed/gatewayapi/v1/fake/fake_httproute.go +++ b/pkg/client/clientset/versioned/typed/gatewayapi/v1/fake/fake_httproute.go @@ -41,22 +41,24 @@ var httproutesKind = v1.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 metav1.GetOptions) (result *v1.HTTPRoute, err error) { + emptyResult := &v1.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewGetAction(httproutesResource, c.ns, name), &v1.HTTPRoute{}) + Invokes(testing.NewGetActionWithOptions(httproutesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.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 metav1.ListOptions) (result *v1.HTTPRouteList, err error) { + emptyResult := &v1.HTTPRouteList{} obj, err := c.Fake. - Invokes(testing.NewListAction(httproutesResource, httproutesKind, c.ns, opts), &v1.HTTPRouteList{}) + Invokes(testing.NewListActionWithOptions(httproutesResource, httproutesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,40 +77,43 @@ func (c *FakeHTTPRoutes) List(ctx context.Context, opts metav1.ListOptions) (res // Watch returns a watch.Interface that watches the requested hTTPRoutes. func (c *FakeHTTPRoutes) Watch(ctx context.Context, opts metav1.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 *v1.HTTPRoute, opts metav1.CreateOptions) (result *v1.HTTPRoute, err error) { + emptyResult := &v1.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(httproutesResource, c.ns, hTTPRoute), &v1.HTTPRoute{}) + Invokes(testing.NewCreateActionWithOptions(httproutesResource, c.ns, hTTPRoute, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.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 *v1.HTTPRoute, opts metav1.UpdateOptions) (result *v1.HTTPRoute, err error) { + emptyResult := &v1.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(httproutesResource, c.ns, hTTPRoute), &v1.HTTPRoute{}) + Invokes(testing.NewUpdateActionWithOptions(httproutesResource, c.ns, hTTPRoute, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.HTTPRoute), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeHTTPRoutes) UpdateStatus(ctx context.Context, hTTPRoute *v1.HTTPRoute, opts metav1.UpdateOptions) (*v1.HTTPRoute, error) { +func (c *FakeHTTPRoutes) UpdateStatus(ctx context.Context, hTTPRoute *v1.HTTPRoute, opts metav1.UpdateOptions) (result *v1.HTTPRoute, err error) { + emptyResult := &v1.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(httproutesResource, "status", c.ns, hTTPRoute), &v1.HTTPRoute{}) + Invokes(testing.NewUpdateSubresourceActionWithOptions(httproutesResource, "status", c.ns, hTTPRoute, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.HTTPRoute), err } @@ -123,7 +128,7 @@ func (c *FakeHTTPRoutes) Delete(ctx context.Context, name string, opts metav1.De // DeleteCollection deletes a collection of objects. func (c *FakeHTTPRoutes) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewDeleteCollectionAction(httproutesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(httproutesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1.HTTPRouteList{}) return err @@ -131,11 +136,12 @@ func (c *FakeHTTPRoutes) DeleteCollection(ctx context.Context, opts metav1.Delet // Patch applies the patch and returns the patched hTTPRoute. func (c *FakeHTTPRoutes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.HTTPRoute, err error) { + emptyResult := &v1.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(httproutesResource, c.ns, name, pt, data, subresources...), &v1.HTTPRoute{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(httproutesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.HTTPRoute), err } diff --git a/pkg/client/clientset/versioned/typed/gatewayapi/v1/httproute.go b/pkg/client/clientset/versioned/typed/gatewayapi/v1/httproute.go index b115d5573..e46cf15da 100644 --- a/pkg/client/clientset/versioned/typed/gatewayapi/v1/httproute.go +++ b/pkg/client/clientset/versioned/typed/gatewayapi/v1/httproute.go @@ -20,14 +20,13 @@ package v1 import ( "context" - "time" v1 "github.com/fluxcd/flagger/pkg/apis/gatewayapi/v1" scheme "github.com/fluxcd/flagger/pkg/client/clientset/versioned/scheme" metav1 "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. @@ -40,6 +39,7 @@ type HTTPRoutesGetter interface { type HTTPRouteInterface interface { Create(ctx context.Context, hTTPRoute *v1.HTTPRoute, opts metav1.CreateOptions) (*v1.HTTPRoute, error) Update(ctx context.Context, hTTPRoute *v1.HTTPRoute, opts metav1.UpdateOptions) (*v1.HTTPRoute, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, hTTPRoute *v1.HTTPRoute, opts metav1.UpdateOptions) (*v1.HTTPRoute, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,144 +52,18 @@ type HTTPRouteInterface interface { // hTTPRoutes implements HTTPRouteInterface type hTTPRoutes struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1.HTTPRoute, *v1.HTTPRouteList] } // newHTTPRoutes returns a HTTPRoutes func newHTTPRoutes(c *GatewayapiV1Client, namespace string) *hTTPRoutes { return &hTTPRoutes{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1.HTTPRoute, *v1.HTTPRouteList]( + "httproutes", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1.HTTPRoute { return &v1.HTTPRoute{} }, + func() *v1.HTTPRouteList { return &v1.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 metav1.GetOptions) (result *v1.HTTPRoute, err error) { - result = &v1.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 metav1.ListOptions) (result *v1.HTTPRouteList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1.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 metav1.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 *v1.HTTPRoute, opts metav1.CreateOptions) (result *v1.HTTPRoute, err error) { - result = &v1.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 *v1.HTTPRoute, opts metav1.UpdateOptions) (result *v1.HTTPRoute, err error) { - result = &v1.HTTPRoute{} - err = c.client.Put(). - Namespace(c.ns). - Resource("httproutes"). - Name(hTTPRoute.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(hTTPRoute). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *hTTPRoutes) UpdateStatus(ctx context.Context, hTTPRoute *v1.HTTPRoute, opts metav1.UpdateOptions) (result *v1.HTTPRoute, err error) { - result = &v1.HTTPRoute{} - err = c.client.Put(). - Namespace(c.ns). - Resource("httproutes"). - Name(hTTPRoute.Name). - SubResource("status"). - 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 metav1.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 metav1.DeleteOptions, listOpts metav1.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 metav1.PatchOptions, subresources ...string) (result *v1.HTTPRoute, err error) { - result = &v1.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/pkg/client/clientset/versioned/typed/gatewayapi/v1beta1/fake/fake_httproute.go b/pkg/client/clientset/versioned/typed/gatewayapi/v1beta1/fake/fake_httproute.go index 89108e2b4..dae821d5b 100644 --- a/pkg/client/clientset/versioned/typed/gatewayapi/v1beta1/fake/fake_httproute.go +++ b/pkg/client/clientset/versioned/typed/gatewayapi/v1beta1/fake/fake_httproute.go @@ -41,22 +41,24 @@ var httproutesKind = v1beta1.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 *v1beta1.HTTPRoute, err error) { + emptyResult := &v1beta1.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewGetAction(httproutesResource, c.ns, name), &v1beta1.HTTPRoute{}) + Invokes(testing.NewGetActionWithOptions(httproutesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.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 *v1beta1.HTTPRouteList, err error) { + emptyResult := &v1beta1.HTTPRouteList{} obj, err := c.Fake. - Invokes(testing.NewListAction(httproutesResource, httproutesKind, c.ns, opts), &v1beta1.HTTPRouteList{}) + Invokes(testing.NewListActionWithOptions(httproutesResource, httproutesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,40 +77,43 @@ 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 *v1beta1.HTTPRoute, opts v1.CreateOptions) (result *v1beta1.HTTPRoute, err error) { + emptyResult := &v1beta1.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(httproutesResource, c.ns, hTTPRoute), &v1beta1.HTTPRoute{}) + Invokes(testing.NewCreateActionWithOptions(httproutesResource, c.ns, hTTPRoute, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.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 *v1beta1.HTTPRoute, opts v1.UpdateOptions) (result *v1beta1.HTTPRoute, err error) { + emptyResult := &v1beta1.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(httproutesResource, c.ns, hTTPRoute), &v1beta1.HTTPRoute{}) + Invokes(testing.NewUpdateActionWithOptions(httproutesResource, c.ns, hTTPRoute, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.HTTPRoute), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeHTTPRoutes) UpdateStatus(ctx context.Context, hTTPRoute *v1beta1.HTTPRoute, opts v1.UpdateOptions) (*v1beta1.HTTPRoute, error) { +func (c *FakeHTTPRoutes) UpdateStatus(ctx context.Context, hTTPRoute *v1beta1.HTTPRoute, opts v1.UpdateOptions) (result *v1beta1.HTTPRoute, err error) { + emptyResult := &v1beta1.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(httproutesResource, "status", c.ns, hTTPRoute), &v1beta1.HTTPRoute{}) + Invokes(testing.NewUpdateSubresourceActionWithOptions(httproutesResource, "status", c.ns, hTTPRoute, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.HTTPRoute), err } @@ -123,7 +128,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, &v1beta1.HTTPRouteList{}) return err @@ -131,11 +136,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 *v1beta1.HTTPRoute, err error) { + emptyResult := &v1beta1.HTTPRoute{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(httproutesResource, c.ns, name, pt, data, subresources...), &v1beta1.HTTPRoute{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(httproutesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.HTTPRoute), err } diff --git a/pkg/client/clientset/versioned/typed/gatewayapi/v1beta1/httproute.go b/pkg/client/clientset/versioned/typed/gatewayapi/v1beta1/httproute.go index a0ddefebc..6bb916924 100644 --- a/pkg/client/clientset/versioned/typed/gatewayapi/v1beta1/httproute.go +++ b/pkg/client/clientset/versioned/typed/gatewayapi/v1beta1/httproute.go @@ -20,14 +20,13 @@ package v1beta1 import ( "context" - "time" v1beta1 "github.com/fluxcd/flagger/pkg/apis/gatewayapi/v1beta1" scheme "github.com/fluxcd/flagger/pkg/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. @@ -40,6 +39,7 @@ type HTTPRoutesGetter interface { type HTTPRouteInterface interface { Create(ctx context.Context, hTTPRoute *v1beta1.HTTPRoute, opts v1.CreateOptions) (*v1beta1.HTTPRoute, error) Update(ctx context.Context, hTTPRoute *v1beta1.HTTPRoute, opts v1.UpdateOptions) (*v1beta1.HTTPRoute, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, hTTPRoute *v1beta1.HTTPRoute, opts v1.UpdateOptions) (*v1beta1.HTTPRoute, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error @@ -52,144 +52,18 @@ type HTTPRouteInterface interface { // hTTPRoutes implements HTTPRouteInterface type hTTPRoutes struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1beta1.HTTPRoute, *v1beta1.HTTPRouteList] } // newHTTPRoutes returns a HTTPRoutes func newHTTPRoutes(c *GatewayapiV1beta1Client, namespace string) *hTTPRoutes { return &hTTPRoutes{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1beta1.HTTPRoute, *v1beta1.HTTPRouteList]( + "httproutes", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1beta1.HTTPRoute { return &v1beta1.HTTPRoute{} }, + func() *v1beta1.HTTPRouteList { return &v1beta1.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 *v1beta1.HTTPRoute, err error) { - result = &v1beta1.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 *v1beta1.HTTPRouteList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta1.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 *v1beta1.HTTPRoute, opts v1.CreateOptions) (result *v1beta1.HTTPRoute, err error) { - result = &v1beta1.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 *v1beta1.HTTPRoute, opts v1.UpdateOptions) (result *v1beta1.HTTPRoute, err error) { - result = &v1beta1.HTTPRoute{} - err = c.client.Put(). - Namespace(c.ns). - Resource("httproutes"). - Name(hTTPRoute.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(hTTPRoute). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *hTTPRoutes) UpdateStatus(ctx context.Context, hTTPRoute *v1beta1.HTTPRoute, opts v1.UpdateOptions) (result *v1beta1.HTTPRoute, err error) { - result = &v1beta1.HTTPRoute{} - err = c.client.Put(). - Namespace(c.ns). - Resource("httproutes"). - Name(hTTPRoute.Name). - SubResource("status"). - 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 *v1beta1.HTTPRoute, err error) { - result = &v1beta1.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/pkg/client/clientset/versioned/typed/gloo/v1/fake/fake_upstream.go b/pkg/client/clientset/versioned/typed/gloo/v1/fake/fake_upstream.go index 4d2d1cc84..b50a00263 100644 --- a/pkg/client/clientset/versioned/typed/gloo/v1/fake/fake_upstream.go +++ b/pkg/client/clientset/versioned/typed/gloo/v1/fake/fake_upstream.go @@ -41,22 +41,24 @@ var upstreamsKind = v1.SchemeGroupVersion.WithKind("Upstream") // Get takes name of the upstream, and returns the corresponding upstream object, and an error if there is any. func (c *FakeUpstreams) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.Upstream, err error) { + emptyResult := &v1.Upstream{} obj, err := c.Fake. - Invokes(testing.NewGetAction(upstreamsResource, c.ns, name), &v1.Upstream{}) + Invokes(testing.NewGetActionWithOptions(upstreamsResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.Upstream), err } // List takes label and field selectors, and returns the list of Upstreams that match those selectors. func (c *FakeUpstreams) List(ctx context.Context, opts metav1.ListOptions) (result *v1.UpstreamList, err error) { + emptyResult := &v1.UpstreamList{} obj, err := c.Fake. - Invokes(testing.NewListAction(upstreamsResource, upstreamsKind, c.ns, opts), &v1.UpstreamList{}) + Invokes(testing.NewListActionWithOptions(upstreamsResource, upstreamsKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeUpstreams) List(ctx context.Context, opts metav1.ListOptions) (resu // Watch returns a watch.Interface that watches the requested upstreams. func (c *FakeUpstreams) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(upstreamsResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(upstreamsResource, c.ns, opts)) } // Create takes the representation of a upstream and creates it. Returns the server's representation of the upstream, and an error, if there is any. func (c *FakeUpstreams) Create(ctx context.Context, upstream *v1.Upstream, opts metav1.CreateOptions) (result *v1.Upstream, err error) { + emptyResult := &v1.Upstream{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(upstreamsResource, c.ns, upstream), &v1.Upstream{}) + Invokes(testing.NewCreateActionWithOptions(upstreamsResource, c.ns, upstream, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.Upstream), err } // Update takes the representation of a upstream and updates it. Returns the server's representation of the upstream, and an error, if there is any. func (c *FakeUpstreams) Update(ctx context.Context, upstream *v1.Upstream, opts metav1.UpdateOptions) (result *v1.Upstream, err error) { + emptyResult := &v1.Upstream{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(upstreamsResource, c.ns, upstream), &v1.Upstream{}) + Invokes(testing.NewUpdateActionWithOptions(upstreamsResource, c.ns, upstream, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.Upstream), err } @@ -111,7 +115,7 @@ func (c *FakeUpstreams) Delete(ctx context.Context, name string, opts metav1.Del // DeleteCollection deletes a collection of objects. func (c *FakeUpstreams) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewDeleteCollectionAction(upstreamsResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(upstreamsResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1.UpstreamList{}) return err @@ -119,11 +123,12 @@ func (c *FakeUpstreams) DeleteCollection(ctx context.Context, opts metav1.Delete // Patch applies the patch and returns the patched upstream. func (c *FakeUpstreams) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Upstream, err error) { + emptyResult := &v1.Upstream{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(upstreamsResource, c.ns, name, pt, data, subresources...), &v1.Upstream{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(upstreamsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.Upstream), err } diff --git a/pkg/client/clientset/versioned/typed/gloo/v1/upstream.go b/pkg/client/clientset/versioned/typed/gloo/v1/upstream.go index 9e465830f..36ac114e8 100644 --- a/pkg/client/clientset/versioned/typed/gloo/v1/upstream.go +++ b/pkg/client/clientset/versioned/typed/gloo/v1/upstream.go @@ -20,14 +20,13 @@ package v1 import ( "context" - "time" v1 "github.com/fluxcd/flagger/pkg/apis/gloo/v1" scheme "github.com/fluxcd/flagger/pkg/client/clientset/versioned/scheme" metav1 "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" ) // UpstreamsGetter has a method to return a UpstreamInterface. @@ -51,128 +50,18 @@ type UpstreamInterface interface { // upstreams implements UpstreamInterface type upstreams struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1.Upstream, *v1.UpstreamList] } // newUpstreams returns a Upstreams func newUpstreams(c *GlooV1Client, namespace string) *upstreams { return &upstreams{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1.Upstream, *v1.UpstreamList]( + "upstreams", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1.Upstream { return &v1.Upstream{} }, + func() *v1.UpstreamList { return &v1.UpstreamList{} }), } } - -// Get takes name of the upstream, and returns the corresponding upstream object, and an error if there is any. -func (c *upstreams) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.Upstream, err error) { - result = &v1.Upstream{} - err = c.client.Get(). - Namespace(c.ns). - Resource("upstreams"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Upstreams that match those selectors. -func (c *upstreams) List(ctx context.Context, opts metav1.ListOptions) (result *v1.UpstreamList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1.UpstreamList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("upstreams"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested upstreams. -func (c *upstreams) Watch(ctx context.Context, opts metav1.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("upstreams"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a upstream and creates it. Returns the server's representation of the upstream, and an error, if there is any. -func (c *upstreams) Create(ctx context.Context, upstream *v1.Upstream, opts metav1.CreateOptions) (result *v1.Upstream, err error) { - result = &v1.Upstream{} - err = c.client.Post(). - Namespace(c.ns). - Resource("upstreams"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(upstream). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a upstream and updates it. Returns the server's representation of the upstream, and an error, if there is any. -func (c *upstreams) Update(ctx context.Context, upstream *v1.Upstream, opts metav1.UpdateOptions) (result *v1.Upstream, err error) { - result = &v1.Upstream{} - err = c.client.Put(). - Namespace(c.ns). - Resource("upstreams"). - Name(upstream.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(upstream). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the upstream and deletes it. Returns an error if one occurs. -func (c *upstreams) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("upstreams"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *upstreams) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.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("upstreams"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched upstream. -func (c *upstreams) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Upstream, err error) { - result = &v1.Upstream{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("upstreams"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/gloogateway/v1/fake/fake_routetable.go b/pkg/client/clientset/versioned/typed/gloogateway/v1/fake/fake_routetable.go index 68eedfa47..a53327860 100644 --- a/pkg/client/clientset/versioned/typed/gloogateway/v1/fake/fake_routetable.go +++ b/pkg/client/clientset/versioned/typed/gloogateway/v1/fake/fake_routetable.go @@ -41,22 +41,24 @@ var routetablesKind = v1.SchemeGroupVersion.WithKind("RouteTable") // Get takes name of the routeTable, and returns the corresponding routeTable object, and an error if there is any. func (c *FakeRouteTables) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.RouteTable, err error) { + emptyResult := &v1.RouteTable{} obj, err := c.Fake. - Invokes(testing.NewGetAction(routetablesResource, c.ns, name), &v1.RouteTable{}) + Invokes(testing.NewGetActionWithOptions(routetablesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.RouteTable), err } // List takes label and field selectors, and returns the list of RouteTables that match those selectors. func (c *FakeRouteTables) List(ctx context.Context, opts metav1.ListOptions) (result *v1.RouteTableList, err error) { + emptyResult := &v1.RouteTableList{} obj, err := c.Fake. - Invokes(testing.NewListAction(routetablesResource, routetablesKind, c.ns, opts), &v1.RouteTableList{}) + Invokes(testing.NewListActionWithOptions(routetablesResource, routetablesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeRouteTables) List(ctx context.Context, opts metav1.ListOptions) (re // Watch returns a watch.Interface that watches the requested routeTables. func (c *FakeRouteTables) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(routetablesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(routetablesResource, c.ns, opts)) } // Create takes the representation of a routeTable and creates it. Returns the server's representation of the routeTable, and an error, if there is any. func (c *FakeRouteTables) Create(ctx context.Context, routeTable *v1.RouteTable, opts metav1.CreateOptions) (result *v1.RouteTable, err error) { + emptyResult := &v1.RouteTable{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(routetablesResource, c.ns, routeTable), &v1.RouteTable{}) + Invokes(testing.NewCreateActionWithOptions(routetablesResource, c.ns, routeTable, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.RouteTable), err } // Update takes the representation of a routeTable and updates it. Returns the server's representation of the routeTable, and an error, if there is any. func (c *FakeRouteTables) Update(ctx context.Context, routeTable *v1.RouteTable, opts metav1.UpdateOptions) (result *v1.RouteTable, err error) { + emptyResult := &v1.RouteTable{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(routetablesResource, c.ns, routeTable), &v1.RouteTable{}) + Invokes(testing.NewUpdateActionWithOptions(routetablesResource, c.ns, routeTable, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.RouteTable), err } @@ -111,7 +115,7 @@ func (c *FakeRouteTables) Delete(ctx context.Context, name string, opts metav1.D // DeleteCollection deletes a collection of objects. func (c *FakeRouteTables) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewDeleteCollectionAction(routetablesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(routetablesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1.RouteTableList{}) return err @@ -119,11 +123,12 @@ func (c *FakeRouteTables) DeleteCollection(ctx context.Context, opts metav1.Dele // Patch applies the patch and returns the patched routeTable. func (c *FakeRouteTables) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.RouteTable, err error) { + emptyResult := &v1.RouteTable{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(routetablesResource, c.ns, name, pt, data, subresources...), &v1.RouteTable{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(routetablesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.RouteTable), err } diff --git a/pkg/client/clientset/versioned/typed/gloogateway/v1/routetable.go b/pkg/client/clientset/versioned/typed/gloogateway/v1/routetable.go index cc7f2c9b5..66f8411d0 100644 --- a/pkg/client/clientset/versioned/typed/gloogateway/v1/routetable.go +++ b/pkg/client/clientset/versioned/typed/gloogateway/v1/routetable.go @@ -20,14 +20,13 @@ package v1 import ( "context" - "time" v1 "github.com/fluxcd/flagger/pkg/apis/gloogateway/v1" scheme "github.com/fluxcd/flagger/pkg/client/clientset/versioned/scheme" metav1 "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" ) // RouteTablesGetter has a method to return a RouteTableInterface. @@ -51,128 +50,18 @@ type RouteTableInterface interface { // routeTables implements RouteTableInterface type routeTables struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1.RouteTable, *v1.RouteTableList] } // newRouteTables returns a RouteTables func newRouteTables(c *GatewayV1Client, namespace string) *routeTables { return &routeTables{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1.RouteTable, *v1.RouteTableList]( + "routetables", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1.RouteTable { return &v1.RouteTable{} }, + func() *v1.RouteTableList { return &v1.RouteTableList{} }), } } - -// Get takes name of the routeTable, and returns the corresponding routeTable object, and an error if there is any. -func (c *routeTables) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.RouteTable, err error) { - result = &v1.RouteTable{} - err = c.client.Get(). - Namespace(c.ns). - Resource("routetables"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of RouteTables that match those selectors. -func (c *routeTables) List(ctx context.Context, opts metav1.ListOptions) (result *v1.RouteTableList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1.RouteTableList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("routetables"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested routeTables. -func (c *routeTables) Watch(ctx context.Context, opts metav1.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("routetables"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a routeTable and creates it. Returns the server's representation of the routeTable, and an error, if there is any. -func (c *routeTables) Create(ctx context.Context, routeTable *v1.RouteTable, opts metav1.CreateOptions) (result *v1.RouteTable, err error) { - result = &v1.RouteTable{} - err = c.client.Post(). - Namespace(c.ns). - Resource("routetables"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(routeTable). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a routeTable and updates it. Returns the server's representation of the routeTable, and an error, if there is any. -func (c *routeTables) Update(ctx context.Context, routeTable *v1.RouteTable, opts metav1.UpdateOptions) (result *v1.RouteTable, err error) { - result = &v1.RouteTable{} - err = c.client.Put(). - Namespace(c.ns). - Resource("routetables"). - Name(routeTable.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(routeTable). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the routeTable and deletes it. Returns an error if one occurs. -func (c *routeTables) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("routetables"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *routeTables) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.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("routetables"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched routeTable. -func (c *routeTables) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.RouteTable, err error) { - result = &v1.RouteTable{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("routetables"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/istio/v1beta1/destinationrule.go b/pkg/client/clientset/versioned/typed/istio/v1beta1/destinationrule.go index 738fe9495..8e140a870 100644 --- a/pkg/client/clientset/versioned/typed/istio/v1beta1/destinationrule.go +++ b/pkg/client/clientset/versioned/typed/istio/v1beta1/destinationrule.go @@ -20,14 +20,13 @@ package v1beta1 import ( "context" - "time" v1beta1 "github.com/fluxcd/flagger/pkg/apis/istio/v1beta1" scheme "github.com/fluxcd/flagger/pkg/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" ) // DestinationRulesGetter has a method to return a DestinationRuleInterface. @@ -51,128 +50,18 @@ type DestinationRuleInterface interface { // destinationRules implements DestinationRuleInterface type destinationRules struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1beta1.DestinationRule, *v1beta1.DestinationRuleList] } // newDestinationRules returns a DestinationRules func newDestinationRules(c *NetworkingV1beta1Client, namespace string) *destinationRules { return &destinationRules{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1beta1.DestinationRule, *v1beta1.DestinationRuleList]( + "destinationrules", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1beta1.DestinationRule { return &v1beta1.DestinationRule{} }, + func() *v1beta1.DestinationRuleList { return &v1beta1.DestinationRuleList{} }), } } - -// Get takes name of the destinationRule, and returns the corresponding destinationRule object, and an error if there is any. -func (c *destinationRules) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.DestinationRule, err error) { - result = &v1beta1.DestinationRule{} - err = c.client.Get(). - Namespace(c.ns). - Resource("destinationrules"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of DestinationRules that match those selectors. -func (c *destinationRules) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.DestinationRuleList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta1.DestinationRuleList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("destinationrules"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested destinationRules. -func (c *destinationRules) 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("destinationrules"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a destinationRule and creates it. Returns the server's representation of the destinationRule, and an error, if there is any. -func (c *destinationRules) Create(ctx context.Context, destinationRule *v1beta1.DestinationRule, opts v1.CreateOptions) (result *v1beta1.DestinationRule, err error) { - result = &v1beta1.DestinationRule{} - err = c.client.Post(). - Namespace(c.ns). - Resource("destinationrules"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(destinationRule). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a destinationRule and updates it. Returns the server's representation of the destinationRule, and an error, if there is any. -func (c *destinationRules) Update(ctx context.Context, destinationRule *v1beta1.DestinationRule, opts v1.UpdateOptions) (result *v1beta1.DestinationRule, err error) { - result = &v1beta1.DestinationRule{} - err = c.client.Put(). - Namespace(c.ns). - Resource("destinationrules"). - Name(destinationRule.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(destinationRule). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the destinationRule and deletes it. Returns an error if one occurs. -func (c *destinationRules) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("destinationrules"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *destinationRules) 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("destinationrules"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched destinationRule. -func (c *destinationRules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.DestinationRule, err error) { - result = &v1beta1.DestinationRule{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("destinationrules"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/istio/v1beta1/fake/fake_destinationrule.go b/pkg/client/clientset/versioned/typed/istio/v1beta1/fake/fake_destinationrule.go index e3947b56f..d6535c59a 100644 --- a/pkg/client/clientset/versioned/typed/istio/v1beta1/fake/fake_destinationrule.go +++ b/pkg/client/clientset/versioned/typed/istio/v1beta1/fake/fake_destinationrule.go @@ -41,22 +41,24 @@ var destinationrulesKind = v1beta1.SchemeGroupVersion.WithKind("DestinationRule" // Get takes name of the destinationRule, and returns the corresponding destinationRule object, and an error if there is any. func (c *FakeDestinationRules) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.DestinationRule, err error) { + emptyResult := &v1beta1.DestinationRule{} obj, err := c.Fake. - Invokes(testing.NewGetAction(destinationrulesResource, c.ns, name), &v1beta1.DestinationRule{}) + Invokes(testing.NewGetActionWithOptions(destinationrulesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.DestinationRule), err } // List takes label and field selectors, and returns the list of DestinationRules that match those selectors. func (c *FakeDestinationRules) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.DestinationRuleList, err error) { + emptyResult := &v1beta1.DestinationRuleList{} obj, err := c.Fake. - Invokes(testing.NewListAction(destinationrulesResource, destinationrulesKind, c.ns, opts), &v1beta1.DestinationRuleList{}) + Invokes(testing.NewListActionWithOptions(destinationrulesResource, destinationrulesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeDestinationRules) List(ctx context.Context, opts v1.ListOptions) (r // Watch returns a watch.Interface that watches the requested destinationRules. func (c *FakeDestinationRules) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(destinationrulesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(destinationrulesResource, c.ns, opts)) } // Create takes the representation of a destinationRule and creates it. Returns the server's representation of the destinationRule, and an error, if there is any. func (c *FakeDestinationRules) Create(ctx context.Context, destinationRule *v1beta1.DestinationRule, opts v1.CreateOptions) (result *v1beta1.DestinationRule, err error) { + emptyResult := &v1beta1.DestinationRule{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(destinationrulesResource, c.ns, destinationRule), &v1beta1.DestinationRule{}) + Invokes(testing.NewCreateActionWithOptions(destinationrulesResource, c.ns, destinationRule, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.DestinationRule), err } // Update takes the representation of a destinationRule and updates it. Returns the server's representation of the destinationRule, and an error, if there is any. func (c *FakeDestinationRules) Update(ctx context.Context, destinationRule *v1beta1.DestinationRule, opts v1.UpdateOptions) (result *v1beta1.DestinationRule, err error) { + emptyResult := &v1beta1.DestinationRule{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(destinationrulesResource, c.ns, destinationRule), &v1beta1.DestinationRule{}) + Invokes(testing.NewUpdateActionWithOptions(destinationrulesResource, c.ns, destinationRule, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.DestinationRule), err } @@ -111,7 +115,7 @@ func (c *FakeDestinationRules) Delete(ctx context.Context, name string, opts v1. // DeleteCollection deletes a collection of objects. func (c *FakeDestinationRules) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(destinationrulesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(destinationrulesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.DestinationRuleList{}) return err @@ -119,11 +123,12 @@ func (c *FakeDestinationRules) DeleteCollection(ctx context.Context, opts v1.Del // Patch applies the patch and returns the patched destinationRule. func (c *FakeDestinationRules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.DestinationRule, err error) { + emptyResult := &v1beta1.DestinationRule{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(destinationrulesResource, c.ns, name, pt, data, subresources...), &v1beta1.DestinationRule{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(destinationrulesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.DestinationRule), err } diff --git a/pkg/client/clientset/versioned/typed/istio/v1beta1/fake/fake_virtualservice.go b/pkg/client/clientset/versioned/typed/istio/v1beta1/fake/fake_virtualservice.go index 41d5830e2..3393896d0 100644 --- a/pkg/client/clientset/versioned/typed/istio/v1beta1/fake/fake_virtualservice.go +++ b/pkg/client/clientset/versioned/typed/istio/v1beta1/fake/fake_virtualservice.go @@ -41,22 +41,24 @@ var virtualservicesKind = v1beta1.SchemeGroupVersion.WithKind("VirtualService") // Get takes name of the virtualService, and returns the corresponding virtualService object, and an error if there is any. func (c *FakeVirtualServices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.VirtualService, err error) { + emptyResult := &v1beta1.VirtualService{} obj, err := c.Fake. - Invokes(testing.NewGetAction(virtualservicesResource, c.ns, name), &v1beta1.VirtualService{}) + Invokes(testing.NewGetActionWithOptions(virtualservicesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.VirtualService), err } // List takes label and field selectors, and returns the list of VirtualServices that match those selectors. func (c *FakeVirtualServices) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.VirtualServiceList, err error) { + emptyResult := &v1beta1.VirtualServiceList{} obj, err := c.Fake. - Invokes(testing.NewListAction(virtualservicesResource, virtualservicesKind, c.ns, opts), &v1beta1.VirtualServiceList{}) + Invokes(testing.NewListActionWithOptions(virtualservicesResource, virtualservicesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeVirtualServices) List(ctx context.Context, opts v1.ListOptions) (re // Watch returns a watch.Interface that watches the requested virtualServices. func (c *FakeVirtualServices) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(virtualservicesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(virtualservicesResource, c.ns, opts)) } // Create takes the representation of a virtualService and creates it. Returns the server's representation of the virtualService, and an error, if there is any. func (c *FakeVirtualServices) Create(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.CreateOptions) (result *v1beta1.VirtualService, err error) { + emptyResult := &v1beta1.VirtualService{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(virtualservicesResource, c.ns, virtualService), &v1beta1.VirtualService{}) + Invokes(testing.NewCreateActionWithOptions(virtualservicesResource, c.ns, virtualService, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.VirtualService), err } // Update takes the representation of a virtualService and updates it. Returns the server's representation of the virtualService, and an error, if there is any. func (c *FakeVirtualServices) Update(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.UpdateOptions) (result *v1beta1.VirtualService, err error) { + emptyResult := &v1beta1.VirtualService{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(virtualservicesResource, c.ns, virtualService), &v1beta1.VirtualService{}) + Invokes(testing.NewUpdateActionWithOptions(virtualservicesResource, c.ns, virtualService, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.VirtualService), err } @@ -111,7 +115,7 @@ func (c *FakeVirtualServices) Delete(ctx context.Context, name string, opts v1.D // DeleteCollection deletes a collection of objects. func (c *FakeVirtualServices) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(virtualservicesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(virtualservicesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1beta1.VirtualServiceList{}) return err @@ -119,11 +123,12 @@ func (c *FakeVirtualServices) DeleteCollection(ctx context.Context, opts v1.Dele // Patch applies the patch and returns the patched virtualService. func (c *FakeVirtualServices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.VirtualService, err error) { + emptyResult := &v1beta1.VirtualService{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(virtualservicesResource, c.ns, name, pt, data, subresources...), &v1beta1.VirtualService{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(virtualservicesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1beta1.VirtualService), err } diff --git a/pkg/client/clientset/versioned/typed/istio/v1beta1/virtualservice.go b/pkg/client/clientset/versioned/typed/istio/v1beta1/virtualservice.go index d8f6c0e38..ea86fb386 100644 --- a/pkg/client/clientset/versioned/typed/istio/v1beta1/virtualservice.go +++ b/pkg/client/clientset/versioned/typed/istio/v1beta1/virtualservice.go @@ -20,14 +20,13 @@ package v1beta1 import ( "context" - "time" v1beta1 "github.com/fluxcd/flagger/pkg/apis/istio/v1beta1" scheme "github.com/fluxcd/flagger/pkg/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" ) // VirtualServicesGetter has a method to return a VirtualServiceInterface. @@ -51,128 +50,18 @@ type VirtualServiceInterface interface { // virtualServices implements VirtualServiceInterface type virtualServices struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1beta1.VirtualService, *v1beta1.VirtualServiceList] } // newVirtualServices returns a VirtualServices func newVirtualServices(c *NetworkingV1beta1Client, namespace string) *virtualServices { return &virtualServices{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1beta1.VirtualService, *v1beta1.VirtualServiceList]( + "virtualservices", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1beta1.VirtualService { return &v1beta1.VirtualService{} }, + func() *v1beta1.VirtualServiceList { return &v1beta1.VirtualServiceList{} }), } } - -// Get takes name of the virtualService, and returns the corresponding virtualService object, and an error if there is any. -func (c *virtualServices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.VirtualService, err error) { - result = &v1beta1.VirtualService{} - err = c.client.Get(). - Namespace(c.ns). - Resource("virtualservices"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of VirtualServices that match those selectors. -func (c *virtualServices) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.VirtualServiceList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta1.VirtualServiceList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("virtualservices"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested virtualServices. -func (c *virtualServices) 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("virtualservices"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a virtualService and creates it. Returns the server's representation of the virtualService, and an error, if there is any. -func (c *virtualServices) Create(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.CreateOptions) (result *v1beta1.VirtualService, err error) { - result = &v1beta1.VirtualService{} - err = c.client.Post(). - Namespace(c.ns). - Resource("virtualservices"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(virtualService). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a virtualService and updates it. Returns the server's representation of the virtualService, and an error, if there is any. -func (c *virtualServices) Update(ctx context.Context, virtualService *v1beta1.VirtualService, opts v1.UpdateOptions) (result *v1beta1.VirtualService, err error) { - result = &v1beta1.VirtualService{} - err = c.client.Put(). - Namespace(c.ns). - Resource("virtualservices"). - Name(virtualService.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(virtualService). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the virtualService and deletes it. Returns an error if one occurs. -func (c *virtualServices) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("virtualservices"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *virtualServices) 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("virtualservices"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched virtualService. -func (c *virtualServices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.VirtualService, err error) { - result = &v1beta1.VirtualService{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("virtualservices"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/keda/v1alpha1/fake/fake_scaledobject.go b/pkg/client/clientset/versioned/typed/keda/v1alpha1/fake/fake_scaledobject.go index a008e0566..e0617e8c5 100644 --- a/pkg/client/clientset/versioned/typed/keda/v1alpha1/fake/fake_scaledobject.go +++ b/pkg/client/clientset/versioned/typed/keda/v1alpha1/fake/fake_scaledobject.go @@ -41,22 +41,24 @@ var scaledobjectsKind = v1alpha1.SchemeGroupVersion.WithKind("ScaledObject") // Get takes name of the scaledObject, and returns the corresponding scaledObject object, and an error if there is any. func (c *FakeScaledObjects) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ScaledObject, err error) { + emptyResult := &v1alpha1.ScaledObject{} obj, err := c.Fake. - Invokes(testing.NewGetAction(scaledobjectsResource, c.ns, name), &v1alpha1.ScaledObject{}) + Invokes(testing.NewGetActionWithOptions(scaledobjectsResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.ScaledObject), err } // List takes label and field selectors, and returns the list of ScaledObjects that match those selectors. func (c *FakeScaledObjects) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ScaledObjectList, err error) { + emptyResult := &v1alpha1.ScaledObjectList{} obj, err := c.Fake. - Invokes(testing.NewListAction(scaledobjectsResource, scaledobjectsKind, c.ns, opts), &v1alpha1.ScaledObjectList{}) + Invokes(testing.NewListActionWithOptions(scaledobjectsResource, scaledobjectsKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,40 +77,43 @@ func (c *FakeScaledObjects) List(ctx context.Context, opts v1.ListOptions) (resu // Watch returns a watch.Interface that watches the requested scaledObjects. func (c *FakeScaledObjects) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(scaledobjectsResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(scaledobjectsResource, c.ns, opts)) } // Create takes the representation of a scaledObject and creates it. Returns the server's representation of the scaledObject, and an error, if there is any. func (c *FakeScaledObjects) Create(ctx context.Context, scaledObject *v1alpha1.ScaledObject, opts v1.CreateOptions) (result *v1alpha1.ScaledObject, err error) { + emptyResult := &v1alpha1.ScaledObject{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(scaledobjectsResource, c.ns, scaledObject), &v1alpha1.ScaledObject{}) + Invokes(testing.NewCreateActionWithOptions(scaledobjectsResource, c.ns, scaledObject, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.ScaledObject), err } // Update takes the representation of a scaledObject and updates it. Returns the server's representation of the scaledObject, and an error, if there is any. func (c *FakeScaledObjects) Update(ctx context.Context, scaledObject *v1alpha1.ScaledObject, opts v1.UpdateOptions) (result *v1alpha1.ScaledObject, err error) { + emptyResult := &v1alpha1.ScaledObject{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(scaledobjectsResource, c.ns, scaledObject), &v1alpha1.ScaledObject{}) + Invokes(testing.NewUpdateActionWithOptions(scaledobjectsResource, c.ns, scaledObject, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.ScaledObject), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeScaledObjects) UpdateStatus(ctx context.Context, scaledObject *v1alpha1.ScaledObject, opts v1.UpdateOptions) (*v1alpha1.ScaledObject, error) { +func (c *FakeScaledObjects) UpdateStatus(ctx context.Context, scaledObject *v1alpha1.ScaledObject, opts v1.UpdateOptions) (result *v1alpha1.ScaledObject, err error) { + emptyResult := &v1alpha1.ScaledObject{} obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(scaledobjectsResource, "status", c.ns, scaledObject), &v1alpha1.ScaledObject{}) + Invokes(testing.NewUpdateSubresourceActionWithOptions(scaledobjectsResource, "status", c.ns, scaledObject, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.ScaledObject), err } @@ -123,7 +128,7 @@ func (c *FakeScaledObjects) Delete(ctx context.Context, name string, opts v1.Del // DeleteCollection deletes a collection of objects. func (c *FakeScaledObjects) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(scaledobjectsResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(scaledobjectsResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha1.ScaledObjectList{}) return err @@ -131,11 +136,12 @@ func (c *FakeScaledObjects) DeleteCollection(ctx context.Context, opts v1.Delete // Patch applies the patch and returns the patched scaledObject. func (c *FakeScaledObjects) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ScaledObject, err error) { + emptyResult := &v1alpha1.ScaledObject{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(scaledobjectsResource, c.ns, name, pt, data, subresources...), &v1alpha1.ScaledObject{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(scaledobjectsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.ScaledObject), err } diff --git a/pkg/client/clientset/versioned/typed/keda/v1alpha1/scaledobject.go b/pkg/client/clientset/versioned/typed/keda/v1alpha1/scaledobject.go index 3a781d191..09dee96ff 100644 --- a/pkg/client/clientset/versioned/typed/keda/v1alpha1/scaledobject.go +++ b/pkg/client/clientset/versioned/typed/keda/v1alpha1/scaledobject.go @@ -20,14 +20,13 @@ package v1alpha1 import ( "context" - "time" v1alpha1 "github.com/fluxcd/flagger/pkg/apis/keda/v1alpha1" scheme "github.com/fluxcd/flagger/pkg/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" ) // ScaledObjectsGetter has a method to return a ScaledObjectInterface. @@ -40,6 +39,7 @@ type ScaledObjectsGetter interface { type ScaledObjectInterface interface { Create(ctx context.Context, scaledObject *v1alpha1.ScaledObject, opts v1.CreateOptions) (*v1alpha1.ScaledObject, error) Update(ctx context.Context, scaledObject *v1alpha1.ScaledObject, opts v1.UpdateOptions) (*v1alpha1.ScaledObject, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, scaledObject *v1alpha1.ScaledObject, opts v1.UpdateOptions) (*v1alpha1.ScaledObject, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error @@ -52,144 +52,18 @@ type ScaledObjectInterface interface { // scaledObjects implements ScaledObjectInterface type scaledObjects struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1alpha1.ScaledObject, *v1alpha1.ScaledObjectList] } // newScaledObjects returns a ScaledObjects func newScaledObjects(c *KedaV1alpha1Client, namespace string) *scaledObjects { return &scaledObjects{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1alpha1.ScaledObject, *v1alpha1.ScaledObjectList]( + "scaledobjects", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha1.ScaledObject { return &v1alpha1.ScaledObject{} }, + func() *v1alpha1.ScaledObjectList { return &v1alpha1.ScaledObjectList{} }), } } - -// Get takes name of the scaledObject, and returns the corresponding scaledObject object, and an error if there is any. -func (c *scaledObjects) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ScaledObject, err error) { - result = &v1alpha1.ScaledObject{} - err = c.client.Get(). - Namespace(c.ns). - Resource("scaledobjects"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of ScaledObjects that match those selectors. -func (c *scaledObjects) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ScaledObjectList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.ScaledObjectList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("scaledobjects"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested scaledObjects. -func (c *scaledObjects) 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("scaledobjects"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a scaledObject and creates it. Returns the server's representation of the scaledObject, and an error, if there is any. -func (c *scaledObjects) Create(ctx context.Context, scaledObject *v1alpha1.ScaledObject, opts v1.CreateOptions) (result *v1alpha1.ScaledObject, err error) { - result = &v1alpha1.ScaledObject{} - err = c.client.Post(). - Namespace(c.ns). - Resource("scaledobjects"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(scaledObject). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a scaledObject and updates it. Returns the server's representation of the scaledObject, and an error, if there is any. -func (c *scaledObjects) Update(ctx context.Context, scaledObject *v1alpha1.ScaledObject, opts v1.UpdateOptions) (result *v1alpha1.ScaledObject, err error) { - result = &v1alpha1.ScaledObject{} - err = c.client.Put(). - Namespace(c.ns). - Resource("scaledobjects"). - Name(scaledObject.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(scaledObject). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *scaledObjects) UpdateStatus(ctx context.Context, scaledObject *v1alpha1.ScaledObject, opts v1.UpdateOptions) (result *v1alpha1.ScaledObject, err error) { - result = &v1alpha1.ScaledObject{} - err = c.client.Put(). - Namespace(c.ns). - Resource("scaledobjects"). - Name(scaledObject.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(scaledObject). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the scaledObject and deletes it. Returns an error if one occurs. -func (c *scaledObjects) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("scaledobjects"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *scaledObjects) 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("scaledobjects"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched scaledObject. -func (c *scaledObjects) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ScaledObject, err error) { - result = &v1alpha1.ScaledObject{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("scaledobjects"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/kuma/v1alpha1/fake/fake_trafficroute.go b/pkg/client/clientset/versioned/typed/kuma/v1alpha1/fake/fake_trafficroute.go index f200b6c3a..448701b59 100644 --- a/pkg/client/clientset/versioned/typed/kuma/v1alpha1/fake/fake_trafficroute.go +++ b/pkg/client/clientset/versioned/typed/kuma/v1alpha1/fake/fake_trafficroute.go @@ -40,20 +40,22 @@ var trafficroutesKind = v1alpha1.SchemeGroupVersion.WithKind("TrafficRoute") // Get takes name of the trafficRoute, and returns the corresponding trafficRoute object, and an error if there is any. func (c *FakeTrafficRoutes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.TrafficRoute, err error) { + emptyResult := &v1alpha1.TrafficRoute{} obj, err := c.Fake. - Invokes(testing.NewRootGetAction(trafficroutesResource, name), &v1alpha1.TrafficRoute{}) + Invokes(testing.NewRootGetActionWithOptions(trafficroutesResource, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TrafficRoute), err } // List takes label and field selectors, and returns the list of TrafficRoutes that match those selectors. func (c *FakeTrafficRoutes) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.TrafficRouteList, err error) { + emptyResult := &v1alpha1.TrafficRouteList{} obj, err := c.Fake. - Invokes(testing.NewRootListAction(trafficroutesResource, trafficroutesKind, opts), &v1alpha1.TrafficRouteList{}) + Invokes(testing.NewRootListActionWithOptions(trafficroutesResource, trafficroutesKind, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -72,25 +74,27 @@ func (c *FakeTrafficRoutes) List(ctx context.Context, opts v1.ListOptions) (resu // Watch returns a watch.Interface that watches the requested trafficRoutes. func (c *FakeTrafficRoutes) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchAction(trafficroutesResource, opts)) + InvokesWatch(testing.NewRootWatchActionWithOptions(trafficroutesResource, opts)) } // Create takes the representation of a trafficRoute and creates it. Returns the server's representation of the trafficRoute, and an error, if there is any. func (c *FakeTrafficRoutes) Create(ctx context.Context, trafficRoute *v1alpha1.TrafficRoute, opts v1.CreateOptions) (result *v1alpha1.TrafficRoute, err error) { + emptyResult := &v1alpha1.TrafficRoute{} obj, err := c.Fake. - Invokes(testing.NewRootCreateAction(trafficroutesResource, trafficRoute), &v1alpha1.TrafficRoute{}) + Invokes(testing.NewRootCreateActionWithOptions(trafficroutesResource, trafficRoute, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TrafficRoute), err } // Update takes the representation of a trafficRoute and updates it. Returns the server's representation of the trafficRoute, and an error, if there is any. func (c *FakeTrafficRoutes) Update(ctx context.Context, trafficRoute *v1alpha1.TrafficRoute, opts v1.UpdateOptions) (result *v1alpha1.TrafficRoute, err error) { + emptyResult := &v1alpha1.TrafficRoute{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateAction(trafficroutesResource, trafficRoute), &v1alpha1.TrafficRoute{}) + Invokes(testing.NewRootUpdateActionWithOptions(trafficroutesResource, trafficRoute, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TrafficRoute), err } @@ -104,7 +108,7 @@ func (c *FakeTrafficRoutes) Delete(ctx context.Context, name string, opts v1.Del // DeleteCollection deletes a collection of objects. func (c *FakeTrafficRoutes) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewRootDeleteCollectionAction(trafficroutesResource, listOpts) + action := testing.NewRootDeleteCollectionActionWithOptions(trafficroutesResource, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha1.TrafficRouteList{}) return err @@ -112,10 +116,11 @@ func (c *FakeTrafficRoutes) DeleteCollection(ctx context.Context, opts v1.Delete // Patch applies the patch and returns the patched trafficRoute. func (c *FakeTrafficRoutes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.TrafficRoute, err error) { + emptyResult := &v1alpha1.TrafficRoute{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(trafficroutesResource, name, pt, data, subresources...), &v1alpha1.TrafficRoute{}) + Invokes(testing.NewRootPatchSubresourceActionWithOptions(trafficroutesResource, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TrafficRoute), err } diff --git a/pkg/client/clientset/versioned/typed/kuma/v1alpha1/trafficroute.go b/pkg/client/clientset/versioned/typed/kuma/v1alpha1/trafficroute.go index 76089aba3..7e238f971 100644 --- a/pkg/client/clientset/versioned/typed/kuma/v1alpha1/trafficroute.go +++ b/pkg/client/clientset/versioned/typed/kuma/v1alpha1/trafficroute.go @@ -20,14 +20,13 @@ package v1alpha1 import ( "context" - "time" v1alpha1 "github.com/fluxcd/flagger/pkg/apis/kuma/v1alpha1" scheme "github.com/fluxcd/flagger/pkg/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" ) // TrafficRoutesGetter has a method to return a TrafficRouteInterface. @@ -51,118 +50,18 @@ type TrafficRouteInterface interface { // trafficRoutes implements TrafficRouteInterface type trafficRoutes struct { - client rest.Interface + *gentype.ClientWithList[*v1alpha1.TrafficRoute, *v1alpha1.TrafficRouteList] } // newTrafficRoutes returns a TrafficRoutes func newTrafficRoutes(c *KumaV1alpha1Client) *trafficRoutes { return &trafficRoutes{ - client: c.RESTClient(), + gentype.NewClientWithList[*v1alpha1.TrafficRoute, *v1alpha1.TrafficRouteList]( + "trafficroutes", + c.RESTClient(), + scheme.ParameterCodec, + "", + func() *v1alpha1.TrafficRoute { return &v1alpha1.TrafficRoute{} }, + func() *v1alpha1.TrafficRouteList { return &v1alpha1.TrafficRouteList{} }), } } - -// Get takes name of the trafficRoute, and returns the corresponding trafficRoute object, and an error if there is any. -func (c *trafficRoutes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.TrafficRoute, err error) { - result = &v1alpha1.TrafficRoute{} - err = c.client.Get(). - Resource("trafficroutes"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of TrafficRoutes that match those selectors. -func (c *trafficRoutes) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.TrafficRouteList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.TrafficRouteList{} - err = c.client.Get(). - Resource("trafficroutes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested trafficRoutes. -func (c *trafficRoutes) 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(). - Resource("trafficroutes"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a trafficRoute and creates it. Returns the server's representation of the trafficRoute, and an error, if there is any. -func (c *trafficRoutes) Create(ctx context.Context, trafficRoute *v1alpha1.TrafficRoute, opts v1.CreateOptions) (result *v1alpha1.TrafficRoute, err error) { - result = &v1alpha1.TrafficRoute{} - err = c.client.Post(). - Resource("trafficroutes"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(trafficRoute). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a trafficRoute and updates it. Returns the server's representation of the trafficRoute, and an error, if there is any. -func (c *trafficRoutes) Update(ctx context.Context, trafficRoute *v1alpha1.TrafficRoute, opts v1.UpdateOptions) (result *v1alpha1.TrafficRoute, err error) { - result = &v1alpha1.TrafficRoute{} - err = c.client.Put(). - Resource("trafficroutes"). - Name(trafficRoute.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(trafficRoute). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the trafficRoute and deletes it. Returns an error if one occurs. -func (c *trafficRoutes) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Resource("trafficroutes"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *trafficRoutes) 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(). - Resource("trafficroutes"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched trafficRoute. -func (c *trafficRoutes) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.TrafficRoute, err error) { - result = &v1alpha1.TrafficRoute{} - err = c.client.Patch(pt). - Resource("trafficroutes"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/projectcontour/v1/fake/fake_httpproxy.go b/pkg/client/clientset/versioned/typed/projectcontour/v1/fake/fake_httpproxy.go index e1037eaec..962495f1b 100644 --- a/pkg/client/clientset/versioned/typed/projectcontour/v1/fake/fake_httpproxy.go +++ b/pkg/client/clientset/versioned/typed/projectcontour/v1/fake/fake_httpproxy.go @@ -41,22 +41,24 @@ var httpproxiesKind = v1.SchemeGroupVersion.WithKind("HTTPProxy") // Get takes name of the hTTPProxy, and returns the corresponding hTTPProxy object, and an error if there is any. func (c *FakeHTTPProxies) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.HTTPProxy, err error) { + emptyResult := &v1.HTTPProxy{} obj, err := c.Fake. - Invokes(testing.NewGetAction(httpproxiesResource, c.ns, name), &v1.HTTPProxy{}) + Invokes(testing.NewGetActionWithOptions(httpproxiesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.HTTPProxy), err } // List takes label and field selectors, and returns the list of HTTPProxies that match those selectors. func (c *FakeHTTPProxies) List(ctx context.Context, opts metav1.ListOptions) (result *v1.HTTPProxyList, err error) { + emptyResult := &v1.HTTPProxyList{} obj, err := c.Fake. - Invokes(testing.NewListAction(httpproxiesResource, httpproxiesKind, c.ns, opts), &v1.HTTPProxyList{}) + Invokes(testing.NewListActionWithOptions(httpproxiesResource, httpproxiesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,40 +77,43 @@ func (c *FakeHTTPProxies) List(ctx context.Context, opts metav1.ListOptions) (re // Watch returns a watch.Interface that watches the requested hTTPProxies. func (c *FakeHTTPProxies) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(httpproxiesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(httpproxiesResource, c.ns, opts)) } // Create takes the representation of a hTTPProxy and creates it. Returns the server's representation of the hTTPProxy, and an error, if there is any. func (c *FakeHTTPProxies) Create(ctx context.Context, hTTPProxy *v1.HTTPProxy, opts metav1.CreateOptions) (result *v1.HTTPProxy, err error) { + emptyResult := &v1.HTTPProxy{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(httpproxiesResource, c.ns, hTTPProxy), &v1.HTTPProxy{}) + Invokes(testing.NewCreateActionWithOptions(httpproxiesResource, c.ns, hTTPProxy, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.HTTPProxy), err } // Update takes the representation of a hTTPProxy and updates it. Returns the server's representation of the hTTPProxy, and an error, if there is any. func (c *FakeHTTPProxies) Update(ctx context.Context, hTTPProxy *v1.HTTPProxy, opts metav1.UpdateOptions) (result *v1.HTTPProxy, err error) { + emptyResult := &v1.HTTPProxy{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(httpproxiesResource, c.ns, hTTPProxy), &v1.HTTPProxy{}) + Invokes(testing.NewUpdateActionWithOptions(httpproxiesResource, c.ns, hTTPProxy, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.HTTPProxy), err } // UpdateStatus was generated because the type contains a Status member. // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeHTTPProxies) UpdateStatus(ctx context.Context, hTTPProxy *v1.HTTPProxy, opts metav1.UpdateOptions) (*v1.HTTPProxy, error) { +func (c *FakeHTTPProxies) UpdateStatus(ctx context.Context, hTTPProxy *v1.HTTPProxy, opts metav1.UpdateOptions) (result *v1.HTTPProxy, err error) { + emptyResult := &v1.HTTPProxy{} obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(httpproxiesResource, "status", c.ns, hTTPProxy), &v1.HTTPProxy{}) + Invokes(testing.NewUpdateSubresourceActionWithOptions(httpproxiesResource, "status", c.ns, hTTPProxy, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.HTTPProxy), err } @@ -123,7 +128,7 @@ func (c *FakeHTTPProxies) Delete(ctx context.Context, name string, opts metav1.D // DeleteCollection deletes a collection of objects. func (c *FakeHTTPProxies) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewDeleteCollectionAction(httpproxiesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(httpproxiesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1.HTTPProxyList{}) return err @@ -131,11 +136,12 @@ func (c *FakeHTTPProxies) DeleteCollection(ctx context.Context, opts metav1.Dele // Patch applies the patch and returns the patched hTTPProxy. func (c *FakeHTTPProxies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.HTTPProxy, err error) { + emptyResult := &v1.HTTPProxy{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(httpproxiesResource, c.ns, name, pt, data, subresources...), &v1.HTTPProxy{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(httpproxiesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1.HTTPProxy), err } diff --git a/pkg/client/clientset/versioned/typed/projectcontour/v1/httpproxy.go b/pkg/client/clientset/versioned/typed/projectcontour/v1/httpproxy.go index b7528fe7b..bdd3ff323 100644 --- a/pkg/client/clientset/versioned/typed/projectcontour/v1/httpproxy.go +++ b/pkg/client/clientset/versioned/typed/projectcontour/v1/httpproxy.go @@ -20,14 +20,13 @@ package v1 import ( "context" - "time" v1 "github.com/fluxcd/flagger/pkg/apis/projectcontour/v1" scheme "github.com/fluxcd/flagger/pkg/client/clientset/versioned/scheme" metav1 "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" ) // HTTPProxiesGetter has a method to return a HTTPProxyInterface. @@ -40,6 +39,7 @@ type HTTPProxiesGetter interface { type HTTPProxyInterface interface { Create(ctx context.Context, hTTPProxy *v1.HTTPProxy, opts metav1.CreateOptions) (*v1.HTTPProxy, error) Update(ctx context.Context, hTTPProxy *v1.HTTPProxy, opts metav1.UpdateOptions) (*v1.HTTPProxy, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, hTTPProxy *v1.HTTPProxy, opts metav1.UpdateOptions) (*v1.HTTPProxy, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,144 +52,18 @@ type HTTPProxyInterface interface { // hTTPProxies implements HTTPProxyInterface type hTTPProxies struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1.HTTPProxy, *v1.HTTPProxyList] } // newHTTPProxies returns a HTTPProxies func newHTTPProxies(c *ProjectcontourV1Client, namespace string) *hTTPProxies { return &hTTPProxies{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1.HTTPProxy, *v1.HTTPProxyList]( + "httpproxies", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1.HTTPProxy { return &v1.HTTPProxy{} }, + func() *v1.HTTPProxyList { return &v1.HTTPProxyList{} }), } } - -// Get takes name of the hTTPProxy, and returns the corresponding hTTPProxy object, and an error if there is any. -func (c *hTTPProxies) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.HTTPProxy, err error) { - result = &v1.HTTPProxy{} - err = c.client.Get(). - Namespace(c.ns). - Resource("httpproxies"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of HTTPProxies that match those selectors. -func (c *hTTPProxies) List(ctx context.Context, opts metav1.ListOptions) (result *v1.HTTPProxyList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1.HTTPProxyList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("httpproxies"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested hTTPProxies. -func (c *hTTPProxies) Watch(ctx context.Context, opts metav1.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("httpproxies"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a hTTPProxy and creates it. Returns the server's representation of the hTTPProxy, and an error, if there is any. -func (c *hTTPProxies) Create(ctx context.Context, hTTPProxy *v1.HTTPProxy, opts metav1.CreateOptions) (result *v1.HTTPProxy, err error) { - result = &v1.HTTPProxy{} - err = c.client.Post(). - Namespace(c.ns). - Resource("httpproxies"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(hTTPProxy). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a hTTPProxy and updates it. Returns the server's representation of the hTTPProxy, and an error, if there is any. -func (c *hTTPProxies) Update(ctx context.Context, hTTPProxy *v1.HTTPProxy, opts metav1.UpdateOptions) (result *v1.HTTPProxy, err error) { - result = &v1.HTTPProxy{} - err = c.client.Put(). - Namespace(c.ns). - Resource("httpproxies"). - Name(hTTPProxy.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(hTTPProxy). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *hTTPProxies) UpdateStatus(ctx context.Context, hTTPProxy *v1.HTTPProxy, opts metav1.UpdateOptions) (result *v1.HTTPProxy, err error) { - result = &v1.HTTPProxy{} - err = c.client.Put(). - Namespace(c.ns). - Resource("httpproxies"). - Name(hTTPProxy.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(hTTPProxy). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the hTTPProxy and deletes it. Returns an error if one occurs. -func (c *hTTPProxies) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("httpproxies"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *hTTPProxies) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.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("httpproxies"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched hTTPProxy. -func (c *hTTPProxies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.HTTPProxy, err error) { - result = &v1.HTTPProxy{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("httpproxies"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/smi/v1alpha1/fake/fake_trafficsplit.go b/pkg/client/clientset/versioned/typed/smi/v1alpha1/fake/fake_trafficsplit.go index 3d2df0002..4add69209 100644 --- a/pkg/client/clientset/versioned/typed/smi/v1alpha1/fake/fake_trafficsplit.go +++ b/pkg/client/clientset/versioned/typed/smi/v1alpha1/fake/fake_trafficsplit.go @@ -41,22 +41,24 @@ var trafficsplitsKind = v1alpha1.SchemeGroupVersion.WithKind("TrafficSplit") // Get takes name of the trafficSplit, and returns the corresponding trafficSplit object, and an error if there is any. func (c *FakeTrafficSplits) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.TrafficSplit, err error) { + emptyResult := &v1alpha1.TrafficSplit{} obj, err := c.Fake. - Invokes(testing.NewGetAction(trafficsplitsResource, c.ns, name), &v1alpha1.TrafficSplit{}) + Invokes(testing.NewGetActionWithOptions(trafficsplitsResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TrafficSplit), err } // List takes label and field selectors, and returns the list of TrafficSplits that match those selectors. func (c *FakeTrafficSplits) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.TrafficSplitList, err error) { + emptyResult := &v1alpha1.TrafficSplitList{} obj, err := c.Fake. - Invokes(testing.NewListAction(trafficsplitsResource, trafficsplitsKind, c.ns, opts), &v1alpha1.TrafficSplitList{}) + Invokes(testing.NewListActionWithOptions(trafficsplitsResource, trafficsplitsKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeTrafficSplits) List(ctx context.Context, opts v1.ListOptions) (resu // Watch returns a watch.Interface that watches the requested trafficSplits. func (c *FakeTrafficSplits) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(trafficsplitsResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(trafficsplitsResource, c.ns, opts)) } // Create takes the representation of a trafficSplit and creates it. Returns the server's representation of the trafficSplit, and an error, if there is any. func (c *FakeTrafficSplits) Create(ctx context.Context, trafficSplit *v1alpha1.TrafficSplit, opts v1.CreateOptions) (result *v1alpha1.TrafficSplit, err error) { + emptyResult := &v1alpha1.TrafficSplit{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(trafficsplitsResource, c.ns, trafficSplit), &v1alpha1.TrafficSplit{}) + Invokes(testing.NewCreateActionWithOptions(trafficsplitsResource, c.ns, trafficSplit, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TrafficSplit), err } // Update takes the representation of a trafficSplit and updates it. Returns the server's representation of the trafficSplit, and an error, if there is any. func (c *FakeTrafficSplits) Update(ctx context.Context, trafficSplit *v1alpha1.TrafficSplit, opts v1.UpdateOptions) (result *v1alpha1.TrafficSplit, err error) { + emptyResult := &v1alpha1.TrafficSplit{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(trafficsplitsResource, c.ns, trafficSplit), &v1alpha1.TrafficSplit{}) + Invokes(testing.NewUpdateActionWithOptions(trafficsplitsResource, c.ns, trafficSplit, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TrafficSplit), err } @@ -111,7 +115,7 @@ func (c *FakeTrafficSplits) Delete(ctx context.Context, name string, opts v1.Del // DeleteCollection deletes a collection of objects. func (c *FakeTrafficSplits) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(trafficsplitsResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(trafficsplitsResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha1.TrafficSplitList{}) return err @@ -119,11 +123,12 @@ func (c *FakeTrafficSplits) DeleteCollection(ctx context.Context, opts v1.Delete // Patch applies the patch and returns the patched trafficSplit. func (c *FakeTrafficSplits) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.TrafficSplit, err error) { + emptyResult := &v1alpha1.TrafficSplit{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(trafficsplitsResource, c.ns, name, pt, data, subresources...), &v1alpha1.TrafficSplit{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(trafficsplitsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TrafficSplit), err } diff --git a/pkg/client/clientset/versioned/typed/smi/v1alpha1/trafficsplit.go b/pkg/client/clientset/versioned/typed/smi/v1alpha1/trafficsplit.go index 649b9e0d5..78e93fd29 100644 --- a/pkg/client/clientset/versioned/typed/smi/v1alpha1/trafficsplit.go +++ b/pkg/client/clientset/versioned/typed/smi/v1alpha1/trafficsplit.go @@ -20,14 +20,13 @@ package v1alpha1 import ( "context" - "time" v1alpha1 "github.com/fluxcd/flagger/pkg/apis/smi/v1alpha1" scheme "github.com/fluxcd/flagger/pkg/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" ) // TrafficSplitsGetter has a method to return a TrafficSplitInterface. @@ -51,128 +50,18 @@ type TrafficSplitInterface interface { // trafficSplits implements TrafficSplitInterface type trafficSplits struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1alpha1.TrafficSplit, *v1alpha1.TrafficSplitList] } // newTrafficSplits returns a TrafficSplits func newTrafficSplits(c *SplitV1alpha1Client, namespace string) *trafficSplits { return &trafficSplits{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1alpha1.TrafficSplit, *v1alpha1.TrafficSplitList]( + "trafficsplits", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha1.TrafficSplit { return &v1alpha1.TrafficSplit{} }, + func() *v1alpha1.TrafficSplitList { return &v1alpha1.TrafficSplitList{} }), } } - -// Get takes name of the trafficSplit, and returns the corresponding trafficSplit object, and an error if there is any. -func (c *trafficSplits) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.TrafficSplit, err error) { - result = &v1alpha1.TrafficSplit{} - err = c.client.Get(). - Namespace(c.ns). - Resource("trafficsplits"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of TrafficSplits that match those selectors. -func (c *trafficSplits) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.TrafficSplitList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.TrafficSplitList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("trafficsplits"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested trafficSplits. -func (c *trafficSplits) 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("trafficsplits"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a trafficSplit and creates it. Returns the server's representation of the trafficSplit, and an error, if there is any. -func (c *trafficSplits) Create(ctx context.Context, trafficSplit *v1alpha1.TrafficSplit, opts v1.CreateOptions) (result *v1alpha1.TrafficSplit, err error) { - result = &v1alpha1.TrafficSplit{} - err = c.client.Post(). - Namespace(c.ns). - Resource("trafficsplits"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(trafficSplit). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a trafficSplit and updates it. Returns the server's representation of the trafficSplit, and an error, if there is any. -func (c *trafficSplits) Update(ctx context.Context, trafficSplit *v1alpha1.TrafficSplit, opts v1.UpdateOptions) (result *v1alpha1.TrafficSplit, err error) { - result = &v1alpha1.TrafficSplit{} - err = c.client.Put(). - Namespace(c.ns). - Resource("trafficsplits"). - Name(trafficSplit.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(trafficSplit). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the trafficSplit and deletes it. Returns an error if one occurs. -func (c *trafficSplits) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("trafficsplits"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *trafficSplits) 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("trafficsplits"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched trafficSplit. -func (c *trafficSplits) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.TrafficSplit, err error) { - result = &v1alpha1.TrafficSplit{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("trafficsplits"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/smi/v1alpha2/fake/fake_trafficsplit.go b/pkg/client/clientset/versioned/typed/smi/v1alpha2/fake/fake_trafficsplit.go index b7f93ecf3..80e4059d7 100644 --- a/pkg/client/clientset/versioned/typed/smi/v1alpha2/fake/fake_trafficsplit.go +++ b/pkg/client/clientset/versioned/typed/smi/v1alpha2/fake/fake_trafficsplit.go @@ -41,22 +41,24 @@ var trafficsplitsKind = v1alpha2.SchemeGroupVersion.WithKind("TrafficSplit") // Get takes name of the trafficSplit, and returns the corresponding trafficSplit object, and an error if there is any. func (c *FakeTrafficSplits) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.TrafficSplit, err error) { + emptyResult := &v1alpha2.TrafficSplit{} obj, err := c.Fake. - Invokes(testing.NewGetAction(trafficsplitsResource, c.ns, name), &v1alpha2.TrafficSplit{}) + Invokes(testing.NewGetActionWithOptions(trafficsplitsResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha2.TrafficSplit), err } // List takes label and field selectors, and returns the list of TrafficSplits that match those selectors. func (c *FakeTrafficSplits) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.TrafficSplitList, err error) { + emptyResult := &v1alpha2.TrafficSplitList{} obj, err := c.Fake. - Invokes(testing.NewListAction(trafficsplitsResource, trafficsplitsKind, c.ns, opts), &v1alpha2.TrafficSplitList{}) + Invokes(testing.NewListActionWithOptions(trafficsplitsResource, trafficsplitsKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeTrafficSplits) List(ctx context.Context, opts v1.ListOptions) (resu // Watch returns a watch.Interface that watches the requested trafficSplits. func (c *FakeTrafficSplits) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(trafficsplitsResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(trafficsplitsResource, c.ns, opts)) } // Create takes the representation of a trafficSplit and creates it. Returns the server's representation of the trafficSplit, and an error, if there is any. func (c *FakeTrafficSplits) Create(ctx context.Context, trafficSplit *v1alpha2.TrafficSplit, opts v1.CreateOptions) (result *v1alpha2.TrafficSplit, err error) { + emptyResult := &v1alpha2.TrafficSplit{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(trafficsplitsResource, c.ns, trafficSplit), &v1alpha2.TrafficSplit{}) + Invokes(testing.NewCreateActionWithOptions(trafficsplitsResource, c.ns, trafficSplit, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha2.TrafficSplit), err } // Update takes the representation of a trafficSplit and updates it. Returns the server's representation of the trafficSplit, and an error, if there is any. func (c *FakeTrafficSplits) Update(ctx context.Context, trafficSplit *v1alpha2.TrafficSplit, opts v1.UpdateOptions) (result *v1alpha2.TrafficSplit, err error) { + emptyResult := &v1alpha2.TrafficSplit{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(trafficsplitsResource, c.ns, trafficSplit), &v1alpha2.TrafficSplit{}) + Invokes(testing.NewUpdateActionWithOptions(trafficsplitsResource, c.ns, trafficSplit, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha2.TrafficSplit), err } @@ -111,7 +115,7 @@ func (c *FakeTrafficSplits) Delete(ctx context.Context, name string, opts v1.Del // DeleteCollection deletes a collection of objects. func (c *FakeTrafficSplits) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(trafficsplitsResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(trafficsplitsResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha2.TrafficSplitList{}) return err @@ -119,11 +123,12 @@ func (c *FakeTrafficSplits) DeleteCollection(ctx context.Context, opts v1.Delete // Patch applies the patch and returns the patched trafficSplit. func (c *FakeTrafficSplits) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.TrafficSplit, err error) { + emptyResult := &v1alpha2.TrafficSplit{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(trafficsplitsResource, c.ns, name, pt, data, subresources...), &v1alpha2.TrafficSplit{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(trafficsplitsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha2.TrafficSplit), err } diff --git a/pkg/client/clientset/versioned/typed/smi/v1alpha2/trafficsplit.go b/pkg/client/clientset/versioned/typed/smi/v1alpha2/trafficsplit.go index 45f5f4fdc..cd0524a19 100644 --- a/pkg/client/clientset/versioned/typed/smi/v1alpha2/trafficsplit.go +++ b/pkg/client/clientset/versioned/typed/smi/v1alpha2/trafficsplit.go @@ -20,14 +20,13 @@ package v1alpha2 import ( "context" - "time" v1alpha2 "github.com/fluxcd/flagger/pkg/apis/smi/v1alpha2" scheme "github.com/fluxcd/flagger/pkg/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" ) // TrafficSplitsGetter has a method to return a TrafficSplitInterface. @@ -51,128 +50,18 @@ type TrafficSplitInterface interface { // trafficSplits implements TrafficSplitInterface type trafficSplits struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1alpha2.TrafficSplit, *v1alpha2.TrafficSplitList] } // newTrafficSplits returns a TrafficSplits func newTrafficSplits(c *SplitV1alpha2Client, namespace string) *trafficSplits { return &trafficSplits{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1alpha2.TrafficSplit, *v1alpha2.TrafficSplitList]( + "trafficsplits", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha2.TrafficSplit { return &v1alpha2.TrafficSplit{} }, + func() *v1alpha2.TrafficSplitList { return &v1alpha2.TrafficSplitList{} }), } } - -// Get takes name of the trafficSplit, and returns the corresponding trafficSplit object, and an error if there is any. -func (c *trafficSplits) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.TrafficSplit, err error) { - result = &v1alpha2.TrafficSplit{} - err = c.client.Get(). - Namespace(c.ns). - Resource("trafficsplits"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of TrafficSplits that match those selectors. -func (c *trafficSplits) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.TrafficSplitList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha2.TrafficSplitList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("trafficsplits"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested trafficSplits. -func (c *trafficSplits) 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("trafficsplits"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a trafficSplit and creates it. Returns the server's representation of the trafficSplit, and an error, if there is any. -func (c *trafficSplits) Create(ctx context.Context, trafficSplit *v1alpha2.TrafficSplit, opts v1.CreateOptions) (result *v1alpha2.TrafficSplit, err error) { - result = &v1alpha2.TrafficSplit{} - err = c.client.Post(). - Namespace(c.ns). - Resource("trafficsplits"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(trafficSplit). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a trafficSplit and updates it. Returns the server's representation of the trafficSplit, and an error, if there is any. -func (c *trafficSplits) Update(ctx context.Context, trafficSplit *v1alpha2.TrafficSplit, opts v1.UpdateOptions) (result *v1alpha2.TrafficSplit, err error) { - result = &v1alpha2.TrafficSplit{} - err = c.client.Put(). - Namespace(c.ns). - Resource("trafficsplits"). - Name(trafficSplit.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(trafficSplit). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the trafficSplit and deletes it. Returns an error if one occurs. -func (c *trafficSplits) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("trafficsplits"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *trafficSplits) 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("trafficsplits"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched trafficSplit. -func (c *trafficSplits) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.TrafficSplit, err error) { - result = &v1alpha2.TrafficSplit{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("trafficsplits"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/smi/v1alpha3/fake/fake_trafficsplit.go b/pkg/client/clientset/versioned/typed/smi/v1alpha3/fake/fake_trafficsplit.go index 746842dce..fc2d1f7bf 100644 --- a/pkg/client/clientset/versioned/typed/smi/v1alpha3/fake/fake_trafficsplit.go +++ b/pkg/client/clientset/versioned/typed/smi/v1alpha3/fake/fake_trafficsplit.go @@ -41,22 +41,24 @@ var trafficsplitsKind = v1alpha3.SchemeGroupVersion.WithKind("TrafficSplit") // Get takes name of the trafficSplit, and returns the corresponding trafficSplit object, and an error if there is any. func (c *FakeTrafficSplits) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha3.TrafficSplit, err error) { + emptyResult := &v1alpha3.TrafficSplit{} obj, err := c.Fake. - Invokes(testing.NewGetAction(trafficsplitsResource, c.ns, name), &v1alpha3.TrafficSplit{}) + Invokes(testing.NewGetActionWithOptions(trafficsplitsResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha3.TrafficSplit), err } // List takes label and field selectors, and returns the list of TrafficSplits that match those selectors. func (c *FakeTrafficSplits) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha3.TrafficSplitList, err error) { + emptyResult := &v1alpha3.TrafficSplitList{} obj, err := c.Fake. - Invokes(testing.NewListAction(trafficsplitsResource, trafficsplitsKind, c.ns, opts), &v1alpha3.TrafficSplitList{}) + Invokes(testing.NewListActionWithOptions(trafficsplitsResource, trafficsplitsKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeTrafficSplits) List(ctx context.Context, opts v1.ListOptions) (resu // Watch returns a watch.Interface that watches the requested trafficSplits. func (c *FakeTrafficSplits) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(trafficsplitsResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(trafficsplitsResource, c.ns, opts)) } // Create takes the representation of a trafficSplit and creates it. Returns the server's representation of the trafficSplit, and an error, if there is any. func (c *FakeTrafficSplits) Create(ctx context.Context, trafficSplit *v1alpha3.TrafficSplit, opts v1.CreateOptions) (result *v1alpha3.TrafficSplit, err error) { + emptyResult := &v1alpha3.TrafficSplit{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(trafficsplitsResource, c.ns, trafficSplit), &v1alpha3.TrafficSplit{}) + Invokes(testing.NewCreateActionWithOptions(trafficsplitsResource, c.ns, trafficSplit, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha3.TrafficSplit), err } // Update takes the representation of a trafficSplit and updates it. Returns the server's representation of the trafficSplit, and an error, if there is any. func (c *FakeTrafficSplits) Update(ctx context.Context, trafficSplit *v1alpha3.TrafficSplit, opts v1.UpdateOptions) (result *v1alpha3.TrafficSplit, err error) { + emptyResult := &v1alpha3.TrafficSplit{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(trafficsplitsResource, c.ns, trafficSplit), &v1alpha3.TrafficSplit{}) + Invokes(testing.NewUpdateActionWithOptions(trafficsplitsResource, c.ns, trafficSplit, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha3.TrafficSplit), err } @@ -111,7 +115,7 @@ func (c *FakeTrafficSplits) Delete(ctx context.Context, name string, opts v1.Del // DeleteCollection deletes a collection of objects. func (c *FakeTrafficSplits) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(trafficsplitsResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(trafficsplitsResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha3.TrafficSplitList{}) return err @@ -119,11 +123,12 @@ func (c *FakeTrafficSplits) DeleteCollection(ctx context.Context, opts v1.Delete // Patch applies the patch and returns the patched trafficSplit. func (c *FakeTrafficSplits) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.TrafficSplit, err error) { + emptyResult := &v1alpha3.TrafficSplit{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(trafficsplitsResource, c.ns, name, pt, data, subresources...), &v1alpha3.TrafficSplit{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(trafficsplitsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha3.TrafficSplit), err } diff --git a/pkg/client/clientset/versioned/typed/smi/v1alpha3/trafficsplit.go b/pkg/client/clientset/versioned/typed/smi/v1alpha3/trafficsplit.go index 73bb996b7..e3b2bd2d8 100644 --- a/pkg/client/clientset/versioned/typed/smi/v1alpha3/trafficsplit.go +++ b/pkg/client/clientset/versioned/typed/smi/v1alpha3/trafficsplit.go @@ -20,14 +20,13 @@ package v1alpha3 import ( "context" - "time" v1alpha3 "github.com/fluxcd/flagger/pkg/apis/smi/v1alpha3" scheme "github.com/fluxcd/flagger/pkg/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" ) // TrafficSplitsGetter has a method to return a TrafficSplitInterface. @@ -51,128 +50,18 @@ type TrafficSplitInterface interface { // trafficSplits implements TrafficSplitInterface type trafficSplits struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1alpha3.TrafficSplit, *v1alpha3.TrafficSplitList] } // newTrafficSplits returns a TrafficSplits func newTrafficSplits(c *SplitV1alpha3Client, namespace string) *trafficSplits { return &trafficSplits{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1alpha3.TrafficSplit, *v1alpha3.TrafficSplitList]( + "trafficsplits", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha3.TrafficSplit { return &v1alpha3.TrafficSplit{} }, + func() *v1alpha3.TrafficSplitList { return &v1alpha3.TrafficSplitList{} }), } } - -// Get takes name of the trafficSplit, and returns the corresponding trafficSplit object, and an error if there is any. -func (c *trafficSplits) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha3.TrafficSplit, err error) { - result = &v1alpha3.TrafficSplit{} - err = c.client.Get(). - Namespace(c.ns). - Resource("trafficsplits"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of TrafficSplits that match those selectors. -func (c *trafficSplits) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha3.TrafficSplitList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha3.TrafficSplitList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("trafficsplits"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested trafficSplits. -func (c *trafficSplits) 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("trafficsplits"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a trafficSplit and creates it. Returns the server's representation of the trafficSplit, and an error, if there is any. -func (c *trafficSplits) Create(ctx context.Context, trafficSplit *v1alpha3.TrafficSplit, opts v1.CreateOptions) (result *v1alpha3.TrafficSplit, err error) { - result = &v1alpha3.TrafficSplit{} - err = c.client.Post(). - Namespace(c.ns). - Resource("trafficsplits"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(trafficSplit). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a trafficSplit and updates it. Returns the server's representation of the trafficSplit, and an error, if there is any. -func (c *trafficSplits) Update(ctx context.Context, trafficSplit *v1alpha3.TrafficSplit, opts v1.UpdateOptions) (result *v1alpha3.TrafficSplit, err error) { - result = &v1alpha3.TrafficSplit{} - err = c.client.Put(). - Namespace(c.ns). - Resource("trafficsplits"). - Name(trafficSplit.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(trafficSplit). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the trafficSplit and deletes it. Returns an error if one occurs. -func (c *trafficSplits) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("trafficsplits"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *trafficSplits) 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("trafficsplits"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched trafficSplit. -func (c *trafficSplits) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha3.TrafficSplit, err error) { - result = &v1alpha3.TrafficSplit{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("trafficsplits"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/traefik/v1alpha1/fake/fake_traefikservice.go b/pkg/client/clientset/versioned/typed/traefik/v1alpha1/fake/fake_traefikservice.go index ee43ee2f8..2a6ca0789 100644 --- a/pkg/client/clientset/versioned/typed/traefik/v1alpha1/fake/fake_traefikservice.go +++ b/pkg/client/clientset/versioned/typed/traefik/v1alpha1/fake/fake_traefikservice.go @@ -41,22 +41,24 @@ var traefikservicesKind = v1alpha1.SchemeGroupVersion.WithKind("TraefikService") // Get takes name of the traefikService, and returns the corresponding traefikService object, and an error if there is any. func (c *FakeTraefikServices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.TraefikService, err error) { + emptyResult := &v1alpha1.TraefikService{} obj, err := c.Fake. - Invokes(testing.NewGetAction(traefikservicesResource, c.ns, name), &v1alpha1.TraefikService{}) + Invokes(testing.NewGetActionWithOptions(traefikservicesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TraefikService), err } // List takes label and field selectors, and returns the list of TraefikServices that match those selectors. func (c *FakeTraefikServices) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.TraefikServiceList, err error) { + emptyResult := &v1alpha1.TraefikServiceList{} obj, err := c.Fake. - Invokes(testing.NewListAction(traefikservicesResource, traefikservicesKind, c.ns, opts), &v1alpha1.TraefikServiceList{}) + Invokes(testing.NewListActionWithOptions(traefikservicesResource, traefikservicesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -75,28 +77,30 @@ func (c *FakeTraefikServices) List(ctx context.Context, opts v1.ListOptions) (re // Watch returns a watch.Interface that watches the requested traefikServices. func (c *FakeTraefikServices) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(traefikservicesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(traefikservicesResource, c.ns, opts)) } // Create takes the representation of a traefikService and creates it. Returns the server's representation of the traefikService, and an error, if there is any. func (c *FakeTraefikServices) Create(ctx context.Context, traefikService *v1alpha1.TraefikService, opts v1.CreateOptions) (result *v1alpha1.TraefikService, err error) { + emptyResult := &v1alpha1.TraefikService{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(traefikservicesResource, c.ns, traefikService), &v1alpha1.TraefikService{}) + Invokes(testing.NewCreateActionWithOptions(traefikservicesResource, c.ns, traefikService, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TraefikService), err } // Update takes the representation of a traefikService and updates it. Returns the server's representation of the traefikService, and an error, if there is any. func (c *FakeTraefikServices) Update(ctx context.Context, traefikService *v1alpha1.TraefikService, opts v1.UpdateOptions) (result *v1alpha1.TraefikService, err error) { + emptyResult := &v1alpha1.TraefikService{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(traefikservicesResource, c.ns, traefikService), &v1alpha1.TraefikService{}) + Invokes(testing.NewUpdateActionWithOptions(traefikservicesResource, c.ns, traefikService, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TraefikService), err } @@ -111,7 +115,7 @@ func (c *FakeTraefikServices) Delete(ctx context.Context, name string, opts v1.D // DeleteCollection deletes a collection of objects. func (c *FakeTraefikServices) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(traefikservicesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(traefikservicesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha1.TraefikServiceList{}) return err @@ -119,11 +123,12 @@ func (c *FakeTraefikServices) DeleteCollection(ctx context.Context, opts v1.Dele // Patch applies the patch and returns the patched traefikService. func (c *FakeTraefikServices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.TraefikService, err error) { + emptyResult := &v1alpha1.TraefikService{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(traefikservicesResource, c.ns, name, pt, data, subresources...), &v1alpha1.TraefikService{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(traefikservicesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TraefikService), err } diff --git a/pkg/client/clientset/versioned/typed/traefik/v1alpha1/traefikservice.go b/pkg/client/clientset/versioned/typed/traefik/v1alpha1/traefikservice.go index 3d1ce4727..f65979917 100644 --- a/pkg/client/clientset/versioned/typed/traefik/v1alpha1/traefikservice.go +++ b/pkg/client/clientset/versioned/typed/traefik/v1alpha1/traefikservice.go @@ -20,14 +20,13 @@ package v1alpha1 import ( "context" - "time" v1alpha1 "github.com/fluxcd/flagger/pkg/apis/traefik/v1alpha1" scheme "github.com/fluxcd/flagger/pkg/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" ) // TraefikServicesGetter has a method to return a TraefikServiceInterface. @@ -51,128 +50,18 @@ type TraefikServiceInterface interface { // traefikServices implements TraefikServiceInterface type traefikServices struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1alpha1.TraefikService, *v1alpha1.TraefikServiceList] } // newTraefikServices returns a TraefikServices func newTraefikServices(c *TraefikV1alpha1Client, namespace string) *traefikServices { return &traefikServices{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1alpha1.TraefikService, *v1alpha1.TraefikServiceList]( + "traefikservices", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha1.TraefikService { return &v1alpha1.TraefikService{} }, + func() *v1alpha1.TraefikServiceList { return &v1alpha1.TraefikServiceList{} }), } } - -// Get takes name of the traefikService, and returns the corresponding traefikService object, and an error if there is any. -func (c *traefikServices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.TraefikService, err error) { - result = &v1alpha1.TraefikService{} - err = c.client.Get(). - Namespace(c.ns). - Resource("traefikservices"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of TraefikServices that match those selectors. -func (c *traefikServices) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.TraefikServiceList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.TraefikServiceList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("traefikservices"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested traefikServices. -func (c *traefikServices) 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("traefikservices"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a traefikService and creates it. Returns the server's representation of the traefikService, and an error, if there is any. -func (c *traefikServices) Create(ctx context.Context, traefikService *v1alpha1.TraefikService, opts v1.CreateOptions) (result *v1alpha1.TraefikService, err error) { - result = &v1alpha1.TraefikService{} - err = c.client.Post(). - Namespace(c.ns). - Resource("traefikservices"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(traefikService). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a traefikService and updates it. Returns the server's representation of the traefikService, and an error, if there is any. -func (c *traefikServices) Update(ctx context.Context, traefikService *v1alpha1.TraefikService, opts v1.UpdateOptions) (result *v1alpha1.TraefikService, err error) { - result = &v1alpha1.TraefikService{} - err = c.client.Put(). - Namespace(c.ns). - Resource("traefikservices"). - Name(traefikService.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(traefikService). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the traefikService and deletes it. Returns an error if one occurs. -func (c *traefikServices) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("traefikservices"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *traefikServices) 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("traefikservices"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched traefikService. -func (c *traefikServices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.TraefikService, err error) { - result = &v1alpha1.TraefikService{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("traefikservices"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go index 014bac86e..bce8238e4 100644 --- a/pkg/client/informers/externalversions/factory.go +++ b/pkg/client/informers/externalversions/factory.go @@ -239,6 +239,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/pkg/client/listers/apisix/v2/apisixroute.go b/pkg/client/listers/apisix/v2/apisixroute.go index a3e6183fd..7a1477afe 100644 --- a/pkg/client/listers/apisix/v2/apisixroute.go +++ b/pkg/client/listers/apisix/v2/apisixroute.go @@ -20,8 +20,8 @@ package v2 import ( v2 "github.com/fluxcd/flagger/pkg/apis/apisix/v2" - "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 ApisixRouteLister interface { // apisixRouteLister implements the ApisixRouteLister interface. type apisixRouteLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v2.ApisixRoute] } // NewApisixRouteLister returns a new ApisixRouteLister. func NewApisixRouteLister(indexer cache.Indexer) ApisixRouteLister { - return &apisixRouteLister{indexer: indexer} -} - -// List lists all ApisixRoutes in the indexer. -func (s *apisixRouteLister) List(selector labels.Selector) (ret []*v2.ApisixRoute, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v2.ApisixRoute)) - }) - return ret, err + return &apisixRouteLister{listers.New[*v2.ApisixRoute](indexer, v2.Resource("apisixroute"))} } // ApisixRoutes returns an object that can list and get ApisixRoutes. func (s *apisixRouteLister) ApisixRoutes(namespace string) ApisixRouteNamespaceLister { - return apisixRouteNamespaceLister{indexer: s.indexer, namespace: namespace} + return apisixRouteNamespaceLister{listers.NewNamespaced[*v2.ApisixRoute](s.ResourceIndexer, namespace)} } // ApisixRouteNamespaceLister helps list and get ApisixRoutes. @@ -74,26 +66,5 @@ type ApisixRouteNamespaceLister interface { // apisixRouteNamespaceLister implements the ApisixRouteNamespaceLister // interface. type apisixRouteNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all ApisixRoutes in the indexer for a given namespace. -func (s apisixRouteNamespaceLister) List(selector labels.Selector) (ret []*v2.ApisixRoute, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v2.ApisixRoute)) - }) - return ret, err -} - -// Get retrieves the ApisixRoute from the indexer for a given namespace and name. -func (s apisixRouteNamespaceLister) Get(name string) (*v2.ApisixRoute, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v2.Resource("apisixroute"), name) - } - return obj.(*v2.ApisixRoute), nil + listers.ResourceIndexer[*v2.ApisixRoute] } diff --git a/pkg/client/listers/appmesh/v1beta1/mesh.go b/pkg/client/listers/appmesh/v1beta1/mesh.go index c47db8799..ab868deb1 100644 --- a/pkg/client/listers/appmesh/v1beta1/mesh.go +++ b/pkg/client/listers/appmesh/v1beta1/mesh.go @@ -20,8 +20,8 @@ package v1beta1 import ( v1beta1 "github.com/fluxcd/flagger/pkg/apis/appmesh/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,30 +39,10 @@ type MeshLister interface { // meshLister implements the MeshLister interface. type meshLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta1.Mesh] } // NewMeshLister returns a new MeshLister. func NewMeshLister(indexer cache.Indexer) MeshLister { - return &meshLister{indexer: indexer} -} - -// List lists all Meshes in the indexer. -func (s *meshLister) List(selector labels.Selector) (ret []*v1beta1.Mesh, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.Mesh)) - }) - return ret, err -} - -// Get retrieves the Mesh from the index for a given name. -func (s *meshLister) Get(name string) (*v1beta1.Mesh, error) { - obj, exists, err := s.indexer.GetByKey(name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("mesh"), name) - } - return obj.(*v1beta1.Mesh), nil + return &meshLister{listers.New[*v1beta1.Mesh](indexer, v1beta1.Resource("mesh"))} } diff --git a/pkg/client/listers/appmesh/v1beta1/virtualnode.go b/pkg/client/listers/appmesh/v1beta1/virtualnode.go index 863e903e0..dde9413f9 100644 --- a/pkg/client/listers/appmesh/v1beta1/virtualnode.go +++ b/pkg/client/listers/appmesh/v1beta1/virtualnode.go @@ -20,8 +20,8 @@ package v1beta1 import ( v1beta1 "github.com/fluxcd/flagger/pkg/apis/appmesh/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 VirtualNodeLister interface { // virtualNodeLister implements the VirtualNodeLister interface. type virtualNodeLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta1.VirtualNode] } // NewVirtualNodeLister returns a new VirtualNodeLister. func NewVirtualNodeLister(indexer cache.Indexer) VirtualNodeLister { - return &virtualNodeLister{indexer: indexer} -} - -// List lists all VirtualNodes in the indexer. -func (s *virtualNodeLister) List(selector labels.Selector) (ret []*v1beta1.VirtualNode, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.VirtualNode)) - }) - return ret, err + return &virtualNodeLister{listers.New[*v1beta1.VirtualNode](indexer, v1beta1.Resource("virtualnode"))} } // VirtualNodes returns an object that can list and get VirtualNodes. func (s *virtualNodeLister) VirtualNodes(namespace string) VirtualNodeNamespaceLister { - return virtualNodeNamespaceLister{indexer: s.indexer, namespace: namespace} + return virtualNodeNamespaceLister{listers.NewNamespaced[*v1beta1.VirtualNode](s.ResourceIndexer, namespace)} } // VirtualNodeNamespaceLister helps list and get VirtualNodes. @@ -74,26 +66,5 @@ type VirtualNodeNamespaceLister interface { // virtualNodeNamespaceLister implements the VirtualNodeNamespaceLister // interface. type virtualNodeNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all VirtualNodes in the indexer for a given namespace. -func (s virtualNodeNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.VirtualNode, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.VirtualNode)) - }) - return ret, err -} - -// Get retrieves the VirtualNode from the indexer for a given namespace and name. -func (s virtualNodeNamespaceLister) Get(name string) (*v1beta1.VirtualNode, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("virtualnode"), name) - } - return obj.(*v1beta1.VirtualNode), nil + listers.ResourceIndexer[*v1beta1.VirtualNode] } diff --git a/pkg/client/listers/appmesh/v1beta1/virtualservice.go b/pkg/client/listers/appmesh/v1beta1/virtualservice.go index af2cfcaa3..d6a2e0ee3 100644 --- a/pkg/client/listers/appmesh/v1beta1/virtualservice.go +++ b/pkg/client/listers/appmesh/v1beta1/virtualservice.go @@ -20,8 +20,8 @@ package v1beta1 import ( v1beta1 "github.com/fluxcd/flagger/pkg/apis/appmesh/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 VirtualServiceLister interface { // virtualServiceLister implements the VirtualServiceLister interface. type virtualServiceLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta1.VirtualService] } // NewVirtualServiceLister returns a new VirtualServiceLister. func NewVirtualServiceLister(indexer cache.Indexer) VirtualServiceLister { - return &virtualServiceLister{indexer: indexer} -} - -// List lists all VirtualServices in the indexer. -func (s *virtualServiceLister) List(selector labels.Selector) (ret []*v1beta1.VirtualService, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.VirtualService)) - }) - return ret, err + return &virtualServiceLister{listers.New[*v1beta1.VirtualService](indexer, v1beta1.Resource("virtualservice"))} } // VirtualServices returns an object that can list and get VirtualServices. func (s *virtualServiceLister) VirtualServices(namespace string) VirtualServiceNamespaceLister { - return virtualServiceNamespaceLister{indexer: s.indexer, namespace: namespace} + return virtualServiceNamespaceLister{listers.NewNamespaced[*v1beta1.VirtualService](s.ResourceIndexer, namespace)} } // VirtualServiceNamespaceLister helps list and get VirtualServices. @@ -74,26 +66,5 @@ type VirtualServiceNamespaceLister interface { // virtualServiceNamespaceLister implements the VirtualServiceNamespaceLister // interface. type virtualServiceNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all VirtualServices in the indexer for a given namespace. -func (s virtualServiceNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.VirtualService, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.VirtualService)) - }) - return ret, err -} - -// Get retrieves the VirtualService from the indexer for a given namespace and name. -func (s virtualServiceNamespaceLister) Get(name string) (*v1beta1.VirtualService, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("virtualservice"), name) - } - return obj.(*v1beta1.VirtualService), nil + listers.ResourceIndexer[*v1beta1.VirtualService] } diff --git a/pkg/client/listers/appmesh/v1beta2/virtualnode.go b/pkg/client/listers/appmesh/v1beta2/virtualnode.go index 7e933af26..dcaa2cda8 100644 --- a/pkg/client/listers/appmesh/v1beta2/virtualnode.go +++ b/pkg/client/listers/appmesh/v1beta2/virtualnode.go @@ -20,8 +20,8 @@ package v1beta2 import ( v1beta2 "github.com/fluxcd/flagger/pkg/apis/appmesh/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 VirtualNodeLister interface { // virtualNodeLister implements the VirtualNodeLister interface. type virtualNodeLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta2.VirtualNode] } // NewVirtualNodeLister returns a new VirtualNodeLister. func NewVirtualNodeLister(indexer cache.Indexer) VirtualNodeLister { - return &virtualNodeLister{indexer: indexer} -} - -// List lists all VirtualNodes in the indexer. -func (s *virtualNodeLister) List(selector labels.Selector) (ret []*v1beta2.VirtualNode, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta2.VirtualNode)) - }) - return ret, err + return &virtualNodeLister{listers.New[*v1beta2.VirtualNode](indexer, v1beta2.Resource("virtualnode"))} } // VirtualNodes returns an object that can list and get VirtualNodes. func (s *virtualNodeLister) VirtualNodes(namespace string) VirtualNodeNamespaceLister { - return virtualNodeNamespaceLister{indexer: s.indexer, namespace: namespace} + return virtualNodeNamespaceLister{listers.NewNamespaced[*v1beta2.VirtualNode](s.ResourceIndexer, namespace)} } // VirtualNodeNamespaceLister helps list and get VirtualNodes. @@ -74,26 +66,5 @@ type VirtualNodeNamespaceLister interface { // virtualNodeNamespaceLister implements the VirtualNodeNamespaceLister // interface. type virtualNodeNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all VirtualNodes in the indexer for a given namespace. -func (s virtualNodeNamespaceLister) List(selector labels.Selector) (ret []*v1beta2.VirtualNode, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta2.VirtualNode)) - }) - return ret, err -} - -// Get retrieves the VirtualNode from the indexer for a given namespace and name. -func (s virtualNodeNamespaceLister) Get(name string) (*v1beta2.VirtualNode, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta2.Resource("virtualnode"), name) - } - return obj.(*v1beta2.VirtualNode), nil + listers.ResourceIndexer[*v1beta2.VirtualNode] } diff --git a/pkg/client/listers/appmesh/v1beta2/virtualrouter.go b/pkg/client/listers/appmesh/v1beta2/virtualrouter.go index f54e5a578..cc370e672 100644 --- a/pkg/client/listers/appmesh/v1beta2/virtualrouter.go +++ b/pkg/client/listers/appmesh/v1beta2/virtualrouter.go @@ -20,8 +20,8 @@ package v1beta2 import ( v1beta2 "github.com/fluxcd/flagger/pkg/apis/appmesh/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 VirtualRouterLister interface { // virtualRouterLister implements the VirtualRouterLister interface. type virtualRouterLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta2.VirtualRouter] } // NewVirtualRouterLister returns a new VirtualRouterLister. func NewVirtualRouterLister(indexer cache.Indexer) VirtualRouterLister { - return &virtualRouterLister{indexer: indexer} -} - -// List lists all VirtualRouters in the indexer. -func (s *virtualRouterLister) List(selector labels.Selector) (ret []*v1beta2.VirtualRouter, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta2.VirtualRouter)) - }) - return ret, err + return &virtualRouterLister{listers.New[*v1beta2.VirtualRouter](indexer, v1beta2.Resource("virtualrouter"))} } // VirtualRouters returns an object that can list and get VirtualRouters. func (s *virtualRouterLister) VirtualRouters(namespace string) VirtualRouterNamespaceLister { - return virtualRouterNamespaceLister{indexer: s.indexer, namespace: namespace} + return virtualRouterNamespaceLister{listers.NewNamespaced[*v1beta2.VirtualRouter](s.ResourceIndexer, namespace)} } // VirtualRouterNamespaceLister helps list and get VirtualRouters. @@ -74,26 +66,5 @@ type VirtualRouterNamespaceLister interface { // virtualRouterNamespaceLister implements the VirtualRouterNamespaceLister // interface. type virtualRouterNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all VirtualRouters in the indexer for a given namespace. -func (s virtualRouterNamespaceLister) List(selector labels.Selector) (ret []*v1beta2.VirtualRouter, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta2.VirtualRouter)) - }) - return ret, err -} - -// Get retrieves the VirtualRouter from the indexer for a given namespace and name. -func (s virtualRouterNamespaceLister) Get(name string) (*v1beta2.VirtualRouter, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta2.Resource("virtualrouter"), name) - } - return obj.(*v1beta2.VirtualRouter), nil + listers.ResourceIndexer[*v1beta2.VirtualRouter] } diff --git a/pkg/client/listers/appmesh/v1beta2/virtualservice.go b/pkg/client/listers/appmesh/v1beta2/virtualservice.go index 1ba3177fc..11fa77a42 100644 --- a/pkg/client/listers/appmesh/v1beta2/virtualservice.go +++ b/pkg/client/listers/appmesh/v1beta2/virtualservice.go @@ -20,8 +20,8 @@ package v1beta2 import ( v1beta2 "github.com/fluxcd/flagger/pkg/apis/appmesh/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 VirtualServiceLister interface { // virtualServiceLister implements the VirtualServiceLister interface. type virtualServiceLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta2.VirtualService] } // NewVirtualServiceLister returns a new VirtualServiceLister. func NewVirtualServiceLister(indexer cache.Indexer) VirtualServiceLister { - return &virtualServiceLister{indexer: indexer} -} - -// List lists all VirtualServices in the indexer. -func (s *virtualServiceLister) List(selector labels.Selector) (ret []*v1beta2.VirtualService, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta2.VirtualService)) - }) - return ret, err + return &virtualServiceLister{listers.New[*v1beta2.VirtualService](indexer, v1beta2.Resource("virtualservice"))} } // VirtualServices returns an object that can list and get VirtualServices. func (s *virtualServiceLister) VirtualServices(namespace string) VirtualServiceNamespaceLister { - return virtualServiceNamespaceLister{indexer: s.indexer, namespace: namespace} + return virtualServiceNamespaceLister{listers.NewNamespaced[*v1beta2.VirtualService](s.ResourceIndexer, namespace)} } // VirtualServiceNamespaceLister helps list and get VirtualServices. @@ -74,26 +66,5 @@ type VirtualServiceNamespaceLister interface { // virtualServiceNamespaceLister implements the VirtualServiceNamespaceLister // interface. type virtualServiceNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all VirtualServices in the indexer for a given namespace. -func (s virtualServiceNamespaceLister) List(selector labels.Selector) (ret []*v1beta2.VirtualService, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta2.VirtualService)) - }) - return ret, err -} - -// Get retrieves the VirtualService from the indexer for a given namespace and name. -func (s virtualServiceNamespaceLister) Get(name string) (*v1beta2.VirtualService, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta2.Resource("virtualservice"), name) - } - return obj.(*v1beta2.VirtualService), nil + listers.ResourceIndexer[*v1beta2.VirtualService] } diff --git a/pkg/client/listers/flagger/v1beta1/alertprovider.go b/pkg/client/listers/flagger/v1beta1/alertprovider.go index c0c629a01..3074041d9 100644 --- a/pkg/client/listers/flagger/v1beta1/alertprovider.go +++ b/pkg/client/listers/flagger/v1beta1/alertprovider.go @@ -20,8 +20,8 @@ package v1beta1 import ( v1beta1 "github.com/fluxcd/flagger/pkg/apis/flagger/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 AlertProviderLister interface { // alertProviderLister implements the AlertProviderLister interface. type alertProviderLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta1.AlertProvider] } // NewAlertProviderLister returns a new AlertProviderLister. func NewAlertProviderLister(indexer cache.Indexer) AlertProviderLister { - return &alertProviderLister{indexer: indexer} -} - -// List lists all AlertProviders in the indexer. -func (s *alertProviderLister) List(selector labels.Selector) (ret []*v1beta1.AlertProvider, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.AlertProvider)) - }) - return ret, err + return &alertProviderLister{listers.New[*v1beta1.AlertProvider](indexer, v1beta1.Resource("alertprovider"))} } // AlertProviders returns an object that can list and get AlertProviders. func (s *alertProviderLister) AlertProviders(namespace string) AlertProviderNamespaceLister { - return alertProviderNamespaceLister{indexer: s.indexer, namespace: namespace} + return alertProviderNamespaceLister{listers.NewNamespaced[*v1beta1.AlertProvider](s.ResourceIndexer, namespace)} } // AlertProviderNamespaceLister helps list and get AlertProviders. @@ -74,26 +66,5 @@ type AlertProviderNamespaceLister interface { // alertProviderNamespaceLister implements the AlertProviderNamespaceLister // interface. type alertProviderNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all AlertProviders in the indexer for a given namespace. -func (s alertProviderNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.AlertProvider, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.AlertProvider)) - }) - return ret, err -} - -// Get retrieves the AlertProvider from the indexer for a given namespace and name. -func (s alertProviderNamespaceLister) Get(name string) (*v1beta1.AlertProvider, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("alertprovider"), name) - } - return obj.(*v1beta1.AlertProvider), nil + listers.ResourceIndexer[*v1beta1.AlertProvider] } diff --git a/pkg/client/listers/flagger/v1beta1/canary.go b/pkg/client/listers/flagger/v1beta1/canary.go index 2631dba80..dbf864a20 100644 --- a/pkg/client/listers/flagger/v1beta1/canary.go +++ b/pkg/client/listers/flagger/v1beta1/canary.go @@ -20,8 +20,8 @@ package v1beta1 import ( v1beta1 "github.com/fluxcd/flagger/pkg/apis/flagger/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 CanaryLister interface { // canaryLister implements the CanaryLister interface. type canaryLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta1.Canary] } // NewCanaryLister returns a new CanaryLister. func NewCanaryLister(indexer cache.Indexer) CanaryLister { - return &canaryLister{indexer: indexer} -} - -// List lists all Canaries in the indexer. -func (s *canaryLister) List(selector labels.Selector) (ret []*v1beta1.Canary, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.Canary)) - }) - return ret, err + return &canaryLister{listers.New[*v1beta1.Canary](indexer, v1beta1.Resource("canary"))} } // Canaries returns an object that can list and get Canaries. func (s *canaryLister) Canaries(namespace string) CanaryNamespaceLister { - return canaryNamespaceLister{indexer: s.indexer, namespace: namespace} + return canaryNamespaceLister{listers.NewNamespaced[*v1beta1.Canary](s.ResourceIndexer, namespace)} } // CanaryNamespaceLister helps list and get Canaries. @@ -74,26 +66,5 @@ type CanaryNamespaceLister interface { // canaryNamespaceLister implements the CanaryNamespaceLister // interface. type canaryNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all Canaries in the indexer for a given namespace. -func (s canaryNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Canary, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.Canary)) - }) - return ret, err -} - -// Get retrieves the Canary from the indexer for a given namespace and name. -func (s canaryNamespaceLister) Get(name string) (*v1beta1.Canary, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("canary"), name) - } - return obj.(*v1beta1.Canary), nil + listers.ResourceIndexer[*v1beta1.Canary] } diff --git a/pkg/client/listers/flagger/v1beta1/metrictemplate.go b/pkg/client/listers/flagger/v1beta1/metrictemplate.go index d8ac6074f..aca8ae8f6 100644 --- a/pkg/client/listers/flagger/v1beta1/metrictemplate.go +++ b/pkg/client/listers/flagger/v1beta1/metrictemplate.go @@ -20,8 +20,8 @@ package v1beta1 import ( v1beta1 "github.com/fluxcd/flagger/pkg/apis/flagger/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 MetricTemplateLister interface { // metricTemplateLister implements the MetricTemplateLister interface. type metricTemplateLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta1.MetricTemplate] } // NewMetricTemplateLister returns a new MetricTemplateLister. func NewMetricTemplateLister(indexer cache.Indexer) MetricTemplateLister { - return &metricTemplateLister{indexer: indexer} -} - -// List lists all MetricTemplates in the indexer. -func (s *metricTemplateLister) List(selector labels.Selector) (ret []*v1beta1.MetricTemplate, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.MetricTemplate)) - }) - return ret, err + return &metricTemplateLister{listers.New[*v1beta1.MetricTemplate](indexer, v1beta1.Resource("metrictemplate"))} } // MetricTemplates returns an object that can list and get MetricTemplates. func (s *metricTemplateLister) MetricTemplates(namespace string) MetricTemplateNamespaceLister { - return metricTemplateNamespaceLister{indexer: s.indexer, namespace: namespace} + return metricTemplateNamespaceLister{listers.NewNamespaced[*v1beta1.MetricTemplate](s.ResourceIndexer, namespace)} } // MetricTemplateNamespaceLister helps list and get MetricTemplates. @@ -74,26 +66,5 @@ type MetricTemplateNamespaceLister interface { // metricTemplateNamespaceLister implements the MetricTemplateNamespaceLister // interface. type metricTemplateNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all MetricTemplates in the indexer for a given namespace. -func (s metricTemplateNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.MetricTemplate, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.MetricTemplate)) - }) - return ret, err -} - -// Get retrieves the MetricTemplate from the indexer for a given namespace and name. -func (s metricTemplateNamespaceLister) Get(name string) (*v1beta1.MetricTemplate, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("metrictemplate"), name) - } - return obj.(*v1beta1.MetricTemplate), nil + listers.ResourceIndexer[*v1beta1.MetricTemplate] } diff --git a/pkg/client/listers/gatewayapi/v1/httproute.go b/pkg/client/listers/gatewayapi/v1/httproute.go index ed4c0517f..6759088ea 100644 --- a/pkg/client/listers/gatewayapi/v1/httproute.go +++ b/pkg/client/listers/gatewayapi/v1/httproute.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/fluxcd/flagger/pkg/apis/gatewayapi/v1" - "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[*v1.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 []*v1.HTTPRoute, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1.HTTPRoute)) - }) - return ret, err + return &hTTPRouteLister{listers.New[*v1.HTTPRoute](indexer, v1.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[*v1.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 []*v1.HTTPRoute, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1.HTTPRoute)) - }) - return ret, err -} - -// Get retrieves the HTTPRoute from the indexer for a given namespace and name. -func (s hTTPRouteNamespaceLister) Get(name string) (*v1.HTTPRoute, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1.Resource("httproute"), name) - } - return obj.(*v1.HTTPRoute), nil + listers.ResourceIndexer[*v1.HTTPRoute] } diff --git a/pkg/client/listers/gatewayapi/v1beta1/httproute.go b/pkg/client/listers/gatewayapi/v1beta1/httproute.go index 1f7c9ad4f..a89965a84 100644 --- a/pkg/client/listers/gatewayapi/v1beta1/httproute.go +++ b/pkg/client/listers/gatewayapi/v1beta1/httproute.go @@ -20,8 +20,8 @@ package v1beta1 import ( v1beta1 "github.com/fluxcd/flagger/pkg/apis/gatewayapi/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 HTTPRouteLister interface { // hTTPRouteLister implements the HTTPRouteLister interface. type hTTPRouteLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta1.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 []*v1beta1.HTTPRoute, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.HTTPRoute)) - }) - return ret, err + return &hTTPRouteLister{listers.New[*v1beta1.HTTPRoute](indexer, v1beta1.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[*v1beta1.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 []*v1beta1.HTTPRoute, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.HTTPRoute)) - }) - return ret, err -} - -// Get retrieves the HTTPRoute from the indexer for a given namespace and name. -func (s hTTPRouteNamespaceLister) Get(name string) (*v1beta1.HTTPRoute, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("httproute"), name) - } - return obj.(*v1beta1.HTTPRoute), nil + listers.ResourceIndexer[*v1beta1.HTTPRoute] } diff --git a/pkg/client/listers/gloo/v1/upstream.go b/pkg/client/listers/gloo/v1/upstream.go index 0f7af0c20..e9cbc0d5c 100644 --- a/pkg/client/listers/gloo/v1/upstream.go +++ b/pkg/client/listers/gloo/v1/upstream.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/fluxcd/flagger/pkg/apis/gloo/v1" - "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 UpstreamLister interface { // upstreamLister implements the UpstreamLister interface. type upstreamLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1.Upstream] } // NewUpstreamLister returns a new UpstreamLister. func NewUpstreamLister(indexer cache.Indexer) UpstreamLister { - return &upstreamLister{indexer: indexer} -} - -// List lists all Upstreams in the indexer. -func (s *upstreamLister) List(selector labels.Selector) (ret []*v1.Upstream, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1.Upstream)) - }) - return ret, err + return &upstreamLister{listers.New[*v1.Upstream](indexer, v1.Resource("upstream"))} } // Upstreams returns an object that can list and get Upstreams. func (s *upstreamLister) Upstreams(namespace string) UpstreamNamespaceLister { - return upstreamNamespaceLister{indexer: s.indexer, namespace: namespace} + return upstreamNamespaceLister{listers.NewNamespaced[*v1.Upstream](s.ResourceIndexer, namespace)} } // UpstreamNamespaceLister helps list and get Upstreams. @@ -74,26 +66,5 @@ type UpstreamNamespaceLister interface { // upstreamNamespaceLister implements the UpstreamNamespaceLister // interface. type upstreamNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all Upstreams in the indexer for a given namespace. -func (s upstreamNamespaceLister) List(selector labels.Selector) (ret []*v1.Upstream, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1.Upstream)) - }) - return ret, err -} - -// Get retrieves the Upstream from the indexer for a given namespace and name. -func (s upstreamNamespaceLister) Get(name string) (*v1.Upstream, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1.Resource("upstream"), name) - } - return obj.(*v1.Upstream), nil + listers.ResourceIndexer[*v1.Upstream] } diff --git a/pkg/client/listers/gloogateway/v1/routetable.go b/pkg/client/listers/gloogateway/v1/routetable.go index 3298a6b13..a393f7c2f 100644 --- a/pkg/client/listers/gloogateway/v1/routetable.go +++ b/pkg/client/listers/gloogateway/v1/routetable.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/fluxcd/flagger/pkg/apis/gloogateway/v1" - "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 RouteTableLister interface { // routeTableLister implements the RouteTableLister interface. type routeTableLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1.RouteTable] } // NewRouteTableLister returns a new RouteTableLister. func NewRouteTableLister(indexer cache.Indexer) RouteTableLister { - return &routeTableLister{indexer: indexer} -} - -// List lists all RouteTables in the indexer. -func (s *routeTableLister) List(selector labels.Selector) (ret []*v1.RouteTable, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1.RouteTable)) - }) - return ret, err + return &routeTableLister{listers.New[*v1.RouteTable](indexer, v1.Resource("routetable"))} } // RouteTables returns an object that can list and get RouteTables. func (s *routeTableLister) RouteTables(namespace string) RouteTableNamespaceLister { - return routeTableNamespaceLister{indexer: s.indexer, namespace: namespace} + return routeTableNamespaceLister{listers.NewNamespaced[*v1.RouteTable](s.ResourceIndexer, namespace)} } // RouteTableNamespaceLister helps list and get RouteTables. @@ -74,26 +66,5 @@ type RouteTableNamespaceLister interface { // routeTableNamespaceLister implements the RouteTableNamespaceLister // interface. type routeTableNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all RouteTables in the indexer for a given namespace. -func (s routeTableNamespaceLister) List(selector labels.Selector) (ret []*v1.RouteTable, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1.RouteTable)) - }) - return ret, err -} - -// Get retrieves the RouteTable from the indexer for a given namespace and name. -func (s routeTableNamespaceLister) Get(name string) (*v1.RouteTable, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1.Resource("routetable"), name) - } - return obj.(*v1.RouteTable), nil + listers.ResourceIndexer[*v1.RouteTable] } diff --git a/pkg/client/listers/istio/v1beta1/destinationrule.go b/pkg/client/listers/istio/v1beta1/destinationrule.go index 65c097122..a2f5ced44 100644 --- a/pkg/client/listers/istio/v1beta1/destinationrule.go +++ b/pkg/client/listers/istio/v1beta1/destinationrule.go @@ -20,8 +20,8 @@ package v1beta1 import ( v1beta1 "github.com/fluxcd/flagger/pkg/apis/istio/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 DestinationRuleLister interface { // destinationRuleLister implements the DestinationRuleLister interface. type destinationRuleLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta1.DestinationRule] } // NewDestinationRuleLister returns a new DestinationRuleLister. func NewDestinationRuleLister(indexer cache.Indexer) DestinationRuleLister { - return &destinationRuleLister{indexer: indexer} -} - -// List lists all DestinationRules in the indexer. -func (s *destinationRuleLister) List(selector labels.Selector) (ret []*v1beta1.DestinationRule, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.DestinationRule)) - }) - return ret, err + return &destinationRuleLister{listers.New[*v1beta1.DestinationRule](indexer, v1beta1.Resource("destinationrule"))} } // DestinationRules returns an object that can list and get DestinationRules. func (s *destinationRuleLister) DestinationRules(namespace string) DestinationRuleNamespaceLister { - return destinationRuleNamespaceLister{indexer: s.indexer, namespace: namespace} + return destinationRuleNamespaceLister{listers.NewNamespaced[*v1beta1.DestinationRule](s.ResourceIndexer, namespace)} } // DestinationRuleNamespaceLister helps list and get DestinationRules. @@ -74,26 +66,5 @@ type DestinationRuleNamespaceLister interface { // destinationRuleNamespaceLister implements the DestinationRuleNamespaceLister // interface. type destinationRuleNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all DestinationRules in the indexer for a given namespace. -func (s destinationRuleNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.DestinationRule, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.DestinationRule)) - }) - return ret, err -} - -// Get retrieves the DestinationRule from the indexer for a given namespace and name. -func (s destinationRuleNamespaceLister) Get(name string) (*v1beta1.DestinationRule, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("destinationrule"), name) - } - return obj.(*v1beta1.DestinationRule), nil + listers.ResourceIndexer[*v1beta1.DestinationRule] } diff --git a/pkg/client/listers/istio/v1beta1/virtualservice.go b/pkg/client/listers/istio/v1beta1/virtualservice.go index f878648a6..bcc83b65d 100644 --- a/pkg/client/listers/istio/v1beta1/virtualservice.go +++ b/pkg/client/listers/istio/v1beta1/virtualservice.go @@ -20,8 +20,8 @@ package v1beta1 import ( v1beta1 "github.com/fluxcd/flagger/pkg/apis/istio/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 VirtualServiceLister interface { // virtualServiceLister implements the VirtualServiceLister interface. type virtualServiceLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1beta1.VirtualService] } // NewVirtualServiceLister returns a new VirtualServiceLister. func NewVirtualServiceLister(indexer cache.Indexer) VirtualServiceLister { - return &virtualServiceLister{indexer: indexer} -} - -// List lists all VirtualServices in the indexer. -func (s *virtualServiceLister) List(selector labels.Selector) (ret []*v1beta1.VirtualService, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.VirtualService)) - }) - return ret, err + return &virtualServiceLister{listers.New[*v1beta1.VirtualService](indexer, v1beta1.Resource("virtualservice"))} } // VirtualServices returns an object that can list and get VirtualServices. func (s *virtualServiceLister) VirtualServices(namespace string) VirtualServiceNamespaceLister { - return virtualServiceNamespaceLister{indexer: s.indexer, namespace: namespace} + return virtualServiceNamespaceLister{listers.NewNamespaced[*v1beta1.VirtualService](s.ResourceIndexer, namespace)} } // VirtualServiceNamespaceLister helps list and get VirtualServices. @@ -74,26 +66,5 @@ type VirtualServiceNamespaceLister interface { // virtualServiceNamespaceLister implements the VirtualServiceNamespaceLister // interface. type virtualServiceNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all VirtualServices in the indexer for a given namespace. -func (s virtualServiceNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.VirtualService, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.VirtualService)) - }) - return ret, err -} - -// Get retrieves the VirtualService from the indexer for a given namespace and name. -func (s virtualServiceNamespaceLister) Get(name string) (*v1beta1.VirtualService, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("virtualservice"), name) - } - return obj.(*v1beta1.VirtualService), nil + listers.ResourceIndexer[*v1beta1.VirtualService] } diff --git a/pkg/client/listers/keda/v1alpha1/scaledobject.go b/pkg/client/listers/keda/v1alpha1/scaledobject.go index eb3752378..30933201c 100644 --- a/pkg/client/listers/keda/v1alpha1/scaledobject.go +++ b/pkg/client/listers/keda/v1alpha1/scaledobject.go @@ -20,8 +20,8 @@ package v1alpha1 import ( v1alpha1 "github.com/fluxcd/flagger/pkg/apis/keda/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 ScaledObjectLister interface { // scaledObjectLister implements the ScaledObjectLister interface. type scaledObjectLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1alpha1.ScaledObject] } // NewScaledObjectLister returns a new ScaledObjectLister. func NewScaledObjectLister(indexer cache.Indexer) ScaledObjectLister { - return &scaledObjectLister{indexer: indexer} -} - -// List lists all ScaledObjects in the indexer. -func (s *scaledObjectLister) List(selector labels.Selector) (ret []*v1alpha1.ScaledObject, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.ScaledObject)) - }) - return ret, err + return &scaledObjectLister{listers.New[*v1alpha1.ScaledObject](indexer, v1alpha1.Resource("scaledobject"))} } // ScaledObjects returns an object that can list and get ScaledObjects. func (s *scaledObjectLister) ScaledObjects(namespace string) ScaledObjectNamespaceLister { - return scaledObjectNamespaceLister{indexer: s.indexer, namespace: namespace} + return scaledObjectNamespaceLister{listers.NewNamespaced[*v1alpha1.ScaledObject](s.ResourceIndexer, namespace)} } // ScaledObjectNamespaceLister helps list and get ScaledObjects. @@ -74,26 +66,5 @@ type ScaledObjectNamespaceLister interface { // scaledObjectNamespaceLister implements the ScaledObjectNamespaceLister // interface. type scaledObjectNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all ScaledObjects in the indexer for a given namespace. -func (s scaledObjectNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ScaledObject, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.ScaledObject)) - }) - return ret, err -} - -// Get retrieves the ScaledObject from the indexer for a given namespace and name. -func (s scaledObjectNamespaceLister) Get(name string) (*v1alpha1.ScaledObject, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("scaledobject"), name) - } - return obj.(*v1alpha1.ScaledObject), nil + listers.ResourceIndexer[*v1alpha1.ScaledObject] } diff --git a/pkg/client/listers/kuma/v1alpha1/trafficroute.go b/pkg/client/listers/kuma/v1alpha1/trafficroute.go index d6869f678..2714562d0 100644 --- a/pkg/client/listers/kuma/v1alpha1/trafficroute.go +++ b/pkg/client/listers/kuma/v1alpha1/trafficroute.go @@ -20,8 +20,8 @@ package v1alpha1 import ( v1alpha1 "github.com/fluxcd/flagger/pkg/apis/kuma/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,30 +39,10 @@ type TrafficRouteLister interface { // trafficRouteLister implements the TrafficRouteLister interface. type trafficRouteLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1alpha1.TrafficRoute] } // NewTrafficRouteLister returns a new TrafficRouteLister. func NewTrafficRouteLister(indexer cache.Indexer) TrafficRouteLister { - return &trafficRouteLister{indexer: indexer} -} - -// List lists all TrafficRoutes in the indexer. -func (s *trafficRouteLister) List(selector labels.Selector) (ret []*v1alpha1.TrafficRoute, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.TrafficRoute)) - }) - return ret, err -} - -// Get retrieves the TrafficRoute from the index for a given name. -func (s *trafficRouteLister) Get(name string) (*v1alpha1.TrafficRoute, error) { - obj, exists, err := s.indexer.GetByKey(name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("trafficroute"), name) - } - return obj.(*v1alpha1.TrafficRoute), nil + return &trafficRouteLister{listers.New[*v1alpha1.TrafficRoute](indexer, v1alpha1.Resource("trafficroute"))} } diff --git a/pkg/client/listers/projectcontour/v1/httpproxy.go b/pkg/client/listers/projectcontour/v1/httpproxy.go index a9e6b684a..4731e1355 100644 --- a/pkg/client/listers/projectcontour/v1/httpproxy.go +++ b/pkg/client/listers/projectcontour/v1/httpproxy.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/fluxcd/flagger/pkg/apis/projectcontour/v1" - "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 HTTPProxyLister interface { // hTTPProxyLister implements the HTTPProxyLister interface. type hTTPProxyLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1.HTTPProxy] } // NewHTTPProxyLister returns a new HTTPProxyLister. func NewHTTPProxyLister(indexer cache.Indexer) HTTPProxyLister { - return &hTTPProxyLister{indexer: indexer} -} - -// List lists all HTTPProxies in the indexer. -func (s *hTTPProxyLister) List(selector labels.Selector) (ret []*v1.HTTPProxy, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1.HTTPProxy)) - }) - return ret, err + return &hTTPProxyLister{listers.New[*v1.HTTPProxy](indexer, v1.Resource("httpproxy"))} } // HTTPProxies returns an object that can list and get HTTPProxies. func (s *hTTPProxyLister) HTTPProxies(namespace string) HTTPProxyNamespaceLister { - return hTTPProxyNamespaceLister{indexer: s.indexer, namespace: namespace} + return hTTPProxyNamespaceLister{listers.NewNamespaced[*v1.HTTPProxy](s.ResourceIndexer, namespace)} } // HTTPProxyNamespaceLister helps list and get HTTPProxies. @@ -74,26 +66,5 @@ type HTTPProxyNamespaceLister interface { // hTTPProxyNamespaceLister implements the HTTPProxyNamespaceLister // interface. type hTTPProxyNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all HTTPProxies in the indexer for a given namespace. -func (s hTTPProxyNamespaceLister) List(selector labels.Selector) (ret []*v1.HTTPProxy, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1.HTTPProxy)) - }) - return ret, err -} - -// Get retrieves the HTTPProxy from the indexer for a given namespace and name. -func (s hTTPProxyNamespaceLister) Get(name string) (*v1.HTTPProxy, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1.Resource("httpproxy"), name) - } - return obj.(*v1.HTTPProxy), nil + listers.ResourceIndexer[*v1.HTTPProxy] } diff --git a/pkg/client/listers/smi/v1alpha1/trafficsplit.go b/pkg/client/listers/smi/v1alpha1/trafficsplit.go index c180fa90c..9dd4a9a7c 100644 --- a/pkg/client/listers/smi/v1alpha1/trafficsplit.go +++ b/pkg/client/listers/smi/v1alpha1/trafficsplit.go @@ -20,8 +20,8 @@ package v1alpha1 import ( v1alpha1 "github.com/fluxcd/flagger/pkg/apis/smi/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 TrafficSplitLister interface { // trafficSplitLister implements the TrafficSplitLister interface. type trafficSplitLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1alpha1.TrafficSplit] } // NewTrafficSplitLister returns a new TrafficSplitLister. func NewTrafficSplitLister(indexer cache.Indexer) TrafficSplitLister { - return &trafficSplitLister{indexer: indexer} -} - -// List lists all TrafficSplits in the indexer. -func (s *trafficSplitLister) List(selector labels.Selector) (ret []*v1alpha1.TrafficSplit, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.TrafficSplit)) - }) - return ret, err + return &trafficSplitLister{listers.New[*v1alpha1.TrafficSplit](indexer, v1alpha1.Resource("trafficsplit"))} } // TrafficSplits returns an object that can list and get TrafficSplits. func (s *trafficSplitLister) TrafficSplits(namespace string) TrafficSplitNamespaceLister { - return trafficSplitNamespaceLister{indexer: s.indexer, namespace: namespace} + return trafficSplitNamespaceLister{listers.NewNamespaced[*v1alpha1.TrafficSplit](s.ResourceIndexer, namespace)} } // TrafficSplitNamespaceLister helps list and get TrafficSplits. @@ -74,26 +66,5 @@ type TrafficSplitNamespaceLister interface { // trafficSplitNamespaceLister implements the TrafficSplitNamespaceLister // interface. type trafficSplitNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all TrafficSplits in the indexer for a given namespace. -func (s trafficSplitNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.TrafficSplit, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.TrafficSplit)) - }) - return ret, err -} - -// Get retrieves the TrafficSplit from the indexer for a given namespace and name. -func (s trafficSplitNamespaceLister) Get(name string) (*v1alpha1.TrafficSplit, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("trafficsplit"), name) - } - return obj.(*v1alpha1.TrafficSplit), nil + listers.ResourceIndexer[*v1alpha1.TrafficSplit] } diff --git a/pkg/client/listers/smi/v1alpha2/trafficsplit.go b/pkg/client/listers/smi/v1alpha2/trafficsplit.go index 705222c4c..4c888bace 100644 --- a/pkg/client/listers/smi/v1alpha2/trafficsplit.go +++ b/pkg/client/listers/smi/v1alpha2/trafficsplit.go @@ -20,8 +20,8 @@ package v1alpha2 import ( v1alpha2 "github.com/fluxcd/flagger/pkg/apis/smi/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 TrafficSplitLister interface { // trafficSplitLister implements the TrafficSplitLister interface. type trafficSplitLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1alpha2.TrafficSplit] } // NewTrafficSplitLister returns a new TrafficSplitLister. func NewTrafficSplitLister(indexer cache.Indexer) TrafficSplitLister { - return &trafficSplitLister{indexer: indexer} -} - -// List lists all TrafficSplits in the indexer. -func (s *trafficSplitLister) List(selector labels.Selector) (ret []*v1alpha2.TrafficSplit, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha2.TrafficSplit)) - }) - return ret, err + return &trafficSplitLister{listers.New[*v1alpha2.TrafficSplit](indexer, v1alpha2.Resource("trafficsplit"))} } // TrafficSplits returns an object that can list and get TrafficSplits. func (s *trafficSplitLister) TrafficSplits(namespace string) TrafficSplitNamespaceLister { - return trafficSplitNamespaceLister{indexer: s.indexer, namespace: namespace} + return trafficSplitNamespaceLister{listers.NewNamespaced[*v1alpha2.TrafficSplit](s.ResourceIndexer, namespace)} } // TrafficSplitNamespaceLister helps list and get TrafficSplits. @@ -74,26 +66,5 @@ type TrafficSplitNamespaceLister interface { // trafficSplitNamespaceLister implements the TrafficSplitNamespaceLister // interface. type trafficSplitNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all TrafficSplits in the indexer for a given namespace. -func (s trafficSplitNamespaceLister) List(selector labels.Selector) (ret []*v1alpha2.TrafficSplit, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha2.TrafficSplit)) - }) - return ret, err -} - -// Get retrieves the TrafficSplit from the indexer for a given namespace and name. -func (s trafficSplitNamespaceLister) Get(name string) (*v1alpha2.TrafficSplit, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha2.Resource("trafficsplit"), name) - } - return obj.(*v1alpha2.TrafficSplit), nil + listers.ResourceIndexer[*v1alpha2.TrafficSplit] } diff --git a/pkg/client/listers/smi/v1alpha3/trafficsplit.go b/pkg/client/listers/smi/v1alpha3/trafficsplit.go index 9ce91ffb1..6190e3403 100644 --- a/pkg/client/listers/smi/v1alpha3/trafficsplit.go +++ b/pkg/client/listers/smi/v1alpha3/trafficsplit.go @@ -20,8 +20,8 @@ package v1alpha3 import ( v1alpha3 "github.com/fluxcd/flagger/pkg/apis/smi/v1alpha3" - "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 TrafficSplitLister interface { // trafficSplitLister implements the TrafficSplitLister interface. type trafficSplitLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1alpha3.TrafficSplit] } // NewTrafficSplitLister returns a new TrafficSplitLister. func NewTrafficSplitLister(indexer cache.Indexer) TrafficSplitLister { - return &trafficSplitLister{indexer: indexer} -} - -// List lists all TrafficSplits in the indexer. -func (s *trafficSplitLister) List(selector labels.Selector) (ret []*v1alpha3.TrafficSplit, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha3.TrafficSplit)) - }) - return ret, err + return &trafficSplitLister{listers.New[*v1alpha3.TrafficSplit](indexer, v1alpha3.Resource("trafficsplit"))} } // TrafficSplits returns an object that can list and get TrafficSplits. func (s *trafficSplitLister) TrafficSplits(namespace string) TrafficSplitNamespaceLister { - return trafficSplitNamespaceLister{indexer: s.indexer, namespace: namespace} + return trafficSplitNamespaceLister{listers.NewNamespaced[*v1alpha3.TrafficSplit](s.ResourceIndexer, namespace)} } // TrafficSplitNamespaceLister helps list and get TrafficSplits. @@ -74,26 +66,5 @@ type TrafficSplitNamespaceLister interface { // trafficSplitNamespaceLister implements the TrafficSplitNamespaceLister // interface. type trafficSplitNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all TrafficSplits in the indexer for a given namespace. -func (s trafficSplitNamespaceLister) List(selector labels.Selector) (ret []*v1alpha3.TrafficSplit, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha3.TrafficSplit)) - }) - return ret, err -} - -// Get retrieves the TrafficSplit from the indexer for a given namespace and name. -func (s trafficSplitNamespaceLister) Get(name string) (*v1alpha3.TrafficSplit, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha3.Resource("trafficsplit"), name) - } - return obj.(*v1alpha3.TrafficSplit), nil + listers.ResourceIndexer[*v1alpha3.TrafficSplit] } diff --git a/pkg/client/listers/traefik/v1alpha1/traefikservice.go b/pkg/client/listers/traefik/v1alpha1/traefikservice.go index 1ca9c744c..bd9a47398 100644 --- a/pkg/client/listers/traefik/v1alpha1/traefikservice.go +++ b/pkg/client/listers/traefik/v1alpha1/traefikservice.go @@ -20,8 +20,8 @@ package v1alpha1 import ( v1alpha1 "github.com/fluxcd/flagger/pkg/apis/traefik/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 TraefikServiceLister interface { // traefikServiceLister implements the TraefikServiceLister interface. type traefikServiceLister struct { - indexer cache.Indexer + listers.ResourceIndexer[*v1alpha1.TraefikService] } // NewTraefikServiceLister returns a new TraefikServiceLister. func NewTraefikServiceLister(indexer cache.Indexer) TraefikServiceLister { - return &traefikServiceLister{indexer: indexer} -} - -// List lists all TraefikServices in the indexer. -func (s *traefikServiceLister) List(selector labels.Selector) (ret []*v1alpha1.TraefikService, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.TraefikService)) - }) - return ret, err + return &traefikServiceLister{listers.New[*v1alpha1.TraefikService](indexer, v1alpha1.Resource("traefikservice"))} } // TraefikServices returns an object that can list and get TraefikServices. func (s *traefikServiceLister) TraefikServices(namespace string) TraefikServiceNamespaceLister { - return traefikServiceNamespaceLister{indexer: s.indexer, namespace: namespace} + return traefikServiceNamespaceLister{listers.NewNamespaced[*v1alpha1.TraefikService](s.ResourceIndexer, namespace)} } // TraefikServiceNamespaceLister helps list and get TraefikServices. @@ -74,26 +66,5 @@ type TraefikServiceNamespaceLister interface { // traefikServiceNamespaceLister implements the TraefikServiceNamespaceLister // interface. type traefikServiceNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all TraefikServices in the indexer for a given namespace. -func (s traefikServiceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.TraefikService, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.TraefikService)) - }) - return ret, err -} - -// Get retrieves the TraefikService from the indexer for a given namespace and name. -func (s traefikServiceNamespaceLister) Get(name string) (*v1alpha1.TraefikService, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("traefikservice"), name) - } - return obj.(*v1alpha1.TraefikService), nil + listers.ResourceIndexer[*v1alpha1.TraefikService] } diff --git a/pkg/router/gateway_api.go b/pkg/router/gateway_api.go index 7d2ae79d1..bc398afda 100644 --- a/pkg/router/gateway_api.go +++ b/pkg/router/gateway_api.go @@ -180,6 +180,7 @@ func (gwr *GatewayAPIRouter) Reconcile(canary *flaggerv1.Canary) error { } gwr.logger.With("canary", fmt.Sprintf("%s.%s", canary.Name, canary.Namespace)). Infof("HTTPRoute %s.%s created", route.GetName(), hrNamespace) + return nil } else if err != nil { return fmt.Errorf("HTTPRoute %s.%s get error: %w", apexSvcName, hrNamespace, err) } diff --git a/pkg/router/gateway_api_v1beta1.go b/pkg/router/gateway_api_v1beta1.go index e9042ea28..b9d8e40e1 100644 --- a/pkg/router/gateway_api_v1beta1.go +++ b/pkg/router/gateway_api_v1beta1.go @@ -162,6 +162,7 @@ func (gwr *GatewayAPIV1Beta1Router) Reconcile(canary *flaggerv1.Canary) error { } gwr.logger.With("canary", fmt.Sprintf("%s.%s", canary.Name, canary.Namespace)). Infof("HTTPRoute %s.%s created", route.GetName(), hrNamespace) + return nil } else if err != nil { return fmt.Errorf("HTTPRoute %s.%s get error: %w", apexSvcName, hrNamespace, err) }