diff --git a/build/yaml/crd/nsx.vmware.com_ipaddressallocations.yaml b/build/yaml/crd/nsx.vmware.com_ipaddressallocations.yaml new file mode 100644 index 000000000..476fa42d6 --- /dev/null +++ b/build/yaml/crd/nsx.vmware.com_ipaddressallocations.yaml @@ -0,0 +1,109 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.14.0 + name: ipaddressallocations.nsx.vmware.com +spec: + group: nsx.vmware.com + names: + kind: IPAddressAllocation + listKind: IPAddressAllocationList + plural: ipaddressallocations + singular: ipaddressallocation + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: IPAddressBlockVisibility of IPAddressAllocation + jsonPath: .spec.ip_address_block_visibility + name: IPAddressBlockVisibility + type: string + - description: CIDRs for the IPAddressAllocation + jsonPath: .status.cidr + name: CIDR + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: IPAddressAllocation is the Schema for the IP allocation API. + 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: IPAddressAllocationSpec defines the desired state of IPAddressAllocation. + properties: + allocation_size: + description: AllocationSize specifies the size of IP CIDR to be allocated. + type: integer + ip_address_block_visibility: + default: Private + description: IPAddressBlockVisibility specifies the visibility of + the IPBlocks to allocate IP addresses. Can be External, Private + or Project. + enum: + - External + - Private + - Project + type: string + type: object + status: + description: IPAddressAllocationStatus defines the observed state of IPAddressAllocation. + properties: + CIDR: + description: CIDR is the allocated CIDR + type: string + conditions: + items: + description: Condition defines condition of custom resource. + properties: + lastTransitionTime: + description: |- + Last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: Message shows a human-readable message about condition. + type: string + reason: + description: Reason shows a brief reason of condition. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: Type defines condition type. + type: string + required: + - status + - type + type: object + type: array + required: + - CIDR + type: object + required: + - metadata + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/build/yaml/samples/nsx_v1alpha1_ipaddressallocation.yaml b/build/yaml/samples/nsx_v1alpha1_ipaddressallocation.yaml new file mode 100644 index 000000000..c56cebd7f --- /dev/null +++ b/build/yaml/samples/nsx_v1alpha1_ipaddressallocation.yaml @@ -0,0 +1,10 @@ +apiVersion: nsx.vmware.com/v1alpha1 +kind: IPAddressAllocation +metadata: + name: guestcluster-workers-a + namespace: sc-a +spec: + ip_address_block_visibility: Private + allocation_size: 26 +status: + CIDR: 172.26.1.0/28 \ No newline at end of file diff --git a/pkg/apis/nsx.vmware.com/v1alpha1/ipaddressallocation_types.go b/pkg/apis/nsx.vmware.com/v1alpha1/ipaddressallocation_types.go new file mode 100644 index 000000000..6a50925c5 --- /dev/null +++ b/pkg/apis/nsx.vmware.com/v1alpha1/ipaddressallocation_types.go @@ -0,0 +1,63 @@ +/* Copyright © 2024 VMware, Inc. All Rights Reserved. + SPDX-License-Identifier: Apache-2.0 */ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type IPAddressVisibility string + +const ( + IPAddressVisibilityExternal = "External" + IPAddressVisibilityPrivate = "Private" + IPAddressVisibilityProject = "Project" +) + +// +genclient +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status +//+kubebuilder:storageversion + +// IPAddressAllocation is the Schema for the IP allocation API. +// +kubebuilder:printcolumn:name="IPAddressBlockVisibility",type=string,JSONPath=`.spec.ip_address_block_visibility`,description="IPAddressBlockVisibility of IPAddressAllocation" +// +kubebuilder:printcolumn:name="CIDR",type=string,JSONPath=`.status.cidr`,description="CIDRs for the IPAddressAllocation" +type IPAddressAllocation struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + Spec IPAddressAllocationSpec `json:"spec"` + Status IPAddressAllocationStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// IPAddressAllocationList contains a list of IPAddressAllocation. +type IPAddressAllocationList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []IPAddressAllocation `json:"items"` +} + +// IPAddressAllocationSpec defines the desired state of IPAddressAllocation. +type IPAddressAllocationSpec struct { + // IPAddressBlockVisibility specifies the visibility of the IPBlocks to allocate IP addresses. Can be External, Private or Project. + // +kubebuilder:validation:Enum=External;Private;Project + // +kubebuilder:default=Private + // +optional + IPAddressBlockVisibility IPAddressVisibility `json:"ip_address_block_visibility,omitempty"` + // AllocationSize specifies the size of IP CIDR to be allocated. + AllocationSize int `json:"allocation_size,omitempty"` +} + +// IPAddressAllocationStatus defines the observed state of IPAddressAllocation. +type IPAddressAllocationStatus struct { + // CIDR is the allocated CIDR + CIDR string `json:"CIDR"` + Conditions []Condition `json:"conditions,omitempty"` +} + +func init() { + SchemeBuilder.Register(&IPAddressAllocation{}, &IPAddressAllocationList{}) +} diff --git a/pkg/apis/nsx.vmware.com/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/nsx.vmware.com/v1alpha1/zz_generated.deepcopy.go index 74ddbb492..5919f2d28 100644 --- a/pkg/apis/nsx.vmware.com/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/nsx.vmware.com/v1alpha1/zz_generated.deepcopy.go @@ -1395,3 +1395,92 @@ func (in *VPCState) DeepCopy() *VPCState { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddressAllocation) DeepCopyInto(out *IPAddressAllocation) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocation. +func (in *IPAddressAllocation) DeepCopy() *IPAddressAllocation { + if in == nil { + return nil + } + out := new(IPAddressAllocation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPAddressAllocation) 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 *IPAddressAllocationList) DeepCopyInto(out *IPAddressAllocationList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]IPAddressAllocation, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationList. +func (in *IPAddressAllocationList) DeepCopy() *IPAddressAllocationList { + if in == nil { + return nil + } + out := new(IPAddressAllocationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPAddressAllocationList) 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 *IPAddressAllocationSpec) DeepCopyInto(out *IPAddressAllocationSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationSpec. +func (in *IPAddressAllocationSpec) DeepCopy() *IPAddressAllocationSpec { + if in == nil { + return nil + } + out := new(IPAddressAllocationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddressAllocationStatus) DeepCopyInto(out *IPAddressAllocationStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationStatus. +func (in *IPAddressAllocationStatus) DeepCopy() *IPAddressAllocationStatus { + if in == nil { + return nil + } + out := new(IPAddressAllocationStatus) + in.DeepCopyInto(out) + return out +} \ No newline at end of file diff --git a/pkg/apis/v1alpha1/ipaddressallocation_types.go b/pkg/apis/v1alpha1/ipaddressallocation_types.go new file mode 100644 index 000000000..6a50925c5 --- /dev/null +++ b/pkg/apis/v1alpha1/ipaddressallocation_types.go @@ -0,0 +1,63 @@ +/* Copyright © 2024 VMware, Inc. All Rights Reserved. + SPDX-License-Identifier: Apache-2.0 */ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type IPAddressVisibility string + +const ( + IPAddressVisibilityExternal = "External" + IPAddressVisibilityPrivate = "Private" + IPAddressVisibilityProject = "Project" +) + +// +genclient +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status +//+kubebuilder:storageversion + +// IPAddressAllocation is the Schema for the IP allocation API. +// +kubebuilder:printcolumn:name="IPAddressBlockVisibility",type=string,JSONPath=`.spec.ip_address_block_visibility`,description="IPAddressBlockVisibility of IPAddressAllocation" +// +kubebuilder:printcolumn:name="CIDR",type=string,JSONPath=`.status.cidr`,description="CIDRs for the IPAddressAllocation" +type IPAddressAllocation struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + Spec IPAddressAllocationSpec `json:"spec"` + Status IPAddressAllocationStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// IPAddressAllocationList contains a list of IPAddressAllocation. +type IPAddressAllocationList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []IPAddressAllocation `json:"items"` +} + +// IPAddressAllocationSpec defines the desired state of IPAddressAllocation. +type IPAddressAllocationSpec struct { + // IPAddressBlockVisibility specifies the visibility of the IPBlocks to allocate IP addresses. Can be External, Private or Project. + // +kubebuilder:validation:Enum=External;Private;Project + // +kubebuilder:default=Private + // +optional + IPAddressBlockVisibility IPAddressVisibility `json:"ip_address_block_visibility,omitempty"` + // AllocationSize specifies the size of IP CIDR to be allocated. + AllocationSize int `json:"allocation_size,omitempty"` +} + +// IPAddressAllocationStatus defines the observed state of IPAddressAllocation. +type IPAddressAllocationStatus struct { + // CIDR is the allocated CIDR + CIDR string `json:"CIDR"` + Conditions []Condition `json:"conditions,omitempty"` +} + +func init() { + SchemeBuilder.Register(&IPAddressAllocation{}, &IPAddressAllocationList{}) +} diff --git a/pkg/apis/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/v1alpha1/zz_generated.deepcopy.go index 74ddbb492..5919f2d28 100644 --- a/pkg/apis/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/v1alpha1/zz_generated.deepcopy.go @@ -1395,3 +1395,92 @@ func (in *VPCState) DeepCopy() *VPCState { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddressAllocation) DeepCopyInto(out *IPAddressAllocation) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocation. +func (in *IPAddressAllocation) DeepCopy() *IPAddressAllocation { + if in == nil { + return nil + } + out := new(IPAddressAllocation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPAddressAllocation) 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 *IPAddressAllocationList) DeepCopyInto(out *IPAddressAllocationList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]IPAddressAllocation, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationList. +func (in *IPAddressAllocationList) DeepCopy() *IPAddressAllocationList { + if in == nil { + return nil + } + out := new(IPAddressAllocationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPAddressAllocationList) 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 *IPAddressAllocationSpec) DeepCopyInto(out *IPAddressAllocationSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationSpec. +func (in *IPAddressAllocationSpec) DeepCopy() *IPAddressAllocationSpec { + if in == nil { + return nil + } + out := new(IPAddressAllocationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddressAllocationStatus) DeepCopyInto(out *IPAddressAllocationStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationStatus. +func (in *IPAddressAllocationStatus) DeepCopy() *IPAddressAllocationStatus { + if in == nil { + return nil + } + out := new(IPAddressAllocationStatus) + in.DeepCopyInto(out) + return out +} \ No newline at end of file diff --git a/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/fake/fake_ipaddressallocation.go b/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/fake/fake_ipaddressallocation.go new file mode 100644 index 000000000..8829426a0 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/fake/fake_ipaddressallocation.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/nsx.vmware.com/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" +) + +// FakeIPAddressAllocations implements IPAddressAllocationInterface +type FakeIPAddressAllocations struct { + Fake *FakeNsxV1alpha1 + ns string +} + +var ipaddressallocationsResource = v1alpha1.SchemeGroupVersion.WithResource("ipaddressallocations") + +var ipaddressallocationsKind = v1alpha1.SchemeGroupVersion.WithKind("IPAddressAllocation") + +// Get takes name of the iPAddressAllocation, and returns the corresponding iPAddressAllocation object, and an error if there is any. +func (c *FakeIPAddressAllocations) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.IPAddressAllocation, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(ipaddressallocationsResource, c.ns, name), &v1alpha1.IPAddressAllocation{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IPAddressAllocation), err +} + +// List takes label and field selectors, and returns the list of IPAddressAllocations that match those selectors. +func (c *FakeIPAddressAllocations) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.IPAddressAllocationList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(ipaddressallocationsResource, ipaddressallocationsKind, c.ns, opts), &v1alpha1.IPAddressAllocationList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.IPAddressAllocationList{ListMeta: obj.(*v1alpha1.IPAddressAllocationList).ListMeta} + for _, item := range obj.(*v1alpha1.IPAddressAllocationList).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 iPAddressAllocations. +func (c *FakeIPAddressAllocations) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(ipaddressallocationsResource, c.ns, opts)) + +} + +// Create takes the representation of a iPAddressAllocation and creates it. Returns the server's representation of the iPAddressAllocation, and an error, if there is any. +func (c *FakeIPAddressAllocations) Create(ctx context.Context, iPAddressAllocation *v1alpha1.IPAddressAllocation, opts v1.CreateOptions) (result *v1alpha1.IPAddressAllocation, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(ipaddressallocationsResource, c.ns, iPAddressAllocation), &v1alpha1.IPAddressAllocation{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IPAddressAllocation), err +} + +// Update takes the representation of a iPAddressAllocation and updates it. Returns the server's representation of the iPAddressAllocation, and an error, if there is any. +func (c *FakeIPAddressAllocations) Update(ctx context.Context, iPAddressAllocation *v1alpha1.IPAddressAllocation, opts v1.UpdateOptions) (result *v1alpha1.IPAddressAllocation, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(ipaddressallocationsResource, c.ns, iPAddressAllocation), &v1alpha1.IPAddressAllocation{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IPAddressAllocation), 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 *FakeIPAddressAllocations) UpdateStatus(ctx context.Context, iPAddressAllocation *v1alpha1.IPAddressAllocation, opts v1.UpdateOptions) (*v1alpha1.IPAddressAllocation, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(ipaddressallocationsResource, "status", c.ns, iPAddressAllocation), &v1alpha1.IPAddressAllocation{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IPAddressAllocation), err +} + +// Delete takes name of the iPAddressAllocation and deletes it. Returns an error if one occurs. +func (c *FakeIPAddressAllocations) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(ipaddressallocationsResource, c.ns, name, opts), &v1alpha1.IPAddressAllocation{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeIPAddressAllocations) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(ipaddressallocationsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.IPAddressAllocationList{}) + return err +} + +// Patch applies the patch and returns the patched iPAddressAllocation. +func (c *FakeIPAddressAllocations) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.IPAddressAllocation, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(ipaddressallocationsResource, c.ns, name, pt, data, subresources...), &v1alpha1.IPAddressAllocation{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.IPAddressAllocation), err +} diff --git a/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/fake/fake_nsx.vmware.com_client.go b/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/fake/fake_nsx.vmware.com_client.go index 716efe23a..f073f5a3c 100644 --- a/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/fake/fake_nsx.vmware.com_client.go +++ b/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/fake/fake_nsx.vmware.com_client.go @@ -15,6 +15,10 @@ type FakeNsxV1alpha1 struct { *testing.Fake } +func (c *FakeNsxV1alpha1) IPAddressAllocations(namespace string) v1alpha1.IPAddressAllocationInterface { + return &FakeIPAddressAllocations{c, namespace} +} + func (c *FakeNsxV1alpha1) IPPools(namespace string) v1alpha1.IPPoolInterface { return &FakeIPPools{c, namespace} } diff --git a/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/generated_expansion.go index c5942e151..cfc317984 100644 --- a/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/generated_expansion.go @@ -5,6 +5,8 @@ package v1alpha1 +type IPAddressAllocationExpansion interface{} + type IPPoolExpansion interface{} type NSXServiceAccountExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/ipaddressallocation.go b/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/ipaddressallocation.go new file mode 100644 index 000000000..532bbacf0 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/ipaddressallocation.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/nsx.vmware.com/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" +) + +// IPAddressAllocationsGetter has a method to return a IPAddressAllocationInterface. +// A group's client should implement this interface. +type IPAddressAllocationsGetter interface { + IPAddressAllocations(namespace string) IPAddressAllocationInterface +} + +// IPAddressAllocationInterface has methods to work with IPAddressAllocation resources. +type IPAddressAllocationInterface interface { + Create(ctx context.Context, iPAddressAllocation *v1alpha1.IPAddressAllocation, opts v1.CreateOptions) (*v1alpha1.IPAddressAllocation, error) + Update(ctx context.Context, iPAddressAllocation *v1alpha1.IPAddressAllocation, opts v1.UpdateOptions) (*v1alpha1.IPAddressAllocation, error) + UpdateStatus(ctx context.Context, iPAddressAllocation *v1alpha1.IPAddressAllocation, opts v1.UpdateOptions) (*v1alpha1.IPAddressAllocation, 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.IPAddressAllocation, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.IPAddressAllocationList, 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.IPAddressAllocation, err error) + IPAddressAllocationExpansion +} + +// iPAddressAllocations implements IPAddressAllocationInterface +type iPAddressAllocations struct { + client rest.Interface + ns string +} + +// newIPAddressAllocations returns a IPAddressAllocations +func newIPAddressAllocations(c *NsxV1alpha1Client, namespace string) *iPAddressAllocations { + return &iPAddressAllocations{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the iPAddressAllocation, and returns the corresponding iPAddressAllocation object, and an error if there is any. +func (c *iPAddressAllocations) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.IPAddressAllocation, err error) { + result = &v1alpha1.IPAddressAllocation{} + err = c.client.Get(). + Namespace(c.ns). + Resource("ipaddressallocations"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of IPAddressAllocations that match those selectors. +func (c *iPAddressAllocations) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.IPAddressAllocationList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.IPAddressAllocationList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("ipaddressallocations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested iPAddressAllocations. +func (c *iPAddressAllocations) 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("ipaddressallocations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a iPAddressAllocation and creates it. Returns the server's representation of the iPAddressAllocation, and an error, if there is any. +func (c *iPAddressAllocations) Create(ctx context.Context, iPAddressAllocation *v1alpha1.IPAddressAllocation, opts v1.CreateOptions) (result *v1alpha1.IPAddressAllocation, err error) { + result = &v1alpha1.IPAddressAllocation{} + err = c.client.Post(). + Namespace(c.ns). + Resource("ipaddressallocations"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iPAddressAllocation). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a iPAddressAllocation and updates it. Returns the server's representation of the iPAddressAllocation, and an error, if there is any. +func (c *iPAddressAllocations) Update(ctx context.Context, iPAddressAllocation *v1alpha1.IPAddressAllocation, opts v1.UpdateOptions) (result *v1alpha1.IPAddressAllocation, err error) { + result = &v1alpha1.IPAddressAllocation{} + err = c.client.Put(). + Namespace(c.ns). + Resource("ipaddressallocations"). + Name(iPAddressAllocation.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iPAddressAllocation). + 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 *iPAddressAllocations) UpdateStatus(ctx context.Context, iPAddressAllocation *v1alpha1.IPAddressAllocation, opts v1.UpdateOptions) (result *v1alpha1.IPAddressAllocation, err error) { + result = &v1alpha1.IPAddressAllocation{} + err = c.client.Put(). + Namespace(c.ns). + Resource("ipaddressallocations"). + Name(iPAddressAllocation.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(iPAddressAllocation). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the iPAddressAllocation and deletes it. Returns an error if one occurs. +func (c *iPAddressAllocations) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("ipaddressallocations"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *iPAddressAllocations) 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("ipaddressallocations"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched iPAddressAllocation. +func (c *iPAddressAllocations) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.IPAddressAllocation, err error) { + result = &v1alpha1.IPAddressAllocation{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("ipaddressallocations"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/nsx.vmware.com_client.go b/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/nsx.vmware.com_client.go index 88726804e..5c50677e3 100644 --- a/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/nsx.vmware.com_client.go +++ b/pkg/client/clientset/versioned/typed/nsx.vmware.com/v1alpha1/nsx.vmware.com_client.go @@ -15,6 +15,7 @@ import ( type NsxV1alpha1Interface interface { RESTClient() rest.Interface + IPAddressAllocationsGetter IPPoolsGetter NSXServiceAccountsGetter NetworkInfosGetter @@ -31,6 +32,10 @@ type NsxV1alpha1Client struct { restClient rest.Interface } +func (c *NsxV1alpha1Client) IPAddressAllocations(namespace string) IPAddressAllocationInterface { + return newIPAddressAllocations(c, namespace) +} + func (c *NsxV1alpha1Client) IPPools(namespace string) IPPoolInterface { return newIPPools(c, namespace) } diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 0e3ae7c62..7f49f905c 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -41,6 +41,8 @@ func (f *genericInformer) Lister() cache.GenericLister { func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { // Group=nsx.vmware.com, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("ipaddressallocations"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Nsx().V1alpha1().IPAddressAllocations().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("ippools"): return &genericInformer{resource: resource.GroupResource(), informer: f.Nsx().V1alpha1().IPPools().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("nsxserviceaccounts"): diff --git a/pkg/client/informers/externalversions/nsx.vmware.com/v1alpha1/interface.go b/pkg/client/informers/externalversions/nsx.vmware.com/v1alpha1/interface.go index 423a9fbbc..835cd1514 100644 --- a/pkg/client/informers/externalversions/nsx.vmware.com/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/nsx.vmware.com/v1alpha1/interface.go @@ -11,6 +11,8 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { + // IPAddressAllocations returns a IPAddressAllocationInformer. + IPAddressAllocations() IPAddressAllocationInformer // IPPools returns a IPPoolInformer. IPPools() IPPoolInformer // NSXServiceAccounts returns a NSXServiceAccountInformer. @@ -42,6 +44,11 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } +// IPAddressAllocations returns a IPAddressAllocationInformer. +func (v *version) IPAddressAllocations() IPAddressAllocationInformer { + return &iPAddressAllocationInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // IPPools returns a IPPoolInformer. func (v *version) IPPools() IPPoolInformer { return &iPPoolInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/informers/externalversions/nsx.vmware.com/v1alpha1/ipaddressallocation.go b/pkg/client/informers/externalversions/nsx.vmware.com/v1alpha1/ipaddressallocation.go new file mode 100644 index 000000000..ff1e7c99a --- /dev/null +++ b/pkg/client/informers/externalversions/nsx.vmware.com/v1alpha1/ipaddressallocation.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" + + nsxvmwarecomv1alpha1 "github.com/vmware-tanzu/nsx-operator/pkg/apis/nsx.vmware.com/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/nsx.vmware.com/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" +) + +// IPAddressAllocationInformer provides access to a shared informer and lister for +// IPAddressAllocations. +type IPAddressAllocationInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.IPAddressAllocationLister +} + +type iPAddressAllocationInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewIPAddressAllocationInformer constructs a new informer for IPAddressAllocation 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 NewIPAddressAllocationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredIPAddressAllocationInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredIPAddressAllocationInformer constructs a new informer for IPAddressAllocation 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 NewFilteredIPAddressAllocationInformer(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.NsxV1alpha1().IPAddressAllocations(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NsxV1alpha1().IPAddressAllocations(namespace).Watch(context.TODO(), options) + }, + }, + &nsxvmwarecomv1alpha1.IPAddressAllocation{}, + resyncPeriod, + indexers, + ) +} + +func (f *iPAddressAllocationInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredIPAddressAllocationInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *iPAddressAllocationInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&nsxvmwarecomv1alpha1.IPAddressAllocation{}, f.defaultInformer) +} + +func (f *iPAddressAllocationInformer) Lister() v1alpha1.IPAddressAllocationLister { + return v1alpha1.NewIPAddressAllocationLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/listers/nsx.vmware.com/v1alpha1/expansion_generated.go b/pkg/client/listers/nsx.vmware.com/v1alpha1/expansion_generated.go index fcaca97ac..f9e197206 100644 --- a/pkg/client/listers/nsx.vmware.com/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/nsx.vmware.com/v1alpha1/expansion_generated.go @@ -5,6 +5,14 @@ package v1alpha1 +// IPAddressAllocationListerExpansion allows custom methods to be added to +// IPAddressAllocationLister. +type IPAddressAllocationListerExpansion interface{} + +// IPAddressAllocationNamespaceListerExpansion allows custom methods to be added to +// IPAddressAllocationNamespaceLister. +type IPAddressAllocationNamespaceListerExpansion interface{} + // IPPoolListerExpansion allows custom methods to be added to // IPPoolLister. type IPPoolListerExpansion interface{} diff --git a/pkg/client/listers/nsx.vmware.com/v1alpha1/ipaddressallocation.go b/pkg/client/listers/nsx.vmware.com/v1alpha1/ipaddressallocation.go new file mode 100644 index 000000000..cb5a8feb2 --- /dev/null +++ b/pkg/client/listers/nsx.vmware.com/v1alpha1/ipaddressallocation.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/nsx.vmware.com/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// IPAddressAllocationLister helps list IPAddressAllocations. +// All objects returned here must be treated as read-only. +type IPAddressAllocationLister interface { + // List lists all IPAddressAllocations in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.IPAddressAllocation, err error) + // IPAddressAllocations returns an object that can list and get IPAddressAllocations. + IPAddressAllocations(namespace string) IPAddressAllocationNamespaceLister + IPAddressAllocationListerExpansion +} + +// iPAddressAllocationLister implements the IPAddressAllocationLister interface. +type iPAddressAllocationLister struct { + indexer cache.Indexer +} + +// NewIPAddressAllocationLister returns a new IPAddressAllocationLister. +func NewIPAddressAllocationLister(indexer cache.Indexer) IPAddressAllocationLister { + return &iPAddressAllocationLister{indexer: indexer} +} + +// List lists all IPAddressAllocations in the indexer. +func (s *iPAddressAllocationLister) List(selector labels.Selector) (ret []*v1alpha1.IPAddressAllocation, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.IPAddressAllocation)) + }) + return ret, err +} + +// IPAddressAllocations returns an object that can list and get IPAddressAllocations. +func (s *iPAddressAllocationLister) IPAddressAllocations(namespace string) IPAddressAllocationNamespaceLister { + return iPAddressAllocationNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// IPAddressAllocationNamespaceLister helps list and get IPAddressAllocations. +// All objects returned here must be treated as read-only. +type IPAddressAllocationNamespaceLister interface { + // List lists all IPAddressAllocations in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.IPAddressAllocation, err error) + // Get retrieves the IPAddressAllocation from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.IPAddressAllocation, error) + IPAddressAllocationNamespaceListerExpansion +} + +// iPAddressAllocationNamespaceLister implements the IPAddressAllocationNamespaceLister +// interface. +type iPAddressAllocationNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all IPAddressAllocations in the indexer for a given namespace. +func (s iPAddressAllocationNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.IPAddressAllocation, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.IPAddressAllocation)) + }) + return ret, err +} + +// Get retrieves the IPAddressAllocation from the indexer for a given namespace and name. +func (s iPAddressAllocationNamespaceLister) Get(name string) (*v1alpha1.IPAddressAllocation, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("ipaddressallocation"), name) + } + return obj.(*v1alpha1.IPAddressAllocation), nil +}