From 8651d99a26f648da7bf6fae239d302000cbeb123 Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 17 Oct 2025 15:36:25 +0300 Subject: [PATCH 1/8] Enforce either optional or required tag on apiserverinternal API group --- hack/golangci-hints.yaml | 4 +--- hack/golangci.yaml | 4 +--- hack/kube-api-linter/exceptions.yaml | 2 +- hack/kube-api-linter/kube-api-linter.yaml | 2 -- .../k8s.io/api/apiserverinternal/v1alpha1/types.go | 14 +++++++++++--- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/hack/golangci-hints.yaml b/hack/golangci-hints.yaml index 730ca6416c7..ddc2a60882c 100644 --- a/hack/golangci-hints.yaml +++ b/hack/golangci-hints.yaml @@ -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|rbac|resource|storage|storagemigration)" + path: "staging/src/k8s.io/api/(admission|apidiscovery|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" @@ -444,7 +444,6 @@ linters: # nomaps: # policy: AllowStringToStringMaps # Determines how the linter should handle maps of basic types. Maps of objects are always disallowed. # optionalFields: - # policy: AllowOptionalFields # Determines how the linter should handle optional fields.optionalfields: # pointers: # preference: Always | WhenRequired # Whether to always require pointers, or only when required. Defaults to `Always`. # policy: SuggestFix | Warn # The policy for pointers in optional fields. Defaults to `SuggestFix`. @@ -455,7 +454,6 @@ linters: # optionalOrRequired: # preferredOptionalMarker: optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`. # preferredRequiredMarker: required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`. - # policy: AllowOptionalFields # Determines how the linter should handle optional fields. # requiredFields: # pointers: # policy: SuggestFix | Warn # The policy for pointers in required fields. Defaults to `SuggestFix`. diff --git a/hack/golangci.yaml b/hack/golangci.yaml index f6988d1d73b..40e4abc9b80 100644 --- a/hack/golangci.yaml +++ b/hack/golangci.yaml @@ -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|rbac|resource|storage|storagemigration)" + path: "staging/src/k8s.io/api/(admission|apidiscovery|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" @@ -453,7 +453,6 @@ linters: # nomaps: # policy: AllowStringToStringMaps # Determines how the linter should handle maps of basic types. Maps of objects are always disallowed. # optionalFields: - # policy: AllowOptionalFields # Determines how the linter should handle optional fields.optionalfields: # pointers: # preference: Always | WhenRequired # Whether to always require pointers, or only when required. Defaults to `Always`. # policy: SuggestFix | Warn # The policy for pointers in optional fields. Defaults to `SuggestFix`. @@ -464,7 +463,6 @@ linters: # optionalOrRequired: # preferredOptionalMarker: optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`. # preferredRequiredMarker: required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`. - # policy: AllowOptionalFields # Determines how the linter should handle optional fields. # requiredFields: # pointers: # policy: SuggestFix | Warn # The policy for pointers in required fields. Defaults to `SuggestFix`. diff --git a/hack/kube-api-linter/exceptions.yaml b/hack/kube-api-linter/exceptions.yaml index b31d8091376..a3d89785bdf 100644 --- a/hack/kube-api-linter/exceptions.yaml +++ b/hack/kube-api-linter/exceptions.yaml @@ -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|rbac|resource|storage|storagemigration)" + path: "staging/src/k8s.io/api/(admission|apidiscovery|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" diff --git a/hack/kube-api-linter/kube-api-linter.yaml b/hack/kube-api-linter/kube-api-linter.yaml index 84dd20d8999..5dc11a6872b 100644 --- a/hack/kube-api-linter/kube-api-linter.yaml +++ b/hack/kube-api-linter/kube-api-linter.yaml @@ -51,7 +51,6 @@ lintersConfig: # nomaps: # policy: AllowStringToStringMaps # Determines how the linter should handle maps of basic types. Maps of objects are always disallowed. # optionalFields: - # policy: AllowOptionalFields # Determines how the linter should handle optional fields.optionalfields: # pointers: # preference: Always | WhenRequired # Whether to always require pointers, or only when required. Defaults to `Always`. # policy: SuggestFix | Warn # The policy for pointers in optional fields. Defaults to `SuggestFix`. @@ -62,7 +61,6 @@ lintersConfig: # optionalOrRequired: # preferredOptionalMarker: optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`. # preferredRequiredMarker: required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`. - # policy: AllowOptionalFields # Determines how the linter should handle optional fields. # requiredFields: # pointers: # policy: SuggestFix | Warn # The policy for pointers in required fields. Defaults to `SuggestFix`. diff --git a/staging/src/k8s.io/api/apiserverinternal/v1alpha1/types.go b/staging/src/k8s.io/api/apiserverinternal/v1alpha1/types.go index 31a419abf13..1507a3be756 100644 --- a/staging/src/k8s.io/api/apiserverinternal/v1alpha1/types.go +++ b/staging/src/k8s.io/api/apiserverinternal/v1alpha1/types.go @@ -28,13 +28,16 @@ import ( type StorageVersion struct { metav1.TypeMeta `json:",inline"` // The name is .. + // +required metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // Spec is an empty spec. It is here to comply with Kubernetes API style. + // +optional Spec StorageVersionSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` // API server instances report the version they can decode and the version they // encode objects to when persisting objects in the backend. + // +optional Status StorageVersionStatus `json:"status" protobuf:"bytes,3,opt,name=status"` } @@ -67,20 +70,24 @@ type StorageVersionStatus struct { // encodes objects to when persisting objects in the backend. type ServerStorageVersion struct { // The ID of the reporting API server. - APIServerID string `json:"apiServerID,omitempty" protobuf:"bytes,1,opt,name=apiServerID"` + // +required + APIServerID string `json:"apiServerID" protobuf:"bytes,1,opt,name=apiServerID"` // The API server encodes the object to this version when persisting it in // the backend (e.g., etcd). - EncodingVersion string `json:"encodingVersion,omitempty" protobuf:"bytes,2,opt,name=encodingVersion"` + // +required + EncodingVersion string `json:"encodingVersion" protobuf:"bytes,2,opt,name=encodingVersion"` // The API server can decode objects encoded in these versions. // The encodingVersion must be included in the decodableVersions. // +listType=set - DecodableVersions []string `json:"decodableVersions,omitempty" protobuf:"bytes,3,opt,name=decodableVersions"` + // +required + DecodableVersions []string `json:"decodableVersions" protobuf:"bytes,3,opt,name=decodableVersions"` // The API server can serve these versions. // DecodableVersions must include all ServedVersions. // +listType=set + // +optional ServedVersions []string `json:"servedVersions,omitempty" protobuf:"bytes,4,opt,name=servedVersions"` } @@ -111,6 +118,7 @@ type StorageVersionCondition struct { // +optional ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,3,opt,name=observedGeneration"` // Last time the condition transitioned from one status to another. + // +optional LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,4,opt,name=lastTransitionTime"` // The reason for the condition's last transition. // +required From c4b2640b32ec7fc2fd00e49fa2167d8a070bb2b3 Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 17 Oct 2025 15:54:49 +0300 Subject: [PATCH 2/8] Remove exceptions for groups with no issues --- hack/golangci-hints.yaml | 2 +- hack/golangci.yaml | 2 +- hack/kube-api-linter/exceptions.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hack/golangci-hints.yaml b/hack/golangci-hints.yaml index ddc2a60882c..2d1ddfc4e60 100644 --- a/hack/golangci-hints.yaml +++ b/hack/golangci-hints.yaml @@ -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|apps|authentication|authorization|autoscaling|batch|certificates|coordination|core|discovery|events|extensions|flowcontrol|networking|rbac|resource|storage|storagemigration)" + path: "staging/src/k8s.io/api/(admission|apidiscovery|apps|authentication|authorization|autoscaling|batch|certificates|core|discovery|events|extensions|flowcontrol|networking|rbac|resource|storage)" # 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" diff --git a/hack/golangci.yaml b/hack/golangci.yaml index 40e4abc9b80..acdc242d153 100644 --- a/hack/golangci.yaml +++ b/hack/golangci.yaml @@ -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|apps|authentication|authorization|autoscaling|batch|certificates|coordination|core|discovery|events|extensions|flowcontrol|networking|rbac|resource|storage|storagemigration)" + path: "staging/src/k8s.io/api/(admission|apidiscovery|apps|authentication|authorization|autoscaling|batch|certificates|core|discovery|events|extensions|flowcontrol|networking|rbac|resource|storage)" # 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" diff --git a/hack/kube-api-linter/exceptions.yaml b/hack/kube-api-linter/exceptions.yaml index a3d89785bdf..1fa17b11e07 100644 --- a/hack/kube-api-linter/exceptions.yaml +++ b/hack/kube-api-linter/exceptions.yaml @@ -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|apps|authentication|authorization|autoscaling|batch|certificates|coordination|core|discovery|events|extensions|flowcontrol|networking|rbac|resource|storage|storagemigration)" + path: "staging/src/k8s.io/api/(admission|apidiscovery|apps|authentication|authorization|autoscaling|batch|certificates|core|discovery|events|extensions|flowcontrol|networking|rbac|resource|storage)" # 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" From a9034c040e0bb24797b8f02597e04e9a4db9cfa0 Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Fri, 19 Dec 2025 17:31:18 +0000 Subject: [PATCH 3/8] Enable nonpointerstructs alongside optionalorrequired --- hack/golangci-hints.yaml | 4 +++- hack/golangci.yaml | 4 +++- hack/kube-api-linter/exceptions.yaml | 3 ++- hack/kube-api-linter/kube-api-linter.yaml | 1 + staging/src/k8s.io/api/admissionregistration/v1/types.go | 1 + .../src/k8s.io/api/admissionregistration/v1alpha1/types.go | 1 + staging/src/k8s.io/api/admissionregistration/v1beta1/types.go | 1 + staging/src/k8s.io/api/autoscaling/v1/types.go | 2 +- staging/src/k8s.io/api/autoscaling/v2/types.go | 2 +- staging/src/k8s.io/api/batch/v1/types.go | 2 +- staging/src/k8s.io/api/batch/v1beta1/types.go | 2 +- staging/src/k8s.io/api/certificates/v1beta1/types.go | 1 + staging/src/k8s.io/api/coordination/v1alpha2/types.go | 2 +- staging/src/k8s.io/api/coordination/v1beta1/types.go | 2 +- staging/src/k8s.io/api/networking/v1/types.go | 2 +- staging/src/k8s.io/api/networking/v1beta1/types.go | 2 +- staging/src/k8s.io/api/rbac/v1/types.go | 2 ++ staging/src/k8s.io/api/rbac/v1alpha1/types.go | 2 ++ staging/src/k8s.io/api/rbac/v1beta1/types.go | 2 ++ staging/src/k8s.io/api/resource/v1/types.go | 1 + staging/src/k8s.io/api/resource/v1alpha3/types.go | 1 + staging/src/k8s.io/api/resource/v1beta1/types.go | 1 + staging/src/k8s.io/api/resource/v1beta2/types.go | 1 + staging/src/k8s.io/api/storage/v1/types.go | 1 + staging/src/k8s.io/api/storage/v1alpha1/types.go | 1 + staging/src/k8s.io/api/storage/v1beta1/types.go | 1 + 26 files changed, 34 insertions(+), 11 deletions(-) diff --git a/hack/golangci-hints.yaml b/hack/golangci-hints.yaml index 2d1ddfc4e60..bde0cce48bf 100644 --- a/hack/golangci-hints.yaml +++ b/hack/golangci-hints.yaml @@ -213,7 +213,8 @@ linters: path: "staging/src/k8s.io/api/resource/(v1|v1beta1|v1beta2)/types.go" # 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" + # The nonpointerstructs linter is included here as well as these two should be enabled hand-in-hand on each API group. + - text: "must be marked as optional or required|is a non-pointer struct with no required fields. It must be marked as optional." path: "staging/src/k8s.io/api/(admission|apidiscovery|apps|authentication|authorization|autoscaling|batch|certificates|core|discovery|events|extensions|flowcontrol|networking|rbac|resource|storage)" # OptionalOrRequired - Existing fields that are marked as both optional and required (based on standard optional vs kubebuilder:validation:Required) and should not be fixed. @@ -405,6 +406,7 @@ linters: # - "nobools" # Bools do not evolve over time, should use enums instead. # - "nofloats" # Ensure floats are not used. - "nomaps" # Ensure maps are not used, unless they are `map[string]string` (for labels/annotations/etc). + - "nonpointerstructs" # Ensure non-pointer structs are correctly tagged as optional or required. - "nonullable" # Ensure fields are not marked as nullable. # - "nophase" # Ensure field names do not have the word "phase" in them. - "notimestamp" # Ensure fields are not named "timestamp", prefer "time". diff --git a/hack/golangci.yaml b/hack/golangci.yaml index acdc242d153..ea5539138ee 100644 --- a/hack/golangci.yaml +++ b/hack/golangci.yaml @@ -224,7 +224,8 @@ linters: path: "staging/src/k8s.io/api/resource/(v1|v1beta1|v1beta2)/types.go" # 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" + # The nonpointerstructs linter is included here as well as these two should be enabled hand-in-hand on each API group. + - text: "must be marked as optional or required|is a non-pointer struct with no required fields. It must be marked as optional." path: "staging/src/k8s.io/api/(admission|apidiscovery|apps|authentication|authorization|autoscaling|batch|certificates|core|discovery|events|extensions|flowcontrol|networking|rbac|resource|storage)" # OptionalOrRequired - Existing fields that are marked as both optional and required (based on standard optional vs kubebuilder:validation:Required) and should not be fixed. @@ -414,6 +415,7 @@ linters: # - "nobools" # Bools do not evolve over time, should use enums instead. # - "nofloats" # Ensure floats are not used. - "nomaps" # Ensure maps are not used, unless they are `map[string]string` (for labels/annotations/etc). + - "nonpointerstructs" # Ensure non-pointer structs are correctly tagged as optional or required. - "nonullable" # Ensure fields are not marked as nullable. # - "nophase" # Ensure field names do not have the word "phase" in them. - "notimestamp" # Ensure fields are not named "timestamp", prefer "time". diff --git a/hack/kube-api-linter/exceptions.yaml b/hack/kube-api-linter/exceptions.yaml index 1fa17b11e07..0733f16139d 100644 --- a/hack/kube-api-linter/exceptions.yaml +++ b/hack/kube-api-linter/exceptions.yaml @@ -89,7 +89,8 @@ path: "staging/src/k8s.io/api/resource/(v1|v1beta1|v1beta2)/types.go" # 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" +# The nonpointerstructs linter is included here as well as these two should be enabled hand-in-hand on each API group. +- text: "must be marked as optional or required|is a non-pointer struct with no required fields. It must be marked as optional." path: "staging/src/k8s.io/api/(admission|apidiscovery|apps|authentication|authorization|autoscaling|batch|certificates|core|discovery|events|extensions|flowcontrol|networking|rbac|resource|storage)" # OptionalOrRequired - Existing fields that are marked as both optional and required (based on standard optional vs kubebuilder:validation:Required) and should not be fixed. diff --git a/hack/kube-api-linter/kube-api-linter.yaml b/hack/kube-api-linter/kube-api-linter.yaml index 5dc11a6872b..2ce454912be 100644 --- a/hack/kube-api-linter/kube-api-linter.yaml +++ b/hack/kube-api-linter/kube-api-linter.yaml @@ -12,6 +12,7 @@ linters: # - "nobools" # Bools do not evolve over time, should use enums instead. # - "nofloats" # Ensure floats are not used. - "nomaps" # Ensure maps are not used, unless they are `map[string]string` (for labels/annotations/etc). + - "nonpointerstructs" # Ensure non-pointer structs are correctly tagged as optional or required. - "nonullable" # Ensure fields are not marked as nullable. # - "nophase" # Ensure field names do not have the word "phase" in them. - "notimestamp" # Ensure fields are not named "timestamp", prefer "time". diff --git a/staging/src/k8s.io/api/admissionregistration/v1/types.go b/staging/src/k8s.io/api/admissionregistration/v1/types.go index 6d85a310d50..636eb406f0a 100644 --- a/staging/src/k8s.io/api/admissionregistration/v1/types.go +++ b/staging/src/k8s.io/api/admissionregistration/v1/types.go @@ -452,6 +452,7 @@ type ValidatingAdmissionPolicyBinding struct { // +optional metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // spec defines the desired behavior of the ValidatingAdmissionPolicyBinding. + // +required Spec ValidatingAdmissionPolicyBindingSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` } diff --git a/staging/src/k8s.io/api/admissionregistration/v1alpha1/types.go b/staging/src/k8s.io/api/admissionregistration/v1alpha1/types.go index 72e8916f4a3..339df8c8f7a 100644 --- a/staging/src/k8s.io/api/admissionregistration/v1alpha1/types.go +++ b/staging/src/k8s.io/api/admissionregistration/v1alpha1/types.go @@ -392,6 +392,7 @@ type ValidatingAdmissionPolicyBinding struct { // +optional metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // spec defines the desired behavior of the ValidatingAdmissionPolicyBinding. + // +required Spec ValidatingAdmissionPolicyBindingSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` } diff --git a/staging/src/k8s.io/api/admissionregistration/v1beta1/types.go b/staging/src/k8s.io/api/admissionregistration/v1beta1/types.go index 32315ed7ff4..5599078b8d4 100644 --- a/staging/src/k8s.io/api/admissionregistration/v1beta1/types.go +++ b/staging/src/k8s.io/api/admissionregistration/v1beta1/types.go @@ -405,6 +405,7 @@ type ValidatingAdmissionPolicyBinding struct { // +optional metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // spec defines the desired behavior of the ValidatingAdmissionPolicyBinding. + // +required Spec ValidatingAdmissionPolicyBindingSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` } diff --git a/staging/src/k8s.io/api/autoscaling/v1/types.go b/staging/src/k8s.io/api/autoscaling/v1/types.go index 55079e980df..645ed2ac57d 100644 --- a/staging/src/k8s.io/api/autoscaling/v1/types.go +++ b/staging/src/k8s.io/api/autoscaling/v1/types.go @@ -97,7 +97,7 @@ type HorizontalPodAutoscaler struct { metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // spec defines the behaviour of autoscaler. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status. - // +optional + // +required Spec HorizontalPodAutoscalerSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` // status is the current information about the autoscaler. diff --git a/staging/src/k8s.io/api/autoscaling/v2/types.go b/staging/src/k8s.io/api/autoscaling/v2/types.go index 1544e9a6089..84d1ec203ee 100644 --- a/staging/src/k8s.io/api/autoscaling/v2/types.go +++ b/staging/src/k8s.io/api/autoscaling/v2/types.go @@ -40,7 +40,7 @@ type HorizontalPodAutoscaler struct { // spec is the specification for the behaviour of the autoscaler. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status. - // +optional + // +required Spec HorizontalPodAutoscalerSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` // status is the current information about the autoscaler. diff --git a/staging/src/k8s.io/api/batch/v1/types.go b/staging/src/k8s.io/api/batch/v1/types.go index 4927dfffbb2..cf6d7d3aacd 100644 --- a/staging/src/k8s.io/api/batch/v1/types.go +++ b/staging/src/k8s.io/api/batch/v1/types.go @@ -686,7 +686,7 @@ type CronJob struct { // Specification of the desired behavior of a cron job, including the schedule. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional + // +required Spec CronJobSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` // Current status of a cron job. diff --git a/staging/src/k8s.io/api/batch/v1beta1/types.go b/staging/src/k8s.io/api/batch/v1beta1/types.go index b640388efc3..63de54bdfc4 100644 --- a/staging/src/k8s.io/api/batch/v1beta1/types.go +++ b/staging/src/k8s.io/api/batch/v1beta1/types.go @@ -52,7 +52,7 @@ type CronJob struct { // Specification of the desired behavior of a cron job, including the schedule. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional + // +required Spec CronJobSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` // Current status of a cron job. diff --git a/staging/src/k8s.io/api/certificates/v1beta1/types.go b/staging/src/k8s.io/api/certificates/v1beta1/types.go index 1eb566b5735..88d58fd4dc7 100644 --- a/staging/src/k8s.io/api/certificates/v1beta1/types.go +++ b/staging/src/k8s.io/api/certificates/v1beta1/types.go @@ -374,6 +374,7 @@ type PodCertificateRequest struct { metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // spec contains the details about the certificate being requested. + // +required Spec PodCertificateRequestSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` // status contains the issued certificate, and a standard set of conditions. diff --git a/staging/src/k8s.io/api/coordination/v1alpha2/types.go b/staging/src/k8s.io/api/coordination/v1alpha2/types.go index 13e1deb067d..f8a6d33af11 100644 --- a/staging/src/k8s.io/api/coordination/v1alpha2/types.go +++ b/staging/src/k8s.io/api/coordination/v1alpha2/types.go @@ -35,7 +35,7 @@ type LeaseCandidate struct { // spec contains the specification of the Lease. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional + // +required Spec LeaseCandidateSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` } diff --git a/staging/src/k8s.io/api/coordination/v1beta1/types.go b/staging/src/k8s.io/api/coordination/v1beta1/types.go index 781d29efce1..ba6d6aa095a 100644 --- a/staging/src/k8s.io/api/coordination/v1beta1/types.go +++ b/staging/src/k8s.io/api/coordination/v1beta1/types.go @@ -106,7 +106,7 @@ type LeaseCandidate struct { // spec contains the specification of the Lease. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional + // +required Spec LeaseCandidateSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` } diff --git a/staging/src/k8s.io/api/networking/v1/types.go b/staging/src/k8s.io/api/networking/v1/types.go index 0188ee0fd5b..f6e65eb3bdb 100644 --- a/staging/src/k8s.io/api/networking/v1/types.go +++ b/staging/src/k8s.io/api/networking/v1/types.go @@ -662,7 +662,7 @@ type IPAddress struct { metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // spec is the desired state of the IPAddress. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional + // +required Spec IPAddressSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` } diff --git a/staging/src/k8s.io/api/networking/v1beta1/types.go b/staging/src/k8s.io/api/networking/v1beta1/types.go index a49c678802c..d84e6a1275c 100644 --- a/staging/src/k8s.io/api/networking/v1beta1/types.go +++ b/staging/src/k8s.io/api/networking/v1beta1/types.go @@ -447,7 +447,7 @@ type IPAddress struct { metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // spec is the desired state of the IPAddress. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional + // +required Spec IPAddressSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` } diff --git a/staging/src/k8s.io/api/rbac/v1/types.go b/staging/src/k8s.io/api/rbac/v1/types.go index 2fde11b3064..7ebe10d749f 100644 --- a/staging/src/k8s.io/api/rbac/v1/types.go +++ b/staging/src/k8s.io/api/rbac/v1/types.go @@ -146,6 +146,7 @@ type RoleBinding struct { // RoleRef can reference a Role in the current namespace or a ClusterRole in the global namespace. // If the RoleRef cannot be resolved, the Authorizer must return an error. // This field is immutable. + // +required RoleRef RoleRef `json:"roleRef" protobuf:"bytes,3,opt,name=roleRef"` } @@ -231,6 +232,7 @@ type ClusterRoleBinding struct { // RoleRef can only reference a ClusterRole in the global namespace. // If the RoleRef cannot be resolved, the Authorizer must return an error. // This field is immutable. + // +required RoleRef RoleRef `json:"roleRef" protobuf:"bytes,3,opt,name=roleRef"` } diff --git a/staging/src/k8s.io/api/rbac/v1alpha1/types.go b/staging/src/k8s.io/api/rbac/v1alpha1/types.go index a0d52ee4fc7..5ad7d33fb6b 100644 --- a/staging/src/k8s.io/api/rbac/v1alpha1/types.go +++ b/staging/src/k8s.io/api/rbac/v1alpha1/types.go @@ -144,6 +144,7 @@ type RoleBinding struct { // RoleRef can reference a Role in the current namespace or a ClusterRole in the global namespace. // If the RoleRef cannot be resolved, the Authorizer must return an error. + // +required RoleRef RoleRef `json:"roleRef" protobuf:"bytes,3,opt,name=roleRef"` } @@ -228,6 +229,7 @@ type ClusterRoleBinding struct { // RoleRef can only reference a ClusterRole in the global namespace. // If the RoleRef cannot be resolved, the Authorizer must return an error. + // +required RoleRef RoleRef `json:"roleRef" protobuf:"bytes,3,opt,name=roleRef"` } diff --git a/staging/src/k8s.io/api/rbac/v1beta1/types.go b/staging/src/k8s.io/api/rbac/v1beta1/types.go index 861e33c9755..183222e9d37 100644 --- a/staging/src/k8s.io/api/rbac/v1beta1/types.go +++ b/staging/src/k8s.io/api/rbac/v1beta1/types.go @@ -152,6 +152,7 @@ type RoleBinding struct { // RoleRef can reference a Role in the current namespace or a ClusterRole in the global namespace. // If the RoleRef cannot be resolved, the Authorizer must return an error. + // +required RoleRef RoleRef `json:"roleRef" protobuf:"bytes,3,opt,name=roleRef"` } @@ -251,6 +252,7 @@ type ClusterRoleBinding struct { // RoleRef can only reference a ClusterRole in the global namespace. // If the RoleRef cannot be resolved, the Authorizer must return an error. + // +required RoleRef RoleRef `json:"roleRef" protobuf:"bytes,3,opt,name=roleRef"` } diff --git a/staging/src/k8s.io/api/resource/v1/types.go b/staging/src/k8s.io/api/resource/v1/types.go index 5f8b31ef732..1ea035d0033 100644 --- a/staging/src/k8s.io/api/resource/v1/types.go +++ b/staging/src/k8s.io/api/resource/v1/types.go @@ -79,6 +79,7 @@ type ResourceSlice struct { // Contains the information published by the driver. // // Changing the spec automatically increments the metadata.generation number. + // +required Spec ResourceSliceSpec `json:"spec" protobuf:"bytes,2,name=spec"` } diff --git a/staging/src/k8s.io/api/resource/v1alpha3/types.go b/staging/src/k8s.io/api/resource/v1alpha3/types.go index ba02edabaa6..9c58bc611e7 100644 --- a/staging/src/k8s.io/api/resource/v1alpha3/types.go +++ b/staging/src/k8s.io/api/resource/v1alpha3/types.go @@ -201,6 +201,7 @@ type DeviceTaintRule struct { // Spec specifies the selector and one taint. // // Changing the spec automatically increments the metadata.generation number. + // +required Spec DeviceTaintRuleSpec `json:"spec" protobuf:"bytes,2,name=spec"` // Status provides information about what was requested in the spec. diff --git a/staging/src/k8s.io/api/resource/v1beta1/types.go b/staging/src/k8s.io/api/resource/v1beta1/types.go index 37d9923eaaf..a070049d4c8 100644 --- a/staging/src/k8s.io/api/resource/v1beta1/types.go +++ b/staging/src/k8s.io/api/resource/v1beta1/types.go @@ -82,6 +82,7 @@ type ResourceSlice struct { // Contains the information published by the driver. // // Changing the spec automatically increments the metadata.generation number. + // +required Spec ResourceSliceSpec `json:"spec" protobuf:"bytes,2,name=spec"` } diff --git a/staging/src/k8s.io/api/resource/v1beta2/types.go b/staging/src/k8s.io/api/resource/v1beta2/types.go index 8bb62f71a29..a33adb1e418 100644 --- a/staging/src/k8s.io/api/resource/v1beta2/types.go +++ b/staging/src/k8s.io/api/resource/v1beta2/types.go @@ -82,6 +82,7 @@ type ResourceSlice struct { // Contains the information published by the driver. // // Changing the spec automatically increments the metadata.generation number. + // +required Spec ResourceSliceSpec `json:"spec" protobuf:"bytes,2,name=spec"` } diff --git a/staging/src/k8s.io/api/storage/v1/types.go b/staging/src/k8s.io/api/storage/v1/types.go index 6264eb7a4bd..b69e0cc94e3 100644 --- a/staging/src/k8s.io/api/storage/v1/types.go +++ b/staging/src/k8s.io/api/storage/v1/types.go @@ -134,6 +134,7 @@ type VolumeAttachment struct { // spec represents specification of the desired attach/detach volume behavior. // Populated by the Kubernetes system. // +k8s:immutable + // +required Spec VolumeAttachmentSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` // status represents status of the VolumeAttachment request. diff --git a/staging/src/k8s.io/api/storage/v1alpha1/types.go b/staging/src/k8s.io/api/storage/v1alpha1/types.go index 3374fdca665..96fb8022a99 100644 --- a/staging/src/k8s.io/api/storage/v1alpha1/types.go +++ b/staging/src/k8s.io/api/storage/v1alpha1/types.go @@ -45,6 +45,7 @@ type VolumeAttachment struct { // spec represents specification of the desired attach/detach volume behavior. // Populated by the Kubernetes system. // +k8s:immutable + // +required Spec VolumeAttachmentSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` // status represents status of the VolumeAttachment request. diff --git a/staging/src/k8s.io/api/storage/v1beta1/types.go b/staging/src/k8s.io/api/storage/v1beta1/types.go index bc9468b935e..d9f52fa68a4 100644 --- a/staging/src/k8s.io/api/storage/v1beta1/types.go +++ b/staging/src/k8s.io/api/storage/v1beta1/types.go @@ -139,6 +139,7 @@ type VolumeAttachment struct { // spec represents specification of the desired attach/detach volume behavior. // Populated by the Kubernetes system. // +k8s:immutable + // +required Spec VolumeAttachmentSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` // status represents status of the VolumeAttachment request. From 0ebf47cb080a207a4829ce8e604e51bb494d63fb Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Thu, 23 Oct 2025 11:11:45 +0100 Subject: [PATCH 4/8] Update generated code --- api/openapi-spec/swagger.json | 29 +++++++++++++++++-- .../v3/apis__autoscaling__v1_openapi.json | 3 ++ .../v3/apis__autoscaling__v2_openapi.json | 3 ++ .../v3/apis__batch__v1_openapi.json | 3 ++ ...coordination.k8s.io__v1alpha2_openapi.json | 3 ++ ..._coordination.k8s.io__v1beta1_openapi.json | 3 ++ ...al.apiserver.k8s.io__v1alpha1_openapi.json | 10 +++++-- .../apis__networking.k8s.io__v1_openapi.json | 3 ++ ...s__networking.k8s.io__v1beta1_openapi.json | 3 ++ pkg/generated/openapi/zz_generated.openapi.go | 16 +++++++++- .../admissionregistration/v1/generated.proto | 1 + .../v1alpha1/generated.proto | 1 + .../v1beta1/generated.proto | 1 + .../v1alpha1/generated.proto | 8 +++++ .../k8s.io/api/autoscaling/v1/generated.proto | 2 +- .../k8s.io/api/autoscaling/v2/generated.proto | 2 +- .../src/k8s.io/api/batch/v1/generated.proto | 2 +- .../k8s.io/api/batch/v1beta1/generated.proto | 2 +- .../api/certificates/v1beta1/generated.proto | 1 + .../api/coordination/v1alpha2/generated.proto | 2 +- .../api/coordination/v1beta1/generated.proto | 2 +- .../k8s.io/api/networking/v1/generated.proto | 2 +- .../api/networking/v1beta1/generated.proto | 2 +- .../src/k8s.io/api/rbac/v1/generated.proto | 2 ++ .../k8s.io/api/rbac/v1alpha1/generated.proto | 2 ++ .../k8s.io/api/rbac/v1beta1/generated.proto | 2 ++ .../k8s.io/api/resource/v1/generated.proto | 1 + .../api/resource/v1alpha3/generated.proto | 1 + .../api/resource/v1beta1/generated.proto | 1 + .../api/resource/v1beta2/generated.proto | 1 + .../src/k8s.io/api/storage/v1/generated.proto | 1 + .../api/storage/v1alpha1/generated.proto | 1 + .../api/storage/v1beta1/generated.proto | 1 + .../generated/openapi/zz_generated.openapi.go | 1 + .../applyconfigurations/internal/internal.go | 2 ++ 35 files changed, 107 insertions(+), 13 deletions(-) diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index 22c8651285f..66096ed75ca 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -1694,6 +1694,11 @@ "x-kubernetes-list-type": "set" } }, + "required": [ + "apiServerID", + "encodingVersion", + "decodableVersions" + ], "type": "object" }, "io.k8s.api.apiserverinternal.v1alpha1.StorageVersion": { @@ -1721,8 +1726,7 @@ } }, "required": [ - "spec", - "status" + "metadata" ], "type": "object", "x-kubernetes-group-version-kind": [ @@ -3558,6 +3562,9 @@ "description": "status is the current information about the autoscaler." } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { @@ -3907,6 +3914,9 @@ "description": "status is the current information about the autoscaler." } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { @@ -4350,6 +4360,9 @@ "description": "Current status of a cron job. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { @@ -5506,6 +5519,9 @@ "description": "spec contains the specification of the Lease. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { @@ -5605,6 +5621,9 @@ "description": "spec contains the specification of the Lease. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { @@ -13666,6 +13685,9 @@ "description": "spec is the desired state of the IPAddress. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { @@ -14423,6 +14445,9 @@ "description": "spec is the desired state of the IPAddress. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { diff --git a/api/openapi-spec/v3/apis__autoscaling__v1_openapi.json b/api/openapi-spec/v3/apis__autoscaling__v1_openapi.json index 9b42ce8dca7..805e62c6c9f 100644 --- a/api/openapi-spec/v3/apis__autoscaling__v1_openapi.json +++ b/api/openapi-spec/v3/apis__autoscaling__v1_openapi.json @@ -65,6 +65,9 @@ "description": "status is the current information about the autoscaler." } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { diff --git a/api/openapi-spec/v3/apis__autoscaling__v2_openapi.json b/api/openapi-spec/v3/apis__autoscaling__v2_openapi.json index 5a40c5f72f6..fe8605b46b2 100644 --- a/api/openapi-spec/v3/apis__autoscaling__v2_openapi.json +++ b/api/openapi-spec/v3/apis__autoscaling__v2_openapi.json @@ -244,6 +244,9 @@ "description": "status is the current information about the autoscaler." } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { diff --git a/api/openapi-spec/v3/apis__batch__v1_openapi.json b/api/openapi-spec/v3/apis__batch__v1_openapi.json index 23731e7eefc..47c2ca5635f 100644 --- a/api/openapi-spec/v3/apis__batch__v1_openapi.json +++ b/api/openapi-spec/v3/apis__batch__v1_openapi.json @@ -40,6 +40,9 @@ "description": "Current status of a cron job. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { diff --git a/api/openapi-spec/v3/apis__coordination.k8s.io__v1alpha2_openapi.json b/api/openapi-spec/v3/apis__coordination.k8s.io__v1alpha2_openapi.json index f0cc5acb856..663b8fb0c65 100644 --- a/api/openapi-spec/v3/apis__coordination.k8s.io__v1alpha2_openapi.json +++ b/api/openapi-spec/v3/apis__coordination.k8s.io__v1alpha2_openapi.json @@ -31,6 +31,9 @@ "description": "spec contains the specification of the Lease. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { diff --git a/api/openapi-spec/v3/apis__coordination.k8s.io__v1beta1_openapi.json b/api/openapi-spec/v3/apis__coordination.k8s.io__v1beta1_openapi.json index 219c3d707d1..170190568ae 100644 --- a/api/openapi-spec/v3/apis__coordination.k8s.io__v1beta1_openapi.json +++ b/api/openapi-spec/v3/apis__coordination.k8s.io__v1beta1_openapi.json @@ -31,6 +31,9 @@ "description": "spec contains the specification of the Lease. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { diff --git a/api/openapi-spec/v3/apis__internal.apiserver.k8s.io__v1alpha1_openapi.json b/api/openapi-spec/v3/apis__internal.apiserver.k8s.io__v1alpha1_openapi.json index 7036d201a7e..2987b2101a7 100644 --- a/api/openapi-spec/v3/apis__internal.apiserver.k8s.io__v1alpha1_openapi.json +++ b/api/openapi-spec/v3/apis__internal.apiserver.k8s.io__v1alpha1_openapi.json @@ -5,6 +5,7 @@ "description": "An API server instance reports the version it can decode and the version it encodes objects to when persisting objects in the backend.", "properties": { "apiServerID": { + "default": "", "description": "The ID of the reporting API server.", "type": "string" }, @@ -18,6 +19,7 @@ "x-kubernetes-list-type": "set" }, "encodingVersion": { + "default": "", "description": "The API server encodes the object to this version when persisting it in the backend (e.g., etcd).", "type": "string" }, @@ -31,6 +33,11 @@ "x-kubernetes-list-type": "set" } }, + "required": [ + "apiServerID", + "encodingVersion", + "decodableVersions" + ], "type": "object" }, "io.k8s.api.apiserverinternal.v1alpha1.StorageVersion": { @@ -73,8 +80,7 @@ } }, "required": [ - "spec", - "status" + "metadata" ], "type": "object", "x-kubernetes-group-version-kind": [ diff --git a/api/openapi-spec/v3/apis__networking.k8s.io__v1_openapi.json b/api/openapi-spec/v3/apis__networking.k8s.io__v1_openapi.json index 2d7ab9807b6..de5a1068241 100644 --- a/api/openapi-spec/v3/apis__networking.k8s.io__v1_openapi.json +++ b/api/openapi-spec/v3/apis__networking.k8s.io__v1_openapi.json @@ -105,6 +105,9 @@ "description": "spec is the desired state of the IPAddress. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { diff --git a/api/openapi-spec/v3/apis__networking.k8s.io__v1beta1_openapi.json b/api/openapi-spec/v3/apis__networking.k8s.io__v1beta1_openapi.json index aedcc995cf9..17d7cd88d8a 100644 --- a/api/openapi-spec/v3/apis__networking.k8s.io__v1beta1_openapi.json +++ b/api/openapi-spec/v3/apis__networking.k8s.io__v1beta1_openapi.json @@ -31,6 +31,9 @@ "description": "spec is the desired state of the IPAddress. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status" } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index 6fce2b14b4f..0f410b94e18 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -2448,6 +2448,7 @@ func schema_k8sio_api_admissionregistration_v1_ValidatingAdmissionPolicyBinding( }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ @@ -4043,6 +4044,7 @@ func schema_k8sio_api_admissionregistration_v1alpha1_ValidatingAdmissionPolicyBi }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ @@ -5645,6 +5647,7 @@ func schema_k8sio_api_admissionregistration_v1beta1_ValidatingAdmissionPolicyBin }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ @@ -7081,6 +7084,7 @@ func schema_k8sio_api_apiserverinternal_v1alpha1_ServerStorageVersion(ref common "apiServerID": { SchemaProps: spec.SchemaProps{ Description: "The ID of the reporting API server.", + Default: "", Type: []string{"string"}, Format: "", }, @@ -7088,6 +7092,7 @@ func schema_k8sio_api_apiserverinternal_v1alpha1_ServerStorageVersion(ref common "encodingVersion": { SchemaProps: spec.SchemaProps{ Description: "The API server encodes the object to this version when persisting it in the backend (e.g., etcd).", + Default: "", Type: []string{"string"}, Format: "", }, @@ -7133,6 +7138,7 @@ func schema_k8sio_api_apiserverinternal_v1alpha1_ServerStorageVersion(ref common }, }, }, + Required: []string{"apiServerID", "encodingVersion", "decodableVersions"}, }, }, } @@ -7181,7 +7187,7 @@ func schema_k8sio_api_apiserverinternal_v1alpha1_StorageVersion(ref common.Refer }, }, }, - Required: []string{"spec", "status"}, + Required: []string{"metadata"}, }, }, Dependencies: []string{ @@ -14380,6 +14386,7 @@ func schema_k8sio_api_autoscaling_v1_HorizontalPodAutoscaler(ref common.Referenc }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ @@ -15351,6 +15358,7 @@ func schema_k8sio_api_autoscaling_v2_HorizontalPodAutoscaler(ref common.Referenc }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ @@ -16092,6 +16100,7 @@ func schema_k8sio_api_batch_v1_CronJob(ref common.ReferenceCallback) common.Open }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ @@ -17011,6 +17020,7 @@ func schema_k8sio_api_batch_v1beta1_CronJob(ref common.ReferenceCallback) common }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ @@ -18564,6 +18574,7 @@ func schema_k8sio_api_coordination_v1alpha2_LeaseCandidate(ref common.ReferenceC }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ @@ -18759,6 +18770,7 @@ func schema_k8sio_api_coordination_v1beta1_LeaseCandidate(ref common.ReferenceCa }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ @@ -40734,6 +40746,7 @@ func schema_k8sio_api_networking_v1_IPAddress(ref common.ReferenceCallback) comm }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ @@ -42188,6 +42201,7 @@ func schema_k8sio_api_networking_v1beta1_IPAddress(ref common.ReferenceCallback) }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ diff --git a/staging/src/k8s.io/api/admissionregistration/v1/generated.proto b/staging/src/k8s.io/api/admissionregistration/v1/generated.proto index 8790255ba52..42db29497a4 100644 --- a/staging/src/k8s.io/api/admissionregistration/v1/generated.proto +++ b/staging/src/k8s.io/api/admissionregistration/v1/generated.proto @@ -604,6 +604,7 @@ message ValidatingAdmissionPolicyBinding { optional .k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1; // spec defines the desired behavior of the ValidatingAdmissionPolicyBinding. + // +required optional ValidatingAdmissionPolicyBindingSpec spec = 2; } diff --git a/staging/src/k8s.io/api/admissionregistration/v1alpha1/generated.proto b/staging/src/k8s.io/api/admissionregistration/v1alpha1/generated.proto index 0692e50cd6b..04499d45860 100644 --- a/staging/src/k8s.io/api/admissionregistration/v1alpha1/generated.proto +++ b/staging/src/k8s.io/api/admissionregistration/v1alpha1/generated.proto @@ -627,6 +627,7 @@ message ValidatingAdmissionPolicyBinding { optional .k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1; // spec defines the desired behavior of the ValidatingAdmissionPolicyBinding. + // +required optional ValidatingAdmissionPolicyBindingSpec spec = 2; } diff --git a/staging/src/k8s.io/api/admissionregistration/v1beta1/generated.proto b/staging/src/k8s.io/api/admissionregistration/v1beta1/generated.proto index 4a1ba6af4f4..a395c0a2ee4 100644 --- a/staging/src/k8s.io/api/admissionregistration/v1beta1/generated.proto +++ b/staging/src/k8s.io/api/admissionregistration/v1beta1/generated.proto @@ -853,6 +853,7 @@ message ValidatingAdmissionPolicyBinding { optional .k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1; // spec defines the desired behavior of the ValidatingAdmissionPolicyBinding. + // +required optional ValidatingAdmissionPolicyBindingSpec spec = 2; } diff --git a/staging/src/k8s.io/api/apiserverinternal/v1alpha1/generated.proto b/staging/src/k8s.io/api/apiserverinternal/v1alpha1/generated.proto index 8a77860720f..b6fb42b9a5a 100644 --- a/staging/src/k8s.io/api/apiserverinternal/v1alpha1/generated.proto +++ b/staging/src/k8s.io/api/apiserverinternal/v1alpha1/generated.proto @@ -32,33 +32,40 @@ option go_package = "k8s.io/api/apiserverinternal/v1alpha1"; // encodes objects to when persisting objects in the backend. message ServerStorageVersion { // The ID of the reporting API server. + // +required optional string apiServerID = 1; // The API server encodes the object to this version when persisting it in // the backend (e.g., etcd). + // +required optional string encodingVersion = 2; // The API server can decode objects encoded in these versions. // The encodingVersion must be included in the decodableVersions. // +listType=set + // +required repeated string decodableVersions = 3; // The API server can serve these versions. // DecodableVersions must include all ServedVersions. // +listType=set + // +optional repeated string servedVersions = 4; } // Storage version of a specific resource. message StorageVersion { // The name is .. + // +required optional .k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1; // Spec is an empty spec. It is here to comply with Kubernetes API style. + // +optional optional StorageVersionSpec spec = 2; // API server instances report the version they can decode and the version they // encode objects to when persisting objects in the backend. + // +optional optional StorageVersionStatus status = 3; } @@ -77,6 +84,7 @@ message StorageVersionCondition { optional int64 observedGeneration = 3; // Last time the condition transitioned from one status to another. + // +optional optional .k8s.io.apimachinery.pkg.apis.meta.v1.Time lastTransitionTime = 4; // The reason for the condition's last transition. diff --git a/staging/src/k8s.io/api/autoscaling/v1/generated.proto b/staging/src/k8s.io/api/autoscaling/v1/generated.proto index 893acf80548..405c57fcbf9 100644 --- a/staging/src/k8s.io/api/autoscaling/v1/generated.proto +++ b/staging/src/k8s.io/api/autoscaling/v1/generated.proto @@ -148,7 +148,7 @@ message HorizontalPodAutoscaler { optional .k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1; // spec defines the behaviour of autoscaler. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status. - // +optional + // +required optional HorizontalPodAutoscalerSpec spec = 2; // status is the current information about the autoscaler. diff --git a/staging/src/k8s.io/api/autoscaling/v2/generated.proto b/staging/src/k8s.io/api/autoscaling/v2/generated.proto index 39877eba6a8..75fc6cefb6f 100644 --- a/staging/src/k8s.io/api/autoscaling/v2/generated.proto +++ b/staging/src/k8s.io/api/autoscaling/v2/generated.proto @@ -175,7 +175,7 @@ message HorizontalPodAutoscaler { // spec is the specification for the behaviour of the autoscaler. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status. - // +optional + // +required optional HorizontalPodAutoscalerSpec spec = 2; // status is the current information about the autoscaler. diff --git a/staging/src/k8s.io/api/batch/v1/generated.proto b/staging/src/k8s.io/api/batch/v1/generated.proto index 989fddc9d2f..3d7d36507b1 100644 --- a/staging/src/k8s.io/api/batch/v1/generated.proto +++ b/staging/src/k8s.io/api/batch/v1/generated.proto @@ -38,7 +38,7 @@ message CronJob { // Specification of the desired behavior of a cron job, including the schedule. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional + // +required optional CronJobSpec spec = 2; // Current status of a cron job. diff --git a/staging/src/k8s.io/api/batch/v1beta1/generated.proto b/staging/src/k8s.io/api/batch/v1beta1/generated.proto index 00a74b24ada..6a26bc728fe 100644 --- a/staging/src/k8s.io/api/batch/v1beta1/generated.proto +++ b/staging/src/k8s.io/api/batch/v1beta1/generated.proto @@ -39,7 +39,7 @@ message CronJob { // Specification of the desired behavior of a cron job, including the schedule. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional + // +required optional CronJobSpec spec = 2; // Current status of a cron job. diff --git a/staging/src/k8s.io/api/certificates/v1beta1/generated.proto b/staging/src/k8s.io/api/certificates/v1beta1/generated.proto index 0d5c82a0b79..4554ec50488 100644 --- a/staging/src/k8s.io/api/certificates/v1beta1/generated.proto +++ b/staging/src/k8s.io/api/certificates/v1beta1/generated.proto @@ -289,6 +289,7 @@ message PodCertificateRequest { optional .k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1; // spec contains the details about the certificate being requested. + // +required optional PodCertificateRequestSpec spec = 2; // status contains the issued certificate, and a standard set of conditions. diff --git a/staging/src/k8s.io/api/coordination/v1alpha2/generated.proto b/staging/src/k8s.io/api/coordination/v1alpha2/generated.proto index 250c6113ec1..379fcf0d5d0 100644 --- a/staging/src/k8s.io/api/coordination/v1alpha2/generated.proto +++ b/staging/src/k8s.io/api/coordination/v1alpha2/generated.proto @@ -38,7 +38,7 @@ message LeaseCandidate { // spec contains the specification of the Lease. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional + // +required optional LeaseCandidateSpec spec = 2; } diff --git a/staging/src/k8s.io/api/coordination/v1beta1/generated.proto b/staging/src/k8s.io/api/coordination/v1beta1/generated.proto index 7ca043f5288..74df40c64fe 100644 --- a/staging/src/k8s.io/api/coordination/v1beta1/generated.proto +++ b/staging/src/k8s.io/api/coordination/v1beta1/generated.proto @@ -50,7 +50,7 @@ message LeaseCandidate { // spec contains the specification of the Lease. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional + // +required optional LeaseCandidateSpec spec = 2; } diff --git a/staging/src/k8s.io/api/networking/v1/generated.proto b/staging/src/k8s.io/api/networking/v1/generated.proto index 2231eda22ad..c4f4d24aaed 100644 --- a/staging/src/k8s.io/api/networking/v1/generated.proto +++ b/staging/src/k8s.io/api/networking/v1/generated.proto @@ -87,7 +87,7 @@ message IPAddress { // spec is the desired state of the IPAddress. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional + // +required optional IPAddressSpec spec = 2; } diff --git a/staging/src/k8s.io/api/networking/v1beta1/generated.proto b/staging/src/k8s.io/api/networking/v1beta1/generated.proto index 7cef8b90cb7..616f6e9bd1a 100644 --- a/staging/src/k8s.io/api/networking/v1beta1/generated.proto +++ b/staging/src/k8s.io/api/networking/v1beta1/generated.proto @@ -88,7 +88,7 @@ message IPAddress { // spec is the desired state of the IPAddress. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status - // +optional + // +required optional IPAddressSpec spec = 2; } diff --git a/staging/src/k8s.io/api/rbac/v1/generated.proto b/staging/src/k8s.io/api/rbac/v1/generated.proto index 56869814ec4..7e3a9d2af79 100644 --- a/staging/src/k8s.io/api/rbac/v1/generated.proto +++ b/staging/src/k8s.io/api/rbac/v1/generated.proto @@ -70,6 +70,7 @@ message ClusterRoleBinding { // RoleRef can only reference a ClusterRole in the global namespace. // If the RoleRef cannot be resolved, the Authorizer must return an error. // This field is immutable. + // +required optional RoleRef roleRef = 3; } @@ -152,6 +153,7 @@ message RoleBinding { // RoleRef can reference a Role in the current namespace or a ClusterRole in the global namespace. // If the RoleRef cannot be resolved, the Authorizer must return an error. // This field is immutable. + // +required optional RoleRef roleRef = 3; } diff --git a/staging/src/k8s.io/api/rbac/v1alpha1/generated.proto b/staging/src/k8s.io/api/rbac/v1alpha1/generated.proto index f787f3976e7..b9e63df836f 100644 --- a/staging/src/k8s.io/api/rbac/v1alpha1/generated.proto +++ b/staging/src/k8s.io/api/rbac/v1alpha1/generated.proto @@ -71,6 +71,7 @@ message ClusterRoleBinding { // RoleRef can only reference a ClusterRole in the global namespace. // If the RoleRef cannot be resolved, the Authorizer must return an error. + // +required optional RoleRef roleRef = 3; } @@ -156,6 +157,7 @@ message RoleBinding { // RoleRef can reference a Role in the current namespace or a ClusterRole in the global namespace. // If the RoleRef cannot be resolved, the Authorizer must return an error. + // +required optional RoleRef roleRef = 3; } diff --git a/staging/src/k8s.io/api/rbac/v1beta1/generated.proto b/staging/src/k8s.io/api/rbac/v1beta1/generated.proto index cac7b413e87..6e225ac8cdd 100644 --- a/staging/src/k8s.io/api/rbac/v1beta1/generated.proto +++ b/staging/src/k8s.io/api/rbac/v1beta1/generated.proto @@ -71,6 +71,7 @@ message ClusterRoleBinding { // RoleRef can only reference a ClusterRole in the global namespace. // If the RoleRef cannot be resolved, the Authorizer must return an error. + // +required optional RoleRef roleRef = 3; } @@ -157,6 +158,7 @@ message RoleBinding { // RoleRef can reference a Role in the current namespace or a ClusterRole in the global namespace. // If the RoleRef cannot be resolved, the Authorizer must return an error. + // +required optional RoleRef roleRef = 3; } diff --git a/staging/src/k8s.io/api/resource/v1/generated.proto b/staging/src/k8s.io/api/resource/v1/generated.proto index eb008939c7f..1e87627497c 100644 --- a/staging/src/k8s.io/api/resource/v1/generated.proto +++ b/staging/src/k8s.io/api/resource/v1/generated.proto @@ -1586,6 +1586,7 @@ message ResourceSlice { // Contains the information published by the driver. // // Changing the spec automatically increments the metadata.generation number. + // +required optional ResourceSliceSpec spec = 2; } diff --git a/staging/src/k8s.io/api/resource/v1alpha3/generated.proto b/staging/src/k8s.io/api/resource/v1alpha3/generated.proto index 6414216db29..f7fae0be64d 100644 --- a/staging/src/k8s.io/api/resource/v1alpha3/generated.proto +++ b/staging/src/k8s.io/api/resource/v1alpha3/generated.proto @@ -140,6 +140,7 @@ message DeviceTaintRule { // Spec specifies the selector and one taint. // // Changing the spec automatically increments the metadata.generation number. + // +required optional DeviceTaintRuleSpec spec = 2; // Status provides information about what was requested in the spec. diff --git a/staging/src/k8s.io/api/resource/v1beta1/generated.proto b/staging/src/k8s.io/api/resource/v1beta1/generated.proto index 70bcf7987c7..5a3ed4ada98 100644 --- a/staging/src/k8s.io/api/resource/v1beta1/generated.proto +++ b/staging/src/k8s.io/api/resource/v1beta1/generated.proto @@ -1613,6 +1613,7 @@ message ResourceSlice { // Contains the information published by the driver. // // Changing the spec automatically increments the metadata.generation number. + // +required optional ResourceSliceSpec spec = 2; } diff --git a/staging/src/k8s.io/api/resource/v1beta2/generated.proto b/staging/src/k8s.io/api/resource/v1beta2/generated.proto index c5fd95b7d8e..44816e484a6 100644 --- a/staging/src/k8s.io/api/resource/v1beta2/generated.proto +++ b/staging/src/k8s.io/api/resource/v1beta2/generated.proto @@ -1598,6 +1598,7 @@ message ResourceSlice { // Contains the information published by the driver. // // Changing the spec automatically increments the metadata.generation number. + // +required optional ResourceSliceSpec spec = 2; } diff --git a/staging/src/k8s.io/api/storage/v1/generated.proto b/staging/src/k8s.io/api/storage/v1/generated.proto index dbc0a0012e6..09ccb8bd69c 100644 --- a/staging/src/k8s.io/api/storage/v1/generated.proto +++ b/staging/src/k8s.io/api/storage/v1/generated.proto @@ -510,6 +510,7 @@ message VolumeAttachment { // spec represents specification of the desired attach/detach volume behavior. // Populated by the Kubernetes system. // +k8s:immutable + // +required optional VolumeAttachmentSpec spec = 2; // status represents status of the VolumeAttachment request. diff --git a/staging/src/k8s.io/api/storage/v1alpha1/generated.proto b/staging/src/k8s.io/api/storage/v1alpha1/generated.proto index b6cd87ede94..e975778fe1d 100644 --- a/staging/src/k8s.io/api/storage/v1alpha1/generated.proto +++ b/staging/src/k8s.io/api/storage/v1alpha1/generated.proto @@ -135,6 +135,7 @@ message VolumeAttachment { // spec represents specification of the desired attach/detach volume behavior. // Populated by the Kubernetes system. // +k8s:immutable + // +required optional VolumeAttachmentSpec spec = 2; // status represents status of the VolumeAttachment request. diff --git a/staging/src/k8s.io/api/storage/v1beta1/generated.proto b/staging/src/k8s.io/api/storage/v1beta1/generated.proto index b6815142e55..1b670ea5936 100644 --- a/staging/src/k8s.io/api/storage/v1beta1/generated.proto +++ b/staging/src/k8s.io/api/storage/v1beta1/generated.proto @@ -512,6 +512,7 @@ message VolumeAttachment { // spec represents specification of the desired attach/detach volume behavior. // Populated by the Kubernetes system. // +k8s:immutable + // +required optional VolumeAttachmentSpec spec = 2; // status represents status of the VolumeAttachment request. diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/generated/openapi/zz_generated.openapi.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/generated/openapi/zz_generated.openapi.go index 065019b5ebe..c1b67ea486e 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/generated/openapi/zz_generated.openapi.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/generated/openapi/zz_generated.openapi.go @@ -425,6 +425,7 @@ func schema_k8sio_api_autoscaling_v1_HorizontalPodAutoscaler(ref common.Referenc }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ diff --git a/staging/src/k8s.io/client-go/applyconfigurations/internal/internal.go b/staging/src/k8s.io/client-go/applyconfigurations/internal/internal.go index c32f94c46cd..5a2e14aa648 100644 --- a/staging/src/k8s.io/client-go/applyconfigurations/internal/internal.go +++ b/staging/src/k8s.io/client-go/applyconfigurations/internal/internal.go @@ -1443,6 +1443,7 @@ var schemaYAML = typed.YAMLObject(`types: - name: apiServerID type: scalar: string + default: "" - name: decodableVersions type: list: @@ -1452,6 +1453,7 @@ var schemaYAML = typed.YAMLObject(`types: - name: encodingVersion type: scalar: string + default: "" - name: servedVersions type: list: From 0b10375aec7460228a14f855224a7e214ef2d06e Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Thu, 22 Jan 2026 11:13:50 +0000 Subject: [PATCH 5/8] Add exception for union type in scheduling API We need to add a marker to allow podgroup to be marked up correctly as a union type, and then teach the nonpointerstructs linter how to understand this --- hack/golangci-hints.yaml | 7 +++++++ hack/golangci.yaml | 7 +++++++ hack/kube-api-linter/exceptions.yaml | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/hack/golangci-hints.yaml b/hack/golangci-hints.yaml index bde0cce48bf..506dad69f7d 100644 --- a/hack/golangci-hints.yaml +++ b/hack/golangci-hints.yaml @@ -224,6 +224,13 @@ linters: # jsontags: 'Port' must be capitalized for backward compatibility - text: 'jsontags: field DaemonEndpoint.Port json tag does not match' path: "staging/src/k8s.io/api/core/v1/types.go" + + # NonPointerStructs - Existing fields that are non-pointer structs but where the current rules are incorrect. + + # The PodGroup.Policy field is a union type, but is not marked up as a union, nor does nonpointerstructs understand unions today. + # Validation makes this require at least one of the fields within to be set. + - text: "nonpointerstructs: field PodGroup.Policy is a non-pointer struct with no required fields. It must be marked as optional." + path: "staging/src/k8s.io/api/scheduling/v1alpha1/types.go" - linters: - forbidigo diff --git a/hack/golangci.yaml b/hack/golangci.yaml index ea5539138ee..81884353387 100644 --- a/hack/golangci.yaml +++ b/hack/golangci.yaml @@ -235,6 +235,13 @@ linters: # jsontags: 'Port' must be capitalized for backward compatibility - text: 'jsontags: field DaemonEndpoint.Port json tag does not match' path: "staging/src/k8s.io/api/core/v1/types.go" + + # NonPointerStructs - Existing fields that are non-pointer structs but where the current rules are incorrect. + + # The PodGroup.Policy field is a union type, but is not marked up as a union, nor does nonpointerstructs understand unions today. + # Validation makes this require at least one of the fields within to be set. + - text: "nonpointerstructs: field PodGroup.Policy is a non-pointer struct with no required fields. It must be marked as optional." + path: "staging/src/k8s.io/api/scheduling/v1alpha1/types.go" - linters: - forbidigo diff --git a/hack/kube-api-linter/exceptions.yaml b/hack/kube-api-linter/exceptions.yaml index 0733f16139d..e2ff283f8dc 100644 --- a/hack/kube-api-linter/exceptions.yaml +++ b/hack/kube-api-linter/exceptions.yaml @@ -100,3 +100,10 @@ # jsontags: 'Port' must be capitalized for backward compatibility - text: 'jsontags: field DaemonEndpoint.Port json tag does not match' path: "staging/src/k8s.io/api/core/v1/types.go" + +# NonPointerStructs - Existing fields that are non-pointer structs but where the current rules are incorrect. + +# The PodGroup.Policy field is a union type, but is not marked up as a union, nor does nonpointerstructs understand unions today. +# Validation makes this require at least one of the fields within to be set. +- text: "nonpointerstructs: field PodGroup.Policy is a non-pointer struct with no required fields. It must be marked as optional." + path: "staging/src/k8s.io/api/scheduling/v1alpha1/types.go" From 551c08e2a2d9350f86747a7d68c1c61f9141526c Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Thu, 12 Feb 2026 17:42:44 +0000 Subject: [PATCH 6/8] Update exceptions to drop "it must be optional" --- hack/golangci-hints.yaml | 4 ++-- hack/golangci.yaml | 4 ++-- hack/kube-api-linter/exceptions.yaml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hack/golangci-hints.yaml b/hack/golangci-hints.yaml index 506dad69f7d..136686f509d 100644 --- a/hack/golangci-hints.yaml +++ b/hack/golangci-hints.yaml @@ -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. # The nonpointerstructs linter is included here as well as these two should be enabled hand-in-hand on each API group. - - text: "must be marked as optional or required|is a non-pointer struct with no required fields. It must be marked as optional." + - text: "must be marked as optional or required|is a non-pointer struct with no required fields." path: "staging/src/k8s.io/api/(admission|apidiscovery|apps|authentication|authorization|autoscaling|batch|certificates|core|discovery|events|extensions|flowcontrol|networking|rbac|resource|storage)" # OptionalOrRequired - Existing fields that are marked as both optional and required (based on standard optional vs kubebuilder:validation:Required) and should not be fixed. @@ -229,7 +229,7 @@ linters: # The PodGroup.Policy field is a union type, but is not marked up as a union, nor does nonpointerstructs understand unions today. # Validation makes this require at least one of the fields within to be set. - - text: "nonpointerstructs: field PodGroup.Policy is a non-pointer struct with no required fields. It must be marked as optional." + - text: "nonpointerstructs: field PodGroup.Policy is a non-pointer struct with no required fields." path: "staging/src/k8s.io/api/scheduling/v1alpha1/types.go" - linters: diff --git a/hack/golangci.yaml b/hack/golangci.yaml index 81884353387..26bf20e9857 100644 --- a/hack/golangci.yaml +++ b/hack/golangci.yaml @@ -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. # The nonpointerstructs linter is included here as well as these two should be enabled hand-in-hand on each API group. - - text: "must be marked as optional or required|is a non-pointer struct with no required fields. It must be marked as optional." + - text: "must be marked as optional or required|is a non-pointer struct with no required fields." path: "staging/src/k8s.io/api/(admission|apidiscovery|apps|authentication|authorization|autoscaling|batch|certificates|core|discovery|events|extensions|flowcontrol|networking|rbac|resource|storage)" # OptionalOrRequired - Existing fields that are marked as both optional and required (based on standard optional vs kubebuilder:validation:Required) and should not be fixed. @@ -240,7 +240,7 @@ linters: # The PodGroup.Policy field is a union type, but is not marked up as a union, nor does nonpointerstructs understand unions today. # Validation makes this require at least one of the fields within to be set. - - text: "nonpointerstructs: field PodGroup.Policy is a non-pointer struct with no required fields. It must be marked as optional." + - text: "nonpointerstructs: field PodGroup.Policy is a non-pointer struct with no required fields." path: "staging/src/k8s.io/api/scheduling/v1alpha1/types.go" - linters: diff --git a/hack/kube-api-linter/exceptions.yaml b/hack/kube-api-linter/exceptions.yaml index e2ff283f8dc..9d14b2361da 100644 --- a/hack/kube-api-linter/exceptions.yaml +++ b/hack/kube-api-linter/exceptions.yaml @@ -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. # The nonpointerstructs linter is included here as well as these two should be enabled hand-in-hand on each API group. -- text: "must be marked as optional or required|is a non-pointer struct with no required fields. It must be marked as optional." +- text: "must be marked as optional or required|is a non-pointer struct with no required fields." path: "staging/src/k8s.io/api/(admission|apidiscovery|apps|authentication|authorization|autoscaling|batch|certificates|core|discovery|events|extensions|flowcontrol|networking|rbac|resource|storage)" # OptionalOrRequired - Existing fields that are marked as both optional and required (based on standard optional vs kubebuilder:validation:Required) and should not be fixed. @@ -105,5 +105,5 @@ # The PodGroup.Policy field is a union type, but is not marked up as a union, nor does nonpointerstructs understand unions today. # Validation makes this require at least one of the fields within to be set. -- text: "nonpointerstructs: field PodGroup.Policy is a non-pointer struct with no required fields. It must be marked as optional." +- text: "nonpointerstructs: field PodGroup.Policy is a non-pointer struct with no required fields." path: "staging/src/k8s.io/api/scheduling/v1alpha1/types.go" From 319978e21630ce41298b47ea1518823502c334ba Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Thu, 12 Feb 2026 17:44:53 +0000 Subject: [PATCH 7/8] Update openapi/swagger --- api/openapi-spec/swagger.json | 3 +++ .../v3/apis__admissionregistration.k8s.io__v1_openapi.json | 3 +++ 2 files changed, 6 insertions(+) diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index 66096ed75ca..72bef7dceeb 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -465,6 +465,9 @@ "description": "spec defines the desired behavior of the ValidatingAdmissionPolicyBinding." } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { diff --git a/api/openapi-spec/v3/apis__admissionregistration.k8s.io__v1_openapi.json b/api/openapi-spec/v3/apis__admissionregistration.k8s.io__v1_openapi.json index 1a12ce0d042..6fca0348f26 100644 --- a/api/openapi-spec/v3/apis__admissionregistration.k8s.io__v1_openapi.json +++ b/api/openapi-spec/v3/apis__admissionregistration.k8s.io__v1_openapi.json @@ -580,6 +580,9 @@ "description": "spec defines the desired behavior of the ValidatingAdmissionPolicyBinding." } }, + "required": [ + "spec" + ], "type": "object", "x-kubernetes-group-version-kind": [ { From 82a9a99a44ce2c41fc07dfcd8651d89652659976 Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Thu, 12 Feb 2026 17:59:07 +0000 Subject: [PATCH 8/8] Restore omitempty on ServerStorageVersion fields --- .../apis__internal.apiserver.k8s.io__v1alpha1_openapi.json | 2 -- pkg/generated/openapi/zz_generated.openapi.go | 2 -- staging/src/k8s.io/api/apiserverinternal/v1alpha1/types.go | 6 +++--- .../client-go/applyconfigurations/internal/internal.go | 2 -- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/api/openapi-spec/v3/apis__internal.apiserver.k8s.io__v1alpha1_openapi.json b/api/openapi-spec/v3/apis__internal.apiserver.k8s.io__v1alpha1_openapi.json index 2987b2101a7..fee3b5410be 100644 --- a/api/openapi-spec/v3/apis__internal.apiserver.k8s.io__v1alpha1_openapi.json +++ b/api/openapi-spec/v3/apis__internal.apiserver.k8s.io__v1alpha1_openapi.json @@ -5,7 +5,6 @@ "description": "An API server instance reports the version it can decode and the version it encodes objects to when persisting objects in the backend.", "properties": { "apiServerID": { - "default": "", "description": "The ID of the reporting API server.", "type": "string" }, @@ -19,7 +18,6 @@ "x-kubernetes-list-type": "set" }, "encodingVersion": { - "default": "", "description": "The API server encodes the object to this version when persisting it in the backend (e.g., etcd).", "type": "string" }, diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index 0f410b94e18..7efbcbd67e1 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -7084,7 +7084,6 @@ func schema_k8sio_api_apiserverinternal_v1alpha1_ServerStorageVersion(ref common "apiServerID": { SchemaProps: spec.SchemaProps{ Description: "The ID of the reporting API server.", - Default: "", Type: []string{"string"}, Format: "", }, @@ -7092,7 +7091,6 @@ func schema_k8sio_api_apiserverinternal_v1alpha1_ServerStorageVersion(ref common "encodingVersion": { SchemaProps: spec.SchemaProps{ Description: "The API server encodes the object to this version when persisting it in the backend (e.g., etcd).", - Default: "", Type: []string{"string"}, Format: "", }, diff --git a/staging/src/k8s.io/api/apiserverinternal/v1alpha1/types.go b/staging/src/k8s.io/api/apiserverinternal/v1alpha1/types.go index 1507a3be756..bbf30cfbf4f 100644 --- a/staging/src/k8s.io/api/apiserverinternal/v1alpha1/types.go +++ b/staging/src/k8s.io/api/apiserverinternal/v1alpha1/types.go @@ -71,18 +71,18 @@ type StorageVersionStatus struct { type ServerStorageVersion struct { // The ID of the reporting API server. // +required - APIServerID string `json:"apiServerID" protobuf:"bytes,1,opt,name=apiServerID"` + APIServerID string `json:"apiServerID,omitempty" protobuf:"bytes,1,opt,name=apiServerID"` // The API server encodes the object to this version when persisting it in // the backend (e.g., etcd). // +required - EncodingVersion string `json:"encodingVersion" protobuf:"bytes,2,opt,name=encodingVersion"` + EncodingVersion string `json:"encodingVersion,omitempty" protobuf:"bytes,2,opt,name=encodingVersion"` // The API server can decode objects encoded in these versions. // The encodingVersion must be included in the decodableVersions. // +listType=set // +required - DecodableVersions []string `json:"decodableVersions" protobuf:"bytes,3,opt,name=decodableVersions"` + DecodableVersions []string `json:"decodableVersions,omitempty" protobuf:"bytes,3,opt,name=decodableVersions"` // The API server can serve these versions. // DecodableVersions must include all ServedVersions. diff --git a/staging/src/k8s.io/client-go/applyconfigurations/internal/internal.go b/staging/src/k8s.io/client-go/applyconfigurations/internal/internal.go index 5a2e14aa648..c32f94c46cd 100644 --- a/staging/src/k8s.io/client-go/applyconfigurations/internal/internal.go +++ b/staging/src/k8s.io/client-go/applyconfigurations/internal/internal.go @@ -1443,7 +1443,6 @@ var schemaYAML = typed.YAMLObject(`types: - name: apiServerID type: scalar: string - default: "" - name: decodableVersions type: list: @@ -1453,7 +1452,6 @@ var schemaYAML = typed.YAMLObject(`types: - name: encodingVersion type: scalar: string - default: "" - name: servedVersions type: list: