api: enable optionalorrequired linter for policy API

Add missing +optional markers to PodDisruptionBudgetStatus fields in
policy/v1 and policy/v1beta1 and enable the optionalorrequired linter
for the policy API group.
This commit is contained in:
Ignoramuss
2026-01-23 19:50:50 -08:00
parent 27dad90a0c
commit d485fe5610
7 changed files with 19 additions and 3 deletions

View File

@@ -214,7 +214,7 @@ linters:
# OptionalOrRequired is being enabled over time. For now, each API group should be added to this list until we comb through each group and fix the missing tags.
- text: "must be marked as optional or required"
path: "staging/src/k8s.io/api/(admission|apidiscovery|apiserverinternal|apps|authentication|authorization|autoscaling|batch|certificates|coordination|core|discovery|events|extensions|flowcontrol|networking|policy|rbac|resource|storage|storagemigration)"
path: "staging/src/k8s.io/api/(admission|apidiscovery|apiserverinternal|apps|authentication|authorization|autoscaling|batch|certificates|coordination|core|discovery|events|extensions|flowcontrol|networking|rbac|resource|storage|storagemigration)"
# OptionalOrRequired - Existing fields that are marked as both optional and required (based on standard optional vs kubebuilder:validation:Required) and should not be fixed.
- text: "field (PortStatus|IngressPortStatus)\\.Error must not be marked as both optional and required"

View File

@@ -225,7 +225,7 @@ linters:
# OptionalOrRequired is being enabled over time. For now, each API group should be added to this list until we comb through each group and fix the missing tags.
- text: "must be marked as optional or required"
path: "staging/src/k8s.io/api/(admission|apidiscovery|apiserverinternal|apps|authentication|authorization|autoscaling|batch|certificates|coordination|core|discovery|events|extensions|flowcontrol|networking|policy|rbac|resource|storage|storagemigration)"
path: "staging/src/k8s.io/api/(admission|apidiscovery|apiserverinternal|apps|authentication|authorization|autoscaling|batch|certificates|coordination|core|discovery|events|extensions|flowcontrol|networking|rbac|resource|storage|storagemigration)"
# OptionalOrRequired - Existing fields that are marked as both optional and required (based on standard optional vs kubebuilder:validation:Required) and should not be fixed.
- text: "field (PortStatus|IngressPortStatus)\\.Error must not be marked as both optional and required"

View File

@@ -90,7 +90,7 @@
# OptionalOrRequired is being enabled over time. For now, each API group should be added to this list until we comb through each group and fix the missing tags.
- text: "must be marked as optional or required"
path: "staging/src/k8s.io/api/(admission|apidiscovery|apiserverinternal|apps|authentication|authorization|autoscaling|batch|certificates|coordination|core|discovery|events|extensions|flowcontrol|networking|policy|rbac|resource|storage|storagemigration)"
path: "staging/src/k8s.io/api/(admission|apidiscovery|apiserverinternal|apps|authentication|authorization|autoscaling|batch|certificates|coordination|core|discovery|events|extensions|flowcontrol|networking|rbac|resource|storage|storagemigration)"
# OptionalOrRequired - Existing fields that are marked as both optional and required (based on standard optional vs kubebuilder:validation:Required) and should not be fixed.
- text: "field (PortStatus|IngressPortStatus)\\.Error must not be marked as both optional and required"

View File

@@ -142,15 +142,19 @@ message PodDisruptionBudgetStatus {
map<string, .k8s.io.apimachinery.pkg.apis.meta.v1.Time> disruptedPods = 2;
// Number of pod disruptions that are currently allowed.
// +optional
optional int32 disruptionsAllowed = 3;
// current number of healthy pods
// +optional
optional int32 currentHealthy = 4;
// minimum desired number of healthy pods
// +optional
optional int32 desiredHealthy = 5;
// total number of pods counted by this disruption budget
// +optional
optional int32 expectedPods = 6;
// Conditions contain conditions for PDB. The disruption controller sets the

View File

@@ -117,15 +117,19 @@ type PodDisruptionBudgetStatus struct {
DisruptedPods map[string]metav1.Time `json:"disruptedPods,omitempty" protobuf:"bytes,2,rep,name=disruptedPods"`
// Number of pod disruptions that are currently allowed.
// +optional
DisruptionsAllowed int32 `json:"disruptionsAllowed" protobuf:"varint,3,opt,name=disruptionsAllowed"`
// current number of healthy pods
// +optional
CurrentHealthy int32 `json:"currentHealthy" protobuf:"varint,4,opt,name=currentHealthy"`
// minimum desired number of healthy pods
// +optional
DesiredHealthy int32 `json:"desiredHealthy" protobuf:"varint,5,opt,name=desiredHealthy"`
// total number of pods counted by this disruption budget
// +optional
ExpectedPods int32 `json:"expectedPods" protobuf:"varint,6,opt,name=expectedPods"`
// Conditions contain conditions for PDB. The disruption controller sets the

View File

@@ -142,15 +142,19 @@ message PodDisruptionBudgetStatus {
map<string, .k8s.io.apimachinery.pkg.apis.meta.v1.Time> disruptedPods = 2;
// Number of pod disruptions that are currently allowed.
// +optional
optional int32 disruptionsAllowed = 3;
// current number of healthy pods
// +optional
optional int32 currentHealthy = 4;
// minimum desired number of healthy pods
// +optional
optional int32 desiredHealthy = 5;
// total number of pods counted by this disruption budget
// +optional
optional int32 expectedPods = 6;
// Conditions contain conditions for PDB. The disruption controller sets the

View File

@@ -114,15 +114,19 @@ type PodDisruptionBudgetStatus struct {
DisruptedPods map[string]metav1.Time `json:"disruptedPods,omitempty" protobuf:"bytes,2,rep,name=disruptedPods"`
// Number of pod disruptions that are currently allowed.
// +optional
DisruptionsAllowed int32 `json:"disruptionsAllowed" protobuf:"varint,3,opt,name=disruptionsAllowed"`
// current number of healthy pods
// +optional
CurrentHealthy int32 `json:"currentHealthy" protobuf:"varint,4,opt,name=currentHealthy"`
// minimum desired number of healthy pods
// +optional
DesiredHealthy int32 `json:"desiredHealthy" protobuf:"varint,5,opt,name=desiredHealthy"`
// total number of pods counted by this disruption budget
// +optional
ExpectedPods int32 `json:"expectedPods" protobuf:"varint,6,opt,name=expectedPods"`
// Conditions contain conditions for PDB. The disruption controller sets the