From df5d028a5e3c95c73a6ca37bb854f6fbd9b22ddd Mon Sep 17 00:00:00 2001 From: zbb88888 Date: Fri, 1 Aug 2025 17:43:45 +0800 Subject: [PATCH 1/4] support crd gen Signed-off-by: zbb88888 --- hack/update-codegen-crd.sh | 14 ++++++++++++++ pkg/apis/kubeovn/v1/provider-network.go | 3 ++- pkg/apis/kubeovn/v1/subnet.go | 3 ++- pkg/internal/big_int.go | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100755 hack/update-codegen-crd.sh diff --git a/hack/update-codegen-crd.sh b/hack/update-codegen-crd.sh new file mode 100755 index 00000000000..3ec74d26264 --- /dev/null +++ b/hack/update-codegen-crd.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -eux +# usage: bash ./hack/update-codegen-crd.sh + +# set GOPROXY you like +export GOPROXY=https://goproxy.cn +# use controller-gen to generate CRDs +# ensure controller-gen is installed +CONTROLLER_TOOLS_VERSION=${CONTROLLER_TOOLS_VERSION:-"v0.17.3"} +go install sigs.k8s.io/controller-tools/cmd/controller-gen@"${CONTROLLER_TOOLS_VERSION}" +go mod tidy + +# generate CRDs +controller-gen crd:allowDangerousTypes=true paths=./pkg/apis/kubeovn/v1 output:crd:artifacts:config=./yamls/crds diff --git a/pkg/apis/kubeovn/v1/provider-network.go b/pkg/apis/kubeovn/v1/provider-network.go index 593913892c2..9f96f3087c7 100644 --- a/pkg/apis/kubeovn/v1/provider-network.go +++ b/pkg/apis/kubeovn/v1/provider-network.go @@ -42,7 +42,8 @@ type ProviderNetworkSpec struct { type ProviderNetworkCondition struct { // Node name Node string `json:"node"` - Condition + + Condition `json:"condition"` } type ProviderNetworkStatus struct { diff --git a/pkg/apis/kubeovn/v1/subnet.go b/pkg/apis/kubeovn/v1/subnet.go index d0c5176072d..0c2b1d869cf 100644 --- a/pkg/apis/kubeovn/v1/subnet.go +++ b/pkg/apis/kubeovn/v1/subnet.go @@ -110,7 +110,8 @@ type NatOutGoingPolicyMatch struct { type NatOutgoingPolicyRuleStatus struct { RuleID string `json:"ruleID"` - NatOutgoingPolicyRule + + NatOutgoingPolicyRule `json:"natOutgoingPolicyRule"` } type SubnetStatus struct { // Conditions represents the latest state of the object diff --git a/pkg/internal/big_int.go b/pkg/internal/big_int.go index 4a43203c207..113828e8ec6 100644 --- a/pkg/internal/big_int.go +++ b/pkg/internal/big_int.go @@ -6,7 +6,7 @@ import ( ) type BigInt struct { - big.Int + big.Int `json:"bigInt"` } func (b BigInt) DeepCopyInto(n *BigInt) { From bb2f640637f0437a524c7493a7ff9edad1e8492b Mon Sep 17 00:00:00 2001 From: zbb88888 Date: Fri, 1 Aug 2025 17:45:28 +0800 Subject: [PATCH 2/4] ignore temp crds for now Signed-off-by: zbb88888 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ab7f1041986..5d93a035d43 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ kube-ovn.yaml !/charts/kube-ovn-v2/crds/kube-ovn-crd.yaml !/charts/kube-ovn/templates/kube-ovn-crd.yaml kube-ovn-crd.yaml +yamls/crds ovn.yaml ovn-ic-controller.yaml ovn-ic-server.yaml From 41ddcf740cbd023befdc0c44f434abded9ddeb75 Mon Sep 17 00:00:00 2001 From: zbb88888 Date: Fri, 1 Aug 2025 17:52:46 +0800 Subject: [PATCH 3/4] Update hack/update-codegen-crd.sh Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- hack/update-codegen-crd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/update-codegen-crd.sh b/hack/update-codegen-crd.sh index 3ec74d26264..791a211f802 100755 --- a/hack/update-codegen-crd.sh +++ b/hack/update-codegen-crd.sh @@ -3,7 +3,7 @@ set -eux # usage: bash ./hack/update-codegen-crd.sh # set GOPROXY you like -export GOPROXY=https://goproxy.cn +export GOPROXY=${GOPROXY:-"https://goproxy.cn"} # use controller-gen to generate CRDs # ensure controller-gen is installed CONTROLLER_TOOLS_VERSION=${CONTROLLER_TOOLS_VERSION:-"v0.17.3"} From 817a16f5308271af0948ed6fd7830256bbc19014 Mon Sep 17 00:00:00 2001 From: zbb88888 Date: Fri, 1 Aug 2025 18:05:37 +0800 Subject: [PATCH 4/4] fix as gemini, but err Signed-off-by: zbb88888 --- pkg/apis/kubeovn/v1/ippool.go | 13 +++++++++---- pkg/internal/big_int.go | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/apis/kubeovn/v1/ippool.go b/pkg/apis/kubeovn/v1/ippool.go index 538eff57031..cfd6ab48738 100644 --- a/pkg/apis/kubeovn/v1/ippool.go +++ b/pkg/apis/kubeovn/v1/ippool.go @@ -37,14 +37,19 @@ type IPPoolSpec struct { } type IPPoolStatus struct { + // TODO:// make Subnet and IP Pool AvailableIPs and UsingIPs type consistent + // +kubebuilder:validation:Type=string V4AvailableIPs internal.BigInt `json:"v4AvailableIPs"` V4AvailableIPRange string `json:"v4AvailableIPRange"` - V4UsingIPs internal.BigInt `json:"v4UsingIPs"` - V4UsingIPRange string `json:"v4UsingIPRange"` + // +kubebuilder:validation:Type=string + V4UsingIPs internal.BigInt `json:"v4UsingIPs"` + V4UsingIPRange string `json:"v4UsingIPRange"` + // +kubebuilder:validation:Type=string V6AvailableIPs internal.BigInt `json:"v6AvailableIPs"` V6AvailableIPRange string `json:"v6AvailableIPRange"` - V6UsingIPs internal.BigInt `json:"v6UsingIPs"` - V6UsingIPRange string `json:"v6UsingIPRange"` + // +kubebuilder:validation:Type=string + V6UsingIPs internal.BigInt `json:"v6UsingIPs"` + V6UsingIPRange string `json:"v6UsingIPRange"` // Conditions represents the latest state of the object // +optional diff --git a/pkg/internal/big_int.go b/pkg/internal/big_int.go index 113828e8ec6..4a43203c207 100644 --- a/pkg/internal/big_int.go +++ b/pkg/internal/big_int.go @@ -6,7 +6,7 @@ import ( ) type BigInt struct { - big.Int `json:"bigInt"` + big.Int } func (b BigInt) DeepCopyInto(n *BigInt) {