From 0b10375aec7460228a14f855224a7e214ef2d06e Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Thu, 22 Jan 2026 11:13:50 +0000 Subject: [PATCH] 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"