diff --git a/pkg/generated/clientset/versioned/fake/clientset_generated.go b/pkg/generated/clientset/versioned/fake/clientset_generated.go index 3a58df415..df37c9cab 100644 --- a/pkg/generated/clientset/versioned/fake/clientset_generated.go +++ b/pkg/generated/clientset/versioned/fake/clientset_generated.go @@ -29,8 +29,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/generated/clientset/versioned/typed/config/v1alpha1/balloonspolicy.go b/pkg/generated/clientset/versioned/typed/config/v1alpha1/balloonspolicy.go index 88be225f6..21e01438e 100644 --- a/pkg/generated/clientset/versioned/typed/config/v1alpha1/balloonspolicy.go +++ b/pkg/generated/clientset/versioned/typed/config/v1alpha1/balloonspolicy.go @@ -18,14 +18,13 @@ package v1alpha1 import ( "context" - "time" v1alpha1 "github.com/containers/nri-plugins/pkg/apis/config/v1alpha1" scheme "github.com/containers/nri-plugins/pkg/generated/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" ) // BalloonsPoliciesGetter has a method to return a BalloonsPolicyInterface. @@ -38,6 +37,7 @@ type BalloonsPoliciesGetter interface { type BalloonsPolicyInterface interface { Create(ctx context.Context, balloonsPolicy *v1alpha1.BalloonsPolicy, opts v1.CreateOptions) (*v1alpha1.BalloonsPolicy, error) Update(ctx context.Context, balloonsPolicy *v1alpha1.BalloonsPolicy, opts v1.UpdateOptions) (*v1alpha1.BalloonsPolicy, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, balloonsPolicy *v1alpha1.BalloonsPolicy, opts v1.UpdateOptions) (*v1alpha1.BalloonsPolicy, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error @@ -50,144 +50,18 @@ type BalloonsPolicyInterface interface { // balloonsPolicies implements BalloonsPolicyInterface type balloonsPolicies struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1alpha1.BalloonsPolicy, *v1alpha1.BalloonsPolicyList] } // newBalloonsPolicies returns a BalloonsPolicies func newBalloonsPolicies(c *ConfigV1alpha1Client, namespace string) *balloonsPolicies { return &balloonsPolicies{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1alpha1.BalloonsPolicy, *v1alpha1.BalloonsPolicyList]( + "balloonspolicies", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha1.BalloonsPolicy { return &v1alpha1.BalloonsPolicy{} }, + func() *v1alpha1.BalloonsPolicyList { return &v1alpha1.BalloonsPolicyList{} }), } } - -// Get takes name of the balloonsPolicy, and returns the corresponding balloonsPolicy object, and an error if there is any. -func (c *balloonsPolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.BalloonsPolicy, err error) { - result = &v1alpha1.BalloonsPolicy{} - err = c.client.Get(). - Namespace(c.ns). - Resource("balloonspolicies"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of BalloonsPolicies that match those selectors. -func (c *balloonsPolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.BalloonsPolicyList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.BalloonsPolicyList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("balloonspolicies"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested balloonsPolicies. -func (c *balloonsPolicies) 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("balloonspolicies"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a balloonsPolicy and creates it. Returns the server's representation of the balloonsPolicy, and an error, if there is any. -func (c *balloonsPolicies) Create(ctx context.Context, balloonsPolicy *v1alpha1.BalloonsPolicy, opts v1.CreateOptions) (result *v1alpha1.BalloonsPolicy, err error) { - result = &v1alpha1.BalloonsPolicy{} - err = c.client.Post(). - Namespace(c.ns). - Resource("balloonspolicies"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(balloonsPolicy). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a balloonsPolicy and updates it. Returns the server's representation of the balloonsPolicy, and an error, if there is any. -func (c *balloonsPolicies) Update(ctx context.Context, balloonsPolicy *v1alpha1.BalloonsPolicy, opts v1.UpdateOptions) (result *v1alpha1.BalloonsPolicy, err error) { - result = &v1alpha1.BalloonsPolicy{} - err = c.client.Put(). - Namespace(c.ns). - Resource("balloonspolicies"). - Name(balloonsPolicy.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(balloonsPolicy). - 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 *balloonsPolicies) UpdateStatus(ctx context.Context, balloonsPolicy *v1alpha1.BalloonsPolicy, opts v1.UpdateOptions) (result *v1alpha1.BalloonsPolicy, err error) { - result = &v1alpha1.BalloonsPolicy{} - err = c.client.Put(). - Namespace(c.ns). - Resource("balloonspolicies"). - Name(balloonsPolicy.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(balloonsPolicy). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the balloonsPolicy and deletes it. Returns an error if one occurs. -func (c *balloonsPolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("balloonspolicies"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *balloonsPolicies) 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("balloonspolicies"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched balloonsPolicy. -func (c *balloonsPolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.BalloonsPolicy, err error) { - result = &v1alpha1.BalloonsPolicy{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("balloonspolicies"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/generated/clientset/versioned/typed/config/v1alpha1/fake/fake_balloonspolicy.go b/pkg/generated/clientset/versioned/typed/config/v1alpha1/fake/fake_balloonspolicy.go index d852e87a5..2a627672b 100644 --- a/pkg/generated/clientset/versioned/typed/config/v1alpha1/fake/fake_balloonspolicy.go +++ b/pkg/generated/clientset/versioned/typed/config/v1alpha1/fake/fake_balloonspolicy.go @@ -39,22 +39,24 @@ var balloonspoliciesKind = v1alpha1.SchemeGroupVersion.WithKind("BalloonsPolicy" // Get takes name of the balloonsPolicy, and returns the corresponding balloonsPolicy object, and an error if there is any. func (c *FakeBalloonsPolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.BalloonsPolicy, err error) { + emptyResult := &v1alpha1.BalloonsPolicy{} obj, err := c.Fake. - Invokes(testing.NewGetAction(balloonspoliciesResource, c.ns, name), &v1alpha1.BalloonsPolicy{}) + Invokes(testing.NewGetActionWithOptions(balloonspoliciesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.BalloonsPolicy), err } // List takes label and field selectors, and returns the list of BalloonsPolicies that match those selectors. func (c *FakeBalloonsPolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.BalloonsPolicyList, err error) { + emptyResult := &v1alpha1.BalloonsPolicyList{} obj, err := c.Fake. - Invokes(testing.NewListAction(balloonspoliciesResource, balloonspoliciesKind, c.ns, opts), &v1alpha1.BalloonsPolicyList{}) + Invokes(testing.NewListActionWithOptions(balloonspoliciesResource, balloonspoliciesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -73,40 +75,43 @@ func (c *FakeBalloonsPolicies) List(ctx context.Context, opts v1.ListOptions) (r // Watch returns a watch.Interface that watches the requested balloonsPolicies. func (c *FakeBalloonsPolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(balloonspoliciesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(balloonspoliciesResource, c.ns, opts)) } // Create takes the representation of a balloonsPolicy and creates it. Returns the server's representation of the balloonsPolicy, and an error, if there is any. func (c *FakeBalloonsPolicies) Create(ctx context.Context, balloonsPolicy *v1alpha1.BalloonsPolicy, opts v1.CreateOptions) (result *v1alpha1.BalloonsPolicy, err error) { + emptyResult := &v1alpha1.BalloonsPolicy{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(balloonspoliciesResource, c.ns, balloonsPolicy), &v1alpha1.BalloonsPolicy{}) + Invokes(testing.NewCreateActionWithOptions(balloonspoliciesResource, c.ns, balloonsPolicy, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.BalloonsPolicy), err } // Update takes the representation of a balloonsPolicy and updates it. Returns the server's representation of the balloonsPolicy, and an error, if there is any. func (c *FakeBalloonsPolicies) Update(ctx context.Context, balloonsPolicy *v1alpha1.BalloonsPolicy, opts v1.UpdateOptions) (result *v1alpha1.BalloonsPolicy, err error) { + emptyResult := &v1alpha1.BalloonsPolicy{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(balloonspoliciesResource, c.ns, balloonsPolicy), &v1alpha1.BalloonsPolicy{}) + Invokes(testing.NewUpdateActionWithOptions(balloonspoliciesResource, c.ns, balloonsPolicy, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.BalloonsPolicy), 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 *FakeBalloonsPolicies) UpdateStatus(ctx context.Context, balloonsPolicy *v1alpha1.BalloonsPolicy, opts v1.UpdateOptions) (*v1alpha1.BalloonsPolicy, error) { +func (c *FakeBalloonsPolicies) UpdateStatus(ctx context.Context, balloonsPolicy *v1alpha1.BalloonsPolicy, opts v1.UpdateOptions) (result *v1alpha1.BalloonsPolicy, err error) { + emptyResult := &v1alpha1.BalloonsPolicy{} obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(balloonspoliciesResource, "status", c.ns, balloonsPolicy), &v1alpha1.BalloonsPolicy{}) + Invokes(testing.NewUpdateSubresourceActionWithOptions(balloonspoliciesResource, "status", c.ns, balloonsPolicy, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.BalloonsPolicy), err } @@ -121,7 +126,7 @@ func (c *FakeBalloonsPolicies) Delete(ctx context.Context, name string, opts v1. // DeleteCollection deletes a collection of objects. func (c *FakeBalloonsPolicies) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(balloonspoliciesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(balloonspoliciesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha1.BalloonsPolicyList{}) return err @@ -129,11 +134,12 @@ func (c *FakeBalloonsPolicies) DeleteCollection(ctx context.Context, opts v1.Del // Patch applies the patch and returns the patched balloonsPolicy. func (c *FakeBalloonsPolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.BalloonsPolicy, err error) { + emptyResult := &v1alpha1.BalloonsPolicy{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(balloonspoliciesResource, c.ns, name, pt, data, subresources...), &v1alpha1.BalloonsPolicy{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(balloonspoliciesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.BalloonsPolicy), err } diff --git a/pkg/generated/clientset/versioned/typed/config/v1alpha1/fake/fake_templatepolicy.go b/pkg/generated/clientset/versioned/typed/config/v1alpha1/fake/fake_templatepolicy.go index 79983073e..3707a2341 100644 --- a/pkg/generated/clientset/versioned/typed/config/v1alpha1/fake/fake_templatepolicy.go +++ b/pkg/generated/clientset/versioned/typed/config/v1alpha1/fake/fake_templatepolicy.go @@ -39,22 +39,24 @@ var templatepoliciesKind = v1alpha1.SchemeGroupVersion.WithKind("TemplatePolicy" // Get takes name of the templatePolicy, and returns the corresponding templatePolicy object, and an error if there is any. func (c *FakeTemplatePolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.TemplatePolicy, err error) { + emptyResult := &v1alpha1.TemplatePolicy{} obj, err := c.Fake. - Invokes(testing.NewGetAction(templatepoliciesResource, c.ns, name), &v1alpha1.TemplatePolicy{}) + Invokes(testing.NewGetActionWithOptions(templatepoliciesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TemplatePolicy), err } // List takes label and field selectors, and returns the list of TemplatePolicies that match those selectors. func (c *FakeTemplatePolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.TemplatePolicyList, err error) { + emptyResult := &v1alpha1.TemplatePolicyList{} obj, err := c.Fake. - Invokes(testing.NewListAction(templatepoliciesResource, templatepoliciesKind, c.ns, opts), &v1alpha1.TemplatePolicyList{}) + Invokes(testing.NewListActionWithOptions(templatepoliciesResource, templatepoliciesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -73,40 +75,43 @@ func (c *FakeTemplatePolicies) List(ctx context.Context, opts v1.ListOptions) (r // Watch returns a watch.Interface that watches the requested templatePolicies. func (c *FakeTemplatePolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(templatepoliciesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(templatepoliciesResource, c.ns, opts)) } // Create takes the representation of a templatePolicy and creates it. Returns the server's representation of the templatePolicy, and an error, if there is any. func (c *FakeTemplatePolicies) Create(ctx context.Context, templatePolicy *v1alpha1.TemplatePolicy, opts v1.CreateOptions) (result *v1alpha1.TemplatePolicy, err error) { + emptyResult := &v1alpha1.TemplatePolicy{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(templatepoliciesResource, c.ns, templatePolicy), &v1alpha1.TemplatePolicy{}) + Invokes(testing.NewCreateActionWithOptions(templatepoliciesResource, c.ns, templatePolicy, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TemplatePolicy), err } // Update takes the representation of a templatePolicy and updates it. Returns the server's representation of the templatePolicy, and an error, if there is any. func (c *FakeTemplatePolicies) Update(ctx context.Context, templatePolicy *v1alpha1.TemplatePolicy, opts v1.UpdateOptions) (result *v1alpha1.TemplatePolicy, err error) { + emptyResult := &v1alpha1.TemplatePolicy{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(templatepoliciesResource, c.ns, templatePolicy), &v1alpha1.TemplatePolicy{}) + Invokes(testing.NewUpdateActionWithOptions(templatepoliciesResource, c.ns, templatePolicy, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TemplatePolicy), 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 *FakeTemplatePolicies) UpdateStatus(ctx context.Context, templatePolicy *v1alpha1.TemplatePolicy, opts v1.UpdateOptions) (*v1alpha1.TemplatePolicy, error) { +func (c *FakeTemplatePolicies) UpdateStatus(ctx context.Context, templatePolicy *v1alpha1.TemplatePolicy, opts v1.UpdateOptions) (result *v1alpha1.TemplatePolicy, err error) { + emptyResult := &v1alpha1.TemplatePolicy{} obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(templatepoliciesResource, "status", c.ns, templatePolicy), &v1alpha1.TemplatePolicy{}) + Invokes(testing.NewUpdateSubresourceActionWithOptions(templatepoliciesResource, "status", c.ns, templatePolicy, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TemplatePolicy), err } @@ -121,7 +126,7 @@ func (c *FakeTemplatePolicies) Delete(ctx context.Context, name string, opts v1. // DeleteCollection deletes a collection of objects. func (c *FakeTemplatePolicies) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(templatepoliciesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(templatepoliciesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha1.TemplatePolicyList{}) return err @@ -129,11 +134,12 @@ func (c *FakeTemplatePolicies) DeleteCollection(ctx context.Context, opts v1.Del // Patch applies the patch and returns the patched templatePolicy. func (c *FakeTemplatePolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.TemplatePolicy, err error) { + emptyResult := &v1alpha1.TemplatePolicy{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(templatepoliciesResource, c.ns, name, pt, data, subresources...), &v1alpha1.TemplatePolicy{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(templatepoliciesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TemplatePolicy), err } diff --git a/pkg/generated/clientset/versioned/typed/config/v1alpha1/fake/fake_topologyawarepolicy.go b/pkg/generated/clientset/versioned/typed/config/v1alpha1/fake/fake_topologyawarepolicy.go index 78e93c619..03be28302 100644 --- a/pkg/generated/clientset/versioned/typed/config/v1alpha1/fake/fake_topologyawarepolicy.go +++ b/pkg/generated/clientset/versioned/typed/config/v1alpha1/fake/fake_topologyawarepolicy.go @@ -39,22 +39,24 @@ var topologyawarepoliciesKind = v1alpha1.SchemeGroupVersion.WithKind("TopologyAw // Get takes name of the topologyAwarePolicy, and returns the corresponding topologyAwarePolicy object, and an error if there is any. func (c *FakeTopologyAwarePolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.TopologyAwarePolicy, err error) { + emptyResult := &v1alpha1.TopologyAwarePolicy{} obj, err := c.Fake. - Invokes(testing.NewGetAction(topologyawarepoliciesResource, c.ns, name), &v1alpha1.TopologyAwarePolicy{}) + Invokes(testing.NewGetActionWithOptions(topologyawarepoliciesResource, c.ns, name, options), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TopologyAwarePolicy), err } // List takes label and field selectors, and returns the list of TopologyAwarePolicies that match those selectors. func (c *FakeTopologyAwarePolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.TopologyAwarePolicyList, err error) { + emptyResult := &v1alpha1.TopologyAwarePolicyList{} obj, err := c.Fake. - Invokes(testing.NewListAction(topologyawarepoliciesResource, topologyawarepoliciesKind, c.ns, opts), &v1alpha1.TopologyAwarePolicyList{}) + Invokes(testing.NewListActionWithOptions(topologyawarepoliciesResource, topologyawarepoliciesKind, c.ns, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -73,40 +75,43 @@ func (c *FakeTopologyAwarePolicies) List(ctx context.Context, opts v1.ListOption // Watch returns a watch.Interface that watches the requested topologyAwarePolicies. func (c *FakeTopologyAwarePolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewWatchAction(topologyawarepoliciesResource, c.ns, opts)) + InvokesWatch(testing.NewWatchActionWithOptions(topologyawarepoliciesResource, c.ns, opts)) } // Create takes the representation of a topologyAwarePolicy and creates it. Returns the server's representation of the topologyAwarePolicy, and an error, if there is any. func (c *FakeTopologyAwarePolicies) Create(ctx context.Context, topologyAwarePolicy *v1alpha1.TopologyAwarePolicy, opts v1.CreateOptions) (result *v1alpha1.TopologyAwarePolicy, err error) { + emptyResult := &v1alpha1.TopologyAwarePolicy{} obj, err := c.Fake. - Invokes(testing.NewCreateAction(topologyawarepoliciesResource, c.ns, topologyAwarePolicy), &v1alpha1.TopologyAwarePolicy{}) + Invokes(testing.NewCreateActionWithOptions(topologyawarepoliciesResource, c.ns, topologyAwarePolicy, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TopologyAwarePolicy), err } // Update takes the representation of a topologyAwarePolicy and updates it. Returns the server's representation of the topologyAwarePolicy, and an error, if there is any. func (c *FakeTopologyAwarePolicies) Update(ctx context.Context, topologyAwarePolicy *v1alpha1.TopologyAwarePolicy, opts v1.UpdateOptions) (result *v1alpha1.TopologyAwarePolicy, err error) { + emptyResult := &v1alpha1.TopologyAwarePolicy{} obj, err := c.Fake. - Invokes(testing.NewUpdateAction(topologyawarepoliciesResource, c.ns, topologyAwarePolicy), &v1alpha1.TopologyAwarePolicy{}) + Invokes(testing.NewUpdateActionWithOptions(topologyawarepoliciesResource, c.ns, topologyAwarePolicy, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TopologyAwarePolicy), 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 *FakeTopologyAwarePolicies) UpdateStatus(ctx context.Context, topologyAwarePolicy *v1alpha1.TopologyAwarePolicy, opts v1.UpdateOptions) (*v1alpha1.TopologyAwarePolicy, error) { +func (c *FakeTopologyAwarePolicies) UpdateStatus(ctx context.Context, topologyAwarePolicy *v1alpha1.TopologyAwarePolicy, opts v1.UpdateOptions) (result *v1alpha1.TopologyAwarePolicy, err error) { + emptyResult := &v1alpha1.TopologyAwarePolicy{} obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(topologyawarepoliciesResource, "status", c.ns, topologyAwarePolicy), &v1alpha1.TopologyAwarePolicy{}) + Invokes(testing.NewUpdateSubresourceActionWithOptions(topologyawarepoliciesResource, "status", c.ns, topologyAwarePolicy, opts), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TopologyAwarePolicy), err } @@ -121,7 +126,7 @@ func (c *FakeTopologyAwarePolicies) Delete(ctx context.Context, name string, opt // DeleteCollection deletes a collection of objects. func (c *FakeTopologyAwarePolicies) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(topologyawarepoliciesResource, c.ns, listOpts) + action := testing.NewDeleteCollectionActionWithOptions(topologyawarepoliciesResource, c.ns, opts, listOpts) _, err := c.Fake.Invokes(action, &v1alpha1.TopologyAwarePolicyList{}) return err @@ -129,11 +134,12 @@ func (c *FakeTopologyAwarePolicies) DeleteCollection(ctx context.Context, opts v // Patch applies the patch and returns the patched topologyAwarePolicy. func (c *FakeTopologyAwarePolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.TopologyAwarePolicy, err error) { + emptyResult := &v1alpha1.TopologyAwarePolicy{} obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(topologyawarepoliciesResource, c.ns, name, pt, data, subresources...), &v1alpha1.TopologyAwarePolicy{}) + Invokes(testing.NewPatchSubresourceActionWithOptions(topologyawarepoliciesResource, c.ns, name, pt, data, opts, subresources...), emptyResult) if obj == nil { - return nil, err + return emptyResult, err } return obj.(*v1alpha1.TopologyAwarePolicy), err } diff --git a/pkg/generated/clientset/versioned/typed/config/v1alpha1/templatepolicy.go b/pkg/generated/clientset/versioned/typed/config/v1alpha1/templatepolicy.go index f38bb7f1c..4f368bbf8 100644 --- a/pkg/generated/clientset/versioned/typed/config/v1alpha1/templatepolicy.go +++ b/pkg/generated/clientset/versioned/typed/config/v1alpha1/templatepolicy.go @@ -18,14 +18,13 @@ package v1alpha1 import ( "context" - "time" v1alpha1 "github.com/containers/nri-plugins/pkg/apis/config/v1alpha1" scheme "github.com/containers/nri-plugins/pkg/generated/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" ) // TemplatePoliciesGetter has a method to return a TemplatePolicyInterface. @@ -38,6 +37,7 @@ type TemplatePoliciesGetter interface { type TemplatePolicyInterface interface { Create(ctx context.Context, templatePolicy *v1alpha1.TemplatePolicy, opts v1.CreateOptions) (*v1alpha1.TemplatePolicy, error) Update(ctx context.Context, templatePolicy *v1alpha1.TemplatePolicy, opts v1.UpdateOptions) (*v1alpha1.TemplatePolicy, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, templatePolicy *v1alpha1.TemplatePolicy, opts v1.UpdateOptions) (*v1alpha1.TemplatePolicy, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error @@ -50,144 +50,18 @@ type TemplatePolicyInterface interface { // templatePolicies implements TemplatePolicyInterface type templatePolicies struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1alpha1.TemplatePolicy, *v1alpha1.TemplatePolicyList] } // newTemplatePolicies returns a TemplatePolicies func newTemplatePolicies(c *ConfigV1alpha1Client, namespace string) *templatePolicies { return &templatePolicies{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1alpha1.TemplatePolicy, *v1alpha1.TemplatePolicyList]( + "templatepolicies", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha1.TemplatePolicy { return &v1alpha1.TemplatePolicy{} }, + func() *v1alpha1.TemplatePolicyList { return &v1alpha1.TemplatePolicyList{} }), } } - -// Get takes name of the templatePolicy, and returns the corresponding templatePolicy object, and an error if there is any. -func (c *templatePolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.TemplatePolicy, err error) { - result = &v1alpha1.TemplatePolicy{} - err = c.client.Get(). - Namespace(c.ns). - Resource("templatepolicies"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of TemplatePolicies that match those selectors. -func (c *templatePolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.TemplatePolicyList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.TemplatePolicyList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("templatepolicies"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested templatePolicies. -func (c *templatePolicies) 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("templatepolicies"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a templatePolicy and creates it. Returns the server's representation of the templatePolicy, and an error, if there is any. -func (c *templatePolicies) Create(ctx context.Context, templatePolicy *v1alpha1.TemplatePolicy, opts v1.CreateOptions) (result *v1alpha1.TemplatePolicy, err error) { - result = &v1alpha1.TemplatePolicy{} - err = c.client.Post(). - Namespace(c.ns). - Resource("templatepolicies"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(templatePolicy). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a templatePolicy and updates it. Returns the server's representation of the templatePolicy, and an error, if there is any. -func (c *templatePolicies) Update(ctx context.Context, templatePolicy *v1alpha1.TemplatePolicy, opts v1.UpdateOptions) (result *v1alpha1.TemplatePolicy, err error) { - result = &v1alpha1.TemplatePolicy{} - err = c.client.Put(). - Namespace(c.ns). - Resource("templatepolicies"). - Name(templatePolicy.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(templatePolicy). - 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 *templatePolicies) UpdateStatus(ctx context.Context, templatePolicy *v1alpha1.TemplatePolicy, opts v1.UpdateOptions) (result *v1alpha1.TemplatePolicy, err error) { - result = &v1alpha1.TemplatePolicy{} - err = c.client.Put(). - Namespace(c.ns). - Resource("templatepolicies"). - Name(templatePolicy.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(templatePolicy). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the templatePolicy and deletes it. Returns an error if one occurs. -func (c *templatePolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("templatepolicies"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *templatePolicies) 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("templatepolicies"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched templatePolicy. -func (c *templatePolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.TemplatePolicy, err error) { - result = &v1alpha1.TemplatePolicy{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("templatepolicies"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/generated/clientset/versioned/typed/config/v1alpha1/topologyawarepolicy.go b/pkg/generated/clientset/versioned/typed/config/v1alpha1/topologyawarepolicy.go index afb84c300..9fe8c08ff 100644 --- a/pkg/generated/clientset/versioned/typed/config/v1alpha1/topologyawarepolicy.go +++ b/pkg/generated/clientset/versioned/typed/config/v1alpha1/topologyawarepolicy.go @@ -18,14 +18,13 @@ package v1alpha1 import ( "context" - "time" v1alpha1 "github.com/containers/nri-plugins/pkg/apis/config/v1alpha1" scheme "github.com/containers/nri-plugins/pkg/generated/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" ) // TopologyAwarePoliciesGetter has a method to return a TopologyAwarePolicyInterface. @@ -38,6 +37,7 @@ type TopologyAwarePoliciesGetter interface { type TopologyAwarePolicyInterface interface { Create(ctx context.Context, topologyAwarePolicy *v1alpha1.TopologyAwarePolicy, opts v1.CreateOptions) (*v1alpha1.TopologyAwarePolicy, error) Update(ctx context.Context, topologyAwarePolicy *v1alpha1.TopologyAwarePolicy, opts v1.UpdateOptions) (*v1alpha1.TopologyAwarePolicy, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, topologyAwarePolicy *v1alpha1.TopologyAwarePolicy, opts v1.UpdateOptions) (*v1alpha1.TopologyAwarePolicy, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error @@ -50,144 +50,18 @@ type TopologyAwarePolicyInterface interface { // topologyAwarePolicies implements TopologyAwarePolicyInterface type topologyAwarePolicies struct { - client rest.Interface - ns string + *gentype.ClientWithList[*v1alpha1.TopologyAwarePolicy, *v1alpha1.TopologyAwarePolicyList] } // newTopologyAwarePolicies returns a TopologyAwarePolicies func newTopologyAwarePolicies(c *ConfigV1alpha1Client, namespace string) *topologyAwarePolicies { return &topologyAwarePolicies{ - client: c.RESTClient(), - ns: namespace, + gentype.NewClientWithList[*v1alpha1.TopologyAwarePolicy, *v1alpha1.TopologyAwarePolicyList]( + "topologyawarepolicies", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha1.TopologyAwarePolicy { return &v1alpha1.TopologyAwarePolicy{} }, + func() *v1alpha1.TopologyAwarePolicyList { return &v1alpha1.TopologyAwarePolicyList{} }), } } - -// Get takes name of the topologyAwarePolicy, and returns the corresponding topologyAwarePolicy object, and an error if there is any. -func (c *topologyAwarePolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.TopologyAwarePolicy, err error) { - result = &v1alpha1.TopologyAwarePolicy{} - err = c.client.Get(). - Namespace(c.ns). - Resource("topologyawarepolicies"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of TopologyAwarePolicies that match those selectors. -func (c *topologyAwarePolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.TopologyAwarePolicyList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.TopologyAwarePolicyList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("topologyawarepolicies"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested topologyAwarePolicies. -func (c *topologyAwarePolicies) 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("topologyawarepolicies"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a topologyAwarePolicy and creates it. Returns the server's representation of the topologyAwarePolicy, and an error, if there is any. -func (c *topologyAwarePolicies) Create(ctx context.Context, topologyAwarePolicy *v1alpha1.TopologyAwarePolicy, opts v1.CreateOptions) (result *v1alpha1.TopologyAwarePolicy, err error) { - result = &v1alpha1.TopologyAwarePolicy{} - err = c.client.Post(). - Namespace(c.ns). - Resource("topologyawarepolicies"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(topologyAwarePolicy). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a topologyAwarePolicy and updates it. Returns the server's representation of the topologyAwarePolicy, and an error, if there is any. -func (c *topologyAwarePolicies) Update(ctx context.Context, topologyAwarePolicy *v1alpha1.TopologyAwarePolicy, opts v1.UpdateOptions) (result *v1alpha1.TopologyAwarePolicy, err error) { - result = &v1alpha1.TopologyAwarePolicy{} - err = c.client.Put(). - Namespace(c.ns). - Resource("topologyawarepolicies"). - Name(topologyAwarePolicy.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(topologyAwarePolicy). - 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 *topologyAwarePolicies) UpdateStatus(ctx context.Context, topologyAwarePolicy *v1alpha1.TopologyAwarePolicy, opts v1.UpdateOptions) (result *v1alpha1.TopologyAwarePolicy, err error) { - result = &v1alpha1.TopologyAwarePolicy{} - err = c.client.Put(). - Namespace(c.ns). - Resource("topologyawarepolicies"). - Name(topologyAwarePolicy.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(topologyAwarePolicy). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the topologyAwarePolicy and deletes it. Returns an error if one occurs. -func (c *topologyAwarePolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("topologyawarepolicies"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *topologyAwarePolicies) 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("topologyawarepolicies"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched topologyAwarePolicy. -func (c *topologyAwarePolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.TopologyAwarePolicy, err error) { - result = &v1alpha1.TopologyAwarePolicy{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("topologyawarepolicies"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -}