From f3bef41f63e83eea8c3b4fa5c7cdb418d155e63f Mon Sep 17 00:00:00 2001 From: Wenqi Qiu Date: Fri, 19 Jul 2024 00:36:16 +0800 Subject: [PATCH] Address comments Signed-off-by: Wenqi Qiu --- build/yaml/crd/nsx.vmware.com_subnets.yaml | 4 ++-- build/yaml/crd/nsx.vmware.com_subnetsets.yaml | 4 ++-- .../yaml/crd/nsx.vmware.com_vpcnetworkconfigurations.yaml | 2 +- .../samples/nsx_v1alpha1_vpcnetworkconfigurations.yaml | 4 ++-- .../nsx.vmware.com/v1alpha1/ipaddressallocation_types.go | 8 ++++---- pkg/apis/nsx.vmware.com/v1alpha1/subnet_types.go | 4 ++-- pkg/apis/nsx.vmware.com/v1alpha1/subnetset_types.go | 4 ++-- .../v1alpha1/vpcnetworkconfiguration_types.go | 6 +++--- pkg/apis/v1alpha1/subnet_types.go | 4 ++-- pkg/apis/v1alpha1/subnetset_types.go | 4 ++-- pkg/apis/v1alpha1/vpcnetworkconfiguration_types.go | 4 ++-- pkg/controllers/namespace/namespace_controller.go | 2 +- .../networkinfo/vpcnetworkconfig_handler_test.go | 4 ++-- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/build/yaml/crd/nsx.vmware.com_subnets.yaml b/build/yaml/crd/nsx.vmware.com_subnets.yaml index 46a838be1..3fac19d3a 100644 --- a/build/yaml/crd/nsx.vmware.com_subnets.yaml +++ b/build/yaml/crd/nsx.vmware.com_subnets.yaml @@ -60,11 +60,11 @@ spec: type: boolean type: object accessMode: - default: Private + default: Private_TGW description: Access mode of Subnet, accessible only from within VPC or from outside VPC. enum: - - Private + - Private_TGW - Public - Project type: string diff --git a/build/yaml/crd/nsx.vmware.com_subnetsets.yaml b/build/yaml/crd/nsx.vmware.com_subnetsets.yaml index f6ffc81b7..d7b9edc6b 100644 --- a/build/yaml/crd/nsx.vmware.com_subnetsets.yaml +++ b/build/yaml/crd/nsx.vmware.com_subnetsets.yaml @@ -60,11 +60,11 @@ spec: type: boolean type: object accessMode: - default: Private + default: Private_TGW description: Access mode of Subnet, accessible only from within VPC or from outside VPC. enum: - - Private + - Private_TGW - Public - Project type: string diff --git a/build/yaml/crd/nsx.vmware.com_vpcnetworkconfigurations.yaml b/build/yaml/crd/nsx.vmware.com_vpcnetworkconfigurations.yaml index 07ecf0e31..554d8b04f 100644 --- a/build/yaml/crd/nsx.vmware.com_vpcnetworkconfigurations.yaml +++ b/build/yaml/crd/nsx.vmware.com_vpcnetworkconfigurations.yaml @@ -76,7 +76,7 @@ spec: Must be Public or Private. enum: - Public - - Private + - Private_TGW - Project type: string privateIPs: diff --git a/build/yaml/samples/nsx_v1alpha1_vpcnetworkconfigurations.yaml b/build/yaml/samples/nsx_v1alpha1_vpcnetworkconfigurations.yaml index c61341f26..1612d2cd8 100644 --- a/build/yaml/samples/nsx_v1alpha1_vpcnetworkconfigurations.yaml +++ b/build/yaml/samples/nsx_v1alpha1_vpcnetworkconfigurations.yaml @@ -12,7 +12,7 @@ spec: privateIPs: - 172.26.0.0/16 - 172.36.0.0/16 - podSubnetAccessMode: Private + podSubnetAccessMode: Private_TGW --- # Sample to create VPCNetworkConfiguration CR using a pre-created NSX VPC. apiVersion: nsx.vmware.com/v1alpha1 @@ -22,6 +22,6 @@ metadata: spec: vpc: /orgs/default/projects/proj-1/vpcs/vpc-1 defaultIPv4SubnetSize: 28 - podSubnetAccessMode: Private + podSubnetAccessMode: Private_TGW vpcConnectivityProfile: /orgs/default/projects/wenqi-test/vpc-connectivity-profiles/default vpcServiceProfile: /orgs/default/projects/wenqi-test/vpc-service-profiles/default diff --git a/pkg/apis/nsx.vmware.com/v1alpha1/ipaddressallocation_types.go b/pkg/apis/nsx.vmware.com/v1alpha1/ipaddressallocation_types.go index 6a50925c5..b7754c563 100644 --- a/pkg/apis/nsx.vmware.com/v1alpha1/ipaddressallocation_types.go +++ b/pkg/apis/nsx.vmware.com/v1alpha1/ipaddressallocation_types.go @@ -16,9 +16,9 @@ const ( ) // +genclient -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status -//+kubebuilder:storageversion +// +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" @@ -31,7 +31,7 @@ type IPAddressAllocation struct { Status IPAddressAllocationStatus `json:"status,omitempty"` } -//+kubebuilder:object:root=true +// +kubebuilder:object:root=true // IPAddressAllocationList contains a list of IPAddressAllocation. type IPAddressAllocationList struct { diff --git a/pkg/apis/nsx.vmware.com/v1alpha1/subnet_types.go b/pkg/apis/nsx.vmware.com/v1alpha1/subnet_types.go index 82ecdb839..adaae2ce1 100644 --- a/pkg/apis/nsx.vmware.com/v1alpha1/subnet_types.go +++ b/pkg/apis/nsx.vmware.com/v1alpha1/subnet_types.go @@ -16,8 +16,8 @@ type SubnetSpec struct { // +kubebuilder:validation:Minimum:=16 IPv4SubnetSize int `json:"ipv4SubnetSize,omitempty"` // Access mode of Subnet, accessible only from within VPC or from outside VPC. - // +kubebuilder:default:=Private - // +kubebuilder:validation:Enum=Private;Public;Project + // +kubebuilder:default:=Private_TGW + // +kubebuilder:validation:Enum=Private_TGW;Public;Project AccessMode AccessMode `json:"accessMode,omitempty"` // Subnet CIDRS. // +kubebuilder:validation:MinItems=0 diff --git a/pkg/apis/nsx.vmware.com/v1alpha1/subnetset_types.go b/pkg/apis/nsx.vmware.com/v1alpha1/subnetset_types.go index 275db8762..cb87addc3 100644 --- a/pkg/apis/nsx.vmware.com/v1alpha1/subnetset_types.go +++ b/pkg/apis/nsx.vmware.com/v1alpha1/subnetset_types.go @@ -14,8 +14,8 @@ type SubnetSetSpec struct { // +kubebuilder:validation:Minimum:=16 IPv4SubnetSize int `json:"ipv4SubnetSize,omitempty"` // Access mode of Subnet, accessible only from within VPC or from outside VPC. - // +kubebuilder:default:=Private - // +kubebuilder:validation:Enum=Private;Public;Project + // +kubebuilder:default:=Private_TGW + // +kubebuilder:validation:Enum=Private_TGW;Public;Project AccessMode AccessMode `json:"accessMode,omitempty"` // Subnet advanced configuration. AdvancedConfig AdvancedConfig `json:"advancedConfig,omitempty"` diff --git a/pkg/apis/nsx.vmware.com/v1alpha1/vpcnetworkconfiguration_types.go b/pkg/apis/nsx.vmware.com/v1alpha1/vpcnetworkconfiguration_types.go index e17d46e06..43015b9a1 100644 --- a/pkg/apis/nsx.vmware.com/v1alpha1/vpcnetworkconfiguration_types.go +++ b/pkg/apis/nsx.vmware.com/v1alpha1/vpcnetworkconfiguration_types.go @@ -10,7 +10,7 @@ import ( const ( AccessModePublic string = "Public" - AccessModePrivate string = "Private" + AccessModePrivate string = "Private_TGW" AccessModeProject string = "Project" LbServiceSizeSmall string = "SMALL" LbServiceSizeMedium string = "MEDIUM" @@ -56,8 +56,8 @@ type VPCNetworkConfigurationSpec struct { // +kubebuilder:default=26 DefaultSubnetSize int `json:"defaultSubnetSize,omitempty"` // PodSubnetAccessMode defines the access mode of the default SubnetSet for PodVM. - // Must be Public or Private. - // +kubebuilder:validation:Enum=Public;Private;Project + // Must be Public, Private_TGW, or Project. + // +kubebuilder:validation:Enum=Public;Private_TGW;Project PodSubnetAccessMode string `json:"podSubnetAccessMode,omitempty"` } diff --git a/pkg/apis/v1alpha1/subnet_types.go b/pkg/apis/v1alpha1/subnet_types.go index 82ecdb839..adaae2ce1 100644 --- a/pkg/apis/v1alpha1/subnet_types.go +++ b/pkg/apis/v1alpha1/subnet_types.go @@ -16,8 +16,8 @@ type SubnetSpec struct { // +kubebuilder:validation:Minimum:=16 IPv4SubnetSize int `json:"ipv4SubnetSize,omitempty"` // Access mode of Subnet, accessible only from within VPC or from outside VPC. - // +kubebuilder:default:=Private - // +kubebuilder:validation:Enum=Private;Public;Project + // +kubebuilder:default:=Private_TGW + // +kubebuilder:validation:Enum=Private_TGW;Public;Project AccessMode AccessMode `json:"accessMode,omitempty"` // Subnet CIDRS. // +kubebuilder:validation:MinItems=0 diff --git a/pkg/apis/v1alpha1/subnetset_types.go b/pkg/apis/v1alpha1/subnetset_types.go index 275db8762..cb87addc3 100644 --- a/pkg/apis/v1alpha1/subnetset_types.go +++ b/pkg/apis/v1alpha1/subnetset_types.go @@ -14,8 +14,8 @@ type SubnetSetSpec struct { // +kubebuilder:validation:Minimum:=16 IPv4SubnetSize int `json:"ipv4SubnetSize,omitempty"` // Access mode of Subnet, accessible only from within VPC or from outside VPC. - // +kubebuilder:default:=Private - // +kubebuilder:validation:Enum=Private;Public;Project + // +kubebuilder:default:=Private_TGW + // +kubebuilder:validation:Enum=Private_TGW;Public;Project AccessMode AccessMode `json:"accessMode,omitempty"` // Subnet advanced configuration. AdvancedConfig AdvancedConfig `json:"advancedConfig,omitempty"` diff --git a/pkg/apis/v1alpha1/vpcnetworkconfiguration_types.go b/pkg/apis/v1alpha1/vpcnetworkconfiguration_types.go index e17d46e06..3ee1b0f7c 100644 --- a/pkg/apis/v1alpha1/vpcnetworkconfiguration_types.go +++ b/pkg/apis/v1alpha1/vpcnetworkconfiguration_types.go @@ -10,7 +10,7 @@ import ( const ( AccessModePublic string = "Public" - AccessModePrivate string = "Private" + AccessModePrivate string = "Private_TGW" AccessModeProject string = "Project" LbServiceSizeSmall string = "SMALL" LbServiceSizeMedium string = "MEDIUM" @@ -57,7 +57,7 @@ type VPCNetworkConfigurationSpec struct { DefaultSubnetSize int `json:"defaultSubnetSize,omitempty"` // PodSubnetAccessMode defines the access mode of the default SubnetSet for PodVM. // Must be Public or Private. - // +kubebuilder:validation:Enum=Public;Private;Project + // +kubebuilder:validation:Enum=Public;Private_TGW;Project PodSubnetAccessMode string `json:"podSubnetAccessMode,omitempty"` } diff --git a/pkg/controllers/namespace/namespace_controller.go b/pkg/controllers/namespace/namespace_controller.go index 87d5e0cc8..feaa71108 100644 --- a/pkg/controllers/namespace/namespace_controller.go +++ b/pkg/controllers/namespace/namespace_controller.go @@ -122,7 +122,7 @@ func (r *NamespaceReconciler) createDefaultSubnetSet(ns string, defaultPodAccess } if name == types.DefaultVMSubnetSet { // use "Private" type for VM - obj.Spec.AccessMode = v1alpha1.AccessMode("Private") + obj.Spec.AccessMode = v1alpha1.AccessMode(v1alpha1.AccessModePrivate) } else if name == types.DefaultPodSubnetSet { obj.Spec.AccessMode = v1alpha1.AccessMode(defaultPodAccessMode) } diff --git a/pkg/controllers/networkinfo/vpcnetworkconfig_handler_test.go b/pkg/controllers/networkinfo/vpcnetworkconfig_handler_test.go index b4ca96f64..23b6bc754 100644 --- a/pkg/controllers/networkinfo/vpcnetworkconfig_handler_test.go +++ b/pkg/controllers/networkinfo/vpcnetworkconfig_handler_test.go @@ -124,8 +124,8 @@ func TestBuildNetworkConfigInfo(t *testing.T) { vpcConnectivityProfile string }{ {"test-nsxtProjectPathToId", testCRD1, "test-gw-path-1", "test-edge-path-1", "default", "nsx_operator_e2e_test", 64, "Public", false, ""}, - {"with-VpcConnectivityProfile", testCRD2, "test-gw-path-2", "test-edge-path-2", "anotherOrg", "anotherProject", 32, "Private", false, "test-VpcConnectivityProfile"}, - {"with-defaultNetworkConfig", testCRD3, "test-gw-path-2", "test-edge-path-2", "anotherOrg", "anotherProject", 32, "Private", true, ""}, + {"with-VpcConnectivityProfile", testCRD2, "test-gw-path-2", "test-edge-path-2", "anotherOrg", "anotherProject", 32, "Private_TGW", false, "test-VpcConnectivityProfile"}, + {"with-defaultNetworkConfig", testCRD3, "test-gw-path-2", "test-edge-path-2", "anotherOrg", "anotherProject", 32, "Private_TGW", true, ""}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {