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 diff --git a/hack/update-codegen-crd.sh b/hack/update-codegen-crd.sh new file mode 100755 index 00000000000..791a211f802 --- /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=${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/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/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