From a1765d003bf635f8040ed1a088be9252b4f29932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E6=B4=AA=E8=B4=9E?= Date: Fri, 13 Sep 2024 16:06:32 +0800 Subject: [PATCH] add namespaceSelector field in subnet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 马洪贞 --- charts/kube-ovn/templates/kube-ovn-crd.yaml | 44 +++++ dist/images/install.sh | 44 +++++ pkg/apis/kubeovn/v1/types.go | 4 +- pkg/apis/kubeovn/v1/zz_generated.deepcopy.go | 15 ++ .../versioned/fake/clientset_generated.go | 6 +- .../typed/kubeovn/v1/fake/fake_ip.go | 29 ++-- .../typed/kubeovn/v1/fake/fake_ippool.go | 36 ++--- .../kubeovn/v1/fake/fake_iptablesdnatrule.go | 36 ++--- .../typed/kubeovn/v1/fake/fake_iptableseip.go | 36 ++--- .../kubeovn/v1/fake/fake_iptablesfiprule.go | 36 ++--- .../kubeovn/v1/fake/fake_iptablessnatrule.go | 36 ++--- .../typed/kubeovn/v1/fake/fake_ovndnatrule.go | 36 ++--- .../typed/kubeovn/v1/fake/fake_ovneip.go | 36 ++--- .../typed/kubeovn/v1/fake/fake_ovnfip.go | 36 ++--- .../typed/kubeovn/v1/fake/fake_ovnsnatrule.go | 36 ++--- .../kubeovn/v1/fake/fake_providernetwork.go | 36 ++--- .../typed/kubeovn/v1/fake/fake_qospolicy.go | 36 ++--- .../kubeovn/v1/fake/fake_securitygroup.go | 36 ++--- .../typed/kubeovn/v1/fake/fake_subnet.go | 36 ++--- .../kubeovn/v1/fake/fake_switchlbrule.go | 36 ++--- .../typed/kubeovn/v1/fake/fake_vip.go | 36 ++--- .../typed/kubeovn/v1/fake/fake_vlan.go | 36 ++--- .../typed/kubeovn/v1/fake/fake_vpc.go | 36 ++--- .../typed/kubeovn/v1/fake/fake_vpcdns.go | 36 ++--- .../kubeovn/v1/fake/fake_vpcnatgateway.go | 36 ++--- .../versioned/typed/kubeovn/v1/ip.go | 119 ++++++++++++-- .../versioned/typed/kubeovn/v1/ippool.go | 135 ++++++++++++++-- .../typed/kubeovn/v1/iptablesdnatrule.go | 135 ++++++++++++++-- .../versioned/typed/kubeovn/v1/iptableseip.go | 135 ++++++++++++++-- .../typed/kubeovn/v1/iptablesfiprule.go | 135 ++++++++++++++-- .../typed/kubeovn/v1/iptablessnatrule.go | 135 ++++++++++++++-- .../versioned/typed/kubeovn/v1/ovndnatrule.go | 135 ++++++++++++++-- .../versioned/typed/kubeovn/v1/ovneip.go | 135 ++++++++++++++-- .../versioned/typed/kubeovn/v1/ovnfip.go | 135 ++++++++++++++-- .../versioned/typed/kubeovn/v1/ovnsnatrule.go | 135 ++++++++++++++-- .../typed/kubeovn/v1/providernetwork.go | 135 ++++++++++++++-- .../versioned/typed/kubeovn/v1/qospolicy.go | 135 ++++++++++++++-- .../typed/kubeovn/v1/securitygroup.go | 135 ++++++++++++++-- .../versioned/typed/kubeovn/v1/subnet.go | 135 ++++++++++++++-- .../typed/kubeovn/v1/switchlbrule.go | 135 ++++++++++++++-- .../versioned/typed/kubeovn/v1/vip.go | 135 ++++++++++++++-- .../versioned/typed/kubeovn/v1/vlan.go | 135 ++++++++++++++-- .../versioned/typed/kubeovn/v1/vpc.go | 135 ++++++++++++++-- .../versioned/typed/kubeovn/v1/vpcdns.go | 135 ++++++++++++++-- .../typed/kubeovn/v1/vpcnatgateway.go | 135 ++++++++++++++-- .../informers/externalversions/factory.go | 11 -- pkg/client/listers/kubeovn/v1/ip.go | 26 ++- pkg/client/listers/kubeovn/v1/ippool.go | 26 ++- .../listers/kubeovn/v1/iptablesdnatrule.go | 26 ++- pkg/client/listers/kubeovn/v1/iptableseip.go | 26 ++- .../listers/kubeovn/v1/iptablesfiprule.go | 26 ++- .../listers/kubeovn/v1/iptablessnatrule.go | 26 ++- pkg/client/listers/kubeovn/v1/ovndnatrule.go | 26 ++- pkg/client/listers/kubeovn/v1/ovneip.go | 26 ++- pkg/client/listers/kubeovn/v1/ovnfip.go | 26 ++- pkg/client/listers/kubeovn/v1/ovnsnatrule.go | 26 ++- .../listers/kubeovn/v1/providernetwork.go | 26 ++- pkg/client/listers/kubeovn/v1/qospolicy.go | 26 ++- .../listers/kubeovn/v1/securitygroup.go | 26 ++- pkg/client/listers/kubeovn/v1/subnet.go | 26 ++- pkg/client/listers/kubeovn/v1/switchlbrule.go | 26 ++- pkg/client/listers/kubeovn/v1/vip.go | 26 ++- pkg/client/listers/kubeovn/v1/vlan.go | 26 ++- pkg/client/listers/kubeovn/v1/vpc.go | 26 ++- pkg/client/listers/kubeovn/v1/vpcdns.go | 26 ++- .../listers/kubeovn/v1/vpcnatgateway.go | 26 ++- pkg/controller/namespace.go | 72 ++++++++- pkg/controller/subnet.go | 150 +++++++++++++----- 68 files changed, 3529 insertions(+), 734 deletions(-) diff --git a/charts/kube-ovn/templates/kube-ovn-crd.yaml b/charts/kube-ovn/templates/kube-ovn-crd.yaml index 7384e9a17d9..81c6255caf4 100644 --- a/charts/kube-ovn/templates/kube-ovn-crd.yaml +++ b/charts/kube-ovn/templates/kube-ovn-crd.yaml @@ -2041,6 +2041,28 @@ spec: type: string dstIPs: type: string + namespaceSelector: + type: array + items: + type: object + properties: + matchLabels: + type: object + additionalProperties: + type: string + matchExpressions: + type: array + items: + type: object + properties: + key: + type: string + operator: + type: string + values: + type: array + items: + type: string conditions: type: array items: @@ -2194,6 +2216,28 @@ spec: type: boolean routeTable: type: string + namespaceSelector: + type: array + items: + type: object + properties: + matchLabels: + type: object + additionalProperties: + type: string + matchExpressions: + type: array + items: + type: object + properties: + key: + type: string + operator: + type: string + values: + type: array + items: + type: string scope: Cluster names: plural: subnets diff --git a/dist/images/install.sh b/dist/images/install.sh index 051a5c69f08..fe0e8239cc6 100755 --- a/dist/images/install.sh +++ b/dist/images/install.sh @@ -2289,6 +2289,28 @@ spec: type: string dstIPs: type: string + namespaceSelector: + type: array + items: + type: object + properties: + matchLabels: + type: object + additionalProperties: + type: string + matchExpressions: + type: array + items: + type: object + properties: + key: + type: string + operator: + type: string + values: + type: array + items: + type: string conditions: type: array items: @@ -2442,6 +2464,28 @@ spec: type: boolean routeTable: type: string + namespaceSelector: + type: array + items: + type: object + properties: + matchLabels: + type: object + additionalProperties: + type: string + matchExpressions: + type: array + items: + type: object + properties: + key: + type: string + operator: + type: string + values: + type: array + items: + type: string scope: Cluster names: plural: subnets diff --git a/pkg/apis/kubeovn/v1/types.go b/pkg/apis/kubeovn/v1/types.go index e53c4e8c579..a1f9233ba55 100644 --- a/pkg/apis/kubeovn/v1/types.go +++ b/pkg/apis/kubeovn/v1/types.go @@ -170,7 +170,8 @@ type SubnetSpec struct { EnableEcmp bool `json:"enableEcmp,omitempty"` EnableMulticastSnoop bool `json:"enableMulticastSnoop,omitempty"` - RouteTable string `json:"routeTable,omitempty"` + RouteTable string `json:"routeTable,omitempty"` + NamespaceSelector []metav1.LabelSelector `json:"namespaceSelector,omitempty"` } type ACL struct { @@ -247,6 +248,7 @@ type SubnetStatus struct { NatOutgoingPolicyRules []NatOutgoingPolicyRuleStatus `json:"natOutgoingPolicyRules"` McastQuerierIP string `json:"mcastQuerierIP"` McastQuerierMAC string `json:"mcastQuerierMAC"` + NamespaceSelector []metav1.LabelSelector `json:"namespaceSelector"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/pkg/apis/kubeovn/v1/zz_generated.deepcopy.go b/pkg/apis/kubeovn/v1/zz_generated.deepcopy.go index 0f3ab4b7273..3558aa60fa2 100644 --- a/pkg/apis/kubeovn/v1/zz_generated.deepcopy.go +++ b/pkg/apis/kubeovn/v1/zz_generated.deepcopy.go @@ -23,6 +23,7 @@ package v1 import ( corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -1920,6 +1921,13 @@ func (in *SubnetSpec) DeepCopyInto(out *SubnetSpec) { *out = new(bool) **out = **in } + if in.NamespaceSelector != nil { + in, out := &in.NamespaceSelector, &out.NamespaceSelector + *out = make([]metav1.LabelSelector, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } @@ -1948,6 +1956,13 @@ func (in *SubnetStatus) DeepCopyInto(out *SubnetStatus) { *out = make([]NatOutgoingPolicyRuleStatus, len(*in)) copy(*out, *in) } + if in.NamespaceSelector != nil { + in, out := &in.NamespaceSelector, &out.NamespaceSelector + *out = make([]metav1.LabelSelector, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index 79e27b9c312..164d4abfa66 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -31,12 +31,8 @@ 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 field management, validations and/or defaults. It shouldn't be considered a replacement +// without applying any 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/kubeovn/v1/fake/fake_ip.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ip.go index 7c00d8df67d..25a7ec10775 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ip.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ip.go @@ -40,22 +40,20 @@ var ipsKind = v1.SchemeGroupVersion.WithKind("IP") // Get takes name of the iP, and returns the corresponding iP object, and an error if there is any. func (c *FakeIPs) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.IP, err error) { - emptyResult := &v1.IP{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(ipsResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(ipsResource, name), &v1.IP{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IP), err } // List takes label and field selectors, and returns the list of IPs that match those selectors. func (c *FakeIPs) List(ctx context.Context, opts metav1.ListOptions) (result *v1.IPList, err error) { - emptyResult := &v1.IPList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(ipsResource, ipsKind, opts), emptyResult) + Invokes(testing.NewRootListAction(ipsResource, ipsKind, opts), &v1.IPList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,27 +72,25 @@ func (c *FakeIPs) List(ctx context.Context, opts metav1.ListOptions) (result *v1 // Watch returns a watch.Interface that watches the requested iPs. func (c *FakeIPs) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(ipsResource, opts)) + InvokesWatch(testing.NewRootWatchAction(ipsResource, opts)) } // Create takes the representation of a iP and creates it. Returns the server's representation of the iP, and an error, if there is any. func (c *FakeIPs) Create(ctx context.Context, iP *v1.IP, opts metav1.CreateOptions) (result *v1.IP, err error) { - emptyResult := &v1.IP{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(ipsResource, iP, opts), emptyResult) + Invokes(testing.NewRootCreateAction(ipsResource, iP), &v1.IP{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IP), err } // Update takes the representation of a iP and updates it. Returns the server's representation of the iP, and an error, if there is any. func (c *FakeIPs) Update(ctx context.Context, iP *v1.IP, opts metav1.UpdateOptions) (result *v1.IP, err error) { - emptyResult := &v1.IP{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(ipsResource, iP, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(ipsResource, iP), &v1.IP{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IP), err } @@ -108,7 +104,7 @@ func (c *FakeIPs) Delete(ctx context.Context, name string, opts metav1.DeleteOpt // DeleteCollection deletes a collection of objects. func (c *FakeIPs) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(ipsResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(ipsResource, listOpts) _, err := c.Fake.Invokes(action, &v1.IPList{}) return err @@ -116,11 +112,10 @@ func (c *FakeIPs) DeleteCollection(ctx context.Context, opts metav1.DeleteOption // Patch applies the patch and returns the patched iP. func (c *FakeIPs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.IP, err error) { - emptyResult := &v1.IP{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(ipsResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(ipsResource, name, pt, data, subresources...), &v1.IP{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IP), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ippool.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ippool.go index 5579395e76b..eccc9af7bae 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ippool.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ippool.go @@ -40,22 +40,20 @@ var ippoolsKind = v1.SchemeGroupVersion.WithKind("IPPool") // Get takes name of the iPPool, and returns the corresponding iPPool object, and an error if there is any. func (c *FakeIPPools) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.IPPool, err error) { - emptyResult := &v1.IPPool{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(ippoolsResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(ippoolsResource, name), &v1.IPPool{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IPPool), err } // List takes label and field selectors, and returns the list of IPPools that match those selectors. func (c *FakeIPPools) List(ctx context.Context, opts metav1.ListOptions) (result *v1.IPPoolList, err error) { - emptyResult := &v1.IPPoolList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(ippoolsResource, ippoolsKind, opts), emptyResult) + Invokes(testing.NewRootListAction(ippoolsResource, ippoolsKind, opts), &v1.IPPoolList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeIPPools) List(ctx context.Context, opts metav1.ListOptions) (result // Watch returns a watch.Interface that watches the requested iPPools. func (c *FakeIPPools) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(ippoolsResource, opts)) + InvokesWatch(testing.NewRootWatchAction(ippoolsResource, opts)) } // Create takes the representation of a iPPool and creates it. Returns the server's representation of the iPPool, and an error, if there is any. func (c *FakeIPPools) Create(ctx context.Context, iPPool *v1.IPPool, opts metav1.CreateOptions) (result *v1.IPPool, err error) { - emptyResult := &v1.IPPool{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(ippoolsResource, iPPool, opts), emptyResult) + Invokes(testing.NewRootCreateAction(ippoolsResource, iPPool), &v1.IPPool{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IPPool), err } // Update takes the representation of a iPPool and updates it. Returns the server's representation of the iPPool, and an error, if there is any. func (c *FakeIPPools) Update(ctx context.Context, iPPool *v1.IPPool, opts metav1.UpdateOptions) (result *v1.IPPool, err error) { - emptyResult := &v1.IPPool{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(ippoolsResource, iPPool, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(ippoolsResource, iPPool), &v1.IPPool{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IPPool), 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 *FakeIPPools) UpdateStatus(ctx context.Context, iPPool *v1.IPPool, opts metav1.UpdateOptions) (result *v1.IPPool, err error) { - emptyResult := &v1.IPPool{} +func (c *FakeIPPools) UpdateStatus(ctx context.Context, iPPool *v1.IPPool, opts metav1.UpdateOptions) (*v1.IPPool, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(ippoolsResource, "status", iPPool, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(ippoolsResource, "status", iPPool), &v1.IPPool{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IPPool), err } @@ -120,7 +115,7 @@ func (c *FakeIPPools) Delete(ctx context.Context, name string, opts metav1.Delet // DeleteCollection deletes a collection of objects. func (c *FakeIPPools) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(ippoolsResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(ippoolsResource, listOpts) _, err := c.Fake.Invokes(action, &v1.IPPoolList{}) return err @@ -128,11 +123,10 @@ func (c *FakeIPPools) DeleteCollection(ctx context.Context, opts metav1.DeleteOp // Patch applies the patch and returns the patched iPPool. func (c *FakeIPPools) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.IPPool, err error) { - emptyResult := &v1.IPPool{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(ippoolsResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(ippoolsResource, name, pt, data, subresources...), &v1.IPPool{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IPPool), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_iptablesdnatrule.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_iptablesdnatrule.go index d7ecd393144..7b3d275edb3 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_iptablesdnatrule.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_iptablesdnatrule.go @@ -40,22 +40,20 @@ var iptablesdnatrulesKind = v1.SchemeGroupVersion.WithKind("IptablesDnatRule") // Get takes name of the iptablesDnatRule, and returns the corresponding iptablesDnatRule object, and an error if there is any. func (c *FakeIptablesDnatRules) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.IptablesDnatRule, err error) { - emptyResult := &v1.IptablesDnatRule{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(iptablesdnatrulesResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(iptablesdnatrulesResource, name), &v1.IptablesDnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesDnatRule), err } // List takes label and field selectors, and returns the list of IptablesDnatRules that match those selectors. func (c *FakeIptablesDnatRules) List(ctx context.Context, opts metav1.ListOptions) (result *v1.IptablesDnatRuleList, err error) { - emptyResult := &v1.IptablesDnatRuleList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(iptablesdnatrulesResource, iptablesdnatrulesKind, opts), emptyResult) + Invokes(testing.NewRootListAction(iptablesdnatrulesResource, iptablesdnatrulesKind, opts), &v1.IptablesDnatRuleList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeIptablesDnatRules) List(ctx context.Context, opts metav1.ListOption // Watch returns a watch.Interface that watches the requested iptablesDnatRules. func (c *FakeIptablesDnatRules) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(iptablesdnatrulesResource, opts)) + InvokesWatch(testing.NewRootWatchAction(iptablesdnatrulesResource, opts)) } // Create takes the representation of a iptablesDnatRule and creates it. Returns the server's representation of the iptablesDnatRule, and an error, if there is any. func (c *FakeIptablesDnatRules) Create(ctx context.Context, iptablesDnatRule *v1.IptablesDnatRule, opts metav1.CreateOptions) (result *v1.IptablesDnatRule, err error) { - emptyResult := &v1.IptablesDnatRule{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(iptablesdnatrulesResource, iptablesDnatRule, opts), emptyResult) + Invokes(testing.NewRootCreateAction(iptablesdnatrulesResource, iptablesDnatRule), &v1.IptablesDnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesDnatRule), err } // Update takes the representation of a iptablesDnatRule and updates it. Returns the server's representation of the iptablesDnatRule, and an error, if there is any. func (c *FakeIptablesDnatRules) Update(ctx context.Context, iptablesDnatRule *v1.IptablesDnatRule, opts metav1.UpdateOptions) (result *v1.IptablesDnatRule, err error) { - emptyResult := &v1.IptablesDnatRule{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(iptablesdnatrulesResource, iptablesDnatRule, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(iptablesdnatrulesResource, iptablesDnatRule), &v1.IptablesDnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesDnatRule), 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 *FakeIptablesDnatRules) UpdateStatus(ctx context.Context, iptablesDnatRule *v1.IptablesDnatRule, opts metav1.UpdateOptions) (result *v1.IptablesDnatRule, err error) { - emptyResult := &v1.IptablesDnatRule{} +func (c *FakeIptablesDnatRules) UpdateStatus(ctx context.Context, iptablesDnatRule *v1.IptablesDnatRule, opts metav1.UpdateOptions) (*v1.IptablesDnatRule, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(iptablesdnatrulesResource, "status", iptablesDnatRule, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(iptablesdnatrulesResource, "status", iptablesDnatRule), &v1.IptablesDnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesDnatRule), err } @@ -120,7 +115,7 @@ func (c *FakeIptablesDnatRules) Delete(ctx context.Context, name string, opts me // DeleteCollection deletes a collection of objects. func (c *FakeIptablesDnatRules) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(iptablesdnatrulesResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(iptablesdnatrulesResource, listOpts) _, err := c.Fake.Invokes(action, &v1.IptablesDnatRuleList{}) return err @@ -128,11 +123,10 @@ func (c *FakeIptablesDnatRules) DeleteCollection(ctx context.Context, opts metav // Patch applies the patch and returns the patched iptablesDnatRule. func (c *FakeIptablesDnatRules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.IptablesDnatRule, err error) { - emptyResult := &v1.IptablesDnatRule{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(iptablesdnatrulesResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(iptablesdnatrulesResource, name, pt, data, subresources...), &v1.IptablesDnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesDnatRule), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_iptableseip.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_iptableseip.go index 8457a12e801..4072757ea1b 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_iptableseip.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_iptableseip.go @@ -40,22 +40,20 @@ var iptableseipsKind = v1.SchemeGroupVersion.WithKind("IptablesEIP") // Get takes name of the iptablesEIP, and returns the corresponding iptablesEIP object, and an error if there is any. func (c *FakeIptablesEIPs) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.IptablesEIP, err error) { - emptyResult := &v1.IptablesEIP{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(iptableseipsResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(iptableseipsResource, name), &v1.IptablesEIP{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesEIP), err } // List takes label and field selectors, and returns the list of IptablesEIPs that match those selectors. func (c *FakeIptablesEIPs) List(ctx context.Context, opts metav1.ListOptions) (result *v1.IptablesEIPList, err error) { - emptyResult := &v1.IptablesEIPList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(iptableseipsResource, iptableseipsKind, opts), emptyResult) + Invokes(testing.NewRootListAction(iptableseipsResource, iptableseipsKind, opts), &v1.IptablesEIPList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeIptablesEIPs) List(ctx context.Context, opts metav1.ListOptions) (r // Watch returns a watch.Interface that watches the requested iptablesEIPs. func (c *FakeIptablesEIPs) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(iptableseipsResource, opts)) + InvokesWatch(testing.NewRootWatchAction(iptableseipsResource, opts)) } // Create takes the representation of a iptablesEIP and creates it. Returns the server's representation of the iptablesEIP, and an error, if there is any. func (c *FakeIptablesEIPs) Create(ctx context.Context, iptablesEIP *v1.IptablesEIP, opts metav1.CreateOptions) (result *v1.IptablesEIP, err error) { - emptyResult := &v1.IptablesEIP{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(iptableseipsResource, iptablesEIP, opts), emptyResult) + Invokes(testing.NewRootCreateAction(iptableseipsResource, iptablesEIP), &v1.IptablesEIP{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesEIP), err } // Update takes the representation of a iptablesEIP and updates it. Returns the server's representation of the iptablesEIP, and an error, if there is any. func (c *FakeIptablesEIPs) Update(ctx context.Context, iptablesEIP *v1.IptablesEIP, opts metav1.UpdateOptions) (result *v1.IptablesEIP, err error) { - emptyResult := &v1.IptablesEIP{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(iptableseipsResource, iptablesEIP, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(iptableseipsResource, iptablesEIP), &v1.IptablesEIP{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesEIP), 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 *FakeIptablesEIPs) UpdateStatus(ctx context.Context, iptablesEIP *v1.IptablesEIP, opts metav1.UpdateOptions) (result *v1.IptablesEIP, err error) { - emptyResult := &v1.IptablesEIP{} +func (c *FakeIptablesEIPs) UpdateStatus(ctx context.Context, iptablesEIP *v1.IptablesEIP, opts metav1.UpdateOptions) (*v1.IptablesEIP, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(iptableseipsResource, "status", iptablesEIP, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(iptableseipsResource, "status", iptablesEIP), &v1.IptablesEIP{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesEIP), err } @@ -120,7 +115,7 @@ func (c *FakeIptablesEIPs) Delete(ctx context.Context, name string, opts metav1. // DeleteCollection deletes a collection of objects. func (c *FakeIptablesEIPs) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(iptableseipsResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(iptableseipsResource, listOpts) _, err := c.Fake.Invokes(action, &v1.IptablesEIPList{}) return err @@ -128,11 +123,10 @@ func (c *FakeIptablesEIPs) DeleteCollection(ctx context.Context, opts metav1.Del // Patch applies the patch and returns the patched iptablesEIP. func (c *FakeIptablesEIPs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.IptablesEIP, err error) { - emptyResult := &v1.IptablesEIP{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(iptableseipsResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(iptableseipsResource, name, pt, data, subresources...), &v1.IptablesEIP{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesEIP), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_iptablesfiprule.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_iptablesfiprule.go index 9414c9aecf0..47167cb2009 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_iptablesfiprule.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_iptablesfiprule.go @@ -40,22 +40,20 @@ var iptablesfiprulesKind = v1.SchemeGroupVersion.WithKind("IptablesFIPRule") // Get takes name of the iptablesFIPRule, and returns the corresponding iptablesFIPRule object, and an error if there is any. func (c *FakeIptablesFIPRules) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.IptablesFIPRule, err error) { - emptyResult := &v1.IptablesFIPRule{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(iptablesfiprulesResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(iptablesfiprulesResource, name), &v1.IptablesFIPRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesFIPRule), err } // List takes label and field selectors, and returns the list of IptablesFIPRules that match those selectors. func (c *FakeIptablesFIPRules) List(ctx context.Context, opts metav1.ListOptions) (result *v1.IptablesFIPRuleList, err error) { - emptyResult := &v1.IptablesFIPRuleList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(iptablesfiprulesResource, iptablesfiprulesKind, opts), emptyResult) + Invokes(testing.NewRootListAction(iptablesfiprulesResource, iptablesfiprulesKind, opts), &v1.IptablesFIPRuleList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeIptablesFIPRules) List(ctx context.Context, opts metav1.ListOptions // Watch returns a watch.Interface that watches the requested iptablesFIPRules. func (c *FakeIptablesFIPRules) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(iptablesfiprulesResource, opts)) + InvokesWatch(testing.NewRootWatchAction(iptablesfiprulesResource, opts)) } // Create takes the representation of a iptablesFIPRule and creates it. Returns the server's representation of the iptablesFIPRule, and an error, if there is any. func (c *FakeIptablesFIPRules) Create(ctx context.Context, iptablesFIPRule *v1.IptablesFIPRule, opts metav1.CreateOptions) (result *v1.IptablesFIPRule, err error) { - emptyResult := &v1.IptablesFIPRule{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(iptablesfiprulesResource, iptablesFIPRule, opts), emptyResult) + Invokes(testing.NewRootCreateAction(iptablesfiprulesResource, iptablesFIPRule), &v1.IptablesFIPRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesFIPRule), err } // Update takes the representation of a iptablesFIPRule and updates it. Returns the server's representation of the iptablesFIPRule, and an error, if there is any. func (c *FakeIptablesFIPRules) Update(ctx context.Context, iptablesFIPRule *v1.IptablesFIPRule, opts metav1.UpdateOptions) (result *v1.IptablesFIPRule, err error) { - emptyResult := &v1.IptablesFIPRule{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(iptablesfiprulesResource, iptablesFIPRule, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(iptablesfiprulesResource, iptablesFIPRule), &v1.IptablesFIPRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesFIPRule), 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 *FakeIptablesFIPRules) UpdateStatus(ctx context.Context, iptablesFIPRule *v1.IptablesFIPRule, opts metav1.UpdateOptions) (result *v1.IptablesFIPRule, err error) { - emptyResult := &v1.IptablesFIPRule{} +func (c *FakeIptablesFIPRules) UpdateStatus(ctx context.Context, iptablesFIPRule *v1.IptablesFIPRule, opts metav1.UpdateOptions) (*v1.IptablesFIPRule, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(iptablesfiprulesResource, "status", iptablesFIPRule, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(iptablesfiprulesResource, "status", iptablesFIPRule), &v1.IptablesFIPRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesFIPRule), err } @@ -120,7 +115,7 @@ func (c *FakeIptablesFIPRules) Delete(ctx context.Context, name string, opts met // DeleteCollection deletes a collection of objects. func (c *FakeIptablesFIPRules) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(iptablesfiprulesResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(iptablesfiprulesResource, listOpts) _, err := c.Fake.Invokes(action, &v1.IptablesFIPRuleList{}) return err @@ -128,11 +123,10 @@ func (c *FakeIptablesFIPRules) DeleteCollection(ctx context.Context, opts metav1 // Patch applies the patch and returns the patched iptablesFIPRule. func (c *FakeIptablesFIPRules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.IptablesFIPRule, err error) { - emptyResult := &v1.IptablesFIPRule{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(iptablesfiprulesResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(iptablesfiprulesResource, name, pt, data, subresources...), &v1.IptablesFIPRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesFIPRule), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_iptablessnatrule.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_iptablessnatrule.go index 97a2db2601b..dd12fb75817 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_iptablessnatrule.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_iptablessnatrule.go @@ -40,22 +40,20 @@ var iptablessnatrulesKind = v1.SchemeGroupVersion.WithKind("IptablesSnatRule") // Get takes name of the iptablesSnatRule, and returns the corresponding iptablesSnatRule object, and an error if there is any. func (c *FakeIptablesSnatRules) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.IptablesSnatRule, err error) { - emptyResult := &v1.IptablesSnatRule{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(iptablessnatrulesResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(iptablessnatrulesResource, name), &v1.IptablesSnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesSnatRule), err } // List takes label and field selectors, and returns the list of IptablesSnatRules that match those selectors. func (c *FakeIptablesSnatRules) List(ctx context.Context, opts metav1.ListOptions) (result *v1.IptablesSnatRuleList, err error) { - emptyResult := &v1.IptablesSnatRuleList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(iptablessnatrulesResource, iptablessnatrulesKind, opts), emptyResult) + Invokes(testing.NewRootListAction(iptablessnatrulesResource, iptablessnatrulesKind, opts), &v1.IptablesSnatRuleList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeIptablesSnatRules) List(ctx context.Context, opts metav1.ListOption // Watch returns a watch.Interface that watches the requested iptablesSnatRules. func (c *FakeIptablesSnatRules) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(iptablessnatrulesResource, opts)) + InvokesWatch(testing.NewRootWatchAction(iptablessnatrulesResource, opts)) } // Create takes the representation of a iptablesSnatRule and creates it. Returns the server's representation of the iptablesSnatRule, and an error, if there is any. func (c *FakeIptablesSnatRules) Create(ctx context.Context, iptablesSnatRule *v1.IptablesSnatRule, opts metav1.CreateOptions) (result *v1.IptablesSnatRule, err error) { - emptyResult := &v1.IptablesSnatRule{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(iptablessnatrulesResource, iptablesSnatRule, opts), emptyResult) + Invokes(testing.NewRootCreateAction(iptablessnatrulesResource, iptablesSnatRule), &v1.IptablesSnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesSnatRule), err } // Update takes the representation of a iptablesSnatRule and updates it. Returns the server's representation of the iptablesSnatRule, and an error, if there is any. func (c *FakeIptablesSnatRules) Update(ctx context.Context, iptablesSnatRule *v1.IptablesSnatRule, opts metav1.UpdateOptions) (result *v1.IptablesSnatRule, err error) { - emptyResult := &v1.IptablesSnatRule{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(iptablessnatrulesResource, iptablesSnatRule, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(iptablessnatrulesResource, iptablesSnatRule), &v1.IptablesSnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesSnatRule), 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 *FakeIptablesSnatRules) UpdateStatus(ctx context.Context, iptablesSnatRule *v1.IptablesSnatRule, opts metav1.UpdateOptions) (result *v1.IptablesSnatRule, err error) { - emptyResult := &v1.IptablesSnatRule{} +func (c *FakeIptablesSnatRules) UpdateStatus(ctx context.Context, iptablesSnatRule *v1.IptablesSnatRule, opts metav1.UpdateOptions) (*v1.IptablesSnatRule, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(iptablessnatrulesResource, "status", iptablesSnatRule, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(iptablessnatrulesResource, "status", iptablesSnatRule), &v1.IptablesSnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesSnatRule), err } @@ -120,7 +115,7 @@ func (c *FakeIptablesSnatRules) Delete(ctx context.Context, name string, opts me // DeleteCollection deletes a collection of objects. func (c *FakeIptablesSnatRules) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(iptablessnatrulesResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(iptablessnatrulesResource, listOpts) _, err := c.Fake.Invokes(action, &v1.IptablesSnatRuleList{}) return err @@ -128,11 +123,10 @@ func (c *FakeIptablesSnatRules) DeleteCollection(ctx context.Context, opts metav // Patch applies the patch and returns the patched iptablesSnatRule. func (c *FakeIptablesSnatRules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.IptablesSnatRule, err error) { - emptyResult := &v1.IptablesSnatRule{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(iptablessnatrulesResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(iptablessnatrulesResource, name, pt, data, subresources...), &v1.IptablesSnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.IptablesSnatRule), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ovndnatrule.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ovndnatrule.go index bbb670fbae2..4632e5e9378 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ovndnatrule.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ovndnatrule.go @@ -40,22 +40,20 @@ var ovndnatrulesKind = v1.SchemeGroupVersion.WithKind("OvnDnatRule") // Get takes name of the ovnDnatRule, and returns the corresponding ovnDnatRule object, and an error if there is any. func (c *FakeOvnDnatRules) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.OvnDnatRule, err error) { - emptyResult := &v1.OvnDnatRule{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(ovndnatrulesResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(ovndnatrulesResource, name), &v1.OvnDnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnDnatRule), err } // List takes label and field selectors, and returns the list of OvnDnatRules that match those selectors. func (c *FakeOvnDnatRules) List(ctx context.Context, opts metav1.ListOptions) (result *v1.OvnDnatRuleList, err error) { - emptyResult := &v1.OvnDnatRuleList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(ovndnatrulesResource, ovndnatrulesKind, opts), emptyResult) + Invokes(testing.NewRootListAction(ovndnatrulesResource, ovndnatrulesKind, opts), &v1.OvnDnatRuleList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeOvnDnatRules) List(ctx context.Context, opts metav1.ListOptions) (r // Watch returns a watch.Interface that watches the requested ovnDnatRules. func (c *FakeOvnDnatRules) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(ovndnatrulesResource, opts)) + InvokesWatch(testing.NewRootWatchAction(ovndnatrulesResource, opts)) } // Create takes the representation of a ovnDnatRule and creates it. Returns the server's representation of the ovnDnatRule, and an error, if there is any. func (c *FakeOvnDnatRules) Create(ctx context.Context, ovnDnatRule *v1.OvnDnatRule, opts metav1.CreateOptions) (result *v1.OvnDnatRule, err error) { - emptyResult := &v1.OvnDnatRule{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(ovndnatrulesResource, ovnDnatRule, opts), emptyResult) + Invokes(testing.NewRootCreateAction(ovndnatrulesResource, ovnDnatRule), &v1.OvnDnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnDnatRule), err } // Update takes the representation of a ovnDnatRule and updates it. Returns the server's representation of the ovnDnatRule, and an error, if there is any. func (c *FakeOvnDnatRules) Update(ctx context.Context, ovnDnatRule *v1.OvnDnatRule, opts metav1.UpdateOptions) (result *v1.OvnDnatRule, err error) { - emptyResult := &v1.OvnDnatRule{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(ovndnatrulesResource, ovnDnatRule, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(ovndnatrulesResource, ovnDnatRule), &v1.OvnDnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnDnatRule), 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 *FakeOvnDnatRules) UpdateStatus(ctx context.Context, ovnDnatRule *v1.OvnDnatRule, opts metav1.UpdateOptions) (result *v1.OvnDnatRule, err error) { - emptyResult := &v1.OvnDnatRule{} +func (c *FakeOvnDnatRules) UpdateStatus(ctx context.Context, ovnDnatRule *v1.OvnDnatRule, opts metav1.UpdateOptions) (*v1.OvnDnatRule, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(ovndnatrulesResource, "status", ovnDnatRule, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(ovndnatrulesResource, "status", ovnDnatRule), &v1.OvnDnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnDnatRule), err } @@ -120,7 +115,7 @@ func (c *FakeOvnDnatRules) Delete(ctx context.Context, name string, opts metav1. // DeleteCollection deletes a collection of objects. func (c *FakeOvnDnatRules) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(ovndnatrulesResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(ovndnatrulesResource, listOpts) _, err := c.Fake.Invokes(action, &v1.OvnDnatRuleList{}) return err @@ -128,11 +123,10 @@ func (c *FakeOvnDnatRules) DeleteCollection(ctx context.Context, opts metav1.Del // Patch applies the patch and returns the patched ovnDnatRule. func (c *FakeOvnDnatRules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.OvnDnatRule, err error) { - emptyResult := &v1.OvnDnatRule{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(ovndnatrulesResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(ovndnatrulesResource, name, pt, data, subresources...), &v1.OvnDnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnDnatRule), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ovneip.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ovneip.go index e81a9bca8dc..b7a9d77b48d 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ovneip.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ovneip.go @@ -40,22 +40,20 @@ var ovneipsKind = v1.SchemeGroupVersion.WithKind("OvnEip") // Get takes name of the ovnEip, and returns the corresponding ovnEip object, and an error if there is any. func (c *FakeOvnEips) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.OvnEip, err error) { - emptyResult := &v1.OvnEip{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(ovneipsResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(ovneipsResource, name), &v1.OvnEip{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnEip), err } // List takes label and field selectors, and returns the list of OvnEips that match those selectors. func (c *FakeOvnEips) List(ctx context.Context, opts metav1.ListOptions) (result *v1.OvnEipList, err error) { - emptyResult := &v1.OvnEipList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(ovneipsResource, ovneipsKind, opts), emptyResult) + Invokes(testing.NewRootListAction(ovneipsResource, ovneipsKind, opts), &v1.OvnEipList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeOvnEips) List(ctx context.Context, opts metav1.ListOptions) (result // Watch returns a watch.Interface that watches the requested ovnEips. func (c *FakeOvnEips) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(ovneipsResource, opts)) + InvokesWatch(testing.NewRootWatchAction(ovneipsResource, opts)) } // Create takes the representation of a ovnEip and creates it. Returns the server's representation of the ovnEip, and an error, if there is any. func (c *FakeOvnEips) Create(ctx context.Context, ovnEip *v1.OvnEip, opts metav1.CreateOptions) (result *v1.OvnEip, err error) { - emptyResult := &v1.OvnEip{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(ovneipsResource, ovnEip, opts), emptyResult) + Invokes(testing.NewRootCreateAction(ovneipsResource, ovnEip), &v1.OvnEip{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnEip), err } // Update takes the representation of a ovnEip and updates it. Returns the server's representation of the ovnEip, and an error, if there is any. func (c *FakeOvnEips) Update(ctx context.Context, ovnEip *v1.OvnEip, opts metav1.UpdateOptions) (result *v1.OvnEip, err error) { - emptyResult := &v1.OvnEip{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(ovneipsResource, ovnEip, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(ovneipsResource, ovnEip), &v1.OvnEip{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnEip), 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 *FakeOvnEips) UpdateStatus(ctx context.Context, ovnEip *v1.OvnEip, opts metav1.UpdateOptions) (result *v1.OvnEip, err error) { - emptyResult := &v1.OvnEip{} +func (c *FakeOvnEips) UpdateStatus(ctx context.Context, ovnEip *v1.OvnEip, opts metav1.UpdateOptions) (*v1.OvnEip, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(ovneipsResource, "status", ovnEip, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(ovneipsResource, "status", ovnEip), &v1.OvnEip{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnEip), err } @@ -120,7 +115,7 @@ func (c *FakeOvnEips) Delete(ctx context.Context, name string, opts metav1.Delet // DeleteCollection deletes a collection of objects. func (c *FakeOvnEips) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(ovneipsResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(ovneipsResource, listOpts) _, err := c.Fake.Invokes(action, &v1.OvnEipList{}) return err @@ -128,11 +123,10 @@ func (c *FakeOvnEips) DeleteCollection(ctx context.Context, opts metav1.DeleteOp // Patch applies the patch and returns the patched ovnEip. func (c *FakeOvnEips) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.OvnEip, err error) { - emptyResult := &v1.OvnEip{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(ovneipsResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(ovneipsResource, name, pt, data, subresources...), &v1.OvnEip{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnEip), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ovnfip.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ovnfip.go index ae43f080952..ae4c2ba955d 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ovnfip.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ovnfip.go @@ -40,22 +40,20 @@ var ovnfipsKind = v1.SchemeGroupVersion.WithKind("OvnFip") // Get takes name of the ovnFip, and returns the corresponding ovnFip object, and an error if there is any. func (c *FakeOvnFips) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.OvnFip, err error) { - emptyResult := &v1.OvnFip{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(ovnfipsResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(ovnfipsResource, name), &v1.OvnFip{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnFip), err } // List takes label and field selectors, and returns the list of OvnFips that match those selectors. func (c *FakeOvnFips) List(ctx context.Context, opts metav1.ListOptions) (result *v1.OvnFipList, err error) { - emptyResult := &v1.OvnFipList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(ovnfipsResource, ovnfipsKind, opts), emptyResult) + Invokes(testing.NewRootListAction(ovnfipsResource, ovnfipsKind, opts), &v1.OvnFipList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeOvnFips) List(ctx context.Context, opts metav1.ListOptions) (result // Watch returns a watch.Interface that watches the requested ovnFips. func (c *FakeOvnFips) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(ovnfipsResource, opts)) + InvokesWatch(testing.NewRootWatchAction(ovnfipsResource, opts)) } // Create takes the representation of a ovnFip and creates it. Returns the server's representation of the ovnFip, and an error, if there is any. func (c *FakeOvnFips) Create(ctx context.Context, ovnFip *v1.OvnFip, opts metav1.CreateOptions) (result *v1.OvnFip, err error) { - emptyResult := &v1.OvnFip{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(ovnfipsResource, ovnFip, opts), emptyResult) + Invokes(testing.NewRootCreateAction(ovnfipsResource, ovnFip), &v1.OvnFip{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnFip), err } // Update takes the representation of a ovnFip and updates it. Returns the server's representation of the ovnFip, and an error, if there is any. func (c *FakeOvnFips) Update(ctx context.Context, ovnFip *v1.OvnFip, opts metav1.UpdateOptions) (result *v1.OvnFip, err error) { - emptyResult := &v1.OvnFip{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(ovnfipsResource, ovnFip, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(ovnfipsResource, ovnFip), &v1.OvnFip{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnFip), 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 *FakeOvnFips) UpdateStatus(ctx context.Context, ovnFip *v1.OvnFip, opts metav1.UpdateOptions) (result *v1.OvnFip, err error) { - emptyResult := &v1.OvnFip{} +func (c *FakeOvnFips) UpdateStatus(ctx context.Context, ovnFip *v1.OvnFip, opts metav1.UpdateOptions) (*v1.OvnFip, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(ovnfipsResource, "status", ovnFip, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(ovnfipsResource, "status", ovnFip), &v1.OvnFip{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnFip), err } @@ -120,7 +115,7 @@ func (c *FakeOvnFips) Delete(ctx context.Context, name string, opts metav1.Delet // DeleteCollection deletes a collection of objects. func (c *FakeOvnFips) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(ovnfipsResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(ovnfipsResource, listOpts) _, err := c.Fake.Invokes(action, &v1.OvnFipList{}) return err @@ -128,11 +123,10 @@ func (c *FakeOvnFips) DeleteCollection(ctx context.Context, opts metav1.DeleteOp // Patch applies the patch and returns the patched ovnFip. func (c *FakeOvnFips) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.OvnFip, err error) { - emptyResult := &v1.OvnFip{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(ovnfipsResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(ovnfipsResource, name, pt, data, subresources...), &v1.OvnFip{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnFip), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ovnsnatrule.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ovnsnatrule.go index cab29ba95fe..6ffb725f5df 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ovnsnatrule.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_ovnsnatrule.go @@ -40,22 +40,20 @@ var ovnsnatrulesKind = v1.SchemeGroupVersion.WithKind("OvnSnatRule") // Get takes name of the ovnSnatRule, and returns the corresponding ovnSnatRule object, and an error if there is any. func (c *FakeOvnSnatRules) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.OvnSnatRule, err error) { - emptyResult := &v1.OvnSnatRule{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(ovnsnatrulesResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(ovnsnatrulesResource, name), &v1.OvnSnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnSnatRule), err } // List takes label and field selectors, and returns the list of OvnSnatRules that match those selectors. func (c *FakeOvnSnatRules) List(ctx context.Context, opts metav1.ListOptions) (result *v1.OvnSnatRuleList, err error) { - emptyResult := &v1.OvnSnatRuleList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(ovnsnatrulesResource, ovnsnatrulesKind, opts), emptyResult) + Invokes(testing.NewRootListAction(ovnsnatrulesResource, ovnsnatrulesKind, opts), &v1.OvnSnatRuleList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeOvnSnatRules) List(ctx context.Context, opts metav1.ListOptions) (r // Watch returns a watch.Interface that watches the requested ovnSnatRules. func (c *FakeOvnSnatRules) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(ovnsnatrulesResource, opts)) + InvokesWatch(testing.NewRootWatchAction(ovnsnatrulesResource, opts)) } // Create takes the representation of a ovnSnatRule and creates it. Returns the server's representation of the ovnSnatRule, and an error, if there is any. func (c *FakeOvnSnatRules) Create(ctx context.Context, ovnSnatRule *v1.OvnSnatRule, opts metav1.CreateOptions) (result *v1.OvnSnatRule, err error) { - emptyResult := &v1.OvnSnatRule{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(ovnsnatrulesResource, ovnSnatRule, opts), emptyResult) + Invokes(testing.NewRootCreateAction(ovnsnatrulesResource, ovnSnatRule), &v1.OvnSnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnSnatRule), err } // Update takes the representation of a ovnSnatRule and updates it. Returns the server's representation of the ovnSnatRule, and an error, if there is any. func (c *FakeOvnSnatRules) Update(ctx context.Context, ovnSnatRule *v1.OvnSnatRule, opts metav1.UpdateOptions) (result *v1.OvnSnatRule, err error) { - emptyResult := &v1.OvnSnatRule{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(ovnsnatrulesResource, ovnSnatRule, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(ovnsnatrulesResource, ovnSnatRule), &v1.OvnSnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnSnatRule), 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 *FakeOvnSnatRules) UpdateStatus(ctx context.Context, ovnSnatRule *v1.OvnSnatRule, opts metav1.UpdateOptions) (result *v1.OvnSnatRule, err error) { - emptyResult := &v1.OvnSnatRule{} +func (c *FakeOvnSnatRules) UpdateStatus(ctx context.Context, ovnSnatRule *v1.OvnSnatRule, opts metav1.UpdateOptions) (*v1.OvnSnatRule, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(ovnsnatrulesResource, "status", ovnSnatRule, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(ovnsnatrulesResource, "status", ovnSnatRule), &v1.OvnSnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnSnatRule), err } @@ -120,7 +115,7 @@ func (c *FakeOvnSnatRules) Delete(ctx context.Context, name string, opts metav1. // DeleteCollection deletes a collection of objects. func (c *FakeOvnSnatRules) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(ovnsnatrulesResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(ovnsnatrulesResource, listOpts) _, err := c.Fake.Invokes(action, &v1.OvnSnatRuleList{}) return err @@ -128,11 +123,10 @@ func (c *FakeOvnSnatRules) DeleteCollection(ctx context.Context, opts metav1.Del // Patch applies the patch and returns the patched ovnSnatRule. func (c *FakeOvnSnatRules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.OvnSnatRule, err error) { - emptyResult := &v1.OvnSnatRule{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(ovnsnatrulesResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(ovnsnatrulesResource, name, pt, data, subresources...), &v1.OvnSnatRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.OvnSnatRule), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_providernetwork.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_providernetwork.go index d7c9a1a4af0..f5b333341a1 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_providernetwork.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_providernetwork.go @@ -40,22 +40,20 @@ var providernetworksKind = v1.SchemeGroupVersion.WithKind("ProviderNetwork") // Get takes name of the providerNetwork, and returns the corresponding providerNetwork object, and an error if there is any. func (c *FakeProviderNetworks) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.ProviderNetwork, err error) { - emptyResult := &v1.ProviderNetwork{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(providernetworksResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(providernetworksResource, name), &v1.ProviderNetwork{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.ProviderNetwork), err } // List takes label and field selectors, and returns the list of ProviderNetworks that match those selectors. func (c *FakeProviderNetworks) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ProviderNetworkList, err error) { - emptyResult := &v1.ProviderNetworkList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(providernetworksResource, providernetworksKind, opts), emptyResult) + Invokes(testing.NewRootListAction(providernetworksResource, providernetworksKind, opts), &v1.ProviderNetworkList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeProviderNetworks) List(ctx context.Context, opts metav1.ListOptions // Watch returns a watch.Interface that watches the requested providerNetworks. func (c *FakeProviderNetworks) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(providernetworksResource, opts)) + InvokesWatch(testing.NewRootWatchAction(providernetworksResource, opts)) } // Create takes the representation of a providerNetwork and creates it. Returns the server's representation of the providerNetwork, and an error, if there is any. func (c *FakeProviderNetworks) Create(ctx context.Context, providerNetwork *v1.ProviderNetwork, opts metav1.CreateOptions) (result *v1.ProviderNetwork, err error) { - emptyResult := &v1.ProviderNetwork{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(providernetworksResource, providerNetwork, opts), emptyResult) + Invokes(testing.NewRootCreateAction(providernetworksResource, providerNetwork), &v1.ProviderNetwork{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.ProviderNetwork), err } // Update takes the representation of a providerNetwork and updates it. Returns the server's representation of the providerNetwork, and an error, if there is any. func (c *FakeProviderNetworks) Update(ctx context.Context, providerNetwork *v1.ProviderNetwork, opts metav1.UpdateOptions) (result *v1.ProviderNetwork, err error) { - emptyResult := &v1.ProviderNetwork{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(providernetworksResource, providerNetwork, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(providernetworksResource, providerNetwork), &v1.ProviderNetwork{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.ProviderNetwork), 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 *FakeProviderNetworks) UpdateStatus(ctx context.Context, providerNetwork *v1.ProviderNetwork, opts metav1.UpdateOptions) (result *v1.ProviderNetwork, err error) { - emptyResult := &v1.ProviderNetwork{} +func (c *FakeProviderNetworks) UpdateStatus(ctx context.Context, providerNetwork *v1.ProviderNetwork, opts metav1.UpdateOptions) (*v1.ProviderNetwork, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(providernetworksResource, "status", providerNetwork, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(providernetworksResource, "status", providerNetwork), &v1.ProviderNetwork{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.ProviderNetwork), err } @@ -120,7 +115,7 @@ func (c *FakeProviderNetworks) Delete(ctx context.Context, name string, opts met // DeleteCollection deletes a collection of objects. func (c *FakeProviderNetworks) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(providernetworksResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(providernetworksResource, listOpts) _, err := c.Fake.Invokes(action, &v1.ProviderNetworkList{}) return err @@ -128,11 +123,10 @@ func (c *FakeProviderNetworks) DeleteCollection(ctx context.Context, opts metav1 // Patch applies the patch and returns the patched providerNetwork. func (c *FakeProviderNetworks) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ProviderNetwork, err error) { - emptyResult := &v1.ProviderNetwork{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(providernetworksResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(providernetworksResource, name, pt, data, subresources...), &v1.ProviderNetwork{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.ProviderNetwork), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_qospolicy.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_qospolicy.go index 96b8ed1b023..03bb8ebfe3d 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_qospolicy.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_qospolicy.go @@ -40,22 +40,20 @@ var qospoliciesKind = v1.SchemeGroupVersion.WithKind("QoSPolicy") // Get takes name of the qoSPolicy, and returns the corresponding qoSPolicy object, and an error if there is any. func (c *FakeQoSPolicies) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.QoSPolicy, err error) { - emptyResult := &v1.QoSPolicy{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(qospoliciesResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(qospoliciesResource, name), &v1.QoSPolicy{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.QoSPolicy), err } // List takes label and field selectors, and returns the list of QoSPolicies that match those selectors. func (c *FakeQoSPolicies) List(ctx context.Context, opts metav1.ListOptions) (result *v1.QoSPolicyList, err error) { - emptyResult := &v1.QoSPolicyList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(qospoliciesResource, qospoliciesKind, opts), emptyResult) + Invokes(testing.NewRootListAction(qospoliciesResource, qospoliciesKind, opts), &v1.QoSPolicyList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeQoSPolicies) List(ctx context.Context, opts metav1.ListOptions) (re // Watch returns a watch.Interface that watches the requested qoSPolicies. func (c *FakeQoSPolicies) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(qospoliciesResource, opts)) + InvokesWatch(testing.NewRootWatchAction(qospoliciesResource, opts)) } // Create takes the representation of a qoSPolicy and creates it. Returns the server's representation of the qoSPolicy, and an error, if there is any. func (c *FakeQoSPolicies) Create(ctx context.Context, qoSPolicy *v1.QoSPolicy, opts metav1.CreateOptions) (result *v1.QoSPolicy, err error) { - emptyResult := &v1.QoSPolicy{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(qospoliciesResource, qoSPolicy, opts), emptyResult) + Invokes(testing.NewRootCreateAction(qospoliciesResource, qoSPolicy), &v1.QoSPolicy{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.QoSPolicy), err } // Update takes the representation of a qoSPolicy and updates it. Returns the server's representation of the qoSPolicy, and an error, if there is any. func (c *FakeQoSPolicies) Update(ctx context.Context, qoSPolicy *v1.QoSPolicy, opts metav1.UpdateOptions) (result *v1.QoSPolicy, err error) { - emptyResult := &v1.QoSPolicy{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(qospoliciesResource, qoSPolicy, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(qospoliciesResource, qoSPolicy), &v1.QoSPolicy{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.QoSPolicy), 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 *FakeQoSPolicies) UpdateStatus(ctx context.Context, qoSPolicy *v1.QoSPolicy, opts metav1.UpdateOptions) (result *v1.QoSPolicy, err error) { - emptyResult := &v1.QoSPolicy{} +func (c *FakeQoSPolicies) UpdateStatus(ctx context.Context, qoSPolicy *v1.QoSPolicy, opts metav1.UpdateOptions) (*v1.QoSPolicy, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(qospoliciesResource, "status", qoSPolicy, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(qospoliciesResource, "status", qoSPolicy), &v1.QoSPolicy{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.QoSPolicy), err } @@ -120,7 +115,7 @@ func (c *FakeQoSPolicies) Delete(ctx context.Context, name string, opts metav1.D // DeleteCollection deletes a collection of objects. func (c *FakeQoSPolicies) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(qospoliciesResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(qospoliciesResource, listOpts) _, err := c.Fake.Invokes(action, &v1.QoSPolicyList{}) return err @@ -128,11 +123,10 @@ func (c *FakeQoSPolicies) DeleteCollection(ctx context.Context, opts metav1.Dele // Patch applies the patch and returns the patched qoSPolicy. func (c *FakeQoSPolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.QoSPolicy, err error) { - emptyResult := &v1.QoSPolicy{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(qospoliciesResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(qospoliciesResource, name, pt, data, subresources...), &v1.QoSPolicy{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.QoSPolicy), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_securitygroup.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_securitygroup.go index bc2807dbc6c..84829bf7f17 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_securitygroup.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_securitygroup.go @@ -40,22 +40,20 @@ var securitygroupsKind = v1.SchemeGroupVersion.WithKind("SecurityGroup") // Get takes name of the securityGroup, and returns the corresponding securityGroup object, and an error if there is any. func (c *FakeSecurityGroups) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.SecurityGroup, err error) { - emptyResult := &v1.SecurityGroup{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(securitygroupsResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(securitygroupsResource, name), &v1.SecurityGroup{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.SecurityGroup), err } // List takes label and field selectors, and returns the list of SecurityGroups that match those selectors. func (c *FakeSecurityGroups) List(ctx context.Context, opts metav1.ListOptions) (result *v1.SecurityGroupList, err error) { - emptyResult := &v1.SecurityGroupList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(securitygroupsResource, securitygroupsKind, opts), emptyResult) + Invokes(testing.NewRootListAction(securitygroupsResource, securitygroupsKind, opts), &v1.SecurityGroupList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeSecurityGroups) List(ctx context.Context, opts metav1.ListOptions) // Watch returns a watch.Interface that watches the requested securityGroups. func (c *FakeSecurityGroups) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(securitygroupsResource, opts)) + InvokesWatch(testing.NewRootWatchAction(securitygroupsResource, opts)) } // Create takes the representation of a securityGroup and creates it. Returns the server's representation of the securityGroup, and an error, if there is any. func (c *FakeSecurityGroups) Create(ctx context.Context, securityGroup *v1.SecurityGroup, opts metav1.CreateOptions) (result *v1.SecurityGroup, err error) { - emptyResult := &v1.SecurityGroup{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(securitygroupsResource, securityGroup, opts), emptyResult) + Invokes(testing.NewRootCreateAction(securitygroupsResource, securityGroup), &v1.SecurityGroup{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.SecurityGroup), err } // Update takes the representation of a securityGroup and updates it. Returns the server's representation of the securityGroup, and an error, if there is any. func (c *FakeSecurityGroups) Update(ctx context.Context, securityGroup *v1.SecurityGroup, opts metav1.UpdateOptions) (result *v1.SecurityGroup, err error) { - emptyResult := &v1.SecurityGroup{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(securitygroupsResource, securityGroup, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(securitygroupsResource, securityGroup), &v1.SecurityGroup{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.SecurityGroup), 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 *FakeSecurityGroups) UpdateStatus(ctx context.Context, securityGroup *v1.SecurityGroup, opts metav1.UpdateOptions) (result *v1.SecurityGroup, err error) { - emptyResult := &v1.SecurityGroup{} +func (c *FakeSecurityGroups) UpdateStatus(ctx context.Context, securityGroup *v1.SecurityGroup, opts metav1.UpdateOptions) (*v1.SecurityGroup, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(securitygroupsResource, "status", securityGroup, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(securitygroupsResource, "status", securityGroup), &v1.SecurityGroup{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.SecurityGroup), err } @@ -120,7 +115,7 @@ func (c *FakeSecurityGroups) Delete(ctx context.Context, name string, opts metav // DeleteCollection deletes a collection of objects. func (c *FakeSecurityGroups) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(securitygroupsResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(securitygroupsResource, listOpts) _, err := c.Fake.Invokes(action, &v1.SecurityGroupList{}) return err @@ -128,11 +123,10 @@ func (c *FakeSecurityGroups) DeleteCollection(ctx context.Context, opts metav1.D // Patch applies the patch and returns the patched securityGroup. func (c *FakeSecurityGroups) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.SecurityGroup, err error) { - emptyResult := &v1.SecurityGroup{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(securitygroupsResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(securitygroupsResource, name, pt, data, subresources...), &v1.SecurityGroup{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.SecurityGroup), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_subnet.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_subnet.go index 7c98aff3336..49eca2f6c45 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_subnet.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_subnet.go @@ -40,22 +40,20 @@ var subnetsKind = v1.SchemeGroupVersion.WithKind("Subnet") // Get takes name of the subnet, and returns the corresponding subnet object, and an error if there is any. func (c *FakeSubnets) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.Subnet, err error) { - emptyResult := &v1.Subnet{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(subnetsResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(subnetsResource, name), &v1.Subnet{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Subnet), err } // List takes label and field selectors, and returns the list of Subnets that match those selectors. func (c *FakeSubnets) List(ctx context.Context, opts metav1.ListOptions) (result *v1.SubnetList, err error) { - emptyResult := &v1.SubnetList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(subnetsResource, subnetsKind, opts), emptyResult) + Invokes(testing.NewRootListAction(subnetsResource, subnetsKind, opts), &v1.SubnetList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeSubnets) List(ctx context.Context, opts metav1.ListOptions) (result // Watch returns a watch.Interface that watches the requested subnets. func (c *FakeSubnets) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(subnetsResource, opts)) + InvokesWatch(testing.NewRootWatchAction(subnetsResource, opts)) } // Create takes the representation of a subnet and creates it. Returns the server's representation of the subnet, and an error, if there is any. func (c *FakeSubnets) Create(ctx context.Context, subnet *v1.Subnet, opts metav1.CreateOptions) (result *v1.Subnet, err error) { - emptyResult := &v1.Subnet{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(subnetsResource, subnet, opts), emptyResult) + Invokes(testing.NewRootCreateAction(subnetsResource, subnet), &v1.Subnet{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Subnet), err } // Update takes the representation of a subnet and updates it. Returns the server's representation of the subnet, and an error, if there is any. func (c *FakeSubnets) Update(ctx context.Context, subnet *v1.Subnet, opts metav1.UpdateOptions) (result *v1.Subnet, err error) { - emptyResult := &v1.Subnet{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(subnetsResource, subnet, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(subnetsResource, subnet), &v1.Subnet{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Subnet), 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 *FakeSubnets) UpdateStatus(ctx context.Context, subnet *v1.Subnet, opts metav1.UpdateOptions) (result *v1.Subnet, err error) { - emptyResult := &v1.Subnet{} +func (c *FakeSubnets) UpdateStatus(ctx context.Context, subnet *v1.Subnet, opts metav1.UpdateOptions) (*v1.Subnet, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(subnetsResource, "status", subnet, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(subnetsResource, "status", subnet), &v1.Subnet{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Subnet), err } @@ -120,7 +115,7 @@ func (c *FakeSubnets) Delete(ctx context.Context, name string, opts metav1.Delet // DeleteCollection deletes a collection of objects. func (c *FakeSubnets) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(subnetsResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(subnetsResource, listOpts) _, err := c.Fake.Invokes(action, &v1.SubnetList{}) return err @@ -128,11 +123,10 @@ func (c *FakeSubnets) DeleteCollection(ctx context.Context, opts metav1.DeleteOp // Patch applies the patch and returns the patched subnet. func (c *FakeSubnets) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Subnet, err error) { - emptyResult := &v1.Subnet{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(subnetsResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(subnetsResource, name, pt, data, subresources...), &v1.Subnet{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Subnet), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_switchlbrule.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_switchlbrule.go index b11f4342c11..ecddb77a309 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_switchlbrule.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_switchlbrule.go @@ -40,22 +40,20 @@ var switchlbrulesKind = v1.SchemeGroupVersion.WithKind("SwitchLBRule") // Get takes name of the switchLBRule, and returns the corresponding switchLBRule object, and an error if there is any. func (c *FakeSwitchLBRules) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.SwitchLBRule, err error) { - emptyResult := &v1.SwitchLBRule{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(switchlbrulesResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(switchlbrulesResource, name), &v1.SwitchLBRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.SwitchLBRule), err } // List takes label and field selectors, and returns the list of SwitchLBRules that match those selectors. func (c *FakeSwitchLBRules) List(ctx context.Context, opts metav1.ListOptions) (result *v1.SwitchLBRuleList, err error) { - emptyResult := &v1.SwitchLBRuleList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(switchlbrulesResource, switchlbrulesKind, opts), emptyResult) + Invokes(testing.NewRootListAction(switchlbrulesResource, switchlbrulesKind, opts), &v1.SwitchLBRuleList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeSwitchLBRules) List(ctx context.Context, opts metav1.ListOptions) ( // Watch returns a watch.Interface that watches the requested switchLBRules. func (c *FakeSwitchLBRules) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(switchlbrulesResource, opts)) + InvokesWatch(testing.NewRootWatchAction(switchlbrulesResource, opts)) } // Create takes the representation of a switchLBRule and creates it. Returns the server's representation of the switchLBRule, and an error, if there is any. func (c *FakeSwitchLBRules) Create(ctx context.Context, switchLBRule *v1.SwitchLBRule, opts metav1.CreateOptions) (result *v1.SwitchLBRule, err error) { - emptyResult := &v1.SwitchLBRule{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(switchlbrulesResource, switchLBRule, opts), emptyResult) + Invokes(testing.NewRootCreateAction(switchlbrulesResource, switchLBRule), &v1.SwitchLBRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.SwitchLBRule), err } // Update takes the representation of a switchLBRule and updates it. Returns the server's representation of the switchLBRule, and an error, if there is any. func (c *FakeSwitchLBRules) Update(ctx context.Context, switchLBRule *v1.SwitchLBRule, opts metav1.UpdateOptions) (result *v1.SwitchLBRule, err error) { - emptyResult := &v1.SwitchLBRule{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(switchlbrulesResource, switchLBRule, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(switchlbrulesResource, switchLBRule), &v1.SwitchLBRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.SwitchLBRule), 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 *FakeSwitchLBRules) UpdateStatus(ctx context.Context, switchLBRule *v1.SwitchLBRule, opts metav1.UpdateOptions) (result *v1.SwitchLBRule, err error) { - emptyResult := &v1.SwitchLBRule{} +func (c *FakeSwitchLBRules) UpdateStatus(ctx context.Context, switchLBRule *v1.SwitchLBRule, opts metav1.UpdateOptions) (*v1.SwitchLBRule, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(switchlbrulesResource, "status", switchLBRule, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(switchlbrulesResource, "status", switchLBRule), &v1.SwitchLBRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.SwitchLBRule), err } @@ -120,7 +115,7 @@ func (c *FakeSwitchLBRules) Delete(ctx context.Context, name string, opts metav1 // DeleteCollection deletes a collection of objects. func (c *FakeSwitchLBRules) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(switchlbrulesResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(switchlbrulesResource, listOpts) _, err := c.Fake.Invokes(action, &v1.SwitchLBRuleList{}) return err @@ -128,11 +123,10 @@ func (c *FakeSwitchLBRules) DeleteCollection(ctx context.Context, opts metav1.De // Patch applies the patch and returns the patched switchLBRule. func (c *FakeSwitchLBRules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.SwitchLBRule, err error) { - emptyResult := &v1.SwitchLBRule{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(switchlbrulesResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(switchlbrulesResource, name, pt, data, subresources...), &v1.SwitchLBRule{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.SwitchLBRule), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vip.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vip.go index 87fbfa0e40c..ee844634485 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vip.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vip.go @@ -40,22 +40,20 @@ var vipsKind = v1.SchemeGroupVersion.WithKind("Vip") // Get takes name of the vip, and returns the corresponding vip object, and an error if there is any. func (c *FakeVips) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.Vip, err error) { - emptyResult := &v1.Vip{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(vipsResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(vipsResource, name), &v1.Vip{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Vip), err } // List takes label and field selectors, and returns the list of Vips that match those selectors. func (c *FakeVips) List(ctx context.Context, opts metav1.ListOptions) (result *v1.VipList, err error) { - emptyResult := &v1.VipList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(vipsResource, vipsKind, opts), emptyResult) + Invokes(testing.NewRootListAction(vipsResource, vipsKind, opts), &v1.VipList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeVips) List(ctx context.Context, opts metav1.ListOptions) (result *v // Watch returns a watch.Interface that watches the requested vips. func (c *FakeVips) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(vipsResource, opts)) + InvokesWatch(testing.NewRootWatchAction(vipsResource, opts)) } // Create takes the representation of a vip and creates it. Returns the server's representation of the vip, and an error, if there is any. func (c *FakeVips) Create(ctx context.Context, vip *v1.Vip, opts metav1.CreateOptions) (result *v1.Vip, err error) { - emptyResult := &v1.Vip{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(vipsResource, vip, opts), emptyResult) + Invokes(testing.NewRootCreateAction(vipsResource, vip), &v1.Vip{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Vip), err } // Update takes the representation of a vip and updates it. Returns the server's representation of the vip, and an error, if there is any. func (c *FakeVips) Update(ctx context.Context, vip *v1.Vip, opts metav1.UpdateOptions) (result *v1.Vip, err error) { - emptyResult := &v1.Vip{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(vipsResource, vip, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(vipsResource, vip), &v1.Vip{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Vip), 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 *FakeVips) UpdateStatus(ctx context.Context, vip *v1.Vip, opts metav1.UpdateOptions) (result *v1.Vip, err error) { - emptyResult := &v1.Vip{} +func (c *FakeVips) UpdateStatus(ctx context.Context, vip *v1.Vip, opts metav1.UpdateOptions) (*v1.Vip, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(vipsResource, "status", vip, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(vipsResource, "status", vip), &v1.Vip{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Vip), err } @@ -120,7 +115,7 @@ func (c *FakeVips) Delete(ctx context.Context, name string, opts metav1.DeleteOp // DeleteCollection deletes a collection of objects. func (c *FakeVips) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(vipsResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(vipsResource, listOpts) _, err := c.Fake.Invokes(action, &v1.VipList{}) return err @@ -128,11 +123,10 @@ func (c *FakeVips) DeleteCollection(ctx context.Context, opts metav1.DeleteOptio // Patch applies the patch and returns the patched vip. func (c *FakeVips) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Vip, err error) { - emptyResult := &v1.Vip{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(vipsResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(vipsResource, name, pt, data, subresources...), &v1.Vip{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Vip), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vlan.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vlan.go index efb1e37decc..07434f67162 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vlan.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vlan.go @@ -40,22 +40,20 @@ var vlansKind = v1.SchemeGroupVersion.WithKind("Vlan") // Get takes name of the vlan, and returns the corresponding vlan object, and an error if there is any. func (c *FakeVlans) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.Vlan, err error) { - emptyResult := &v1.Vlan{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(vlansResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(vlansResource, name), &v1.Vlan{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Vlan), err } // List takes label and field selectors, and returns the list of Vlans that match those selectors. func (c *FakeVlans) List(ctx context.Context, opts metav1.ListOptions) (result *v1.VlanList, err error) { - emptyResult := &v1.VlanList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(vlansResource, vlansKind, opts), emptyResult) + Invokes(testing.NewRootListAction(vlansResource, vlansKind, opts), &v1.VlanList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeVlans) List(ctx context.Context, opts metav1.ListOptions) (result * // Watch returns a watch.Interface that watches the requested vlans. func (c *FakeVlans) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(vlansResource, opts)) + InvokesWatch(testing.NewRootWatchAction(vlansResource, opts)) } // Create takes the representation of a vlan and creates it. Returns the server's representation of the vlan, and an error, if there is any. func (c *FakeVlans) Create(ctx context.Context, vlan *v1.Vlan, opts metav1.CreateOptions) (result *v1.Vlan, err error) { - emptyResult := &v1.Vlan{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(vlansResource, vlan, opts), emptyResult) + Invokes(testing.NewRootCreateAction(vlansResource, vlan), &v1.Vlan{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Vlan), err } // Update takes the representation of a vlan and updates it. Returns the server's representation of the vlan, and an error, if there is any. func (c *FakeVlans) Update(ctx context.Context, vlan *v1.Vlan, opts metav1.UpdateOptions) (result *v1.Vlan, err error) { - emptyResult := &v1.Vlan{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(vlansResource, vlan, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(vlansResource, vlan), &v1.Vlan{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Vlan), 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 *FakeVlans) UpdateStatus(ctx context.Context, vlan *v1.Vlan, opts metav1.UpdateOptions) (result *v1.Vlan, err error) { - emptyResult := &v1.Vlan{} +func (c *FakeVlans) UpdateStatus(ctx context.Context, vlan *v1.Vlan, opts metav1.UpdateOptions) (*v1.Vlan, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(vlansResource, "status", vlan, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(vlansResource, "status", vlan), &v1.Vlan{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Vlan), err } @@ -120,7 +115,7 @@ func (c *FakeVlans) Delete(ctx context.Context, name string, opts metav1.DeleteO // DeleteCollection deletes a collection of objects. func (c *FakeVlans) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(vlansResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(vlansResource, listOpts) _, err := c.Fake.Invokes(action, &v1.VlanList{}) return err @@ -128,11 +123,10 @@ func (c *FakeVlans) DeleteCollection(ctx context.Context, opts metav1.DeleteOpti // Patch applies the patch and returns the patched vlan. func (c *FakeVlans) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Vlan, err error) { - emptyResult := &v1.Vlan{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(vlansResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(vlansResource, name, pt, data, subresources...), &v1.Vlan{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Vlan), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vpc.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vpc.go index 2b2ca6f17c3..a4eeb8ea36e 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vpc.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vpc.go @@ -40,22 +40,20 @@ var vpcsKind = v1.SchemeGroupVersion.WithKind("Vpc") // Get takes name of the vpc, and returns the corresponding vpc object, and an error if there is any. func (c *FakeVpcs) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.Vpc, err error) { - emptyResult := &v1.Vpc{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(vpcsResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(vpcsResource, name), &v1.Vpc{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Vpc), err } // List takes label and field selectors, and returns the list of Vpcs that match those selectors. func (c *FakeVpcs) List(ctx context.Context, opts metav1.ListOptions) (result *v1.VpcList, err error) { - emptyResult := &v1.VpcList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(vpcsResource, vpcsKind, opts), emptyResult) + Invokes(testing.NewRootListAction(vpcsResource, vpcsKind, opts), &v1.VpcList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeVpcs) List(ctx context.Context, opts metav1.ListOptions) (result *v // Watch returns a watch.Interface that watches the requested vpcs. func (c *FakeVpcs) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(vpcsResource, opts)) + InvokesWatch(testing.NewRootWatchAction(vpcsResource, opts)) } // Create takes the representation of a vpc and creates it. Returns the server's representation of the vpc, and an error, if there is any. func (c *FakeVpcs) Create(ctx context.Context, vpc *v1.Vpc, opts metav1.CreateOptions) (result *v1.Vpc, err error) { - emptyResult := &v1.Vpc{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(vpcsResource, vpc, opts), emptyResult) + Invokes(testing.NewRootCreateAction(vpcsResource, vpc), &v1.Vpc{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Vpc), err } // Update takes the representation of a vpc and updates it. Returns the server's representation of the vpc, and an error, if there is any. func (c *FakeVpcs) Update(ctx context.Context, vpc *v1.Vpc, opts metav1.UpdateOptions) (result *v1.Vpc, err error) { - emptyResult := &v1.Vpc{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(vpcsResource, vpc, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(vpcsResource, vpc), &v1.Vpc{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Vpc), 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 *FakeVpcs) UpdateStatus(ctx context.Context, vpc *v1.Vpc, opts metav1.UpdateOptions) (result *v1.Vpc, err error) { - emptyResult := &v1.Vpc{} +func (c *FakeVpcs) UpdateStatus(ctx context.Context, vpc *v1.Vpc, opts metav1.UpdateOptions) (*v1.Vpc, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(vpcsResource, "status", vpc, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(vpcsResource, "status", vpc), &v1.Vpc{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Vpc), err } @@ -120,7 +115,7 @@ func (c *FakeVpcs) Delete(ctx context.Context, name string, opts metav1.DeleteOp // DeleteCollection deletes a collection of objects. func (c *FakeVpcs) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(vpcsResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(vpcsResource, listOpts) _, err := c.Fake.Invokes(action, &v1.VpcList{}) return err @@ -128,11 +123,10 @@ func (c *FakeVpcs) DeleteCollection(ctx context.Context, opts metav1.DeleteOptio // Patch applies the patch and returns the patched vpc. func (c *FakeVpcs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Vpc, err error) { - emptyResult := &v1.Vpc{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(vpcsResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(vpcsResource, name, pt, data, subresources...), &v1.Vpc{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.Vpc), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vpcdns.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vpcdns.go index a615f2a0b29..21a7155d542 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vpcdns.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vpcdns.go @@ -40,22 +40,20 @@ var vpcdnsesKind = v1.SchemeGroupVersion.WithKind("VpcDns") // Get takes name of the vpcDns, and returns the corresponding vpcDns object, and an error if there is any. func (c *FakeVpcDnses) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.VpcDns, err error) { - emptyResult := &v1.VpcDns{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(vpcdnsesResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(vpcdnsesResource, name), &v1.VpcDns{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.VpcDns), err } // List takes label and field selectors, and returns the list of VpcDnses that match those selectors. func (c *FakeVpcDnses) List(ctx context.Context, opts metav1.ListOptions) (result *v1.VpcDnsList, err error) { - emptyResult := &v1.VpcDnsList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(vpcdnsesResource, vpcdnsesKind, opts), emptyResult) + Invokes(testing.NewRootListAction(vpcdnsesResource, vpcdnsesKind, opts), &v1.VpcDnsList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeVpcDnses) List(ctx context.Context, opts metav1.ListOptions) (resul // Watch returns a watch.Interface that watches the requested vpcDnses. func (c *FakeVpcDnses) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(vpcdnsesResource, opts)) + InvokesWatch(testing.NewRootWatchAction(vpcdnsesResource, opts)) } // Create takes the representation of a vpcDns and creates it. Returns the server's representation of the vpcDns, and an error, if there is any. func (c *FakeVpcDnses) Create(ctx context.Context, vpcDns *v1.VpcDns, opts metav1.CreateOptions) (result *v1.VpcDns, err error) { - emptyResult := &v1.VpcDns{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(vpcdnsesResource, vpcDns, opts), emptyResult) + Invokes(testing.NewRootCreateAction(vpcdnsesResource, vpcDns), &v1.VpcDns{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.VpcDns), err } // Update takes the representation of a vpcDns and updates it. Returns the server's representation of the vpcDns, and an error, if there is any. func (c *FakeVpcDnses) Update(ctx context.Context, vpcDns *v1.VpcDns, opts metav1.UpdateOptions) (result *v1.VpcDns, err error) { - emptyResult := &v1.VpcDns{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(vpcdnsesResource, vpcDns, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(vpcdnsesResource, vpcDns), &v1.VpcDns{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.VpcDns), 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 *FakeVpcDnses) UpdateStatus(ctx context.Context, vpcDns *v1.VpcDns, opts metav1.UpdateOptions) (result *v1.VpcDns, err error) { - emptyResult := &v1.VpcDns{} +func (c *FakeVpcDnses) UpdateStatus(ctx context.Context, vpcDns *v1.VpcDns, opts metav1.UpdateOptions) (*v1.VpcDns, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(vpcdnsesResource, "status", vpcDns, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(vpcdnsesResource, "status", vpcDns), &v1.VpcDns{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.VpcDns), err } @@ -120,7 +115,7 @@ func (c *FakeVpcDnses) Delete(ctx context.Context, name string, opts metav1.Dele // DeleteCollection deletes a collection of objects. func (c *FakeVpcDnses) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(vpcdnsesResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(vpcdnsesResource, listOpts) _, err := c.Fake.Invokes(action, &v1.VpcDnsList{}) return err @@ -128,11 +123,10 @@ func (c *FakeVpcDnses) DeleteCollection(ctx context.Context, opts metav1.DeleteO // Patch applies the patch and returns the patched vpcDns. func (c *FakeVpcDnses) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.VpcDns, err error) { - emptyResult := &v1.VpcDns{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(vpcdnsesResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(vpcdnsesResource, name, pt, data, subresources...), &v1.VpcDns{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.VpcDns), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vpcnatgateway.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vpcnatgateway.go index 6ef40bc4774..f1d6955c137 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vpcnatgateway.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/fake/fake_vpcnatgateway.go @@ -40,22 +40,20 @@ var vpcnatgatewaysKind = v1.SchemeGroupVersion.WithKind("VpcNatGateway") // Get takes name of the vpcNatGateway, and returns the corresponding vpcNatGateway object, and an error if there is any. func (c *FakeVpcNatGateways) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.VpcNatGateway, err error) { - emptyResult := &v1.VpcNatGateway{} obj, err := c.Fake. - Invokes(testing.NewRootGetActionWithOptions(vpcnatgatewaysResource, name, options), emptyResult) + Invokes(testing.NewRootGetAction(vpcnatgatewaysResource, name), &v1.VpcNatGateway{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.VpcNatGateway), err } // List takes label and field selectors, and returns the list of VpcNatGateways that match those selectors. func (c *FakeVpcNatGateways) List(ctx context.Context, opts metav1.ListOptions) (result *v1.VpcNatGatewayList, err error) { - emptyResult := &v1.VpcNatGatewayList{} obj, err := c.Fake. - Invokes(testing.NewRootListActionWithOptions(vpcnatgatewaysResource, vpcnatgatewaysKind, opts), emptyResult) + Invokes(testing.NewRootListAction(vpcnatgatewaysResource, vpcnatgatewaysKind, opts), &v1.VpcNatGatewayList{}) if obj == nil { - return emptyResult, err + return nil, err } label, _, _ := testing.ExtractFromListOptions(opts) @@ -74,39 +72,36 @@ func (c *FakeVpcNatGateways) List(ctx context.Context, opts metav1.ListOptions) // Watch returns a watch.Interface that watches the requested vpcNatGateways. func (c *FakeVpcNatGateways) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { return c.Fake. - InvokesWatch(testing.NewRootWatchActionWithOptions(vpcnatgatewaysResource, opts)) + InvokesWatch(testing.NewRootWatchAction(vpcnatgatewaysResource, opts)) } // Create takes the representation of a vpcNatGateway and creates it. Returns the server's representation of the vpcNatGateway, and an error, if there is any. func (c *FakeVpcNatGateways) Create(ctx context.Context, vpcNatGateway *v1.VpcNatGateway, opts metav1.CreateOptions) (result *v1.VpcNatGateway, err error) { - emptyResult := &v1.VpcNatGateway{} obj, err := c.Fake. - Invokes(testing.NewRootCreateActionWithOptions(vpcnatgatewaysResource, vpcNatGateway, opts), emptyResult) + Invokes(testing.NewRootCreateAction(vpcnatgatewaysResource, vpcNatGateway), &v1.VpcNatGateway{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.VpcNatGateway), err } // Update takes the representation of a vpcNatGateway and updates it. Returns the server's representation of the vpcNatGateway, and an error, if there is any. func (c *FakeVpcNatGateways) Update(ctx context.Context, vpcNatGateway *v1.VpcNatGateway, opts metav1.UpdateOptions) (result *v1.VpcNatGateway, err error) { - emptyResult := &v1.VpcNatGateway{} obj, err := c.Fake. - Invokes(testing.NewRootUpdateActionWithOptions(vpcnatgatewaysResource, vpcNatGateway, opts), emptyResult) + Invokes(testing.NewRootUpdateAction(vpcnatgatewaysResource, vpcNatGateway), &v1.VpcNatGateway{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.VpcNatGateway), 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 *FakeVpcNatGateways) UpdateStatus(ctx context.Context, vpcNatGateway *v1.VpcNatGateway, opts metav1.UpdateOptions) (result *v1.VpcNatGateway, err error) { - emptyResult := &v1.VpcNatGateway{} +func (c *FakeVpcNatGateways) UpdateStatus(ctx context.Context, vpcNatGateway *v1.VpcNatGateway, opts metav1.UpdateOptions) (*v1.VpcNatGateway, error) { obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceActionWithOptions(vpcnatgatewaysResource, "status", vpcNatGateway, opts), emptyResult) + Invokes(testing.NewRootUpdateSubresourceAction(vpcnatgatewaysResource, "status", vpcNatGateway), &v1.VpcNatGateway{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.VpcNatGateway), err } @@ -120,7 +115,7 @@ func (c *FakeVpcNatGateways) Delete(ctx context.Context, name string, opts metav // DeleteCollection deletes a collection of objects. func (c *FakeVpcNatGateways) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - action := testing.NewRootDeleteCollectionActionWithOptions(vpcnatgatewaysResource, opts, listOpts) + action := testing.NewRootDeleteCollectionAction(vpcnatgatewaysResource, listOpts) _, err := c.Fake.Invokes(action, &v1.VpcNatGatewayList{}) return err @@ -128,11 +123,10 @@ func (c *FakeVpcNatGateways) DeleteCollection(ctx context.Context, opts metav1.D // Patch applies the patch and returns the patched vpcNatGateway. func (c *FakeVpcNatGateways) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.VpcNatGateway, err error) { - emptyResult := &v1.VpcNatGateway{} obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceActionWithOptions(vpcnatgatewaysResource, name, pt, data, opts, subresources...), emptyResult) + Invokes(testing.NewRootPatchSubresourceAction(vpcnatgatewaysResource, name, pt, data, subresources...), &v1.VpcNatGateway{}) if obj == nil { - return emptyResult, err + return nil, err } return obj.(*v1.VpcNatGateway), err } diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/ip.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/ip.go index 62a0c930b1c..53015e82f54 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/ip.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/ip.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // IPsGetter has a method to return a IPInterface. @@ -50,18 +51,118 @@ type IPInterface interface { // iPs implements IPInterface type iPs struct { - *gentype.ClientWithList[*v1.IP, *v1.IPList] + client rest.Interface } // newIPs returns a IPs func newIPs(c *KubeovnV1Client) *iPs { return &iPs{ - gentype.NewClientWithList[*v1.IP, *v1.IPList]( - "ips", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.IP { return &v1.IP{} }, - func() *v1.IPList { return &v1.IPList{} }), + client: c.RESTClient(), } } + +// Get takes name of the iP, and returns the corresponding iP object, and an error if there is any. +func (c *iPs) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.IP, err error) { + result = &v1.IP{} + err = c.client.Get(). + Resource("ips"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of IPs that match those selectors. +func (c *iPs) List(ctx context.Context, opts metav1.ListOptions) (result *v1.IPList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.IPList{} + err = c.client.Get(). + Resource("ips"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested iPs. +func (c *iPs) 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(). + Resource("ips"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a iP and creates it. Returns the server's representation of the iP, and an error, if there is any. +func (c *iPs) Create(ctx context.Context, iP *v1.IP, opts metav1.CreateOptions) (result *v1.IP, err error) { + result = &v1.IP{} + err = c.client.Post(). + Resource("ips"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iP). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a iP and updates it. Returns the server's representation of the iP, and an error, if there is any. +func (c *iPs) Update(ctx context.Context, iP *v1.IP, opts metav1.UpdateOptions) (result *v1.IP, err error) { + result = &v1.IP{} + err = c.client.Put(). + Resource("ips"). + Name(iP.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iP). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the iP and deletes it. Returns an error if one occurs. +func (c *iPs) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("ips"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *iPs) 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(). + Resource("ips"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched iP. +func (c *iPs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.IP, err error) { + result = &v1.IP{} + err = c.client.Patch(pt). + Resource("ips"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/ippool.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/ippool.go index c307de9ba95..bd6c7bff6bf 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/ippool.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/ippool.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // IPPoolsGetter has a method to return a IPPoolInterface. @@ -39,7 +40,6 @@ type IPPoolsGetter interface { type IPPoolInterface interface { Create(ctx context.Context, iPPool *v1.IPPool, opts metav1.CreateOptions) (*v1.IPPool, error) Update(ctx context.Context, iPPool *v1.IPPool, opts metav1.UpdateOptions) (*v1.IPPool, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, iPPool *v1.IPPool, opts metav1.UpdateOptions) (*v1.IPPool, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type IPPoolInterface interface { // iPPools implements IPPoolInterface type iPPools struct { - *gentype.ClientWithList[*v1.IPPool, *v1.IPPoolList] + client rest.Interface } // newIPPools returns a IPPools func newIPPools(c *KubeovnV1Client) *iPPools { return &iPPools{ - gentype.NewClientWithList[*v1.IPPool, *v1.IPPoolList]( - "ippools", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.IPPool { return &v1.IPPool{} }, - func() *v1.IPPoolList { return &v1.IPPoolList{} }), + client: c.RESTClient(), } } + +// Get takes name of the iPPool, and returns the corresponding iPPool object, and an error if there is any. +func (c *iPPools) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.IPPool, err error) { + result = &v1.IPPool{} + err = c.client.Get(). + Resource("ippools"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of IPPools that match those selectors. +func (c *iPPools) List(ctx context.Context, opts metav1.ListOptions) (result *v1.IPPoolList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.IPPoolList{} + err = c.client.Get(). + Resource("ippools"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested iPPools. +func (c *iPPools) 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(). + Resource("ippools"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a iPPool and creates it. Returns the server's representation of the iPPool, and an error, if there is any. +func (c *iPPools) Create(ctx context.Context, iPPool *v1.IPPool, opts metav1.CreateOptions) (result *v1.IPPool, err error) { + result = &v1.IPPool{} + err = c.client.Post(). + Resource("ippools"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iPPool). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a iPPool and updates it. Returns the server's representation of the iPPool, and an error, if there is any. +func (c *iPPools) Update(ctx context.Context, iPPool *v1.IPPool, opts metav1.UpdateOptions) (result *v1.IPPool, err error) { + result = &v1.IPPool{} + err = c.client.Put(). + Resource("ippools"). + Name(iPPool.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iPPool). + 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 *iPPools) UpdateStatus(ctx context.Context, iPPool *v1.IPPool, opts metav1.UpdateOptions) (result *v1.IPPool, err error) { + result = &v1.IPPool{} + err = c.client.Put(). + Resource("ippools"). + Name(iPPool.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iPPool). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the iPPool and deletes it. Returns an error if one occurs. +func (c *iPPools) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("ippools"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *iPPools) 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(). + Resource("ippools"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched iPPool. +func (c *iPPools) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.IPPool, err error) { + result = &v1.IPPool{} + err = c.client.Patch(pt). + Resource("ippools"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/iptablesdnatrule.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/iptablesdnatrule.go index 89ac3cdf6d5..b2088e59d5e 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/iptablesdnatrule.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/iptablesdnatrule.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // IptablesDnatRulesGetter has a method to return a IptablesDnatRuleInterface. @@ -39,7 +40,6 @@ type IptablesDnatRulesGetter interface { type IptablesDnatRuleInterface interface { Create(ctx context.Context, iptablesDnatRule *v1.IptablesDnatRule, opts metav1.CreateOptions) (*v1.IptablesDnatRule, error) Update(ctx context.Context, iptablesDnatRule *v1.IptablesDnatRule, opts metav1.UpdateOptions) (*v1.IptablesDnatRule, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, iptablesDnatRule *v1.IptablesDnatRule, opts metav1.UpdateOptions) (*v1.IptablesDnatRule, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type IptablesDnatRuleInterface interface { // iptablesDnatRules implements IptablesDnatRuleInterface type iptablesDnatRules struct { - *gentype.ClientWithList[*v1.IptablesDnatRule, *v1.IptablesDnatRuleList] + client rest.Interface } // newIptablesDnatRules returns a IptablesDnatRules func newIptablesDnatRules(c *KubeovnV1Client) *iptablesDnatRules { return &iptablesDnatRules{ - gentype.NewClientWithList[*v1.IptablesDnatRule, *v1.IptablesDnatRuleList]( - "iptables-dnat-rules", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.IptablesDnatRule { return &v1.IptablesDnatRule{} }, - func() *v1.IptablesDnatRuleList { return &v1.IptablesDnatRuleList{} }), + client: c.RESTClient(), } } + +// Get takes name of the iptablesDnatRule, and returns the corresponding iptablesDnatRule object, and an error if there is any. +func (c *iptablesDnatRules) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.IptablesDnatRule, err error) { + result = &v1.IptablesDnatRule{} + err = c.client.Get(). + Resource("iptables-dnat-rules"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of IptablesDnatRules that match those selectors. +func (c *iptablesDnatRules) List(ctx context.Context, opts metav1.ListOptions) (result *v1.IptablesDnatRuleList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.IptablesDnatRuleList{} + err = c.client.Get(). + Resource("iptables-dnat-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested iptablesDnatRules. +func (c *iptablesDnatRules) 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(). + Resource("iptables-dnat-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a iptablesDnatRule and creates it. Returns the server's representation of the iptablesDnatRule, and an error, if there is any. +func (c *iptablesDnatRules) Create(ctx context.Context, iptablesDnatRule *v1.IptablesDnatRule, opts metav1.CreateOptions) (result *v1.IptablesDnatRule, err error) { + result = &v1.IptablesDnatRule{} + err = c.client.Post(). + Resource("iptables-dnat-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iptablesDnatRule). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a iptablesDnatRule and updates it. Returns the server's representation of the iptablesDnatRule, and an error, if there is any. +func (c *iptablesDnatRules) Update(ctx context.Context, iptablesDnatRule *v1.IptablesDnatRule, opts metav1.UpdateOptions) (result *v1.IptablesDnatRule, err error) { + result = &v1.IptablesDnatRule{} + err = c.client.Put(). + Resource("iptables-dnat-rules"). + Name(iptablesDnatRule.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iptablesDnatRule). + 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 *iptablesDnatRules) UpdateStatus(ctx context.Context, iptablesDnatRule *v1.IptablesDnatRule, opts metav1.UpdateOptions) (result *v1.IptablesDnatRule, err error) { + result = &v1.IptablesDnatRule{} + err = c.client.Put(). + Resource("iptables-dnat-rules"). + Name(iptablesDnatRule.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iptablesDnatRule). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the iptablesDnatRule and deletes it. Returns an error if one occurs. +func (c *iptablesDnatRules) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("iptables-dnat-rules"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *iptablesDnatRules) 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(). + Resource("iptables-dnat-rules"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched iptablesDnatRule. +func (c *iptablesDnatRules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.IptablesDnatRule, err error) { + result = &v1.IptablesDnatRule{} + err = c.client.Patch(pt). + Resource("iptables-dnat-rules"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/iptableseip.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/iptableseip.go index 5a17e62469e..607ad8e9928 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/iptableseip.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/iptableseip.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // IptablesEIPsGetter has a method to return a IptablesEIPInterface. @@ -39,7 +40,6 @@ type IptablesEIPsGetter interface { type IptablesEIPInterface interface { Create(ctx context.Context, iptablesEIP *v1.IptablesEIP, opts metav1.CreateOptions) (*v1.IptablesEIP, error) Update(ctx context.Context, iptablesEIP *v1.IptablesEIP, opts metav1.UpdateOptions) (*v1.IptablesEIP, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, iptablesEIP *v1.IptablesEIP, opts metav1.UpdateOptions) (*v1.IptablesEIP, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type IptablesEIPInterface interface { // iptablesEIPs implements IptablesEIPInterface type iptablesEIPs struct { - *gentype.ClientWithList[*v1.IptablesEIP, *v1.IptablesEIPList] + client rest.Interface } // newIptablesEIPs returns a IptablesEIPs func newIptablesEIPs(c *KubeovnV1Client) *iptablesEIPs { return &iptablesEIPs{ - gentype.NewClientWithList[*v1.IptablesEIP, *v1.IptablesEIPList]( - "iptables-eips", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.IptablesEIP { return &v1.IptablesEIP{} }, - func() *v1.IptablesEIPList { return &v1.IptablesEIPList{} }), + client: c.RESTClient(), } } + +// Get takes name of the iptablesEIP, and returns the corresponding iptablesEIP object, and an error if there is any. +func (c *iptablesEIPs) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.IptablesEIP, err error) { + result = &v1.IptablesEIP{} + err = c.client.Get(). + Resource("iptables-eips"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of IptablesEIPs that match those selectors. +func (c *iptablesEIPs) List(ctx context.Context, opts metav1.ListOptions) (result *v1.IptablesEIPList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.IptablesEIPList{} + err = c.client.Get(). + Resource("iptables-eips"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested iptablesEIPs. +func (c *iptablesEIPs) 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(). + Resource("iptables-eips"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a iptablesEIP and creates it. Returns the server's representation of the iptablesEIP, and an error, if there is any. +func (c *iptablesEIPs) Create(ctx context.Context, iptablesEIP *v1.IptablesEIP, opts metav1.CreateOptions) (result *v1.IptablesEIP, err error) { + result = &v1.IptablesEIP{} + err = c.client.Post(). + Resource("iptables-eips"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iptablesEIP). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a iptablesEIP and updates it. Returns the server's representation of the iptablesEIP, and an error, if there is any. +func (c *iptablesEIPs) Update(ctx context.Context, iptablesEIP *v1.IptablesEIP, opts metav1.UpdateOptions) (result *v1.IptablesEIP, err error) { + result = &v1.IptablesEIP{} + err = c.client.Put(). + Resource("iptables-eips"). + Name(iptablesEIP.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iptablesEIP). + 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 *iptablesEIPs) UpdateStatus(ctx context.Context, iptablesEIP *v1.IptablesEIP, opts metav1.UpdateOptions) (result *v1.IptablesEIP, err error) { + result = &v1.IptablesEIP{} + err = c.client.Put(). + Resource("iptables-eips"). + Name(iptablesEIP.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iptablesEIP). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the iptablesEIP and deletes it. Returns an error if one occurs. +func (c *iptablesEIPs) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("iptables-eips"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *iptablesEIPs) 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(). + Resource("iptables-eips"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched iptablesEIP. +func (c *iptablesEIPs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.IptablesEIP, err error) { + result = &v1.IptablesEIP{} + err = c.client.Patch(pt). + Resource("iptables-eips"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/iptablesfiprule.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/iptablesfiprule.go index 7ea4e7d2824..2cc7fef6cd4 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/iptablesfiprule.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/iptablesfiprule.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // IptablesFIPRulesGetter has a method to return a IptablesFIPRuleInterface. @@ -39,7 +40,6 @@ type IptablesFIPRulesGetter interface { type IptablesFIPRuleInterface interface { Create(ctx context.Context, iptablesFIPRule *v1.IptablesFIPRule, opts metav1.CreateOptions) (*v1.IptablesFIPRule, error) Update(ctx context.Context, iptablesFIPRule *v1.IptablesFIPRule, opts metav1.UpdateOptions) (*v1.IptablesFIPRule, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, iptablesFIPRule *v1.IptablesFIPRule, opts metav1.UpdateOptions) (*v1.IptablesFIPRule, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type IptablesFIPRuleInterface interface { // iptablesFIPRules implements IptablesFIPRuleInterface type iptablesFIPRules struct { - *gentype.ClientWithList[*v1.IptablesFIPRule, *v1.IptablesFIPRuleList] + client rest.Interface } // newIptablesFIPRules returns a IptablesFIPRules func newIptablesFIPRules(c *KubeovnV1Client) *iptablesFIPRules { return &iptablesFIPRules{ - gentype.NewClientWithList[*v1.IptablesFIPRule, *v1.IptablesFIPRuleList]( - "iptables-fip-rules", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.IptablesFIPRule { return &v1.IptablesFIPRule{} }, - func() *v1.IptablesFIPRuleList { return &v1.IptablesFIPRuleList{} }), + client: c.RESTClient(), } } + +// Get takes name of the iptablesFIPRule, and returns the corresponding iptablesFIPRule object, and an error if there is any. +func (c *iptablesFIPRules) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.IptablesFIPRule, err error) { + result = &v1.IptablesFIPRule{} + err = c.client.Get(). + Resource("iptables-fip-rules"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of IptablesFIPRules that match those selectors. +func (c *iptablesFIPRules) List(ctx context.Context, opts metav1.ListOptions) (result *v1.IptablesFIPRuleList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.IptablesFIPRuleList{} + err = c.client.Get(). + Resource("iptables-fip-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested iptablesFIPRules. +func (c *iptablesFIPRules) 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(). + Resource("iptables-fip-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a iptablesFIPRule and creates it. Returns the server's representation of the iptablesFIPRule, and an error, if there is any. +func (c *iptablesFIPRules) Create(ctx context.Context, iptablesFIPRule *v1.IptablesFIPRule, opts metav1.CreateOptions) (result *v1.IptablesFIPRule, err error) { + result = &v1.IptablesFIPRule{} + err = c.client.Post(). + Resource("iptables-fip-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iptablesFIPRule). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a iptablesFIPRule and updates it. Returns the server's representation of the iptablesFIPRule, and an error, if there is any. +func (c *iptablesFIPRules) Update(ctx context.Context, iptablesFIPRule *v1.IptablesFIPRule, opts metav1.UpdateOptions) (result *v1.IptablesFIPRule, err error) { + result = &v1.IptablesFIPRule{} + err = c.client.Put(). + Resource("iptables-fip-rules"). + Name(iptablesFIPRule.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iptablesFIPRule). + 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 *iptablesFIPRules) UpdateStatus(ctx context.Context, iptablesFIPRule *v1.IptablesFIPRule, opts metav1.UpdateOptions) (result *v1.IptablesFIPRule, err error) { + result = &v1.IptablesFIPRule{} + err = c.client.Put(). + Resource("iptables-fip-rules"). + Name(iptablesFIPRule.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iptablesFIPRule). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the iptablesFIPRule and deletes it. Returns an error if one occurs. +func (c *iptablesFIPRules) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("iptables-fip-rules"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *iptablesFIPRules) 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(). + Resource("iptables-fip-rules"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched iptablesFIPRule. +func (c *iptablesFIPRules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.IptablesFIPRule, err error) { + result = &v1.IptablesFIPRule{} + err = c.client.Patch(pt). + Resource("iptables-fip-rules"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/iptablessnatrule.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/iptablessnatrule.go index 9b34cc4fa3a..576d1fbb92c 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/iptablessnatrule.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/iptablessnatrule.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // IptablesSnatRulesGetter has a method to return a IptablesSnatRuleInterface. @@ -39,7 +40,6 @@ type IptablesSnatRulesGetter interface { type IptablesSnatRuleInterface interface { Create(ctx context.Context, iptablesSnatRule *v1.IptablesSnatRule, opts metav1.CreateOptions) (*v1.IptablesSnatRule, error) Update(ctx context.Context, iptablesSnatRule *v1.IptablesSnatRule, opts metav1.UpdateOptions) (*v1.IptablesSnatRule, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, iptablesSnatRule *v1.IptablesSnatRule, opts metav1.UpdateOptions) (*v1.IptablesSnatRule, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type IptablesSnatRuleInterface interface { // iptablesSnatRules implements IptablesSnatRuleInterface type iptablesSnatRules struct { - *gentype.ClientWithList[*v1.IptablesSnatRule, *v1.IptablesSnatRuleList] + client rest.Interface } // newIptablesSnatRules returns a IptablesSnatRules func newIptablesSnatRules(c *KubeovnV1Client) *iptablesSnatRules { return &iptablesSnatRules{ - gentype.NewClientWithList[*v1.IptablesSnatRule, *v1.IptablesSnatRuleList]( - "iptables-snat-rules", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.IptablesSnatRule { return &v1.IptablesSnatRule{} }, - func() *v1.IptablesSnatRuleList { return &v1.IptablesSnatRuleList{} }), + client: c.RESTClient(), } } + +// Get takes name of the iptablesSnatRule, and returns the corresponding iptablesSnatRule object, and an error if there is any. +func (c *iptablesSnatRules) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.IptablesSnatRule, err error) { + result = &v1.IptablesSnatRule{} + err = c.client.Get(). + Resource("iptables-snat-rules"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of IptablesSnatRules that match those selectors. +func (c *iptablesSnatRules) List(ctx context.Context, opts metav1.ListOptions) (result *v1.IptablesSnatRuleList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.IptablesSnatRuleList{} + err = c.client.Get(). + Resource("iptables-snat-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested iptablesSnatRules. +func (c *iptablesSnatRules) 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(). + Resource("iptables-snat-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a iptablesSnatRule and creates it. Returns the server's representation of the iptablesSnatRule, and an error, if there is any. +func (c *iptablesSnatRules) Create(ctx context.Context, iptablesSnatRule *v1.IptablesSnatRule, opts metav1.CreateOptions) (result *v1.IptablesSnatRule, err error) { + result = &v1.IptablesSnatRule{} + err = c.client.Post(). + Resource("iptables-snat-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iptablesSnatRule). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a iptablesSnatRule and updates it. Returns the server's representation of the iptablesSnatRule, and an error, if there is any. +func (c *iptablesSnatRules) Update(ctx context.Context, iptablesSnatRule *v1.IptablesSnatRule, opts metav1.UpdateOptions) (result *v1.IptablesSnatRule, err error) { + result = &v1.IptablesSnatRule{} + err = c.client.Put(). + Resource("iptables-snat-rules"). + Name(iptablesSnatRule.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iptablesSnatRule). + 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 *iptablesSnatRules) UpdateStatus(ctx context.Context, iptablesSnatRule *v1.IptablesSnatRule, opts metav1.UpdateOptions) (result *v1.IptablesSnatRule, err error) { + result = &v1.IptablesSnatRule{} + err = c.client.Put(). + Resource("iptables-snat-rules"). + Name(iptablesSnatRule.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iptablesSnatRule). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the iptablesSnatRule and deletes it. Returns an error if one occurs. +func (c *iptablesSnatRules) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("iptables-snat-rules"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *iptablesSnatRules) 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(). + Resource("iptables-snat-rules"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched iptablesSnatRule. +func (c *iptablesSnatRules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.IptablesSnatRule, err error) { + result = &v1.IptablesSnatRule{} + err = c.client.Patch(pt). + Resource("iptables-snat-rules"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/ovndnatrule.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/ovndnatrule.go index ce15014da81..e7665899be0 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/ovndnatrule.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/ovndnatrule.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // OvnDnatRulesGetter has a method to return a OvnDnatRuleInterface. @@ -39,7 +40,6 @@ type OvnDnatRulesGetter interface { type OvnDnatRuleInterface interface { Create(ctx context.Context, ovnDnatRule *v1.OvnDnatRule, opts metav1.CreateOptions) (*v1.OvnDnatRule, error) Update(ctx context.Context, ovnDnatRule *v1.OvnDnatRule, opts metav1.UpdateOptions) (*v1.OvnDnatRule, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, ovnDnatRule *v1.OvnDnatRule, opts metav1.UpdateOptions) (*v1.OvnDnatRule, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type OvnDnatRuleInterface interface { // ovnDnatRules implements OvnDnatRuleInterface type ovnDnatRules struct { - *gentype.ClientWithList[*v1.OvnDnatRule, *v1.OvnDnatRuleList] + client rest.Interface } // newOvnDnatRules returns a OvnDnatRules func newOvnDnatRules(c *KubeovnV1Client) *ovnDnatRules { return &ovnDnatRules{ - gentype.NewClientWithList[*v1.OvnDnatRule, *v1.OvnDnatRuleList]( - "ovn-dnat-rules", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.OvnDnatRule { return &v1.OvnDnatRule{} }, - func() *v1.OvnDnatRuleList { return &v1.OvnDnatRuleList{} }), + client: c.RESTClient(), } } + +// Get takes name of the ovnDnatRule, and returns the corresponding ovnDnatRule object, and an error if there is any. +func (c *ovnDnatRules) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.OvnDnatRule, err error) { + result = &v1.OvnDnatRule{} + err = c.client.Get(). + Resource("ovn-dnat-rules"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of OvnDnatRules that match those selectors. +func (c *ovnDnatRules) List(ctx context.Context, opts metav1.ListOptions) (result *v1.OvnDnatRuleList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.OvnDnatRuleList{} + err = c.client.Get(). + Resource("ovn-dnat-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested ovnDnatRules. +func (c *ovnDnatRules) 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(). + Resource("ovn-dnat-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a ovnDnatRule and creates it. Returns the server's representation of the ovnDnatRule, and an error, if there is any. +func (c *ovnDnatRules) Create(ctx context.Context, ovnDnatRule *v1.OvnDnatRule, opts metav1.CreateOptions) (result *v1.OvnDnatRule, err error) { + result = &v1.OvnDnatRule{} + err = c.client.Post(). + Resource("ovn-dnat-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(ovnDnatRule). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a ovnDnatRule and updates it. Returns the server's representation of the ovnDnatRule, and an error, if there is any. +func (c *ovnDnatRules) Update(ctx context.Context, ovnDnatRule *v1.OvnDnatRule, opts metav1.UpdateOptions) (result *v1.OvnDnatRule, err error) { + result = &v1.OvnDnatRule{} + err = c.client.Put(). + Resource("ovn-dnat-rules"). + Name(ovnDnatRule.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(ovnDnatRule). + 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 *ovnDnatRules) UpdateStatus(ctx context.Context, ovnDnatRule *v1.OvnDnatRule, opts metav1.UpdateOptions) (result *v1.OvnDnatRule, err error) { + result = &v1.OvnDnatRule{} + err = c.client.Put(). + Resource("ovn-dnat-rules"). + Name(ovnDnatRule.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(ovnDnatRule). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the ovnDnatRule and deletes it. Returns an error if one occurs. +func (c *ovnDnatRules) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("ovn-dnat-rules"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *ovnDnatRules) 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(). + Resource("ovn-dnat-rules"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched ovnDnatRule. +func (c *ovnDnatRules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.OvnDnatRule, err error) { + result = &v1.OvnDnatRule{} + err = c.client.Patch(pt). + Resource("ovn-dnat-rules"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/ovneip.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/ovneip.go index 4fbed307958..509d0492cac 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/ovneip.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/ovneip.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // OvnEipsGetter has a method to return a OvnEipInterface. @@ -39,7 +40,6 @@ type OvnEipsGetter interface { type OvnEipInterface interface { Create(ctx context.Context, ovnEip *v1.OvnEip, opts metav1.CreateOptions) (*v1.OvnEip, error) Update(ctx context.Context, ovnEip *v1.OvnEip, opts metav1.UpdateOptions) (*v1.OvnEip, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, ovnEip *v1.OvnEip, opts metav1.UpdateOptions) (*v1.OvnEip, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type OvnEipInterface interface { // ovnEips implements OvnEipInterface type ovnEips struct { - *gentype.ClientWithList[*v1.OvnEip, *v1.OvnEipList] + client rest.Interface } // newOvnEips returns a OvnEips func newOvnEips(c *KubeovnV1Client) *ovnEips { return &ovnEips{ - gentype.NewClientWithList[*v1.OvnEip, *v1.OvnEipList]( - "ovn-eips", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.OvnEip { return &v1.OvnEip{} }, - func() *v1.OvnEipList { return &v1.OvnEipList{} }), + client: c.RESTClient(), } } + +// Get takes name of the ovnEip, and returns the corresponding ovnEip object, and an error if there is any. +func (c *ovnEips) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.OvnEip, err error) { + result = &v1.OvnEip{} + err = c.client.Get(). + Resource("ovn-eips"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of OvnEips that match those selectors. +func (c *ovnEips) List(ctx context.Context, opts metav1.ListOptions) (result *v1.OvnEipList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.OvnEipList{} + err = c.client.Get(). + Resource("ovn-eips"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested ovnEips. +func (c *ovnEips) 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(). + Resource("ovn-eips"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a ovnEip and creates it. Returns the server's representation of the ovnEip, and an error, if there is any. +func (c *ovnEips) Create(ctx context.Context, ovnEip *v1.OvnEip, opts metav1.CreateOptions) (result *v1.OvnEip, err error) { + result = &v1.OvnEip{} + err = c.client.Post(). + Resource("ovn-eips"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(ovnEip). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a ovnEip and updates it. Returns the server's representation of the ovnEip, and an error, if there is any. +func (c *ovnEips) Update(ctx context.Context, ovnEip *v1.OvnEip, opts metav1.UpdateOptions) (result *v1.OvnEip, err error) { + result = &v1.OvnEip{} + err = c.client.Put(). + Resource("ovn-eips"). + Name(ovnEip.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(ovnEip). + 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 *ovnEips) UpdateStatus(ctx context.Context, ovnEip *v1.OvnEip, opts metav1.UpdateOptions) (result *v1.OvnEip, err error) { + result = &v1.OvnEip{} + err = c.client.Put(). + Resource("ovn-eips"). + Name(ovnEip.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(ovnEip). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the ovnEip and deletes it. Returns an error if one occurs. +func (c *ovnEips) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("ovn-eips"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *ovnEips) 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(). + Resource("ovn-eips"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched ovnEip. +func (c *ovnEips) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.OvnEip, err error) { + result = &v1.OvnEip{} + err = c.client.Patch(pt). + Resource("ovn-eips"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/ovnfip.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/ovnfip.go index 0f8e23d7f24..0f20cebdfe0 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/ovnfip.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/ovnfip.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // OvnFipsGetter has a method to return a OvnFipInterface. @@ -39,7 +40,6 @@ type OvnFipsGetter interface { type OvnFipInterface interface { Create(ctx context.Context, ovnFip *v1.OvnFip, opts metav1.CreateOptions) (*v1.OvnFip, error) Update(ctx context.Context, ovnFip *v1.OvnFip, opts metav1.UpdateOptions) (*v1.OvnFip, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, ovnFip *v1.OvnFip, opts metav1.UpdateOptions) (*v1.OvnFip, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type OvnFipInterface interface { // ovnFips implements OvnFipInterface type ovnFips struct { - *gentype.ClientWithList[*v1.OvnFip, *v1.OvnFipList] + client rest.Interface } // newOvnFips returns a OvnFips func newOvnFips(c *KubeovnV1Client) *ovnFips { return &ovnFips{ - gentype.NewClientWithList[*v1.OvnFip, *v1.OvnFipList]( - "ovn-fips", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.OvnFip { return &v1.OvnFip{} }, - func() *v1.OvnFipList { return &v1.OvnFipList{} }), + client: c.RESTClient(), } } + +// Get takes name of the ovnFip, and returns the corresponding ovnFip object, and an error if there is any. +func (c *ovnFips) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.OvnFip, err error) { + result = &v1.OvnFip{} + err = c.client.Get(). + Resource("ovn-fips"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of OvnFips that match those selectors. +func (c *ovnFips) List(ctx context.Context, opts metav1.ListOptions) (result *v1.OvnFipList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.OvnFipList{} + err = c.client.Get(). + Resource("ovn-fips"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested ovnFips. +func (c *ovnFips) 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(). + Resource("ovn-fips"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a ovnFip and creates it. Returns the server's representation of the ovnFip, and an error, if there is any. +func (c *ovnFips) Create(ctx context.Context, ovnFip *v1.OvnFip, opts metav1.CreateOptions) (result *v1.OvnFip, err error) { + result = &v1.OvnFip{} + err = c.client.Post(). + Resource("ovn-fips"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(ovnFip). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a ovnFip and updates it. Returns the server's representation of the ovnFip, and an error, if there is any. +func (c *ovnFips) Update(ctx context.Context, ovnFip *v1.OvnFip, opts metav1.UpdateOptions) (result *v1.OvnFip, err error) { + result = &v1.OvnFip{} + err = c.client.Put(). + Resource("ovn-fips"). + Name(ovnFip.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(ovnFip). + 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 *ovnFips) UpdateStatus(ctx context.Context, ovnFip *v1.OvnFip, opts metav1.UpdateOptions) (result *v1.OvnFip, err error) { + result = &v1.OvnFip{} + err = c.client.Put(). + Resource("ovn-fips"). + Name(ovnFip.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(ovnFip). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the ovnFip and deletes it. Returns an error if one occurs. +func (c *ovnFips) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("ovn-fips"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *ovnFips) 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(). + Resource("ovn-fips"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched ovnFip. +func (c *ovnFips) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.OvnFip, err error) { + result = &v1.OvnFip{} + err = c.client.Patch(pt). + Resource("ovn-fips"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/ovnsnatrule.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/ovnsnatrule.go index b485fc4ebd6..93bb2c01b12 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/ovnsnatrule.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/ovnsnatrule.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // OvnSnatRulesGetter has a method to return a OvnSnatRuleInterface. @@ -39,7 +40,6 @@ type OvnSnatRulesGetter interface { type OvnSnatRuleInterface interface { Create(ctx context.Context, ovnSnatRule *v1.OvnSnatRule, opts metav1.CreateOptions) (*v1.OvnSnatRule, error) Update(ctx context.Context, ovnSnatRule *v1.OvnSnatRule, opts metav1.UpdateOptions) (*v1.OvnSnatRule, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, ovnSnatRule *v1.OvnSnatRule, opts metav1.UpdateOptions) (*v1.OvnSnatRule, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type OvnSnatRuleInterface interface { // ovnSnatRules implements OvnSnatRuleInterface type ovnSnatRules struct { - *gentype.ClientWithList[*v1.OvnSnatRule, *v1.OvnSnatRuleList] + client rest.Interface } // newOvnSnatRules returns a OvnSnatRules func newOvnSnatRules(c *KubeovnV1Client) *ovnSnatRules { return &ovnSnatRules{ - gentype.NewClientWithList[*v1.OvnSnatRule, *v1.OvnSnatRuleList]( - "ovn-snat-rules", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.OvnSnatRule { return &v1.OvnSnatRule{} }, - func() *v1.OvnSnatRuleList { return &v1.OvnSnatRuleList{} }), + client: c.RESTClient(), } } + +// Get takes name of the ovnSnatRule, and returns the corresponding ovnSnatRule object, and an error if there is any. +func (c *ovnSnatRules) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.OvnSnatRule, err error) { + result = &v1.OvnSnatRule{} + err = c.client.Get(). + Resource("ovn-snat-rules"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of OvnSnatRules that match those selectors. +func (c *ovnSnatRules) List(ctx context.Context, opts metav1.ListOptions) (result *v1.OvnSnatRuleList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.OvnSnatRuleList{} + err = c.client.Get(). + Resource("ovn-snat-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested ovnSnatRules. +func (c *ovnSnatRules) 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(). + Resource("ovn-snat-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a ovnSnatRule and creates it. Returns the server's representation of the ovnSnatRule, and an error, if there is any. +func (c *ovnSnatRules) Create(ctx context.Context, ovnSnatRule *v1.OvnSnatRule, opts metav1.CreateOptions) (result *v1.OvnSnatRule, err error) { + result = &v1.OvnSnatRule{} + err = c.client.Post(). + Resource("ovn-snat-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(ovnSnatRule). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a ovnSnatRule and updates it. Returns the server's representation of the ovnSnatRule, and an error, if there is any. +func (c *ovnSnatRules) Update(ctx context.Context, ovnSnatRule *v1.OvnSnatRule, opts metav1.UpdateOptions) (result *v1.OvnSnatRule, err error) { + result = &v1.OvnSnatRule{} + err = c.client.Put(). + Resource("ovn-snat-rules"). + Name(ovnSnatRule.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(ovnSnatRule). + 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 *ovnSnatRules) UpdateStatus(ctx context.Context, ovnSnatRule *v1.OvnSnatRule, opts metav1.UpdateOptions) (result *v1.OvnSnatRule, err error) { + result = &v1.OvnSnatRule{} + err = c.client.Put(). + Resource("ovn-snat-rules"). + Name(ovnSnatRule.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(ovnSnatRule). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the ovnSnatRule and deletes it. Returns an error if one occurs. +func (c *ovnSnatRules) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("ovn-snat-rules"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *ovnSnatRules) 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(). + Resource("ovn-snat-rules"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched ovnSnatRule. +func (c *ovnSnatRules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.OvnSnatRule, err error) { + result = &v1.OvnSnatRule{} + err = c.client.Patch(pt). + Resource("ovn-snat-rules"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/providernetwork.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/providernetwork.go index e1c7f09f614..fcef8da37fa 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/providernetwork.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/providernetwork.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // ProviderNetworksGetter has a method to return a ProviderNetworkInterface. @@ -39,7 +40,6 @@ type ProviderNetworksGetter interface { type ProviderNetworkInterface interface { Create(ctx context.Context, providerNetwork *v1.ProviderNetwork, opts metav1.CreateOptions) (*v1.ProviderNetwork, error) Update(ctx context.Context, providerNetwork *v1.ProviderNetwork, opts metav1.UpdateOptions) (*v1.ProviderNetwork, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, providerNetwork *v1.ProviderNetwork, opts metav1.UpdateOptions) (*v1.ProviderNetwork, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type ProviderNetworkInterface interface { // providerNetworks implements ProviderNetworkInterface type providerNetworks struct { - *gentype.ClientWithList[*v1.ProviderNetwork, *v1.ProviderNetworkList] + client rest.Interface } // newProviderNetworks returns a ProviderNetworks func newProviderNetworks(c *KubeovnV1Client) *providerNetworks { return &providerNetworks{ - gentype.NewClientWithList[*v1.ProviderNetwork, *v1.ProviderNetworkList]( - "provider-networks", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.ProviderNetwork { return &v1.ProviderNetwork{} }, - func() *v1.ProviderNetworkList { return &v1.ProviderNetworkList{} }), + client: c.RESTClient(), } } + +// Get takes name of the providerNetwork, and returns the corresponding providerNetwork object, and an error if there is any. +func (c *providerNetworks) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.ProviderNetwork, err error) { + result = &v1.ProviderNetwork{} + err = c.client.Get(). + Resource("provider-networks"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ProviderNetworks that match those selectors. +func (c *providerNetworks) List(ctx context.Context, opts metav1.ListOptions) (result *v1.ProviderNetworkList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ProviderNetworkList{} + err = c.client.Get(). + Resource("provider-networks"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested providerNetworks. +func (c *providerNetworks) 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(). + Resource("provider-networks"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a providerNetwork and creates it. Returns the server's representation of the providerNetwork, and an error, if there is any. +func (c *providerNetworks) Create(ctx context.Context, providerNetwork *v1.ProviderNetwork, opts metav1.CreateOptions) (result *v1.ProviderNetwork, err error) { + result = &v1.ProviderNetwork{} + err = c.client.Post(). + Resource("provider-networks"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(providerNetwork). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a providerNetwork and updates it. Returns the server's representation of the providerNetwork, and an error, if there is any. +func (c *providerNetworks) Update(ctx context.Context, providerNetwork *v1.ProviderNetwork, opts metav1.UpdateOptions) (result *v1.ProviderNetwork, err error) { + result = &v1.ProviderNetwork{} + err = c.client.Put(). + Resource("provider-networks"). + Name(providerNetwork.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(providerNetwork). + 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 *providerNetworks) UpdateStatus(ctx context.Context, providerNetwork *v1.ProviderNetwork, opts metav1.UpdateOptions) (result *v1.ProviderNetwork, err error) { + result = &v1.ProviderNetwork{} + err = c.client.Put(). + Resource("provider-networks"). + Name(providerNetwork.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(providerNetwork). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the providerNetwork and deletes it. Returns an error if one occurs. +func (c *providerNetworks) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("provider-networks"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *providerNetworks) 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(). + Resource("provider-networks"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched providerNetwork. +func (c *providerNetworks) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.ProviderNetwork, err error) { + result = &v1.ProviderNetwork{} + err = c.client.Patch(pt). + Resource("provider-networks"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/qospolicy.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/qospolicy.go index 2580941f872..1a051aad72c 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/qospolicy.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/qospolicy.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // QoSPoliciesGetter has a method to return a QoSPolicyInterface. @@ -39,7 +40,6 @@ type QoSPoliciesGetter interface { type QoSPolicyInterface interface { Create(ctx context.Context, qoSPolicy *v1.QoSPolicy, opts metav1.CreateOptions) (*v1.QoSPolicy, error) Update(ctx context.Context, qoSPolicy *v1.QoSPolicy, opts metav1.UpdateOptions) (*v1.QoSPolicy, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, qoSPolicy *v1.QoSPolicy, opts metav1.UpdateOptions) (*v1.QoSPolicy, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type QoSPolicyInterface interface { // qoSPolicies implements QoSPolicyInterface type qoSPolicies struct { - *gentype.ClientWithList[*v1.QoSPolicy, *v1.QoSPolicyList] + client rest.Interface } // newQoSPolicies returns a QoSPolicies func newQoSPolicies(c *KubeovnV1Client) *qoSPolicies { return &qoSPolicies{ - gentype.NewClientWithList[*v1.QoSPolicy, *v1.QoSPolicyList]( - "qos-policies", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.QoSPolicy { return &v1.QoSPolicy{} }, - func() *v1.QoSPolicyList { return &v1.QoSPolicyList{} }), + client: c.RESTClient(), } } + +// Get takes name of the qoSPolicy, and returns the corresponding qoSPolicy object, and an error if there is any. +func (c *qoSPolicies) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.QoSPolicy, err error) { + result = &v1.QoSPolicy{} + err = c.client.Get(). + Resource("qos-policies"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of QoSPolicies that match those selectors. +func (c *qoSPolicies) List(ctx context.Context, opts metav1.ListOptions) (result *v1.QoSPolicyList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.QoSPolicyList{} + err = c.client.Get(). + Resource("qos-policies"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested qoSPolicies. +func (c *qoSPolicies) 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(). + Resource("qos-policies"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a qoSPolicy and creates it. Returns the server's representation of the qoSPolicy, and an error, if there is any. +func (c *qoSPolicies) Create(ctx context.Context, qoSPolicy *v1.QoSPolicy, opts metav1.CreateOptions) (result *v1.QoSPolicy, err error) { + result = &v1.QoSPolicy{} + err = c.client.Post(). + Resource("qos-policies"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(qoSPolicy). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a qoSPolicy and updates it. Returns the server's representation of the qoSPolicy, and an error, if there is any. +func (c *qoSPolicies) Update(ctx context.Context, qoSPolicy *v1.QoSPolicy, opts metav1.UpdateOptions) (result *v1.QoSPolicy, err error) { + result = &v1.QoSPolicy{} + err = c.client.Put(). + Resource("qos-policies"). + Name(qoSPolicy.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(qoSPolicy). + 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 *qoSPolicies) UpdateStatus(ctx context.Context, qoSPolicy *v1.QoSPolicy, opts metav1.UpdateOptions) (result *v1.QoSPolicy, err error) { + result = &v1.QoSPolicy{} + err = c.client.Put(). + Resource("qos-policies"). + Name(qoSPolicy.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(qoSPolicy). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the qoSPolicy and deletes it. Returns an error if one occurs. +func (c *qoSPolicies) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("qos-policies"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *qoSPolicies) 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(). + Resource("qos-policies"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched qoSPolicy. +func (c *qoSPolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.QoSPolicy, err error) { + result = &v1.QoSPolicy{} + err = c.client.Patch(pt). + Resource("qos-policies"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/securitygroup.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/securitygroup.go index 6ec917d5a83..391baf47c56 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/securitygroup.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/securitygroup.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // SecurityGroupsGetter has a method to return a SecurityGroupInterface. @@ -39,7 +40,6 @@ type SecurityGroupsGetter interface { type SecurityGroupInterface interface { Create(ctx context.Context, securityGroup *v1.SecurityGroup, opts metav1.CreateOptions) (*v1.SecurityGroup, error) Update(ctx context.Context, securityGroup *v1.SecurityGroup, opts metav1.UpdateOptions) (*v1.SecurityGroup, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, securityGroup *v1.SecurityGroup, opts metav1.UpdateOptions) (*v1.SecurityGroup, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type SecurityGroupInterface interface { // securityGroups implements SecurityGroupInterface type securityGroups struct { - *gentype.ClientWithList[*v1.SecurityGroup, *v1.SecurityGroupList] + client rest.Interface } // newSecurityGroups returns a SecurityGroups func newSecurityGroups(c *KubeovnV1Client) *securityGroups { return &securityGroups{ - gentype.NewClientWithList[*v1.SecurityGroup, *v1.SecurityGroupList]( - "security-groups", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.SecurityGroup { return &v1.SecurityGroup{} }, - func() *v1.SecurityGroupList { return &v1.SecurityGroupList{} }), + client: c.RESTClient(), } } + +// Get takes name of the securityGroup, and returns the corresponding securityGroup object, and an error if there is any. +func (c *securityGroups) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.SecurityGroup, err error) { + result = &v1.SecurityGroup{} + err = c.client.Get(). + Resource("security-groups"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of SecurityGroups that match those selectors. +func (c *securityGroups) List(ctx context.Context, opts metav1.ListOptions) (result *v1.SecurityGroupList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.SecurityGroupList{} + err = c.client.Get(). + Resource("security-groups"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested securityGroups. +func (c *securityGroups) 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(). + Resource("security-groups"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a securityGroup and creates it. Returns the server's representation of the securityGroup, and an error, if there is any. +func (c *securityGroups) Create(ctx context.Context, securityGroup *v1.SecurityGroup, opts metav1.CreateOptions) (result *v1.SecurityGroup, err error) { + result = &v1.SecurityGroup{} + err = c.client.Post(). + Resource("security-groups"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(securityGroup). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a securityGroup and updates it. Returns the server's representation of the securityGroup, and an error, if there is any. +func (c *securityGroups) Update(ctx context.Context, securityGroup *v1.SecurityGroup, opts metav1.UpdateOptions) (result *v1.SecurityGroup, err error) { + result = &v1.SecurityGroup{} + err = c.client.Put(). + Resource("security-groups"). + Name(securityGroup.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(securityGroup). + 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 *securityGroups) UpdateStatus(ctx context.Context, securityGroup *v1.SecurityGroup, opts metav1.UpdateOptions) (result *v1.SecurityGroup, err error) { + result = &v1.SecurityGroup{} + err = c.client.Put(). + Resource("security-groups"). + Name(securityGroup.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(securityGroup). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the securityGroup and deletes it. Returns an error if one occurs. +func (c *securityGroups) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("security-groups"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *securityGroups) 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(). + Resource("security-groups"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched securityGroup. +func (c *securityGroups) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.SecurityGroup, err error) { + result = &v1.SecurityGroup{} + err = c.client.Patch(pt). + Resource("security-groups"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/subnet.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/subnet.go index f546e4cc9ec..a1638ef10f5 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/subnet.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/subnet.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // SubnetsGetter has a method to return a SubnetInterface. @@ -39,7 +40,6 @@ type SubnetsGetter interface { type SubnetInterface interface { Create(ctx context.Context, subnet *v1.Subnet, opts metav1.CreateOptions) (*v1.Subnet, error) Update(ctx context.Context, subnet *v1.Subnet, opts metav1.UpdateOptions) (*v1.Subnet, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, subnet *v1.Subnet, opts metav1.UpdateOptions) (*v1.Subnet, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type SubnetInterface interface { // subnets implements SubnetInterface type subnets struct { - *gentype.ClientWithList[*v1.Subnet, *v1.SubnetList] + client rest.Interface } // newSubnets returns a Subnets func newSubnets(c *KubeovnV1Client) *subnets { return &subnets{ - gentype.NewClientWithList[*v1.Subnet, *v1.SubnetList]( - "subnets", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.Subnet { return &v1.Subnet{} }, - func() *v1.SubnetList { return &v1.SubnetList{} }), + client: c.RESTClient(), } } + +// Get takes name of the subnet, and returns the corresponding subnet object, and an error if there is any. +func (c *subnets) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.Subnet, err error) { + result = &v1.Subnet{} + err = c.client.Get(). + Resource("subnets"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Subnets that match those selectors. +func (c *subnets) List(ctx context.Context, opts metav1.ListOptions) (result *v1.SubnetList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.SubnetList{} + err = c.client.Get(). + Resource("subnets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested subnets. +func (c *subnets) 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(). + Resource("subnets"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a subnet and creates it. Returns the server's representation of the subnet, and an error, if there is any. +func (c *subnets) Create(ctx context.Context, subnet *v1.Subnet, opts metav1.CreateOptions) (result *v1.Subnet, err error) { + result = &v1.Subnet{} + err = c.client.Post(). + Resource("subnets"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(subnet). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a subnet and updates it. Returns the server's representation of the subnet, and an error, if there is any. +func (c *subnets) Update(ctx context.Context, subnet *v1.Subnet, opts metav1.UpdateOptions) (result *v1.Subnet, err error) { + result = &v1.Subnet{} + err = c.client.Put(). + Resource("subnets"). + Name(subnet.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(subnet). + 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 *subnets) UpdateStatus(ctx context.Context, subnet *v1.Subnet, opts metav1.UpdateOptions) (result *v1.Subnet, err error) { + result = &v1.Subnet{} + err = c.client.Put(). + Resource("subnets"). + Name(subnet.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(subnet). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the subnet and deletes it. Returns an error if one occurs. +func (c *subnets) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("subnets"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *subnets) 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(). + Resource("subnets"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched subnet. +func (c *subnets) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Subnet, err error) { + result = &v1.Subnet{} + err = c.client.Patch(pt). + Resource("subnets"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/switchlbrule.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/switchlbrule.go index 8b1bdbb0ef0..537deb6a187 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/switchlbrule.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/switchlbrule.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // SwitchLBRulesGetter has a method to return a SwitchLBRuleInterface. @@ -39,7 +40,6 @@ type SwitchLBRulesGetter interface { type SwitchLBRuleInterface interface { Create(ctx context.Context, switchLBRule *v1.SwitchLBRule, opts metav1.CreateOptions) (*v1.SwitchLBRule, error) Update(ctx context.Context, switchLBRule *v1.SwitchLBRule, opts metav1.UpdateOptions) (*v1.SwitchLBRule, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, switchLBRule *v1.SwitchLBRule, opts metav1.UpdateOptions) (*v1.SwitchLBRule, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type SwitchLBRuleInterface interface { // switchLBRules implements SwitchLBRuleInterface type switchLBRules struct { - *gentype.ClientWithList[*v1.SwitchLBRule, *v1.SwitchLBRuleList] + client rest.Interface } // newSwitchLBRules returns a SwitchLBRules func newSwitchLBRules(c *KubeovnV1Client) *switchLBRules { return &switchLBRules{ - gentype.NewClientWithList[*v1.SwitchLBRule, *v1.SwitchLBRuleList]( - "switch-lb-rules", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.SwitchLBRule { return &v1.SwitchLBRule{} }, - func() *v1.SwitchLBRuleList { return &v1.SwitchLBRuleList{} }), + client: c.RESTClient(), } } + +// Get takes name of the switchLBRule, and returns the corresponding switchLBRule object, and an error if there is any. +func (c *switchLBRules) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.SwitchLBRule, err error) { + result = &v1.SwitchLBRule{} + err = c.client.Get(). + Resource("switch-lb-rules"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of SwitchLBRules that match those selectors. +func (c *switchLBRules) List(ctx context.Context, opts metav1.ListOptions) (result *v1.SwitchLBRuleList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.SwitchLBRuleList{} + err = c.client.Get(). + Resource("switch-lb-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested switchLBRules. +func (c *switchLBRules) 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(). + Resource("switch-lb-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a switchLBRule and creates it. Returns the server's representation of the switchLBRule, and an error, if there is any. +func (c *switchLBRules) Create(ctx context.Context, switchLBRule *v1.SwitchLBRule, opts metav1.CreateOptions) (result *v1.SwitchLBRule, err error) { + result = &v1.SwitchLBRule{} + err = c.client.Post(). + Resource("switch-lb-rules"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(switchLBRule). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a switchLBRule and updates it. Returns the server's representation of the switchLBRule, and an error, if there is any. +func (c *switchLBRules) Update(ctx context.Context, switchLBRule *v1.SwitchLBRule, opts metav1.UpdateOptions) (result *v1.SwitchLBRule, err error) { + result = &v1.SwitchLBRule{} + err = c.client.Put(). + Resource("switch-lb-rules"). + Name(switchLBRule.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(switchLBRule). + 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 *switchLBRules) UpdateStatus(ctx context.Context, switchLBRule *v1.SwitchLBRule, opts metav1.UpdateOptions) (result *v1.SwitchLBRule, err error) { + result = &v1.SwitchLBRule{} + err = c.client.Put(). + Resource("switch-lb-rules"). + Name(switchLBRule.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(switchLBRule). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the switchLBRule and deletes it. Returns an error if one occurs. +func (c *switchLBRules) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("switch-lb-rules"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *switchLBRules) 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(). + Resource("switch-lb-rules"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched switchLBRule. +func (c *switchLBRules) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.SwitchLBRule, err error) { + result = &v1.SwitchLBRule{} + err = c.client.Patch(pt). + Resource("switch-lb-rules"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/vip.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/vip.go index 9c8f3d73b29..b355e6079bc 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/vip.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/vip.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // VipsGetter has a method to return a VipInterface. @@ -39,7 +40,6 @@ type VipsGetter interface { type VipInterface interface { Create(ctx context.Context, vip *v1.Vip, opts metav1.CreateOptions) (*v1.Vip, error) Update(ctx context.Context, vip *v1.Vip, opts metav1.UpdateOptions) (*v1.Vip, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, vip *v1.Vip, opts metav1.UpdateOptions) (*v1.Vip, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type VipInterface interface { // vips implements VipInterface type vips struct { - *gentype.ClientWithList[*v1.Vip, *v1.VipList] + client rest.Interface } // newVips returns a Vips func newVips(c *KubeovnV1Client) *vips { return &vips{ - gentype.NewClientWithList[*v1.Vip, *v1.VipList]( - "vips", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.Vip { return &v1.Vip{} }, - func() *v1.VipList { return &v1.VipList{} }), + client: c.RESTClient(), } } + +// Get takes name of the vip, and returns the corresponding vip object, and an error if there is any. +func (c *vips) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.Vip, err error) { + result = &v1.Vip{} + err = c.client.Get(). + Resource("vips"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Vips that match those selectors. +func (c *vips) List(ctx context.Context, opts metav1.ListOptions) (result *v1.VipList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.VipList{} + err = c.client.Get(). + Resource("vips"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested vips. +func (c *vips) 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(). + Resource("vips"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a vip and creates it. Returns the server's representation of the vip, and an error, if there is any. +func (c *vips) Create(ctx context.Context, vip *v1.Vip, opts metav1.CreateOptions) (result *v1.Vip, err error) { + result = &v1.Vip{} + err = c.client.Post(). + Resource("vips"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(vip). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a vip and updates it. Returns the server's representation of the vip, and an error, if there is any. +func (c *vips) Update(ctx context.Context, vip *v1.Vip, opts metav1.UpdateOptions) (result *v1.Vip, err error) { + result = &v1.Vip{} + err = c.client.Put(). + Resource("vips"). + Name(vip.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(vip). + 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 *vips) UpdateStatus(ctx context.Context, vip *v1.Vip, opts metav1.UpdateOptions) (result *v1.Vip, err error) { + result = &v1.Vip{} + err = c.client.Put(). + Resource("vips"). + Name(vip.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(vip). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the vip and deletes it. Returns an error if one occurs. +func (c *vips) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("vips"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *vips) 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(). + Resource("vips"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched vip. +func (c *vips) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Vip, err error) { + result = &v1.Vip{} + err = c.client.Patch(pt). + Resource("vips"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/vlan.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/vlan.go index 958f0be2dce..64e91699707 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/vlan.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/vlan.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // VlansGetter has a method to return a VlanInterface. @@ -39,7 +40,6 @@ type VlansGetter interface { type VlanInterface interface { Create(ctx context.Context, vlan *v1.Vlan, opts metav1.CreateOptions) (*v1.Vlan, error) Update(ctx context.Context, vlan *v1.Vlan, opts metav1.UpdateOptions) (*v1.Vlan, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, vlan *v1.Vlan, opts metav1.UpdateOptions) (*v1.Vlan, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type VlanInterface interface { // vlans implements VlanInterface type vlans struct { - *gentype.ClientWithList[*v1.Vlan, *v1.VlanList] + client rest.Interface } // newVlans returns a Vlans func newVlans(c *KubeovnV1Client) *vlans { return &vlans{ - gentype.NewClientWithList[*v1.Vlan, *v1.VlanList]( - "vlans", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.Vlan { return &v1.Vlan{} }, - func() *v1.VlanList { return &v1.VlanList{} }), + client: c.RESTClient(), } } + +// Get takes name of the vlan, and returns the corresponding vlan object, and an error if there is any. +func (c *vlans) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.Vlan, err error) { + result = &v1.Vlan{} + err = c.client.Get(). + Resource("vlans"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Vlans that match those selectors. +func (c *vlans) List(ctx context.Context, opts metav1.ListOptions) (result *v1.VlanList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.VlanList{} + err = c.client.Get(). + Resource("vlans"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested vlans. +func (c *vlans) 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(). + Resource("vlans"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a vlan and creates it. Returns the server's representation of the vlan, and an error, if there is any. +func (c *vlans) Create(ctx context.Context, vlan *v1.Vlan, opts metav1.CreateOptions) (result *v1.Vlan, err error) { + result = &v1.Vlan{} + err = c.client.Post(). + Resource("vlans"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(vlan). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a vlan and updates it. Returns the server's representation of the vlan, and an error, if there is any. +func (c *vlans) Update(ctx context.Context, vlan *v1.Vlan, opts metav1.UpdateOptions) (result *v1.Vlan, err error) { + result = &v1.Vlan{} + err = c.client.Put(). + Resource("vlans"). + Name(vlan.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(vlan). + 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 *vlans) UpdateStatus(ctx context.Context, vlan *v1.Vlan, opts metav1.UpdateOptions) (result *v1.Vlan, err error) { + result = &v1.Vlan{} + err = c.client.Put(). + Resource("vlans"). + Name(vlan.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(vlan). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the vlan and deletes it. Returns an error if one occurs. +func (c *vlans) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("vlans"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *vlans) 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(). + Resource("vlans"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched vlan. +func (c *vlans) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Vlan, err error) { + result = &v1.Vlan{} + err = c.client.Patch(pt). + Resource("vlans"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/vpc.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/vpc.go index 84ba616217c..788500624fd 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/vpc.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/vpc.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // VpcsGetter has a method to return a VpcInterface. @@ -39,7 +40,6 @@ type VpcsGetter interface { type VpcInterface interface { Create(ctx context.Context, vpc *v1.Vpc, opts metav1.CreateOptions) (*v1.Vpc, error) Update(ctx context.Context, vpc *v1.Vpc, opts metav1.UpdateOptions) (*v1.Vpc, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, vpc *v1.Vpc, opts metav1.UpdateOptions) (*v1.Vpc, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type VpcInterface interface { // vpcs implements VpcInterface type vpcs struct { - *gentype.ClientWithList[*v1.Vpc, *v1.VpcList] + client rest.Interface } // newVpcs returns a Vpcs func newVpcs(c *KubeovnV1Client) *vpcs { return &vpcs{ - gentype.NewClientWithList[*v1.Vpc, *v1.VpcList]( - "vpcs", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.Vpc { return &v1.Vpc{} }, - func() *v1.VpcList { return &v1.VpcList{} }), + client: c.RESTClient(), } } + +// Get takes name of the vpc, and returns the corresponding vpc object, and an error if there is any. +func (c *vpcs) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.Vpc, err error) { + result = &v1.Vpc{} + err = c.client.Get(). + Resource("vpcs"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Vpcs that match those selectors. +func (c *vpcs) List(ctx context.Context, opts metav1.ListOptions) (result *v1.VpcList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.VpcList{} + err = c.client.Get(). + Resource("vpcs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested vpcs. +func (c *vpcs) 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(). + Resource("vpcs"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a vpc and creates it. Returns the server's representation of the vpc, and an error, if there is any. +func (c *vpcs) Create(ctx context.Context, vpc *v1.Vpc, opts metav1.CreateOptions) (result *v1.Vpc, err error) { + result = &v1.Vpc{} + err = c.client.Post(). + Resource("vpcs"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(vpc). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a vpc and updates it. Returns the server's representation of the vpc, and an error, if there is any. +func (c *vpcs) Update(ctx context.Context, vpc *v1.Vpc, opts metav1.UpdateOptions) (result *v1.Vpc, err error) { + result = &v1.Vpc{} + err = c.client.Put(). + Resource("vpcs"). + Name(vpc.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(vpc). + 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 *vpcs) UpdateStatus(ctx context.Context, vpc *v1.Vpc, opts metav1.UpdateOptions) (result *v1.Vpc, err error) { + result = &v1.Vpc{} + err = c.client.Put(). + Resource("vpcs"). + Name(vpc.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(vpc). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the vpc and deletes it. Returns an error if one occurs. +func (c *vpcs) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("vpcs"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *vpcs) 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(). + Resource("vpcs"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched vpc. +func (c *vpcs) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.Vpc, err error) { + result = &v1.Vpc{} + err = c.client.Patch(pt). + Resource("vpcs"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/vpcdns.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/vpcdns.go index 02e8ec80882..a5190ce56af 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/vpcdns.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/vpcdns.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // VpcDnsesGetter has a method to return a VpcDnsInterface. @@ -39,7 +40,6 @@ type VpcDnsesGetter interface { type VpcDnsInterface interface { Create(ctx context.Context, vpcDns *v1.VpcDns, opts metav1.CreateOptions) (*v1.VpcDns, error) Update(ctx context.Context, vpcDns *v1.VpcDns, opts metav1.UpdateOptions) (*v1.VpcDns, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, vpcDns *v1.VpcDns, opts metav1.UpdateOptions) (*v1.VpcDns, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type VpcDnsInterface interface { // vpcDnses implements VpcDnsInterface type vpcDnses struct { - *gentype.ClientWithList[*v1.VpcDns, *v1.VpcDnsList] + client rest.Interface } // newVpcDnses returns a VpcDnses func newVpcDnses(c *KubeovnV1Client) *vpcDnses { return &vpcDnses{ - gentype.NewClientWithList[*v1.VpcDns, *v1.VpcDnsList]( - "vpc-dnses", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.VpcDns { return &v1.VpcDns{} }, - func() *v1.VpcDnsList { return &v1.VpcDnsList{} }), + client: c.RESTClient(), } } + +// Get takes name of the vpcDns, and returns the corresponding vpcDns object, and an error if there is any. +func (c *vpcDnses) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.VpcDns, err error) { + result = &v1.VpcDns{} + err = c.client.Get(). + Resource("vpc-dnses"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of VpcDnses that match those selectors. +func (c *vpcDnses) List(ctx context.Context, opts metav1.ListOptions) (result *v1.VpcDnsList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.VpcDnsList{} + err = c.client.Get(). + Resource("vpc-dnses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested vpcDnses. +func (c *vpcDnses) 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(). + Resource("vpc-dnses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a vpcDns and creates it. Returns the server's representation of the vpcDns, and an error, if there is any. +func (c *vpcDnses) Create(ctx context.Context, vpcDns *v1.VpcDns, opts metav1.CreateOptions) (result *v1.VpcDns, err error) { + result = &v1.VpcDns{} + err = c.client.Post(). + Resource("vpc-dnses"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(vpcDns). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a vpcDns and updates it. Returns the server's representation of the vpcDns, and an error, if there is any. +func (c *vpcDnses) Update(ctx context.Context, vpcDns *v1.VpcDns, opts metav1.UpdateOptions) (result *v1.VpcDns, err error) { + result = &v1.VpcDns{} + err = c.client.Put(). + Resource("vpc-dnses"). + Name(vpcDns.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(vpcDns). + 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 *vpcDnses) UpdateStatus(ctx context.Context, vpcDns *v1.VpcDns, opts metav1.UpdateOptions) (result *v1.VpcDns, err error) { + result = &v1.VpcDns{} + err = c.client.Put(). + Resource("vpc-dnses"). + Name(vpcDns.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(vpcDns). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the vpcDns and deletes it. Returns an error if one occurs. +func (c *vpcDnses) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("vpc-dnses"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *vpcDnses) 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(). + Resource("vpc-dnses"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched vpcDns. +func (c *vpcDnses) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.VpcDns, err error) { + result = &v1.VpcDns{} + err = c.client.Patch(pt). + Resource("vpc-dnses"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/kubeovn/v1/vpcnatgateway.go b/pkg/client/clientset/versioned/typed/kubeovn/v1/vpcnatgateway.go index d94f35ce6ab..074523ed533 100644 --- a/pkg/client/clientset/versioned/typed/kubeovn/v1/vpcnatgateway.go +++ b/pkg/client/clientset/versioned/typed/kubeovn/v1/vpcnatgateway.go @@ -20,13 +20,14 @@ package v1 import ( "context" + "time" v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" scheme "github.com/kubeovn/kube-ovn/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" - gentype "k8s.io/client-go/gentype" + rest "k8s.io/client-go/rest" ) // VpcNatGatewaysGetter has a method to return a VpcNatGatewayInterface. @@ -39,7 +40,6 @@ type VpcNatGatewaysGetter interface { type VpcNatGatewayInterface interface { Create(ctx context.Context, vpcNatGateway *v1.VpcNatGateway, opts metav1.CreateOptions) (*v1.VpcNatGateway, error) Update(ctx context.Context, vpcNatGateway *v1.VpcNatGateway, opts metav1.UpdateOptions) (*v1.VpcNatGateway, error) - // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). UpdateStatus(ctx context.Context, vpcNatGateway *v1.VpcNatGateway, opts metav1.UpdateOptions) (*v1.VpcNatGateway, error) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error @@ -52,18 +52,133 @@ type VpcNatGatewayInterface interface { // vpcNatGateways implements VpcNatGatewayInterface type vpcNatGateways struct { - *gentype.ClientWithList[*v1.VpcNatGateway, *v1.VpcNatGatewayList] + client rest.Interface } // newVpcNatGateways returns a VpcNatGateways func newVpcNatGateways(c *KubeovnV1Client) *vpcNatGateways { return &vpcNatGateways{ - gentype.NewClientWithList[*v1.VpcNatGateway, *v1.VpcNatGatewayList]( - "vpc-nat-gateways", - c.RESTClient(), - scheme.ParameterCodec, - "", - func() *v1.VpcNatGateway { return &v1.VpcNatGateway{} }, - func() *v1.VpcNatGatewayList { return &v1.VpcNatGatewayList{} }), + client: c.RESTClient(), } } + +// Get takes name of the vpcNatGateway, and returns the corresponding vpcNatGateway object, and an error if there is any. +func (c *vpcNatGateways) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.VpcNatGateway, err error) { + result = &v1.VpcNatGateway{} + err = c.client.Get(). + Resource("vpc-nat-gateways"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of VpcNatGateways that match those selectors. +func (c *vpcNatGateways) List(ctx context.Context, opts metav1.ListOptions) (result *v1.VpcNatGatewayList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.VpcNatGatewayList{} + err = c.client.Get(). + Resource("vpc-nat-gateways"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested vpcNatGateways. +func (c *vpcNatGateways) 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(). + Resource("vpc-nat-gateways"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a vpcNatGateway and creates it. Returns the server's representation of the vpcNatGateway, and an error, if there is any. +func (c *vpcNatGateways) Create(ctx context.Context, vpcNatGateway *v1.VpcNatGateway, opts metav1.CreateOptions) (result *v1.VpcNatGateway, err error) { + result = &v1.VpcNatGateway{} + err = c.client.Post(). + Resource("vpc-nat-gateways"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(vpcNatGateway). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a vpcNatGateway and updates it. Returns the server's representation of the vpcNatGateway, and an error, if there is any. +func (c *vpcNatGateways) Update(ctx context.Context, vpcNatGateway *v1.VpcNatGateway, opts metav1.UpdateOptions) (result *v1.VpcNatGateway, err error) { + result = &v1.VpcNatGateway{} + err = c.client.Put(). + Resource("vpc-nat-gateways"). + Name(vpcNatGateway.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(vpcNatGateway). + 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 *vpcNatGateways) UpdateStatus(ctx context.Context, vpcNatGateway *v1.VpcNatGateway, opts metav1.UpdateOptions) (result *v1.VpcNatGateway, err error) { + result = &v1.VpcNatGateway{} + err = c.client.Put(). + Resource("vpc-nat-gateways"). + Name(vpcNatGateway.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(vpcNatGateway). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the vpcNatGateway and deletes it. Returns an error if one occurs. +func (c *vpcNatGateways) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("vpc-nat-gateways"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *vpcNatGateways) 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(). + Resource("vpc-nat-gateways"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched vpcNatGateway. +func (c *vpcNatGateways) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.VpcNatGateway, err error) { + result = &v1.VpcNatGateway{} + err = c.client.Patch(pt). + Resource("vpc-nat-gateways"). + 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 fc814f1999b..23bfb16bd5c 100644 --- a/pkg/client/informers/externalversions/factory.go +++ b/pkg/client/informers/externalversions/factory.go @@ -42,7 +42,6 @@ type sharedInformerFactory struct { lock sync.Mutex defaultResync time.Duration customResync map[reflect.Type]time.Duration - transform cache.TransformFunc informers map[reflect.Type]cache.SharedIndexInformer // startedInformers is used for tracking which informers have been started. @@ -81,14 +80,6 @@ func WithNamespace(namespace string) SharedInformerOption { } } -// WithTransform sets a transform on all informers. -func WithTransform(transform cache.TransformFunc) SharedInformerOption { - return func(factory *sharedInformerFactory) *sharedInformerFactory { - factory.transform = transform - return factory - } -} - // NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { return NewSharedInformerFactoryWithOptions(client, defaultResync) @@ -193,7 +184,6 @@ func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internal } informer = newFunc(f.client, resyncPeriod) - informer.SetTransform(f.transform) f.informers[informerType] = informer return informer @@ -228,7 +218,6 @@ 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/kubeovn/v1/ip.go b/pkg/client/listers/kubeovn/v1/ip.go index e32e6099ee9..7e86509820f 100644 --- a/pkg/client/listers/kubeovn/v1/ip.go +++ b/pkg/client/listers/kubeovn/v1/ip.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type IPLister interface { // iPLister implements the IPLister interface. type iPLister struct { - listers.ResourceIndexer[*v1.IP] + indexer cache.Indexer } // NewIPLister returns a new IPLister. func NewIPLister(indexer cache.Indexer) IPLister { - return &iPLister{listers.New[*v1.IP](indexer, v1.Resource("ip"))} + return &iPLister{indexer: indexer} +} + +// List lists all IPs in the indexer. +func (s *iPLister) List(selector labels.Selector) (ret []*v1.IP, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.IP)) + }) + return ret, err +} + +// Get retrieves the IP from the index for a given name. +func (s *iPLister) Get(name string) (*v1.IP, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("ip"), name) + } + return obj.(*v1.IP), nil } diff --git a/pkg/client/listers/kubeovn/v1/ippool.go b/pkg/client/listers/kubeovn/v1/ippool.go index cfb6329f8d3..95058c4a38f 100644 --- a/pkg/client/listers/kubeovn/v1/ippool.go +++ b/pkg/client/listers/kubeovn/v1/ippool.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type IPPoolLister interface { // iPPoolLister implements the IPPoolLister interface. type iPPoolLister struct { - listers.ResourceIndexer[*v1.IPPool] + indexer cache.Indexer } // NewIPPoolLister returns a new IPPoolLister. func NewIPPoolLister(indexer cache.Indexer) IPPoolLister { - return &iPPoolLister{listers.New[*v1.IPPool](indexer, v1.Resource("ippool"))} + return &iPPoolLister{indexer: indexer} +} + +// List lists all IPPools in the indexer. +func (s *iPPoolLister) List(selector labels.Selector) (ret []*v1.IPPool, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.IPPool)) + }) + return ret, err +} + +// Get retrieves the IPPool from the index for a given name. +func (s *iPPoolLister) Get(name string) (*v1.IPPool, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("ippool"), name) + } + return obj.(*v1.IPPool), nil } diff --git a/pkg/client/listers/kubeovn/v1/iptablesdnatrule.go b/pkg/client/listers/kubeovn/v1/iptablesdnatrule.go index 94e98336ef8..ade64f00764 100644 --- a/pkg/client/listers/kubeovn/v1/iptablesdnatrule.go +++ b/pkg/client/listers/kubeovn/v1/iptablesdnatrule.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type IptablesDnatRuleLister interface { // iptablesDnatRuleLister implements the IptablesDnatRuleLister interface. type iptablesDnatRuleLister struct { - listers.ResourceIndexer[*v1.IptablesDnatRule] + indexer cache.Indexer } // NewIptablesDnatRuleLister returns a new IptablesDnatRuleLister. func NewIptablesDnatRuleLister(indexer cache.Indexer) IptablesDnatRuleLister { - return &iptablesDnatRuleLister{listers.New[*v1.IptablesDnatRule](indexer, v1.Resource("iptablesdnatrule"))} + return &iptablesDnatRuleLister{indexer: indexer} +} + +// List lists all IptablesDnatRules in the indexer. +func (s *iptablesDnatRuleLister) List(selector labels.Selector) (ret []*v1.IptablesDnatRule, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.IptablesDnatRule)) + }) + return ret, err +} + +// Get retrieves the IptablesDnatRule from the index for a given name. +func (s *iptablesDnatRuleLister) Get(name string) (*v1.IptablesDnatRule, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("iptablesdnatrule"), name) + } + return obj.(*v1.IptablesDnatRule), nil } diff --git a/pkg/client/listers/kubeovn/v1/iptableseip.go b/pkg/client/listers/kubeovn/v1/iptableseip.go index 160e8c5f586..f76d6f6b59d 100644 --- a/pkg/client/listers/kubeovn/v1/iptableseip.go +++ b/pkg/client/listers/kubeovn/v1/iptableseip.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type IptablesEIPLister interface { // iptablesEIPLister implements the IptablesEIPLister interface. type iptablesEIPLister struct { - listers.ResourceIndexer[*v1.IptablesEIP] + indexer cache.Indexer } // NewIptablesEIPLister returns a new IptablesEIPLister. func NewIptablesEIPLister(indexer cache.Indexer) IptablesEIPLister { - return &iptablesEIPLister{listers.New[*v1.IptablesEIP](indexer, v1.Resource("iptableseip"))} + return &iptablesEIPLister{indexer: indexer} +} + +// List lists all IptablesEIPs in the indexer. +func (s *iptablesEIPLister) List(selector labels.Selector) (ret []*v1.IptablesEIP, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.IptablesEIP)) + }) + return ret, err +} + +// Get retrieves the IptablesEIP from the index for a given name. +func (s *iptablesEIPLister) Get(name string) (*v1.IptablesEIP, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("iptableseip"), name) + } + return obj.(*v1.IptablesEIP), nil } diff --git a/pkg/client/listers/kubeovn/v1/iptablesfiprule.go b/pkg/client/listers/kubeovn/v1/iptablesfiprule.go index d97baf245d3..dccd3b371a2 100644 --- a/pkg/client/listers/kubeovn/v1/iptablesfiprule.go +++ b/pkg/client/listers/kubeovn/v1/iptablesfiprule.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type IptablesFIPRuleLister interface { // iptablesFIPRuleLister implements the IptablesFIPRuleLister interface. type iptablesFIPRuleLister struct { - listers.ResourceIndexer[*v1.IptablesFIPRule] + indexer cache.Indexer } // NewIptablesFIPRuleLister returns a new IptablesFIPRuleLister. func NewIptablesFIPRuleLister(indexer cache.Indexer) IptablesFIPRuleLister { - return &iptablesFIPRuleLister{listers.New[*v1.IptablesFIPRule](indexer, v1.Resource("iptablesfiprule"))} + return &iptablesFIPRuleLister{indexer: indexer} +} + +// List lists all IptablesFIPRules in the indexer. +func (s *iptablesFIPRuleLister) List(selector labels.Selector) (ret []*v1.IptablesFIPRule, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.IptablesFIPRule)) + }) + return ret, err +} + +// Get retrieves the IptablesFIPRule from the index for a given name. +func (s *iptablesFIPRuleLister) Get(name string) (*v1.IptablesFIPRule, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("iptablesfiprule"), name) + } + return obj.(*v1.IptablesFIPRule), nil } diff --git a/pkg/client/listers/kubeovn/v1/iptablessnatrule.go b/pkg/client/listers/kubeovn/v1/iptablessnatrule.go index cc81db98247..7308fd8388c 100644 --- a/pkg/client/listers/kubeovn/v1/iptablessnatrule.go +++ b/pkg/client/listers/kubeovn/v1/iptablessnatrule.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type IptablesSnatRuleLister interface { // iptablesSnatRuleLister implements the IptablesSnatRuleLister interface. type iptablesSnatRuleLister struct { - listers.ResourceIndexer[*v1.IptablesSnatRule] + indexer cache.Indexer } // NewIptablesSnatRuleLister returns a new IptablesSnatRuleLister. func NewIptablesSnatRuleLister(indexer cache.Indexer) IptablesSnatRuleLister { - return &iptablesSnatRuleLister{listers.New[*v1.IptablesSnatRule](indexer, v1.Resource("iptablessnatrule"))} + return &iptablesSnatRuleLister{indexer: indexer} +} + +// List lists all IptablesSnatRules in the indexer. +func (s *iptablesSnatRuleLister) List(selector labels.Selector) (ret []*v1.IptablesSnatRule, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.IptablesSnatRule)) + }) + return ret, err +} + +// Get retrieves the IptablesSnatRule from the index for a given name. +func (s *iptablesSnatRuleLister) Get(name string) (*v1.IptablesSnatRule, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("iptablessnatrule"), name) + } + return obj.(*v1.IptablesSnatRule), nil } diff --git a/pkg/client/listers/kubeovn/v1/ovndnatrule.go b/pkg/client/listers/kubeovn/v1/ovndnatrule.go index fd17243985f..629841e1e0a 100644 --- a/pkg/client/listers/kubeovn/v1/ovndnatrule.go +++ b/pkg/client/listers/kubeovn/v1/ovndnatrule.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type OvnDnatRuleLister interface { // ovnDnatRuleLister implements the OvnDnatRuleLister interface. type ovnDnatRuleLister struct { - listers.ResourceIndexer[*v1.OvnDnatRule] + indexer cache.Indexer } // NewOvnDnatRuleLister returns a new OvnDnatRuleLister. func NewOvnDnatRuleLister(indexer cache.Indexer) OvnDnatRuleLister { - return &ovnDnatRuleLister{listers.New[*v1.OvnDnatRule](indexer, v1.Resource("ovndnatrule"))} + return &ovnDnatRuleLister{indexer: indexer} +} + +// List lists all OvnDnatRules in the indexer. +func (s *ovnDnatRuleLister) List(selector labels.Selector) (ret []*v1.OvnDnatRule, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.OvnDnatRule)) + }) + return ret, err +} + +// Get retrieves the OvnDnatRule from the index for a given name. +func (s *ovnDnatRuleLister) Get(name string) (*v1.OvnDnatRule, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("ovndnatrule"), name) + } + return obj.(*v1.OvnDnatRule), nil } diff --git a/pkg/client/listers/kubeovn/v1/ovneip.go b/pkg/client/listers/kubeovn/v1/ovneip.go index 1f5ac201242..534fe338ca0 100644 --- a/pkg/client/listers/kubeovn/v1/ovneip.go +++ b/pkg/client/listers/kubeovn/v1/ovneip.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type OvnEipLister interface { // ovnEipLister implements the OvnEipLister interface. type ovnEipLister struct { - listers.ResourceIndexer[*v1.OvnEip] + indexer cache.Indexer } // NewOvnEipLister returns a new OvnEipLister. func NewOvnEipLister(indexer cache.Indexer) OvnEipLister { - return &ovnEipLister{listers.New[*v1.OvnEip](indexer, v1.Resource("ovneip"))} + return &ovnEipLister{indexer: indexer} +} + +// List lists all OvnEips in the indexer. +func (s *ovnEipLister) List(selector labels.Selector) (ret []*v1.OvnEip, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.OvnEip)) + }) + return ret, err +} + +// Get retrieves the OvnEip from the index for a given name. +func (s *ovnEipLister) Get(name string) (*v1.OvnEip, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("ovneip"), name) + } + return obj.(*v1.OvnEip), nil } diff --git a/pkg/client/listers/kubeovn/v1/ovnfip.go b/pkg/client/listers/kubeovn/v1/ovnfip.go index a7276b125ee..24173bac404 100644 --- a/pkg/client/listers/kubeovn/v1/ovnfip.go +++ b/pkg/client/listers/kubeovn/v1/ovnfip.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type OvnFipLister interface { // ovnFipLister implements the OvnFipLister interface. type ovnFipLister struct { - listers.ResourceIndexer[*v1.OvnFip] + indexer cache.Indexer } // NewOvnFipLister returns a new OvnFipLister. func NewOvnFipLister(indexer cache.Indexer) OvnFipLister { - return &ovnFipLister{listers.New[*v1.OvnFip](indexer, v1.Resource("ovnfip"))} + return &ovnFipLister{indexer: indexer} +} + +// List lists all OvnFips in the indexer. +func (s *ovnFipLister) List(selector labels.Selector) (ret []*v1.OvnFip, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.OvnFip)) + }) + return ret, err +} + +// Get retrieves the OvnFip from the index for a given name. +func (s *ovnFipLister) Get(name string) (*v1.OvnFip, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("ovnfip"), name) + } + return obj.(*v1.OvnFip), nil } diff --git a/pkg/client/listers/kubeovn/v1/ovnsnatrule.go b/pkg/client/listers/kubeovn/v1/ovnsnatrule.go index 5944b06bd6f..1610f4e0688 100644 --- a/pkg/client/listers/kubeovn/v1/ovnsnatrule.go +++ b/pkg/client/listers/kubeovn/v1/ovnsnatrule.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type OvnSnatRuleLister interface { // ovnSnatRuleLister implements the OvnSnatRuleLister interface. type ovnSnatRuleLister struct { - listers.ResourceIndexer[*v1.OvnSnatRule] + indexer cache.Indexer } // NewOvnSnatRuleLister returns a new OvnSnatRuleLister. func NewOvnSnatRuleLister(indexer cache.Indexer) OvnSnatRuleLister { - return &ovnSnatRuleLister{listers.New[*v1.OvnSnatRule](indexer, v1.Resource("ovnsnatrule"))} + return &ovnSnatRuleLister{indexer: indexer} +} + +// List lists all OvnSnatRules in the indexer. +func (s *ovnSnatRuleLister) List(selector labels.Selector) (ret []*v1.OvnSnatRule, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.OvnSnatRule)) + }) + return ret, err +} + +// Get retrieves the OvnSnatRule from the index for a given name. +func (s *ovnSnatRuleLister) Get(name string) (*v1.OvnSnatRule, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("ovnsnatrule"), name) + } + return obj.(*v1.OvnSnatRule), nil } diff --git a/pkg/client/listers/kubeovn/v1/providernetwork.go b/pkg/client/listers/kubeovn/v1/providernetwork.go index 4345af44697..6cd37240293 100644 --- a/pkg/client/listers/kubeovn/v1/providernetwork.go +++ b/pkg/client/listers/kubeovn/v1/providernetwork.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type ProviderNetworkLister interface { // providerNetworkLister implements the ProviderNetworkLister interface. type providerNetworkLister struct { - listers.ResourceIndexer[*v1.ProviderNetwork] + indexer cache.Indexer } // NewProviderNetworkLister returns a new ProviderNetworkLister. func NewProviderNetworkLister(indexer cache.Indexer) ProviderNetworkLister { - return &providerNetworkLister{listers.New[*v1.ProviderNetwork](indexer, v1.Resource("providernetwork"))} + return &providerNetworkLister{indexer: indexer} +} + +// List lists all ProviderNetworks in the indexer. +func (s *providerNetworkLister) List(selector labels.Selector) (ret []*v1.ProviderNetwork, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.ProviderNetwork)) + }) + return ret, err +} + +// Get retrieves the ProviderNetwork from the index for a given name. +func (s *providerNetworkLister) Get(name string) (*v1.ProviderNetwork, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("providernetwork"), name) + } + return obj.(*v1.ProviderNetwork), nil } diff --git a/pkg/client/listers/kubeovn/v1/qospolicy.go b/pkg/client/listers/kubeovn/v1/qospolicy.go index 2994089bb47..dd9acf2250d 100644 --- a/pkg/client/listers/kubeovn/v1/qospolicy.go +++ b/pkg/client/listers/kubeovn/v1/qospolicy.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type QoSPolicyLister interface { // qoSPolicyLister implements the QoSPolicyLister interface. type qoSPolicyLister struct { - listers.ResourceIndexer[*v1.QoSPolicy] + indexer cache.Indexer } // NewQoSPolicyLister returns a new QoSPolicyLister. func NewQoSPolicyLister(indexer cache.Indexer) QoSPolicyLister { - return &qoSPolicyLister{listers.New[*v1.QoSPolicy](indexer, v1.Resource("qospolicy"))} + return &qoSPolicyLister{indexer: indexer} +} + +// List lists all QoSPolicies in the indexer. +func (s *qoSPolicyLister) List(selector labels.Selector) (ret []*v1.QoSPolicy, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.QoSPolicy)) + }) + return ret, err +} + +// Get retrieves the QoSPolicy from the index for a given name. +func (s *qoSPolicyLister) Get(name string) (*v1.QoSPolicy, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("qospolicy"), name) + } + return obj.(*v1.QoSPolicy), nil } diff --git a/pkg/client/listers/kubeovn/v1/securitygroup.go b/pkg/client/listers/kubeovn/v1/securitygroup.go index 06c7a36688b..c36052ce4df 100644 --- a/pkg/client/listers/kubeovn/v1/securitygroup.go +++ b/pkg/client/listers/kubeovn/v1/securitygroup.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type SecurityGroupLister interface { // securityGroupLister implements the SecurityGroupLister interface. type securityGroupLister struct { - listers.ResourceIndexer[*v1.SecurityGroup] + indexer cache.Indexer } // NewSecurityGroupLister returns a new SecurityGroupLister. func NewSecurityGroupLister(indexer cache.Indexer) SecurityGroupLister { - return &securityGroupLister{listers.New[*v1.SecurityGroup](indexer, v1.Resource("securitygroup"))} + return &securityGroupLister{indexer: indexer} +} + +// List lists all SecurityGroups in the indexer. +func (s *securityGroupLister) List(selector labels.Selector) (ret []*v1.SecurityGroup, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.SecurityGroup)) + }) + return ret, err +} + +// Get retrieves the SecurityGroup from the index for a given name. +func (s *securityGroupLister) Get(name string) (*v1.SecurityGroup, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("securitygroup"), name) + } + return obj.(*v1.SecurityGroup), nil } diff --git a/pkg/client/listers/kubeovn/v1/subnet.go b/pkg/client/listers/kubeovn/v1/subnet.go index 25f92314f8c..43235d8bacc 100644 --- a/pkg/client/listers/kubeovn/v1/subnet.go +++ b/pkg/client/listers/kubeovn/v1/subnet.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type SubnetLister interface { // subnetLister implements the SubnetLister interface. type subnetLister struct { - listers.ResourceIndexer[*v1.Subnet] + indexer cache.Indexer } // NewSubnetLister returns a new SubnetLister. func NewSubnetLister(indexer cache.Indexer) SubnetLister { - return &subnetLister{listers.New[*v1.Subnet](indexer, v1.Resource("subnet"))} + return &subnetLister{indexer: indexer} +} + +// List lists all Subnets in the indexer. +func (s *subnetLister) List(selector labels.Selector) (ret []*v1.Subnet, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.Subnet)) + }) + return ret, err +} + +// Get retrieves the Subnet from the index for a given name. +func (s *subnetLister) Get(name string) (*v1.Subnet, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("subnet"), name) + } + return obj.(*v1.Subnet), nil } diff --git a/pkg/client/listers/kubeovn/v1/switchlbrule.go b/pkg/client/listers/kubeovn/v1/switchlbrule.go index 37d97f1b841..fd2872db147 100644 --- a/pkg/client/listers/kubeovn/v1/switchlbrule.go +++ b/pkg/client/listers/kubeovn/v1/switchlbrule.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type SwitchLBRuleLister interface { // switchLBRuleLister implements the SwitchLBRuleLister interface. type switchLBRuleLister struct { - listers.ResourceIndexer[*v1.SwitchLBRule] + indexer cache.Indexer } // NewSwitchLBRuleLister returns a new SwitchLBRuleLister. func NewSwitchLBRuleLister(indexer cache.Indexer) SwitchLBRuleLister { - return &switchLBRuleLister{listers.New[*v1.SwitchLBRule](indexer, v1.Resource("switchlbrule"))} + return &switchLBRuleLister{indexer: indexer} +} + +// List lists all SwitchLBRules in the indexer. +func (s *switchLBRuleLister) List(selector labels.Selector) (ret []*v1.SwitchLBRule, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.SwitchLBRule)) + }) + return ret, err +} + +// Get retrieves the SwitchLBRule from the index for a given name. +func (s *switchLBRuleLister) Get(name string) (*v1.SwitchLBRule, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("switchlbrule"), name) + } + return obj.(*v1.SwitchLBRule), nil } diff --git a/pkg/client/listers/kubeovn/v1/vip.go b/pkg/client/listers/kubeovn/v1/vip.go index 87736f3c7f1..95c52124b44 100644 --- a/pkg/client/listers/kubeovn/v1/vip.go +++ b/pkg/client/listers/kubeovn/v1/vip.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type VipLister interface { // vipLister implements the VipLister interface. type vipLister struct { - listers.ResourceIndexer[*v1.Vip] + indexer cache.Indexer } // NewVipLister returns a new VipLister. func NewVipLister(indexer cache.Indexer) VipLister { - return &vipLister{listers.New[*v1.Vip](indexer, v1.Resource("vip"))} + return &vipLister{indexer: indexer} +} + +// List lists all Vips in the indexer. +func (s *vipLister) List(selector labels.Selector) (ret []*v1.Vip, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.Vip)) + }) + return ret, err +} + +// Get retrieves the Vip from the index for a given name. +func (s *vipLister) Get(name string) (*v1.Vip, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("vip"), name) + } + return obj.(*v1.Vip), nil } diff --git a/pkg/client/listers/kubeovn/v1/vlan.go b/pkg/client/listers/kubeovn/v1/vlan.go index d0d5bfa595d..471c798e1d7 100644 --- a/pkg/client/listers/kubeovn/v1/vlan.go +++ b/pkg/client/listers/kubeovn/v1/vlan.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type VlanLister interface { // vlanLister implements the VlanLister interface. type vlanLister struct { - listers.ResourceIndexer[*v1.Vlan] + indexer cache.Indexer } // NewVlanLister returns a new VlanLister. func NewVlanLister(indexer cache.Indexer) VlanLister { - return &vlanLister{listers.New[*v1.Vlan](indexer, v1.Resource("vlan"))} + return &vlanLister{indexer: indexer} +} + +// List lists all Vlans in the indexer. +func (s *vlanLister) List(selector labels.Selector) (ret []*v1.Vlan, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.Vlan)) + }) + return ret, err +} + +// Get retrieves the Vlan from the index for a given name. +func (s *vlanLister) Get(name string) (*v1.Vlan, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("vlan"), name) + } + return obj.(*v1.Vlan), nil } diff --git a/pkg/client/listers/kubeovn/v1/vpc.go b/pkg/client/listers/kubeovn/v1/vpc.go index fcaac837cb4..5dcf66ea76e 100644 --- a/pkg/client/listers/kubeovn/v1/vpc.go +++ b/pkg/client/listers/kubeovn/v1/vpc.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type VpcLister interface { // vpcLister implements the VpcLister interface. type vpcLister struct { - listers.ResourceIndexer[*v1.Vpc] + indexer cache.Indexer } // NewVpcLister returns a new VpcLister. func NewVpcLister(indexer cache.Indexer) VpcLister { - return &vpcLister{listers.New[*v1.Vpc](indexer, v1.Resource("vpc"))} + return &vpcLister{indexer: indexer} +} + +// List lists all Vpcs in the indexer. +func (s *vpcLister) List(selector labels.Selector) (ret []*v1.Vpc, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.Vpc)) + }) + return ret, err +} + +// Get retrieves the Vpc from the index for a given name. +func (s *vpcLister) Get(name string) (*v1.Vpc, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("vpc"), name) + } + return obj.(*v1.Vpc), nil } diff --git a/pkg/client/listers/kubeovn/v1/vpcdns.go b/pkg/client/listers/kubeovn/v1/vpcdns.go index d3649c528b1..5eaf1929c5f 100644 --- a/pkg/client/listers/kubeovn/v1/vpcdns.go +++ b/pkg/client/listers/kubeovn/v1/vpcdns.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type VpcDnsLister interface { // vpcDnsLister implements the VpcDnsLister interface. type vpcDnsLister struct { - listers.ResourceIndexer[*v1.VpcDns] + indexer cache.Indexer } // NewVpcDnsLister returns a new VpcDnsLister. func NewVpcDnsLister(indexer cache.Indexer) VpcDnsLister { - return &vpcDnsLister{listers.New[*v1.VpcDns](indexer, v1.Resource("vpcdns"))} + return &vpcDnsLister{indexer: indexer} +} + +// List lists all VpcDnses in the indexer. +func (s *vpcDnsLister) List(selector labels.Selector) (ret []*v1.VpcDns, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.VpcDns)) + }) + return ret, err +} + +// Get retrieves the VpcDns from the index for a given name. +func (s *vpcDnsLister) Get(name string) (*v1.VpcDns, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("vpcdns"), name) + } + return obj.(*v1.VpcDns), nil } diff --git a/pkg/client/listers/kubeovn/v1/vpcnatgateway.go b/pkg/client/listers/kubeovn/v1/vpcnatgateway.go index 845fe60ec35..d4e578d34df 100644 --- a/pkg/client/listers/kubeovn/v1/vpcnatgateway.go +++ b/pkg/client/listers/kubeovn/v1/vpcnatgateway.go @@ -20,8 +20,8 @@ package v1 import ( v1 "github.com/kubeovn/kube-ovn/pkg/apis/kubeovn/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/listers" "k8s.io/client-go/tools/cache" ) @@ -39,10 +39,30 @@ type VpcNatGatewayLister interface { // vpcNatGatewayLister implements the VpcNatGatewayLister interface. type vpcNatGatewayLister struct { - listers.ResourceIndexer[*v1.VpcNatGateway] + indexer cache.Indexer } // NewVpcNatGatewayLister returns a new VpcNatGatewayLister. func NewVpcNatGatewayLister(indexer cache.Indexer) VpcNatGatewayLister { - return &vpcNatGatewayLister{listers.New[*v1.VpcNatGateway](indexer, v1.Resource("vpcnatgateway"))} + return &vpcNatGatewayLister{indexer: indexer} +} + +// List lists all VpcNatGateways in the indexer. +func (s *vpcNatGatewayLister) List(selector labels.Selector) (ret []*v1.VpcNatGateway, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.VpcNatGateway)) + }) + return ret, err +} + +// Get retrieves the VpcNatGateway from the index for a given name. +func (s *vpcNatGatewayLister) Get(name string) (*v1.VpcNatGateway, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("vpcnatgateway"), name) + } + return obj.(*v1.VpcNatGateway), nil } diff --git a/pkg/controller/namespace.go b/pkg/controller/namespace.go index aac80e456cd..a31030c9e22 100644 --- a/pkg/controller/namespace.go +++ b/pkg/controller/namespace.go @@ -10,6 +10,7 @@ import ( "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/selection" "k8s.io/apimachinery/pkg/types" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/client-go/tools/cache" @@ -63,6 +64,40 @@ func (c *Controller) enqueueUpdateNamespace(oldObj, newObj interface{}) { if c.config.EnableANP { c.updateAnpsByLabelsMatch(newObj.(*v1.Namespace).Labels, nil) } + + var expectSubnets []string + subnets, err := c.subnetsLister.List(labels.Everything()) + if err != nil { + klog.Errorf("failed to list subnets %v", err) + return + } + for _, subnet := range subnets { + changed := false + for _, nsSelector := range subnet.Spec.NamespaceSelector { + matchSelector, err := mergeSelector(nsSelector) + if err != nil { + klog.Errorf("failed to merge selector, %v", err) + return + } + + if matchSelector.Matches(labels.Set(newNs.Labels)) { + c.addNamespaceQueue.Add(newNs.Name) + changed = true + break + } + } + if changed { + break + } + + if slices.Contains(subnet.Spec.Namespaces, newNs.Name) { + expectSubnets = append(expectSubnets, subnet.Name) + } + } + // when ns delete labels which match subnet.spec.namespaceSelector, the annotation logical_switch for the ns will be updated + if !slices.Equal(expectSubnets, strings.Split(newNs.Annotations[util.LogicalSwitchAnnotation], ",")) { + c.addNamespaceQueue.Add(newNs.Name) + } } // in case annotations are removed by other controllers @@ -70,10 +105,6 @@ func (c *Controller) enqueueUpdateNamespace(oldObj, newObj interface{}) { klog.Warningf("no logical switch annotation for ns %s", newNs.Name) c.addNamespaceQueue.Add(newNs.Name) } - - if newNs.Annotations != nil && newNs.Annotations[util.LogicalSwitchAnnotation] != "" && !reflect.DeepEqual(oldNs.Annotations, newNs.Annotations) { - c.addNamespaceQueue.Add(newNs.Name) - } } func (c *Controller) handleAddNamespace(key string) error { @@ -114,6 +145,26 @@ func (c *Controller) handleAddNamespace(key string) error { break } } + + // bind subnet with namespaceLabelSeletcor which select the namespace + for _, nsSelector := range s.Spec.NamespaceSelector { + matchSelector, err := mergeSelector(nsSelector) + if err != nil { + klog.Errorf("failed to merge selector, %v", err) + return err + } + + if matchSelector.Matches(labels.Set(namespace.Labels)) { + if slices.Contains(lss, s.Name) { + break + } + lss = append(lss, s.Name) + cidrs = append(cidrs, s.Spec.CIDRBlock) + excludeIps = append(excludeIps, strings.Join(s.Spec.ExcludeIps, ",")) + break + } + } + // check if subnet is in custom vpc with configured defaultSubnet, then annotate the namespace with this subnet if s.Spec.Vpc != "" && s.Spec.Vpc != c.config.ClusterRouter { vpc, err := c.vpcsLister.Get(s.Spec.Vpc) @@ -198,3 +249,16 @@ func (c *Controller) handleAddNamespace(key string) error { } return err } + +func mergeSelector(nsSelector metav1.LabelSelector) (labels.Selector, error) { + matchSelector := labels.Set(nsSelector.MatchLabels).AsSelector() + for _, express := range nsSelector.MatchExpressions { + selectorRequirement, err := labels.NewRequirement(express.Key, selection.Operator(strings.ToLower(string(express.Operator))), express.Values) + if err != nil { + klog.Errorf("failed to get MatchExpressions selector, %v", err) + return matchSelector, err + } + matchSelector = matchSelector.Add(*selectorRequirement) + } + return matchSelector, nil +} diff --git a/pkg/controller/subnet.go b/pkg/controller/subnet.go index 47eefb25dca..f1cf46b1aed 100644 --- a/pkg/controller/subnet.go +++ b/pkg/controller/subnet.go @@ -14,6 +14,7 @@ import ( "time" "github.com/ovn-org/libovsdb/ovsdb" + "github.com/scylladb/go-set/strset" v1 "k8s.io/api/core/v1" k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -134,6 +135,7 @@ func (c *Controller) enqueueUpdateSubnet(oldObj, newObj interface{}) { oldSubnet.Spec.NatOutgoing != newSubnet.Spec.NatOutgoing || oldSubnet.Spec.EnableMulticastSnoop != newSubnet.Spec.EnableMulticastSnoop || !reflect.DeepEqual(oldSubnet.Spec.NatOutgoingPolicyRules, newSubnet.Spec.NatOutgoingPolicyRules) || + !reflect.DeepEqual(oldSubnet.Spec.NamespaceSelector, newSubnet.Spec.NamespaceSelector) || (newSubnet.Spec.U2OInterconnection && newSubnet.Spec.U2OInterconnectionIP != "" && oldSubnet.Spec.U2OInterconnectionIP != newSubnet.Spec.U2OInterconnectionIP) { klog.V(3).Infof("enqueue update subnet %s", key) @@ -374,23 +376,23 @@ func (c *Controller) syncSubnetFinalizer(cl client.Client) error { }) } -func (c *Controller) handleSubnetFinalizer(subnet *kubeovnv1.Subnet) (bool, error) { +func (c *Controller) handleSubnetFinalizer(subnet *kubeovnv1.Subnet) (*kubeovnv1.Subnet, bool, error) { if subnet.DeletionTimestamp.IsZero() && len(subnet.GetFinalizers()) == 0 { newSubnet := subnet.DeepCopy() controllerutil.AddFinalizer(newSubnet, util.KubeOVNControllerFinalizer) patch, err := util.GenerateMergePatchPayload(subnet, newSubnet) if err != nil { klog.Errorf("failed to generate patch payload for subnet '%s', %v", subnet.Name, err) - return false, err + return newSubnet, false, err } - if _, err := c.config.KubeOvnClient.KubeovnV1().Subnets().Patch(context.Background(), subnet.Name, - types.MergePatchType, patch, metav1.PatchOptions{}, ""); err != nil { + patchSubnet, err := c.config.KubeOvnClient.KubeovnV1().Subnets().Patch(context.Background(), subnet.Name, types.MergePatchType, patch, metav1.PatchOptions{}, "") + if err != nil { klog.Errorf("failed to add finalizer to subnet %s, %v", subnet.Name, err) - return false, err + return patchSubnet, false, err } // wait local cache ready time.Sleep(1 * time.Second) - return false, nil + return patchSubnet, false, nil } usingIPs := subnet.Status.V4UsingIPs @@ -405,19 +407,19 @@ func (c *Controller) handleSubnetFinalizer(subnet *kubeovnv1.Subnet) (bool, erro patch, err := util.GenerateMergePatchPayload(subnet, newSubnet) if err != nil { klog.Errorf("failed to generate patch payload for subnet '%s', %v", subnet.Name, err) - return false, err + return newSubnet, false, err } if _, err := c.config.KubeOvnClient.KubeovnV1().Subnets().Patch(context.Background(), subnet.Name, types.MergePatchType, patch, metav1.PatchOptions{}, ""); err != nil { klog.Errorf("failed to remove finalizer from subnet %s, %v", subnet.Name, err) - return false, err + return newSubnet, false, err } - return true, nil + return newSubnet, true, nil } - return false, nil + return subnet, false, nil } -func (c Controller) patchSubnetStatus(subnet *kubeovnv1.Subnet, reason, errStr string) error { +func (c Controller) patchSubnetStatus(subnet *kubeovnv1.Subnet, reason, errStr string) (*kubeovnv1.Subnet, error) { if errStr != "" { subnet.Status.SetError(reason, errStr) if reason == "ValidateLogicalSwitchFailed" { @@ -441,13 +443,13 @@ func (c Controller) patchSubnetStatus(subnet *kubeovnv1.Subnet, reason, errStr s bytes, err := subnet.Status.Bytes() if err != nil { klog.Error(err) - return err + return subnet, err } - if _, err := c.config.KubeOvnClient.KubeovnV1().Subnets().Patch(context.Background(), subnet.Name, types.MergePatchType, bytes, metav1.PatchOptions{}, "status"); err != nil { + newSubnet, err := c.config.KubeOvnClient.KubeovnV1().Subnets().Patch(context.Background(), subnet.Name, types.MergePatchType, bytes, metav1.PatchOptions{}, "status") + if err != nil { klog.Errorf("failed to patch status for subnet %s, %v", subnet.Name, err) - return err } - return nil + return newSubnet, err } func (c *Controller) validateVpcBySubnet(subnet *kubeovnv1.Subnet) (*kubeovnv1.Vpc, error) { @@ -505,7 +507,7 @@ func (c *Controller) checkSubnetConflict(subnet *kubeovnv1.Subnet) error { if util.CIDROverlap(sub.Spec.CIDRBlock, subnet.Spec.CIDRBlock) { err = fmt.Errorf("subnet %s cidr %s is conflict with subnet %s cidr %s", subnet.Name, subnet.Spec.CIDRBlock, sub.Name, sub.Spec.CIDRBlock) klog.Error(err) - if err = c.patchSubnetStatus(subnet, "ValidateLogicalSwitchFailed", err.Error()); err != nil { + if _, err = c.patchSubnetStatus(subnet, "ValidateLogicalSwitchFailed", err.Error()); err != nil { klog.Error(err) return err } @@ -516,7 +518,7 @@ func (c *Controller) checkSubnetConflict(subnet *kubeovnv1.Subnet) error { subnet.Spec.PolicyRoutingTableID == sub.Spec.PolicyRoutingTableID { err = fmt.Errorf("subnet %s policy routing table ID %d is conflict with subnet %s policy routing table ID %d", subnet.Name, subnet.Spec.PolicyRoutingTableID, sub.Name, sub.Spec.PolicyRoutingTableID) klog.Error(err) - if err = c.patchSubnetStatus(subnet, "ValidateLogicalSwitchFailed", err.Error()); err != nil { + if _, err = c.patchSubnetStatus(subnet, "ValidateLogicalSwitchFailed", err.Error()); err != nil { klog.Error(err) return err } @@ -535,7 +537,7 @@ func (c *Controller) checkSubnetConflict(subnet *kubeovnv1.Subnet) error { if addr.Type == v1.NodeInternalIP && util.CIDRContainIP(subnet.Spec.CIDRBlock, addr.Address) { err = fmt.Errorf("subnet %s cidr %s conflict with node %s address %s", subnet.Name, subnet.Spec.CIDRBlock, node.Name, addr.Address) klog.Error(err) - if err = c.patchSubnetStatus(subnet, "ValidateLogicalSwitchFailed", err.Error()); err != nil { + if _, err = c.patchSubnetStatus(subnet, "ValidateLogicalSwitchFailed", err.Error()); err != nil { klog.Error(err) return err } @@ -629,13 +631,13 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error { if err = util.ValidateSubnet(*subnet); err != nil { klog.Errorf("failed to validate subnet %s, %v", subnet.Name, err) - if err = c.patchSubnetStatus(subnet, "ValidateLogicalSwitchFailed", err.Error()); err != nil { + if _, err = c.patchSubnetStatus(subnet, "ValidateLogicalSwitchFailed", err.Error()); err != nil { klog.Error(err) return err } return err } - if err = c.patchSubnetStatus(subnet, "ValidateLogicalSwitchSuccess", ""); err != nil { + if subnet, err = c.patchSubnetStatus(subnet, "ValidateLogicalSwitchSuccess", ""); err != nil { klog.Error(err) return err } @@ -656,7 +658,7 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error { return err } - deleted, err := c.handleSubnetFinalizer(subnet) + subnet, deleted, err := c.handleSubnetFinalizer(subnet) if err != nil { klog.Errorf("handle subnet finalizer failed %v", err) return err @@ -667,7 +669,7 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error { if !isOvnSubnet(subnet) { // subnet provider is not ovn, and vpc is empty, should not reconcile - if err = c.patchSubnetStatus(subnet, "SetNonOvnSubnetSuccess", ""); err != nil { + if _, err = c.patchSubnetStatus(subnet, "SetNonOvnSubnetSuccess", ""); err != nil { klog.Error(err) return err } @@ -743,7 +745,7 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error { } if subnet.Spec.EnableLb != nil && *subnet.Spec.EnableLb { if err := c.OVNNbClient.LogicalSwitchUpdateLoadBalancers(subnet.Name, ovsdb.MutateOperationInsert, lbs...); err != nil { - if err = c.patchSubnetStatus(subnet, "AddLbToLogicalSwitchFailed", err.Error()); err != nil { + if _, err = c.patchSubnetStatus(subnet, "AddLbToLogicalSwitchFailed", err.Error()); err != nil { klog.Error(err) return err } @@ -775,7 +777,7 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error { if subnet.Spec.Private { if err := c.OVNNbClient.SetLogicalSwitchPrivate(subnet.Name, subnet.Spec.CIDRBlock, c.config.NodeSwitchCIDR, subnet.Spec.AllowSubnets); err != nil { - if err = c.patchSubnetStatus(subnet, "SetPrivateLogicalSwitchFailed", err.Error()); err != nil { + if _, err = c.patchSubnetStatus(subnet, "SetPrivateLogicalSwitchFailed", err.Error()); err != nil { klog.Error(err) return err } @@ -783,14 +785,14 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error { return err } - if err = c.patchSubnetStatus(subnet, "SetPrivateLogicalSwitchSuccess", ""); err != nil { + if _, err = c.patchSubnetStatus(subnet, "SetPrivateLogicalSwitchSuccess", ""); err != nil { klog.Error(err) return err } } else { // clear acl when direction is "" if err = c.OVNNbClient.DeleteAcls(subnet.Name, logicalSwitchKey, "", nil); err != nil { - if err = c.patchSubnetStatus(subnet, "ResetLogicalSwitchAclFailed", err.Error()); err != nil { + if _, err = c.patchSubnetStatus(subnet, "ResetLogicalSwitchAclFailed", err.Error()); err != nil { klog.Error(err) return err } @@ -798,14 +800,14 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error { return err } - if err = c.patchSubnetStatus(subnet, "ResetLogicalSwitchAclSuccess", ""); err != nil { + if _, err = c.patchSubnetStatus(subnet, "ResetLogicalSwitchAclSuccess", ""); err != nil { klog.Error(err) return err } } if err := c.OVNNbClient.UpdateLogicalSwitchACL(subnet.Name, subnet.Spec.CIDRBlock, subnet.Spec.Acls, subnet.Spec.AllowEWTraffic); err != nil { - if err = c.patchSubnetStatus(subnet, "SetLogicalSwitchAclsFailed", err.Error()); err != nil { + if _, err = c.patchSubnetStatus(subnet, "SetLogicalSwitchAclsFailed", err.Error()); err != nil { klog.Error(err) return err } @@ -1021,7 +1023,8 @@ func (c *Controller) updateVlanStatusForSubnetDeletion(vlan *kubeovnv1.Vlan, sub } func (c *Controller) reconcileSubnet(subnet *kubeovnv1.Subnet) error { - if err := c.reconcileNamespaces(subnet); err != nil { + var err error + if subnet, err = c.reconcileNamespaces(subnet); err != nil { klog.Errorf("reconcile namespaces for subnet %s failed, %v", subnet.Name, err) return err } @@ -1168,7 +1171,7 @@ func (c *Controller) syncVirtualPort(key string) error { return nil } -func (c *Controller) reconcileNamespaces(subnet *kubeovnv1.Subnet) error { +func (c *Controller) reconcileNamespaces(subnet *kubeovnv1.Subnet) (*kubeovnv1.Subnet, error) { var ( namespaces []*v1.Namespace err error @@ -1182,17 +1185,88 @@ func (c *Controller) reconcileNamespaces(subnet *kubeovnv1.Subnet) error { // 2. update unbind namespace annotation if namespaces, err = c.namespacesLister.List(labels.Everything()); err != nil { klog.Errorf("failed to list namespaces, %v", err) - return err + return subnet, err } for _, ns := range namespaces { - // when subnet cidr changed, the ns annotation with the subnet should be updated - if ns.Annotations != nil && slices.Contains(strings.Split(ns.Annotations[util.LogicalSwitchAnnotation], ","), subnet.Name) { + if ns.Annotations != nil && slices.Contains(strings.Split(ns.Annotations[util.LogicalSwitchAnnotation], ","), subnet.Name) && + // ns deleted from subnet.Spec.Namespaces + (!slices.Contains(subnet.Spec.Namespaces, ns.Name) || + // when subnet cidr changed, the ns annotation with the subnet should be updated + !slices.Contains(strings.Split(ns.Annotations[util.CidrAnnotation], ";"), subnet.Spec.CIDRBlock)) { c.addNamespaceQueue.Add(ns.Name) } } - return nil + newSubnet := subnet.DeepCopy() + // 3. subnet select namespaces with NamespaceSelector + if !reflect.DeepEqual(subnet.Status.NamespaceSelector, subnet.Spec.NamespaceSelector) { + toAddNss, toDelNss, err := c.diffNamespaces(subnet.Spec.NamespaceSelector, subnet.Status.NamespaceSelector) + if err != nil { + klog.Errorf("failed to diff namespaces by selector, %v", err) + return newSubnet, err + } + for _, ns := range toAddNss { + c.addNamespaceQueue.Add(ns) + } + for _, ns := range toDelNss { + c.addNamespaceQueue.Add(ns) + } + klog.Infof("namespaces selected by subnet selector, add %v, delete %v", toAddNss, toDelNss) + + subnet.Status.NamespaceSelector = subnet.Spec.NamespaceSelector + if newSubnet, err = c.patchSubnetStatus(subnet, "RecordNamespaceSelector", ""); err != nil { + klog.Error(err) + return newSubnet, err + } + } + + return newSubnet, nil +} + +func (c *Controller) diffNamespaces(newSelector, oldSelector []metav1.LabelSelector) ([]string, []string, error) { + var toAddNss, toDelNss []string + + expectNss, err := c.getNamespacesBySelector(newSelector) + if err != nil { + klog.Errorf("failed to list namespaces by selector, %v", err) + return toAddNss, toDelNss, err + } + + existNss, err := c.getNamespacesBySelector(oldSelector) + if err != nil { + klog.Errorf("failed to list namespaces by selector, %v", err) + return toAddNss, toDelNss, err + } + + expectedNssSet := strset.New(expectNss...) + existNssSet := strset.New(existNss...) + + toAddNss = strset.Difference(expectedNssSet, existNssSet).List() + toDelNss = strset.Difference(existNssSet, expectedNssSet).List() + + return toAddNss, toDelNss, nil +} + +func (c *Controller) getNamespacesBySelector(nsSelectors []metav1.LabelSelector) ([]string, error) { + var expectNss []string + for _, nsSelector := range nsSelectors { + matchSelector, err := mergeSelector(nsSelector) + if err != nil { + klog.Errorf("failed to merge selector, %v", err) + return expectNss, err + } + + nss, err := c.namespacesLister.List(matchSelector) + if err != nil { + klog.Errorf("failed to list namespaces by selector, %v", err) + return expectNss, err + } + for _, ns := range nss { + expectNss = append(expectNss, ns.Name) + } + } + return expectNss, nil } func (c *Controller) reconcileCustomVpcBfdStaticRoute(vpcName, subnetName string) error { @@ -1354,7 +1428,7 @@ func (c *Controller) reconcileDistributedSubnetRouteInDefaultVpc(subnet *kubeovn return err } subnet.Status.ActivateGateway = "" - if err := c.patchSubnetStatus(subnet, "ChangeToDistributedGw", ""); err != nil { + if _, err := c.patchSubnetStatus(subnet, "ChangeToDistributedGw", ""); err != nil { klog.Error(err) return err } @@ -1489,7 +1563,7 @@ func (c *Controller) reconcileDefaultCentralizedSubnetRouteInDefaultVpc(subnet * if newActivateNode == "" { klog.Warningf("all gateways of subnet %s are not ready", subnet.Name) subnet.Status.ActivateGateway = newActivateNode - if err := c.patchSubnetStatus(subnet, "NoActiveGatewayFound", fmt.Sprintf("subnet %s gws are not ready", subnet.Name)); err != nil { + if _, err := c.patchSubnetStatus(subnet, "NoActiveGatewayFound", fmt.Sprintf("subnet %s gws are not ready", subnet.Name)); err != nil { klog.Error(err) return err } @@ -1504,7 +1578,7 @@ func (c *Controller) reconcileDefaultCentralizedSubnetRouteInDefaultVpc(subnet * return err } subnet.Status.ActivateGateway = newActivateNode - if err := c.patchSubnetStatus(subnet, "ReconcileCentralizedGatewaySuccess", ""); err != nil { + if _, err := c.patchSubnetStatus(subnet, "ReconcileCentralizedGatewaySuccess", ""); err != nil { klog.Error(err) return err } @@ -1676,7 +1750,7 @@ func (c *Controller) reconcileOvnDefaultVpcRoute(subnet *kubeovnv1.Subnet) error // centralized subnet if subnet.Spec.GatewayNode == "" { subnet.Status.NotReady("NoReadyGateway", "") - if err := c.patchSubnetStatus(subnet, "NoReadyGateway", ""); err != nil { + if _, err := c.patchSubnetStatus(subnet, "NoReadyGateway", ""); err != nil { klog.Error(err) return err }