forked from vmware-tanzu/nsx-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request vmware-tanzu#288 from zhengxiexie/codegen_alpha2_v…
…pc_dev Support codegen for v1alpha2
- Loading branch information
Showing
90 changed files
with
1,820 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
--- | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,23 +9,23 @@ APIS=./pkg/apis | |
APIS_PKG=github.com/vmware-tanzu/nsx-operator/pkg/apis | ||
OUTPUT_PKG=github.com/vmware-tanzu/nsx-operator/pkg/client | ||
GROUP=nsx.vmware.com | ||
VERSION=v1alpha1 | ||
GROUP_VERSION=$GROUP:$VERSION | ||
|
||
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. | ||
CODEGEN_PKG=$(go env GOMODCACHE)/k8s.io/[email protected] | ||
|
||
rm -fr "${APIS:?}/${GROUP:?}" | ||
rm -fr ./pkg/client | ||
mkdir -p "${APIS}/${GROUP}/${VERSION}" | ||
cp -r "${APIS}/${VERSION}"/* "${APIS}/${GROUP}/${VERSION}/" | ||
|
||
for VERSION in v1alpha1 v1alpha2; do | ||
mkdir -p "${APIS}/${GROUP}/${VERSION}" | ||
cp -r "${APIS}/${VERSION}"/* "${APIS}/${GROUP}/${VERSION}/" | ||
done | ||
|
||
bash "${CODEGEN_PKG}"/generate-groups.sh "client,lister,informer" \ | ||
${OUTPUT_PKG} ${APIS_PKG} \ | ||
${GROUP_VERSION} \ | ||
--go-header-file "${SCRIPT_ROOT}"/hack/boilerplate.go.txt \ | ||
--output-base "${SCRIPT_ROOT}" -v 10 | ||
bash "${CODEGEN_PKG}"/generate-groups.sh "deepcopy,client,informer,lister" \ | ||
${OUTPUT_PKG} ${APIS_PKG} \ | ||
${GROUP}:v1alpha1,v1alpha2 \ | ||
--go-header-file "${SCRIPT_ROOT}"/hack/boilerplate.go.txt \ | ||
--output-base "${SCRIPT_ROOT}" -v 10 | ||
|
||
mv ./${OUTPUT_PKG} ./pkg/ | ||
rm -rf ./github.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* Copyright © 2023 VMware, Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 */ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// +genclient | ||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
|
||
// IPPool is the Schema for the ippools API. | ||
type IPPool struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata"` | ||
|
||
Spec IPPoolSpec `json:"spec"` | ||
Status IPPoolStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// IPPoolList contains a list of IPPool. | ||
type IPPoolList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []IPPool `json:"items"` | ||
} | ||
|
||
// IPPoolSpec defines the desired state of IPPool. | ||
type IPPoolSpec struct { | ||
// Subnets defines set of subnets need to be allocated. | ||
// +optional | ||
Subnets []SubnetRequest `json:"subnets"` | ||
} | ||
|
||
// IPPoolStatus defines the observed state of IPPool. | ||
type IPPoolStatus struct { | ||
// Subnets defines subnets allocation result. | ||
Subnets []SubnetResult `json:"subnets"` | ||
// Conditions defines current state of the IPPool. | ||
Conditions []Condition `json:"conditions"` | ||
} | ||
|
||
// SubnetRequest defines the subnet allocation request. | ||
type SubnetRequest struct { | ||
// PrefixLength defines prefix length for this subnet. | ||
PrefixLength int `json:"prefixLength,omitempty"` | ||
|
||
// IPFamily defines the IP family type for this subnet, could be IPv4 or IPv6. | ||
// This is optional, the default is IPv4. | ||
// +kubebuilder:validation:Enum=IPv4;IPv6 | ||
// +kubebuilder:default=IPv4 | ||
IPFamily string `json:"ipFamily,omitempty"` | ||
|
||
// Name defines the name of this subnet. | ||
Name string `json:"name"` | ||
} | ||
|
||
// SubnetResult defines the subnet allocation result. | ||
type SubnetResult struct { | ||
// CIDR defines the allocated CIDR. | ||
CIDR string `json:"cidr"` | ||
|
||
// Name defines the name of this subnet. | ||
Name string `json:"name"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&IPPool{}, &IPPoolList{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.