diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index 5ed5008bb..54f0c6e59 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -24,7 +24,10 @@ jobs: - name: Run golangci-lint run: make golangci - + + - name: Run code-generator + run: make generated + - name: Run build run: make build diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 7522374b4..203eb7243 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -12,6 +12,7 @@ GROUP=vpc SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. CODEGEN_PKG=$(go env GOMODCACHE)/k8s.io/code-generator@v0.27.1 +mv ./pkg/client/go.mod client.go.mod rm -fr ./pkg/client bash "${CODEGEN_PKG}"/generate-groups.sh "deepcopy,client,informer,lister" \ @@ -22,7 +23,7 @@ ${GROUP}:v1alpha1 \ mv ./${OUTPUT_PKG} ./pkg/ cd ./pkg/client -go mod init github.com/vmware-tanzu/nsx-operator/pkg/client +mv ../../client.go.mod ./go.mod go mod tidy cd ../../ rm -rf ./github.com \ No newline at end of file diff --git a/pkg/client/clientset/versioned/typed/vpc/v1alpha1/fake/fake_subnetconnectionbindingmap.go b/pkg/client/clientset/versioned/typed/vpc/v1alpha1/fake/fake_subnetconnectionbindingmap.go new file mode 100644 index 000000000..20f62c1d1 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/vpc/v1alpha1/fake/fake_subnetconnectionbindingmap.go @@ -0,0 +1,128 @@ +/* Copyright © 2024 VMware, Inc. All Rights Reserved. + SPDX-License-Identifier: Apache-2.0 */ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "github.com/vmware-tanzu/nsx-operator/pkg/apis/vpc/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeSubnetConnectionBindingMaps implements SubnetConnectionBindingMapInterface +type FakeSubnetConnectionBindingMaps struct { + Fake *FakeCrdV1alpha1 + ns string +} + +var subnetconnectionbindingmapsResource = v1alpha1.SchemeGroupVersion.WithResource("subnetconnectionbindingmaps") + +var subnetconnectionbindingmapsKind = v1alpha1.SchemeGroupVersion.WithKind("SubnetConnectionBindingMap") + +// Get takes name of the subnetConnectionBindingMap, and returns the corresponding subnetConnectionBindingMap object, and an error if there is any. +func (c *FakeSubnetConnectionBindingMaps) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SubnetConnectionBindingMap, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(subnetconnectionbindingmapsResource, c.ns, name), &v1alpha1.SubnetConnectionBindingMap{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SubnetConnectionBindingMap), err +} + +// List takes label and field selectors, and returns the list of SubnetConnectionBindingMaps that match those selectors. +func (c *FakeSubnetConnectionBindingMaps) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SubnetConnectionBindingMapList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(subnetconnectionbindingmapsResource, subnetconnectionbindingmapsKind, c.ns, opts), &v1alpha1.SubnetConnectionBindingMapList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.SubnetConnectionBindingMapList{ListMeta: obj.(*v1alpha1.SubnetConnectionBindingMapList).ListMeta} + for _, item := range obj.(*v1alpha1.SubnetConnectionBindingMapList).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 subnetConnectionBindingMaps. +func (c *FakeSubnetConnectionBindingMaps) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(subnetconnectionbindingmapsResource, c.ns, opts)) + +} + +// Create takes the representation of a subnetConnectionBindingMap and creates it. Returns the server's representation of the subnetConnectionBindingMap, and an error, if there is any. +func (c *FakeSubnetConnectionBindingMaps) Create(ctx context.Context, subnetConnectionBindingMap *v1alpha1.SubnetConnectionBindingMap, opts v1.CreateOptions) (result *v1alpha1.SubnetConnectionBindingMap, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(subnetconnectionbindingmapsResource, c.ns, subnetConnectionBindingMap), &v1alpha1.SubnetConnectionBindingMap{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SubnetConnectionBindingMap), err +} + +// Update takes the representation of a subnetConnectionBindingMap and updates it. Returns the server's representation of the subnetConnectionBindingMap, and an error, if there is any. +func (c *FakeSubnetConnectionBindingMaps) Update(ctx context.Context, subnetConnectionBindingMap *v1alpha1.SubnetConnectionBindingMap, opts v1.UpdateOptions) (result *v1alpha1.SubnetConnectionBindingMap, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(subnetconnectionbindingmapsResource, c.ns, subnetConnectionBindingMap), &v1alpha1.SubnetConnectionBindingMap{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SubnetConnectionBindingMap), 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 *FakeSubnetConnectionBindingMaps) UpdateStatus(ctx context.Context, subnetConnectionBindingMap *v1alpha1.SubnetConnectionBindingMap, opts v1.UpdateOptions) (*v1alpha1.SubnetConnectionBindingMap, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(subnetconnectionbindingmapsResource, "status", c.ns, subnetConnectionBindingMap), &v1alpha1.SubnetConnectionBindingMap{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SubnetConnectionBindingMap), err +} + +// Delete takes name of the subnetConnectionBindingMap and deletes it. Returns an error if one occurs. +func (c *FakeSubnetConnectionBindingMaps) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(subnetconnectionbindingmapsResource, c.ns, name, opts), &v1alpha1.SubnetConnectionBindingMap{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeSubnetConnectionBindingMaps) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(subnetconnectionbindingmapsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.SubnetConnectionBindingMapList{}) + return err +} + +// Patch applies the patch and returns the patched subnetConnectionBindingMap. +func (c *FakeSubnetConnectionBindingMaps) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SubnetConnectionBindingMap, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(subnetconnectionbindingmapsResource, c.ns, name, pt, data, subresources...), &v1alpha1.SubnetConnectionBindingMap{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SubnetConnectionBindingMap), err +} diff --git a/pkg/client/clientset/versioned/typed/vpc/v1alpha1/fake/fake_vpc_client.go b/pkg/client/clientset/versioned/typed/vpc/v1alpha1/fake/fake_vpc_client.go index f61b00f3d..b1de58415 100644 --- a/pkg/client/clientset/versioned/typed/vpc/v1alpha1/fake/fake_vpc_client.go +++ b/pkg/client/clientset/versioned/typed/vpc/v1alpha1/fake/fake_vpc_client.go @@ -43,6 +43,10 @@ func (c *FakeCrdV1alpha1) Subnets(namespace string) v1alpha1.SubnetInterface { return &FakeSubnets{c, namespace} } +func (c *FakeCrdV1alpha1) SubnetConnectionBindingMaps(namespace string) v1alpha1.SubnetConnectionBindingMapInterface { + return &FakeSubnetConnectionBindingMaps{c, namespace} +} + func (c *FakeCrdV1alpha1) SubnetPorts(namespace string) v1alpha1.SubnetPortInterface { return &FakeSubnetPorts{c, namespace} } diff --git a/pkg/client/clientset/versioned/typed/vpc/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/vpc/v1alpha1/generated_expansion.go index 113c6070f..521bd161e 100644 --- a/pkg/client/clientset/versioned/typed/vpc/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/vpc/v1alpha1/generated_expansion.go @@ -19,6 +19,8 @@ type StaticRouteExpansion interface{} type SubnetExpansion interface{} +type SubnetConnectionBindingMapExpansion interface{} + type SubnetPortExpansion interface{} type SubnetSetExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/vpc/v1alpha1/subnetconnectionbindingmap.go b/pkg/client/clientset/versioned/typed/vpc/v1alpha1/subnetconnectionbindingmap.go new file mode 100644 index 000000000..75f53d0c8 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/vpc/v1alpha1/subnetconnectionbindingmap.go @@ -0,0 +1,182 @@ +/* Copyright © 2024 VMware, Inc. All Rights Reserved. + SPDX-License-Identifier: Apache-2.0 */ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "github.com/vmware-tanzu/nsx-operator/pkg/apis/vpc/v1alpha1" + scheme "github.com/vmware-tanzu/nsx-operator/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// SubnetConnectionBindingMapsGetter has a method to return a SubnetConnectionBindingMapInterface. +// A group's client should implement this interface. +type SubnetConnectionBindingMapsGetter interface { + SubnetConnectionBindingMaps(namespace string) SubnetConnectionBindingMapInterface +} + +// SubnetConnectionBindingMapInterface has methods to work with SubnetConnectionBindingMap resources. +type SubnetConnectionBindingMapInterface interface { + Create(ctx context.Context, subnetConnectionBindingMap *v1alpha1.SubnetConnectionBindingMap, opts v1.CreateOptions) (*v1alpha1.SubnetConnectionBindingMap, error) + Update(ctx context.Context, subnetConnectionBindingMap *v1alpha1.SubnetConnectionBindingMap, opts v1.UpdateOptions) (*v1alpha1.SubnetConnectionBindingMap, error) + UpdateStatus(ctx context.Context, subnetConnectionBindingMap *v1alpha1.SubnetConnectionBindingMap, opts v1.UpdateOptions) (*v1alpha1.SubnetConnectionBindingMap, 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.SubnetConnectionBindingMap, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.SubnetConnectionBindingMapList, 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.SubnetConnectionBindingMap, err error) + SubnetConnectionBindingMapExpansion +} + +// subnetConnectionBindingMaps implements SubnetConnectionBindingMapInterface +type subnetConnectionBindingMaps struct { + client rest.Interface + ns string +} + +// newSubnetConnectionBindingMaps returns a SubnetConnectionBindingMaps +func newSubnetConnectionBindingMaps(c *CrdV1alpha1Client, namespace string) *subnetConnectionBindingMaps { + return &subnetConnectionBindingMaps{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the subnetConnectionBindingMap, and returns the corresponding subnetConnectionBindingMap object, and an error if there is any. +func (c *subnetConnectionBindingMaps) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SubnetConnectionBindingMap, err error) { + result = &v1alpha1.SubnetConnectionBindingMap{} + err = c.client.Get(). + Namespace(c.ns). + Resource("subnetconnectionbindingmaps"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of SubnetConnectionBindingMaps that match those selectors. +func (c *subnetConnectionBindingMaps) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SubnetConnectionBindingMapList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.SubnetConnectionBindingMapList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("subnetconnectionbindingmaps"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested subnetConnectionBindingMaps. +func (c *subnetConnectionBindingMaps) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("subnetconnectionbindingmaps"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a subnetConnectionBindingMap and creates it. Returns the server's representation of the subnetConnectionBindingMap, and an error, if there is any. +func (c *subnetConnectionBindingMaps) Create(ctx context.Context, subnetConnectionBindingMap *v1alpha1.SubnetConnectionBindingMap, opts v1.CreateOptions) (result *v1alpha1.SubnetConnectionBindingMap, err error) { + result = &v1alpha1.SubnetConnectionBindingMap{} + err = c.client.Post(). + Namespace(c.ns). + Resource("subnetconnectionbindingmaps"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(subnetConnectionBindingMap). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a subnetConnectionBindingMap and updates it. Returns the server's representation of the subnetConnectionBindingMap, and an error, if there is any. +func (c *subnetConnectionBindingMaps) Update(ctx context.Context, subnetConnectionBindingMap *v1alpha1.SubnetConnectionBindingMap, opts v1.UpdateOptions) (result *v1alpha1.SubnetConnectionBindingMap, err error) { + result = &v1alpha1.SubnetConnectionBindingMap{} + err = c.client.Put(). + Namespace(c.ns). + Resource("subnetconnectionbindingmaps"). + Name(subnetConnectionBindingMap.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(subnetConnectionBindingMap). + 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 *subnetConnectionBindingMaps) UpdateStatus(ctx context.Context, subnetConnectionBindingMap *v1alpha1.SubnetConnectionBindingMap, opts v1.UpdateOptions) (result *v1alpha1.SubnetConnectionBindingMap, err error) { + result = &v1alpha1.SubnetConnectionBindingMap{} + err = c.client.Put(). + Namespace(c.ns). + Resource("subnetconnectionbindingmaps"). + Name(subnetConnectionBindingMap.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(subnetConnectionBindingMap). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the subnetConnectionBindingMap and deletes it. Returns an error if one occurs. +func (c *subnetConnectionBindingMaps) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("subnetconnectionbindingmaps"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *subnetConnectionBindingMaps) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("subnetconnectionbindingmaps"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched subnetConnectionBindingMap. +func (c *subnetConnectionBindingMaps) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SubnetConnectionBindingMap, err error) { + result = &v1alpha1.SubnetConnectionBindingMap{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("subnetconnectionbindingmaps"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/vpc/v1alpha1/vpc_client.go b/pkg/client/clientset/versioned/typed/vpc/v1alpha1/vpc_client.go index d7ba28a5f..987bbff38 100644 --- a/pkg/client/clientset/versioned/typed/vpc/v1alpha1/vpc_client.go +++ b/pkg/client/clientset/versioned/typed/vpc/v1alpha1/vpc_client.go @@ -22,6 +22,7 @@ type CrdV1alpha1Interface interface { SecurityPoliciesGetter StaticRoutesGetter SubnetsGetter + SubnetConnectionBindingMapsGetter SubnetPortsGetter SubnetSetsGetter VPCNetworkConfigurationsGetter @@ -60,6 +61,10 @@ func (c *CrdV1alpha1Client) Subnets(namespace string) SubnetInterface { return newSubnets(c, namespace) } +func (c *CrdV1alpha1Client) SubnetConnectionBindingMaps(namespace string) SubnetConnectionBindingMapInterface { + return newSubnetConnectionBindingMaps(c, namespace) +} + func (c *CrdV1alpha1Client) SubnetPorts(namespace string) SubnetPortInterface { return newSubnetPorts(c, namespace) } diff --git a/pkg/client/go.mod b/pkg/client/go.mod index 85ac652cb..a2eb4d8a1 100644 --- a/pkg/client/go.mod +++ b/pkg/client/go.mod @@ -19,6 +19,7 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/gnostic-models v0.6.8 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/josharian/intern v1.0.0 // indirect diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 4cc4a7192..8e17da8ac 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -54,6 +54,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Crd().V1alpha1().StaticRoutes().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("subnets"): return &genericInformer{resource: resource.GroupResource(), informer: f.Crd().V1alpha1().Subnets().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("subnetconnectionbindingmaps"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Crd().V1alpha1().SubnetConnectionBindingMaps().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("subnetports"): return &genericInformer{resource: resource.GroupResource(), informer: f.Crd().V1alpha1().SubnetPorts().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("subnetsets"): diff --git a/pkg/client/informers/externalversions/vpc/v1alpha1/interface.go b/pkg/client/informers/externalversions/vpc/v1alpha1/interface.go index 296d61738..e13677fb7 100644 --- a/pkg/client/informers/externalversions/vpc/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/vpc/v1alpha1/interface.go @@ -25,6 +25,8 @@ type Interface interface { StaticRoutes() StaticRouteInformer // Subnets returns a SubnetInformer. Subnets() SubnetInformer + // SubnetConnectionBindingMaps returns a SubnetConnectionBindingMapInformer. + SubnetConnectionBindingMaps() SubnetConnectionBindingMapInformer // SubnetPorts returns a SubnetPortInformer. SubnetPorts() SubnetPortInformer // SubnetSets returns a SubnetSetInformer. @@ -79,6 +81,11 @@ func (v *version) Subnets() SubnetInformer { return &subnetInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } +// SubnetConnectionBindingMaps returns a SubnetConnectionBindingMapInformer. +func (v *version) SubnetConnectionBindingMaps() SubnetConnectionBindingMapInformer { + return &subnetConnectionBindingMapInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // SubnetPorts returns a SubnetPortInformer. func (v *version) SubnetPorts() SubnetPortInformer { return &subnetPortInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/informers/externalversions/vpc/v1alpha1/subnetconnectionbindingmap.go b/pkg/client/informers/externalversions/vpc/v1alpha1/subnetconnectionbindingmap.go new file mode 100644 index 000000000..147c39083 --- /dev/null +++ b/pkg/client/informers/externalversions/vpc/v1alpha1/subnetconnectionbindingmap.go @@ -0,0 +1,77 @@ +/* Copyright © 2024 VMware, Inc. All Rights Reserved. + SPDX-License-Identifier: Apache-2.0 */ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + vpcv1alpha1 "github.com/vmware-tanzu/nsx-operator/pkg/apis/vpc/v1alpha1" + versioned "github.com/vmware-tanzu/nsx-operator/pkg/client/clientset/versioned" + internalinterfaces "github.com/vmware-tanzu/nsx-operator/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/vmware-tanzu/nsx-operator/pkg/client/listers/vpc/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" +) + +// SubnetConnectionBindingMapInformer provides access to a shared informer and lister for +// SubnetConnectionBindingMaps. +type SubnetConnectionBindingMapInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.SubnetConnectionBindingMapLister +} + +type subnetConnectionBindingMapInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewSubnetConnectionBindingMapInformer constructs a new informer for SubnetConnectionBindingMap 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 NewSubnetConnectionBindingMapInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredSubnetConnectionBindingMapInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredSubnetConnectionBindingMapInformer constructs a new informer for SubnetConnectionBindingMap 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 NewFilteredSubnetConnectionBindingMapInformer(client versioned.Interface, namespace string, 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.CrdV1alpha1().SubnetConnectionBindingMaps(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CrdV1alpha1().SubnetConnectionBindingMaps(namespace).Watch(context.TODO(), options) + }, + }, + &vpcv1alpha1.SubnetConnectionBindingMap{}, + resyncPeriod, + indexers, + ) +} + +func (f *subnetConnectionBindingMapInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredSubnetConnectionBindingMapInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *subnetConnectionBindingMapInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&vpcv1alpha1.SubnetConnectionBindingMap{}, f.defaultInformer) +} + +func (f *subnetConnectionBindingMapInformer) Lister() v1alpha1.SubnetConnectionBindingMapLister { + return v1alpha1.NewSubnetConnectionBindingMapLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/listers/vpc/v1alpha1/expansion_generated.go b/pkg/client/listers/vpc/v1alpha1/expansion_generated.go index 3b5ef6f01..dd356070b 100644 --- a/pkg/client/listers/vpc/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/vpc/v1alpha1/expansion_generated.go @@ -61,6 +61,14 @@ type SubnetListerExpansion interface{} // SubnetNamespaceLister. type SubnetNamespaceListerExpansion interface{} +// SubnetConnectionBindingMapListerExpansion allows custom methods to be added to +// SubnetConnectionBindingMapLister. +type SubnetConnectionBindingMapListerExpansion interface{} + +// SubnetConnectionBindingMapNamespaceListerExpansion allows custom methods to be added to +// SubnetConnectionBindingMapNamespaceLister. +type SubnetConnectionBindingMapNamespaceListerExpansion interface{} + // SubnetPortListerExpansion allows custom methods to be added to // SubnetPortLister. type SubnetPortListerExpansion interface{} diff --git a/pkg/client/listers/vpc/v1alpha1/subnetconnectionbindingmap.go b/pkg/client/listers/vpc/v1alpha1/subnetconnectionbindingmap.go new file mode 100644 index 000000000..8b89c4461 --- /dev/null +++ b/pkg/client/listers/vpc/v1alpha1/subnetconnectionbindingmap.go @@ -0,0 +1,86 @@ +/* Copyright © 2024 VMware, Inc. All Rights Reserved. + SPDX-License-Identifier: Apache-2.0 */ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/vmware-tanzu/nsx-operator/pkg/apis/vpc/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// SubnetConnectionBindingMapLister helps list SubnetConnectionBindingMaps. +// All objects returned here must be treated as read-only. +type SubnetConnectionBindingMapLister interface { + // List lists all SubnetConnectionBindingMaps in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.SubnetConnectionBindingMap, err error) + // SubnetConnectionBindingMaps returns an object that can list and get SubnetConnectionBindingMaps. + SubnetConnectionBindingMaps(namespace string) SubnetConnectionBindingMapNamespaceLister + SubnetConnectionBindingMapListerExpansion +} + +// subnetConnectionBindingMapLister implements the SubnetConnectionBindingMapLister interface. +type subnetConnectionBindingMapLister struct { + indexer cache.Indexer +} + +// NewSubnetConnectionBindingMapLister returns a new SubnetConnectionBindingMapLister. +func NewSubnetConnectionBindingMapLister(indexer cache.Indexer) SubnetConnectionBindingMapLister { + return &subnetConnectionBindingMapLister{indexer: indexer} +} + +// List lists all SubnetConnectionBindingMaps in the indexer. +func (s *subnetConnectionBindingMapLister) List(selector labels.Selector) (ret []*v1alpha1.SubnetConnectionBindingMap, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.SubnetConnectionBindingMap)) + }) + return ret, err +} + +// SubnetConnectionBindingMaps returns an object that can list and get SubnetConnectionBindingMaps. +func (s *subnetConnectionBindingMapLister) SubnetConnectionBindingMaps(namespace string) SubnetConnectionBindingMapNamespaceLister { + return subnetConnectionBindingMapNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// SubnetConnectionBindingMapNamespaceLister helps list and get SubnetConnectionBindingMaps. +// All objects returned here must be treated as read-only. +type SubnetConnectionBindingMapNamespaceLister interface { + // List lists all SubnetConnectionBindingMaps in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.SubnetConnectionBindingMap, err error) + // Get retrieves the SubnetConnectionBindingMap from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.SubnetConnectionBindingMap, error) + SubnetConnectionBindingMapNamespaceListerExpansion +} + +// subnetConnectionBindingMapNamespaceLister implements the SubnetConnectionBindingMapNamespaceLister +// interface. +type subnetConnectionBindingMapNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all SubnetConnectionBindingMaps in the indexer for a given namespace. +func (s subnetConnectionBindingMapNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.SubnetConnectionBindingMap, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.SubnetConnectionBindingMap)) + }) + return ret, err +} + +// Get retrieves the SubnetConnectionBindingMap from the indexer for a given namespace and name. +func (s subnetConnectionBindingMapNamespaceLister) Get(name string) (*v1alpha1.SubnetConnectionBindingMap, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("subnetconnectionbindingmap"), name) + } + return obj.(*v1alpha1.SubnetConnectionBindingMap), nil +}