Skip to content

Commit 17b5d2a

Browse files
authored
⚠️ Align Spec fields to optionalfields API conventions (#12431)
* Align Spec fields to optionalfields API conventions * Fix review findings * Fix unit tests
1 parent f51f43b commit 17b5d2a

File tree

50 files changed

+311
-52
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+311
-52
lines changed

api/addons/v1beta2/clusterresourceset_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ type ClusterResourceSet struct {
204204
metav1.ObjectMeta `json:"metadata,omitempty"`
205205

206206
// spec is the desired state of ClusterResourceSet.
207-
// +optional
208-
Spec ClusterResourceSetSpec `json:"spec,omitempty"`
207+
// +required
208+
Spec ClusterResourceSetSpec `json:"spec,omitempty,omitzero"`
209209
// status is the observed state of ClusterResourceSet.
210210
// +optional
211211
Status ClusterResourceSetStatus `json:"status,omitempty,omitzero"`

api/addons/v1beta2/clusterresourcesetbinding_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ type ClusterResourceSetBinding struct {
127127
// +optional
128128
metav1.ObjectMeta `json:"metadata,omitempty"`
129129
// spec is the desired state of ClusterResourceSetBinding.
130-
// +optional
131-
Spec ClusterResourceSetBindingSpec `json:"spec,omitempty"`
130+
// +required
131+
Spec ClusterResourceSetBindingSpec `json:"spec,omitempty,omitzero"`
132132
}
133133

134134
// ANCHOR: ClusterResourceSetBindingSpec

api/bootstrap/kubeadm/v1beta2/kubeadmconfig_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ var (
5050

5151
// KubeadmConfigSpec defines the desired state of KubeadmConfig.
5252
// Either ClusterConfiguration and InitConfiguration should be defined or the JoinConfiguration should be defined.
53+
// +kubebuilder:validation:MinProperties=1
5354
type KubeadmConfigSpec struct {
5455
// clusterConfiguration along with InitConfiguration are the configurations necessary for the init command
5556
// +optional
@@ -543,7 +544,7 @@ type KubeadmConfig struct {
543544

544545
// spec is the desired state of KubeadmConfig.
545546
// +optional
546-
Spec KubeadmConfigSpec `json:"spec,omitempty"`
547+
Spec KubeadmConfigSpec `json:"spec,omitempty,omitzero"`
547548
// status is the observed state of KubeadmConfig.
548549
// +optional
549550
Status KubeadmConfigStatus `json:"status,omitempty,omitzero"`

api/bootstrap/kubeadm/v1beta2/kubeadmconfigtemplate_types.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type KubeadmConfigTemplateSpec struct {
3030
}
3131

3232
// KubeadmConfigTemplateResource defines the Template structure.
33+
// +kubebuilder:validation:MinProperties=1
3334
type KubeadmConfigTemplateResource struct {
3435
// metadata is the standard object's metadata.
3536
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
@@ -38,7 +39,7 @@ type KubeadmConfigTemplateResource struct {
3839

3940
// spec is the desired state of KubeadmConfig.
4041
// +optional
41-
Spec KubeadmConfigSpec `json:"spec,omitempty"`
42+
Spec KubeadmConfigSpec `json:"spec,omitempty,omitzero"`
4243
}
4344

4445
// +kubebuilder:object:root=true
@@ -56,7 +57,7 @@ type KubeadmConfigTemplate struct {
5657

5758
// spec is the desired state of KubeadmConfigTemplate.
5859
// +optional
59-
Spec KubeadmConfigTemplateSpec `json:"spec,omitempty"`
60+
Spec KubeadmConfigTemplateSpec `json:"spec,omitempty,omitzero"`
6061
}
6162

6263
// +kubebuilder:object:root=true

api/controlplane/kubeadm/v1beta2/kubeadm_control_plane_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@ type KubeadmControlPlaneSpec struct {
441441

442442
// kubeadmConfigSpec is a KubeadmConfigSpec
443443
// to use for initializing and joining machines to the control plane.
444-
// +required
445-
KubeadmConfigSpec bootstrapv1.KubeadmConfigSpec `json:"kubeadmConfigSpec"`
444+
// +optional
445+
KubeadmConfigSpec bootstrapv1.KubeadmConfigSpec `json:"kubeadmConfigSpec,omitempty,omitzero"`
446446

447447
// rolloutBefore is a field to indicate a rollout should be performed
448448
// if the specified criteria is met.
@@ -807,8 +807,8 @@ type KubeadmControlPlane struct {
807807
metav1.ObjectMeta `json:"metadata,omitempty"`
808808

809809
// spec is the desired state of KubeadmControlPlane.
810-
// +optional
811-
Spec KubeadmControlPlaneSpec `json:"spec,omitempty"`
810+
// +required
811+
Spec KubeadmControlPlaneSpec `json:"spec,omitempty,omitzero"`
812812
// status is the observed state of KubeadmControlPlane.
813813
// +optional
814814
Status KubeadmControlPlaneStatus `json:"status,omitempty,omitzero"`

api/controlplane/kubeadm/v1beta2/kubeadmcontrolplanetemplate_types.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type KubeadmControlPlaneTemplate struct {
4646

4747
// spec is the desired state of KubeadmControlPlaneTemplate.
4848
// +optional
49-
Spec KubeadmControlPlaneTemplateSpec `json:"spec,omitempty"`
49+
Spec KubeadmControlPlaneTemplateSpec `json:"spec,omitempty,omitzero"`
5050
}
5151

5252
// +kubebuilder:object:root=true
@@ -67,15 +67,16 @@ func init() {
6767
}
6868

6969
// KubeadmControlPlaneTemplateResource describes the data needed to create a KubeadmControlPlane from a template.
70+
// +kubebuilder:validation:MinProperties=1
7071
type KubeadmControlPlaneTemplateResource struct {
7172
// metadata is the standard object's metadata.
7273
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
7374
// +optional
7475
ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"`
7576

7677
// spec is the desired state of KubeadmControlPlaneTemplateResource.
77-
// +required
78-
Spec KubeadmControlPlaneTemplateResourceSpec `json:"spec"`
78+
// +optional
79+
Spec KubeadmControlPlaneTemplateResourceSpec `json:"spec,omitempty,omitzero"`
7980
}
8081

8182
// KubeadmControlPlaneTemplateResourceSpec defines the desired state of KubeadmControlPlane.
@@ -91,8 +92,8 @@ type KubeadmControlPlaneTemplateResourceSpec struct {
9192

9293
// kubeadmConfigSpec is a KubeadmConfigSpec
9394
// to use for initializing and joining machines to the control plane.
94-
// +required
95-
KubeadmConfigSpec bootstrapv1.KubeadmConfigSpec `json:"kubeadmConfigSpec"`
95+
// +optional
96+
KubeadmConfigSpec bootstrapv1.KubeadmConfigSpec `json:"kubeadmConfigSpec,omitempty,omitzero"`
9697

9798
// rolloutBefore is a field to indicate a rollout should be performed
9899
// if the specified criteria is met.

api/core/v1beta2/cluster_types.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ const (
458458
// ANCHOR: ClusterSpec
459459

460460
// ClusterSpec defines the desired state of Cluster.
461+
// +kubebuilder:validation:MinProperties=1
461462
type ClusterSpec struct {
462463
// paused can be used to prevent controllers from processing the Cluster and all its associated objects.
463464
// +optional
@@ -1185,8 +1186,8 @@ type Cluster struct {
11851186
metav1.ObjectMeta `json:"metadata,omitempty"`
11861187

11871188
// spec is the desired state of Cluster.
1188-
// +optional
1189-
Spec ClusterSpec `json:"spec,omitempty"`
1189+
// +required
1190+
Spec ClusterSpec `json:"spec,omitempty,omitzero"`
11901191
// status is the observed state of Cluster.
11911192
// +optional
11921193
Status ClusterStatus `json:"status,omitempty,omitzero"`

api/core/v1beta2/clusterclass_types.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,15 @@ type ClusterClass struct {
8181
metav1.ObjectMeta `json:"metadata,omitempty"`
8282

8383
// spec is the desired state of ClusterClass.
84-
// +optional
85-
Spec ClusterClassSpec `json:"spec,omitempty"`
84+
// +required
85+
Spec ClusterClassSpec `json:"spec,omitempty,omitzero"`
8686
// status is the observed state of ClusterClass.
8787
// +optional
8888
Status ClusterClassStatus `json:"status,omitempty,omitzero"`
8989
}
9090

9191
// ClusterClassSpec describes the desired state of the ClusterClass.
92+
// +kubebuilder:validation:MinProperties=1
9293
type ClusterClassSpec struct {
9394
// availabilityGates specifies additional conditions to include when evaluating Cluster Available condition.
9495
//

api/core/v1beta2/machine_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,8 @@ type Machine struct {
736736
metav1.ObjectMeta `json:"metadata,omitempty"`
737737

738738
// spec is the desired state of Machine.
739-
// +optional
740-
Spec MachineSpec `json:"spec,omitempty"`
739+
// +required
740+
Spec MachineSpec `json:"spec,omitempty,omitzero"`
741741
// status is the observed state of Machine.
742742
// +optional
743743
Status MachineStatus `json:"status,omitempty,omitzero"`

api/core/v1beta2/machinedeployment_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,8 @@ type MachineDeployment struct {
593593
metav1.ObjectMeta `json:"metadata,omitempty"`
594594

595595
// spec is the desired state of MachineDeployment.
596-
// +optional
597-
Spec MachineDeploymentSpec `json:"spec,omitempty"`
596+
// +required
597+
Spec MachineDeploymentSpec `json:"spec,omitempty,omitzero"`
598598
// status is the observed state of MachineDeployment.
599599
// +optional
600600
Status MachineDeploymentStatus `json:"status,omitempty,omitzero"`

0 commit comments

Comments
 (0)