@@ -524,8 +524,8 @@ type ClusterAvailabilityGate struct {
524
524
// Note: Both Cluster API conditions or conditions added by 3rd party controllers can be used as availability gates.
525
525
// +required
526
526
// +kubebuilder:validation:Pattern=`^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$`
527
- // +kubebuilder:validation:MaxLength=316
528
527
// +kubebuilder:validation:MinLength=1
528
+ // +kubebuilder:validation:MaxLength=316
529
529
ConditionType string `json:"conditionType"`
530
530
531
531
// polarity of the conditionType specified in this availabilityGate.
@@ -542,6 +542,8 @@ type ClusterAvailabilityGate struct {
542
542
type Topology struct {
543
543
// class is the name of the ClusterClass object to create the topology.
544
544
// +required
545
+ // +kubebuilder:validation:MinLength=1
546
+ // +kubebuilder:validation:MaxLength=253
545
547
Class string `json:"class"`
546
548
547
549
// classNamespace is the namespace of the ClusterClass object to create the topology.
@@ -555,6 +557,8 @@ type Topology struct {
555
557
556
558
// version is the Kubernetes version of the cluster.
557
559
// +required
560
+ // +kubebuilder:validation:MinLength=1
561
+ // +kubebuilder:validation:MaxLength=256
558
562
Version string `json:"version"`
559
563
560
564
// rolloutAfter performs a rollout of the entire cluster one component at a time,
@@ -672,18 +676,24 @@ type MachineDeploymentTopology struct {
672
676
// This should match one of the deployment classes defined in the ClusterClass object
673
677
// mentioned in the `Cluster.Spec.Class` field.
674
678
// +required
679
+ // +kubebuilder:validation:MinLength=1
680
+ // +kubebuilder:validation:MaxLength=256
675
681
Class string `json:"class"`
676
682
677
683
// name is the unique identifier for this MachineDeploymentTopology.
678
684
// The value is used with other unique identifiers to create a MachineDeployment's Name
679
685
// (e.g. cluster's name, etc). In case the name is greater than the allowed maximum length,
680
686
// the values are hashed together.
681
687
// +required
688
+ // +kubebuilder:validation:MinLength=1
689
+ // +kubebuilder:validation:MaxLength=256
682
690
Name string `json:"name"`
683
691
684
692
// failureDomain is the failure domain the machines will be created in.
685
693
// Must match a key in the FailureDomains map stored on the cluster object.
686
694
// +optional
695
+ // +kubebuilder:validation:MinLength=1
696
+ // +kubebuilder:validation:MaxLength=256
687
697
FailureDomain * string `json:"failureDomain,omitempty"`
688
698
689
699
// replicas is the number of worker nodes belonging to this set.
@@ -777,19 +787,25 @@ type MachinePoolTopology struct {
777
787
// This should match one of the deployment classes defined in the ClusterClass object
778
788
// mentioned in the `Cluster.Spec.Class` field.
779
789
// +required
790
+ // +kubebuilder:validation:MinLength=1
791
+ // +kubebuilder:validation:MaxLength=256
780
792
Class string `json:"class"`
781
793
782
794
// name is the unique identifier for this MachinePoolTopology.
783
795
// The value is used with other unique identifiers to create a MachinePool's Name
784
796
// (e.g. cluster's name, etc). In case the name is greater than the allowed maximum length,
785
797
// the values are hashed together.
786
798
// +required
799
+ // +kubebuilder:validation:MinLength=1
800
+ // +kubebuilder:validation:MaxLength=256
787
801
Name string `json:"name"`
788
802
789
803
// failureDomains is the list of failure domains the machine pool will be created in.
790
804
// Must match a key in the FailureDomains map stored on the cluster object.
791
805
// +optional
792
806
// +kubebuilder:validation:MaxItems=100
807
+ // +kubebuilder:validation:items:MinLength=1
808
+ // +kubebuilder:validation:items:MaxLength=256
793
809
FailureDomains []string `json:"failureDomains,omitempty"`
794
810
795
811
// nodeDrainTimeout is the total amount of time that the controller will spend on draining a node.
@@ -833,13 +849,16 @@ type MachinePoolTopology struct {
833
849
type ClusterVariable struct {
834
850
// name of the variable.
835
851
// +required
852
+ // +kubebuilder:validation:MinLength=1
853
+ // +kubebuilder:validation:MaxLength=256
836
854
Name string `json:"name"`
837
855
838
856
// definitionFrom specifies where the definition of this Variable is from.
839
857
//
840
858
// Deprecated: This field is deprecated, must not be set anymore and is going to be removed in the next apiVersion.
841
859
//
842
860
// +optional
861
+ // +kubebuilder:validation:MaxLength=256
843
862
DefinitionFrom string `json:"definitionFrom,omitempty"`
844
863
845
864
// value of the variable.
@@ -905,6 +924,8 @@ type ClusterNetwork struct {
905
924
906
925
// serviceDomain is the domain name for services.
907
926
// +optional
927
+ // +kubebuilder:validation:MinLength=1
928
+ // +kubebuilder:validation:MaxLength=253
908
929
ServiceDomain string `json:"serviceDomain,omitempty"`
909
930
}
910
931
@@ -915,8 +936,10 @@ type ClusterNetwork struct {
915
936
// NetworkRanges represents ranges of network addresses.
916
937
type NetworkRanges struct {
917
938
// cidrBlocks is a list of CIDR blocks.
918
- // +kubebuilder:validation:MaxItems=100
919
939
// +required
940
+ // +kubebuilder:validation:MaxItems=100
941
+ // +kubebuilder:validation:items:MinLength=1
942
+ // +kubebuilder:validation:items:MaxLength=43
920
943
CIDRBlocks []string `json:"cidrBlocks"`
921
944
}
922
945
@@ -952,11 +975,13 @@ type ClusterStatus struct {
952
975
// Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.
953
976
//
954
977
// +optional
978
+ // +kubebuilder:validation:MinLength=1
979
+ // +kubebuilder:validation:MaxLength=10240
955
980
FailureMessage * string `json:"failureMessage,omitempty"`
956
981
957
982
// phase represents the current phase of cluster actuation.
958
- // E.g. Pending, Running, Terminating, Failed etc.
959
983
// +optional
984
+ // +kubebuilder:validation:Enum=Pending;Provisioning;Provisioned;Deleting;Failed;Unknown
960
985
Phase string `json:"phase,omitempty"`
961
986
962
987
// infrastructureReady is the state of the infrastructure provider.
@@ -1082,7 +1107,9 @@ func (c *ClusterStatus) GetTypedPhase() ClusterPhase {
1082
1107
// APIEndpoint represents a reachable Kubernetes API endpoint.
1083
1108
type APIEndpoint struct {
1084
1109
// host is the hostname on which the API server is serving.
1110
+ // TODO: Can't set MinLength=1 for now, because this struct is not always used in pointer fields so today we have cases where host is set to an empty string.
1085
1111
// +required
1112
+ // +kubebuilder:validation:MaxLength=512
1086
1113
Host string `json:"host"`
1087
1114
1088
1115
// port is the port on which the API server is serving.
0 commit comments