From 2182441bdd02ff372b0eb4e3ec8348ebed5ab632 Mon Sep 17 00:00:00 2001 From: Matteo Fari Date: Thu, 23 Oct 2025 11:28:31 +0200 Subject: [PATCH] enabled jsontags for kal and added exceptions enabled jsontags for kal and added exceptions --- hack/golangci.yaml | 6 +++++- hack/kube-api-linter/exceptions.yaml | 4 ++++ hack/kube-api-linter/kube-api-linter.yaml | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/hack/golangci.yaml b/hack/golangci.yaml index 571789f0f2d..b97e59ee354 100644 --- a/hack/golangci.yaml +++ b/hack/golangci.yaml @@ -230,6 +230,10 @@ linters: # 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" path: "staging/src/k8s.io/api/(core/v1|extensions/v1beta1|networking/(v1|v1beta1))" + + # jsontags: 'Port' must be capitalized for backward compatibility + - text: 'jsontags: field Port json tag does not match pattern "[^"]+": Port$' + path: "staging/src/k8s.io/api/core/v1/types.go" - linters: - forbidigo @@ -405,7 +409,7 @@ linters: - "conditions" # Ensure conditions have the correct json tags and markers. - "conflictingmarkers" # Detect mutually exclusive markers on the same field. - "integers" # Ensure only int32 and int64 are used for integers. - # - "jsontags" # Ensure every field has a json tag. + - "jsontags" # Ensure every field has a json tag. # - "maxlength" # Ensure all strings and arrays have maximum lengths/maximum items. ONLY for CRDs until declarative markers exist in core types. # - "nobools" # Bools do not evolve over time, should use enums instead. # - "nofloats" # Ensure floats are not used. diff --git a/hack/kube-api-linter/exceptions.yaml b/hack/kube-api-linter/exceptions.yaml index da1962b57da..98157b6fd0f 100644 --- a/hack/kube-api-linter/exceptions.yaml +++ b/hack/kube-api-linter/exceptions.yaml @@ -95,3 +95,7 @@ # 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" path: "staging/src/k8s.io/api/(core/v1|extensions/v1beta1|networking/(v1|v1beta1))" + +# jsontags: 'Port' must be capitalized for backward compatibility +- text: 'jsontags: field Port json tag does not match pattern "[^"]+": Port$' + path: "staging/src/k8s.io/api/core/v1/types.go" diff --git a/hack/kube-api-linter/kube-api-linter.yaml b/hack/kube-api-linter/kube-api-linter.yaml index f4562f134e2..84dd20d8999 100644 --- a/hack/kube-api-linter/kube-api-linter.yaml +++ b/hack/kube-api-linter/kube-api-linter.yaml @@ -7,7 +7,7 @@ linters: - "conditions" # Ensure conditions have the correct json tags and markers. - "conflictingmarkers" # Detect mutually exclusive markers on the same field. - "integers" # Ensure only int32 and int64 are used for integers. - # - "jsontags" # Ensure every field has a json tag. + - "jsontags" # Ensure every field has a json tag. # - "maxlength" # Ensure all strings and arrays have maximum lengths/maximum items. ONLY for CRDs until declarative markers exist in core types. # - "nobools" # Bools do not evolve over time, should use enums instead. # - "nofloats" # Ensure floats are not used.