From baf0faee9eaac685ed53a8a8a09c2084cf177095 Mon Sep 17 00:00:00 2001 From: RainbowMango Date: Sat, 6 Mar 2021 16:23:20 +0800 Subject: [PATCH] Deal with auto-generated files Signed-off-by: RainbowMango --- ...rk.karmada.io_clusterresourcebindings.yaml | 96 +++++++++++ .../work/v1alpha1/zz_generated.deepcopy.go | 60 +++++++ .../work/v1alpha1/zz_generated.register.go | 2 + .../work/v1alpha1/clusterresourcebinding.go | 152 ++++++++++++++++++ .../fake/fake_clusterresourcebinding.go | 106 ++++++++++++ .../work/v1alpha1/fake/fake_work_client.go | 4 + .../work/v1alpha1/generated_expansion.go | 2 + .../typed/work/v1alpha1/work_client.go | 5 + .../informers/externalversions/generic.go | 2 + .../work/v1alpha1/clusterresourcebinding.go | 73 +++++++++ .../work/v1alpha1/interface.go | 7 + .../work/v1alpha1/clusterresourcebinding.go | 52 ++++++ .../work/v1alpha1/expansion_generated.go | 4 + 13 files changed, 565 insertions(+) create mode 100644 artifacts/deploy/work.karmada.io_clusterresourcebindings.yaml create mode 100644 pkg/generated/clientset/versioned/typed/work/v1alpha1/clusterresourcebinding.go create mode 100644 pkg/generated/clientset/versioned/typed/work/v1alpha1/fake/fake_clusterresourcebinding.go create mode 100644 pkg/generated/informers/externalversions/work/v1alpha1/clusterresourcebinding.go create mode 100644 pkg/generated/listers/work/v1alpha1/clusterresourcebinding.go diff --git a/artifacts/deploy/work.karmada.io_clusterresourcebindings.yaml b/artifacts/deploy/work.karmada.io_clusterresourcebindings.yaml new file mode 100644 index 000000000..3464d8eab --- /dev/null +++ b/artifacts/deploy/work.karmada.io_clusterresourcebindings.yaml @@ -0,0 +1,96 @@ + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.4.1 + creationTimestamp: null + name: clusterresourcebindings.work.karmada.io +spec: + group: work.karmada.io + names: + kind: ClusterResourceBinding + listKind: ClusterResourceBindingList + plural: clusterresourcebindings + singular: clusterresourcebinding + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: ClusterResourceBinding represents a binding of a kubernetes resource + with a ClusterPropagationPolicy. + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: Spec represents the desired behavior. + properties: + clusters: + description: Clusters represents target member clusters where the + resource to be deployed. + items: + description: TargetCluster represents the identifier of a member + cluster. + properties: + name: + description: Name of target cluster. + type: string + required: + - name + type: object + type: array + resource: + description: Resource represents the Kubernetes resource to be propagated. + properties: + apiVersion: + description: APIVersion represents the API version of the referent. + type: string + kind: + description: Kind represents the Kind of the referent. + type: string + name: + description: Name represents the name of the referent. + type: string + namespace: + description: Namespace represents the namespace for the referent. + For non-namespace scoped resources(e.g. 'ClusterRole'),do not + need specify Namespace, and for namespace scoped resources, + Namespace is required. If Namespace is not specified, means + the resource is non-namespace scoped. + type: string + resourceVersion: + description: ResourceVersion represents the internal version of + the referenced object, that can be used by clients to determine + when object has changed. + type: string + required: + - apiVersion + - kind + - name + type: object + required: + - resource + type: object + required: + - spec + type: object + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/pkg/apis/work/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/work/v1alpha1/zz_generated.deepcopy.go index e1dee1dcf..b41d29bbe 100644 --- a/pkg/apis/work/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/work/v1alpha1/zz_generated.deepcopy.go @@ -26,6 +26,66 @@ func (in *AggregatedStatusItem) DeepCopy() *AggregatedStatusItem { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterResourceBinding) DeepCopyInto(out *ClusterResourceBinding) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterResourceBinding. +func (in *ClusterResourceBinding) DeepCopy() *ClusterResourceBinding { + if in == nil { + return nil + } + out := new(ClusterResourceBinding) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterResourceBinding) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterResourceBindingList) DeepCopyInto(out *ClusterResourceBindingList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterResourceBinding, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterResourceBindingList. +func (in *ClusterResourceBindingList) DeepCopy() *ClusterResourceBindingList { + if in == nil { + return nil + } + out := new(ClusterResourceBindingList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterResourceBindingList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DeploymentStatus) DeepCopyInto(out *DeploymentStatus) { *out = *in diff --git a/pkg/apis/work/v1alpha1/zz_generated.register.go b/pkg/apis/work/v1alpha1/zz_generated.register.go index b373cdc0e..95e031685 100644 --- a/pkg/apis/work/v1alpha1/zz_generated.register.go +++ b/pkg/apis/work/v1alpha1/zz_generated.register.go @@ -42,6 +42,8 @@ func init() { // Adds the list of known types to Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, + &ClusterResourceBinding{}, + &ClusterResourceBindingList{}, &ResourceBinding{}, &ResourceBindingList{}, &Work{}, diff --git a/pkg/generated/clientset/versioned/typed/work/v1alpha1/clusterresourcebinding.go b/pkg/generated/clientset/versioned/typed/work/v1alpha1/clusterresourcebinding.go new file mode 100644 index 000000000..6531dc348 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/work/v1alpha1/clusterresourcebinding.go @@ -0,0 +1,152 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha1" + scheme "github.com/karmada-io/karmada/pkg/generated/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// ClusterResourceBindingsGetter has a method to return a ClusterResourceBindingInterface. +// A group's client should implement this interface. +type ClusterResourceBindingsGetter interface { + ClusterResourceBindings() ClusterResourceBindingInterface +} + +// ClusterResourceBindingInterface has methods to work with ClusterResourceBinding resources. +type ClusterResourceBindingInterface interface { + Create(ctx context.Context, clusterResourceBinding *v1alpha1.ClusterResourceBinding, opts v1.CreateOptions) (*v1alpha1.ClusterResourceBinding, error) + Update(ctx context.Context, clusterResourceBinding *v1alpha1.ClusterResourceBinding, opts v1.UpdateOptions) (*v1alpha1.ClusterResourceBinding, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.ClusterResourceBinding, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ClusterResourceBindingList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterResourceBinding, err error) + ClusterResourceBindingExpansion +} + +// clusterResourceBindings implements ClusterResourceBindingInterface +type clusterResourceBindings struct { + client rest.Interface +} + +// newClusterResourceBindings returns a ClusterResourceBindings +func newClusterResourceBindings(c *WorkV1alpha1Client) *clusterResourceBindings { + return &clusterResourceBindings{ + client: c.RESTClient(), + } +} + +// Get takes name of the clusterResourceBinding, and returns the corresponding clusterResourceBinding object, and an error if there is any. +func (c *clusterResourceBindings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ClusterResourceBinding, err error) { + result = &v1alpha1.ClusterResourceBinding{} + err = c.client.Get(). + Resource("clusterresourcebindings"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ClusterResourceBindings that match those selectors. +func (c *clusterResourceBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterResourceBindingList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ClusterResourceBindingList{} + err = c.client.Get(). + Resource("clusterresourcebindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested clusterResourceBindings. +func (c *clusterResourceBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("clusterresourcebindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a clusterResourceBinding and creates it. Returns the server's representation of the clusterResourceBinding, and an error, if there is any. +func (c *clusterResourceBindings) Create(ctx context.Context, clusterResourceBinding *v1alpha1.ClusterResourceBinding, opts v1.CreateOptions) (result *v1alpha1.ClusterResourceBinding, err error) { + result = &v1alpha1.ClusterResourceBinding{} + err = c.client.Post(). + Resource("clusterresourcebindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(clusterResourceBinding). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a clusterResourceBinding and updates it. Returns the server's representation of the clusterResourceBinding, and an error, if there is any. +func (c *clusterResourceBindings) Update(ctx context.Context, clusterResourceBinding *v1alpha1.ClusterResourceBinding, opts v1.UpdateOptions) (result *v1alpha1.ClusterResourceBinding, err error) { + result = &v1alpha1.ClusterResourceBinding{} + err = c.client.Put(). + Resource("clusterresourcebindings"). + Name(clusterResourceBinding.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(clusterResourceBinding). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the clusterResourceBinding and deletes it. Returns an error if one occurs. +func (c *clusterResourceBindings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("clusterresourcebindings"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *clusterResourceBindings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("clusterresourcebindings"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched clusterResourceBinding. +func (c *clusterResourceBindings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterResourceBinding, err error) { + result = &v1alpha1.ClusterResourceBinding{} + err = c.client.Patch(pt). + Resource("clusterresourcebindings"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/generated/clientset/versioned/typed/work/v1alpha1/fake/fake_clusterresourcebinding.go b/pkg/generated/clientset/versioned/typed/work/v1alpha1/fake/fake_clusterresourcebinding.go new file mode 100644 index 000000000..5c6d593a8 --- /dev/null +++ b/pkg/generated/clientset/versioned/typed/work/v1alpha1/fake/fake_clusterresourcebinding.go @@ -0,0 +1,106 @@ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeClusterResourceBindings implements ClusterResourceBindingInterface +type FakeClusterResourceBindings struct { + Fake *FakeWorkV1alpha1 +} + +var clusterresourcebindingsResource = schema.GroupVersionResource{Group: "work.karmada.io", Version: "v1alpha1", Resource: "clusterresourcebindings"} + +var clusterresourcebindingsKind = schema.GroupVersionKind{Group: "work.karmada.io", Version: "v1alpha1", Kind: "ClusterResourceBinding"} + +// Get takes name of the clusterResourceBinding, and returns the corresponding clusterResourceBinding object, and an error if there is any. +func (c *FakeClusterResourceBindings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ClusterResourceBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(clusterresourcebindingsResource, name), &v1alpha1.ClusterResourceBinding{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterResourceBinding), err +} + +// List takes label and field selectors, and returns the list of ClusterResourceBindings that match those selectors. +func (c *FakeClusterResourceBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ClusterResourceBindingList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(clusterresourcebindingsResource, clusterresourcebindingsKind, opts), &v1alpha1.ClusterResourceBindingList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ClusterResourceBindingList{ListMeta: obj.(*v1alpha1.ClusterResourceBindingList).ListMeta} + for _, item := range obj.(*v1alpha1.ClusterResourceBindingList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested clusterResourceBindings. +func (c *FakeClusterResourceBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(clusterresourcebindingsResource, opts)) +} + +// Create takes the representation of a clusterResourceBinding and creates it. Returns the server's representation of the clusterResourceBinding, and an error, if there is any. +func (c *FakeClusterResourceBindings) Create(ctx context.Context, clusterResourceBinding *v1alpha1.ClusterResourceBinding, opts v1.CreateOptions) (result *v1alpha1.ClusterResourceBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(clusterresourcebindingsResource, clusterResourceBinding), &v1alpha1.ClusterResourceBinding{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterResourceBinding), err +} + +// Update takes the representation of a clusterResourceBinding and updates it. Returns the server's representation of the clusterResourceBinding, and an error, if there is any. +func (c *FakeClusterResourceBindings) Update(ctx context.Context, clusterResourceBinding *v1alpha1.ClusterResourceBinding, opts v1.UpdateOptions) (result *v1alpha1.ClusterResourceBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(clusterresourcebindingsResource, clusterResourceBinding), &v1alpha1.ClusterResourceBinding{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterResourceBinding), err +} + +// Delete takes name of the clusterResourceBinding and deletes it. Returns an error if one occurs. +func (c *FakeClusterResourceBindings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(clusterresourcebindingsResource, name), &v1alpha1.ClusterResourceBinding{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeClusterResourceBindings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(clusterresourcebindingsResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.ClusterResourceBindingList{}) + return err +} + +// Patch applies the patch and returns the patched clusterResourceBinding. +func (c *FakeClusterResourceBindings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ClusterResourceBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(clusterresourcebindingsResource, name, pt, data, subresources...), &v1alpha1.ClusterResourceBinding{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterResourceBinding), err +} diff --git a/pkg/generated/clientset/versioned/typed/work/v1alpha1/fake/fake_work_client.go b/pkg/generated/clientset/versioned/typed/work/v1alpha1/fake/fake_work_client.go index 985428541..cd802efa9 100644 --- a/pkg/generated/clientset/versioned/typed/work/v1alpha1/fake/fake_work_client.go +++ b/pkg/generated/clientset/versioned/typed/work/v1alpha1/fake/fake_work_client.go @@ -12,6 +12,10 @@ type FakeWorkV1alpha1 struct { *testing.Fake } +func (c *FakeWorkV1alpha1) ClusterResourceBindings() v1alpha1.ClusterResourceBindingInterface { + return &FakeClusterResourceBindings{c} +} + func (c *FakeWorkV1alpha1) ResourceBindings(namespace string) v1alpha1.ResourceBindingInterface { return &FakeResourceBindings{c, namespace} } diff --git a/pkg/generated/clientset/versioned/typed/work/v1alpha1/generated_expansion.go b/pkg/generated/clientset/versioned/typed/work/v1alpha1/generated_expansion.go index fb511c923..1d5a7d461 100644 --- a/pkg/generated/clientset/versioned/typed/work/v1alpha1/generated_expansion.go +++ b/pkg/generated/clientset/versioned/typed/work/v1alpha1/generated_expansion.go @@ -2,6 +2,8 @@ package v1alpha1 +type ClusterResourceBindingExpansion interface{} + type ResourceBindingExpansion interface{} type WorkExpansion interface{} diff --git a/pkg/generated/clientset/versioned/typed/work/v1alpha1/work_client.go b/pkg/generated/clientset/versioned/typed/work/v1alpha1/work_client.go index c22b46301..6f12a8e04 100644 --- a/pkg/generated/clientset/versioned/typed/work/v1alpha1/work_client.go +++ b/pkg/generated/clientset/versioned/typed/work/v1alpha1/work_client.go @@ -10,6 +10,7 @@ import ( type WorkV1alpha1Interface interface { RESTClient() rest.Interface + ClusterResourceBindingsGetter ResourceBindingsGetter WorksGetter } @@ -19,6 +20,10 @@ type WorkV1alpha1Client struct { restClient rest.Interface } +func (c *WorkV1alpha1Client) ClusterResourceBindings() ClusterResourceBindingInterface { + return newClusterResourceBindings(c) +} + func (c *WorkV1alpha1Client) ResourceBindings(namespace string) ResourceBindingInterface { return newResourceBindings(c, namespace) } diff --git a/pkg/generated/informers/externalversions/generic.go b/pkg/generated/informers/externalversions/generic.go index 72bf870fd..a3b03b99b 100644 --- a/pkg/generated/informers/externalversions/generic.go +++ b/pkg/generated/informers/externalversions/generic.go @@ -53,6 +53,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Policy().V1alpha1().PropagationPolicies().Informer()}, nil // Group=work.karmada.io, Version=v1alpha1 + case workv1alpha1.SchemeGroupVersion.WithResource("clusterresourcebindings"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Work().V1alpha1().ClusterResourceBindings().Informer()}, nil case workv1alpha1.SchemeGroupVersion.WithResource("resourcebindings"): return &genericInformer{resource: resource.GroupResource(), informer: f.Work().V1alpha1().ResourceBindings().Informer()}, nil case workv1alpha1.SchemeGroupVersion.WithResource("works"): diff --git a/pkg/generated/informers/externalversions/work/v1alpha1/clusterresourcebinding.go b/pkg/generated/informers/externalversions/work/v1alpha1/clusterresourcebinding.go new file mode 100644 index 000000000..92b343161 --- /dev/null +++ b/pkg/generated/informers/externalversions/work/v1alpha1/clusterresourcebinding.go @@ -0,0 +1,73 @@ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + workv1alpha1 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha1" + versioned "github.com/karmada-io/karmada/pkg/generated/clientset/versioned" + internalinterfaces "github.com/karmada-io/karmada/pkg/generated/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/karmada-io/karmada/pkg/generated/listers/work/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ClusterResourceBindingInformer provides access to a shared informer and lister for +// ClusterResourceBindings. +type ClusterResourceBindingInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ClusterResourceBindingLister +} + +type clusterResourceBindingInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewClusterResourceBindingInformer constructs a new informer for ClusterResourceBinding type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewClusterResourceBindingInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredClusterResourceBindingInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredClusterResourceBindingInformer constructs a new informer for ClusterResourceBinding type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredClusterResourceBindingInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.WorkV1alpha1().ClusterResourceBindings().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.WorkV1alpha1().ClusterResourceBindings().Watch(context.TODO(), options) + }, + }, + &workv1alpha1.ClusterResourceBinding{}, + resyncPeriod, + indexers, + ) +} + +func (f *clusterResourceBindingInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredClusterResourceBindingInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *clusterResourceBindingInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&workv1alpha1.ClusterResourceBinding{}, f.defaultInformer) +} + +func (f *clusterResourceBindingInformer) Lister() v1alpha1.ClusterResourceBindingLister { + return v1alpha1.NewClusterResourceBindingLister(f.Informer().GetIndexer()) +} diff --git a/pkg/generated/informers/externalversions/work/v1alpha1/interface.go b/pkg/generated/informers/externalversions/work/v1alpha1/interface.go index 72291634e..7bca2b32a 100644 --- a/pkg/generated/informers/externalversions/work/v1alpha1/interface.go +++ b/pkg/generated/informers/externalversions/work/v1alpha1/interface.go @@ -8,6 +8,8 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { + // ClusterResourceBindings returns a ClusterResourceBindingInformer. + ClusterResourceBindings() ClusterResourceBindingInformer // ResourceBindings returns a ResourceBindingInformer. ResourceBindings() ResourceBindingInformer // Works returns a WorkInformer. @@ -25,6 +27,11 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } +// ClusterResourceBindings returns a ClusterResourceBindingInformer. +func (v *version) ClusterResourceBindings() ClusterResourceBindingInformer { + return &clusterResourceBindingInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + // ResourceBindings returns a ResourceBindingInformer. func (v *version) ResourceBindings() ResourceBindingInformer { return &resourceBindingInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/generated/listers/work/v1alpha1/clusterresourcebinding.go b/pkg/generated/listers/work/v1alpha1/clusterresourcebinding.go new file mode 100644 index 000000000..a51b75508 --- /dev/null +++ b/pkg/generated/listers/work/v1alpha1/clusterresourcebinding.go @@ -0,0 +1,52 @@ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/karmada-io/karmada/pkg/apis/work/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// ClusterResourceBindingLister helps list ClusterResourceBindings. +// All objects returned here must be treated as read-only. +type ClusterResourceBindingLister interface { + // List lists all ClusterResourceBindings in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.ClusterResourceBinding, err error) + // Get retrieves the ClusterResourceBinding from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.ClusterResourceBinding, error) + ClusterResourceBindingListerExpansion +} + +// clusterResourceBindingLister implements the ClusterResourceBindingLister interface. +type clusterResourceBindingLister struct { + indexer cache.Indexer +} + +// NewClusterResourceBindingLister returns a new ClusterResourceBindingLister. +func NewClusterResourceBindingLister(indexer cache.Indexer) ClusterResourceBindingLister { + return &clusterResourceBindingLister{indexer: indexer} +} + +// List lists all ClusterResourceBindings in the indexer. +func (s *clusterResourceBindingLister) List(selector labels.Selector) (ret []*v1alpha1.ClusterResourceBinding, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ClusterResourceBinding)) + }) + return ret, err +} + +// Get retrieves the ClusterResourceBinding from the index for a given name. +func (s *clusterResourceBindingLister) Get(name string) (*v1alpha1.ClusterResourceBinding, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("clusterresourcebinding"), name) + } + return obj.(*v1alpha1.ClusterResourceBinding), nil +} diff --git a/pkg/generated/listers/work/v1alpha1/expansion_generated.go b/pkg/generated/listers/work/v1alpha1/expansion_generated.go index a46c4c7e5..a895a1896 100644 --- a/pkg/generated/listers/work/v1alpha1/expansion_generated.go +++ b/pkg/generated/listers/work/v1alpha1/expansion_generated.go @@ -2,6 +2,10 @@ package v1alpha1 +// ClusterResourceBindingListerExpansion allows custom methods to be added to +// ClusterResourceBindingLister. +type ClusterResourceBindingListerExpansion interface{} + // ResourceBindingListerExpansion allows custom methods to be added to // ResourceBindingLister. type ResourceBindingListerExpansion interface{}