@@ -14,9 +14,54 @@ linters:
1414 settings :
1515 linters :
1616 enable :
17+ - " commentstart" # Ensure comments start with the serialized version of the field name.
18+ - " conditions" # Ensure conditions have the correct json tags and markers.
19+ - " conflictingmarkers"
20+ - " duplicatemarkers" # Ensure there are no exact duplicate markers. for types and fields.
21+ - " forbiddenmarkers" # Ensure that types and fields do not contain any markers that are forbidden.
22+ - " integers" # Ensure only int32 and int64 are used for integers.
23+ - " jsontags" # Ensure every field has a json tag.
24+ - " maxlength" # Ensure all strings and arrays have maximum lengths/maximum items.
25+ - " nobools" # Bools do not evolve over time, should use enums instead.
26+ - " nodurations" # Prevents usage of `Duration` types.
27+ - " nofloats" # Ensure floats are not used.
28+ - " nonullable" # Ensure that types and fields do not have the nullable marker.
1729 - " nophase" # Phase fields are discouraged by the Kube API conventions, use conditions instead.
30+ - " notimestamp" # Prevents usage of 'Timestamp' fields
31+ - " optionalfields" # Ensure that all fields marked as optional adhere to being pointers and
32+ # having the `omitempty` value in their `json` tag where appropriate.
33+ - " optionalorrequired" # Every field should be marked as `+optional` or `+required`.
34+ - " requiredfields" # Required fields should not be pointers, and should not have `omitempty`
35+ - " ssatags" # Ensure array fields have the appropriate listType markers
36+ - " statusoptional" # Ensure all first children within status should be optional.
37+ - " statussubresource" # All root objects that have a `status` field should have a status subresource.
38+ - " uniquemarkers" # Ensure that types and fields do not contain more than a single definition of a marker that should only be present once.
1839 disable :
1940 - " *" # We will manually enable new linters after understanding the impact. Disable all by default.
41+ lintersConfig :
42+ conflictingmarkers :
43+ conflicts :
44+ - name : " default_vs_required"
45+ sets :
46+ - [ "default", "kubebuilder:default" ]
47+ - [ "required", "kubebuilder:validation:Required", "k8s:required" ]
48+ description : " A field with a default value cannot be required"
49+ conditions :
50+ isFirstField : Warn # Require conditions to be the first field in the status struct.
51+ usePatchStrategy : Forbid # Forbid patchStrategy markers on the Conditions field.
52+ useProtobuf : Forbid # We don't use protobuf, so protobuf tags are not required.\
53+ forbiddenmarkers :
54+ markers :
55+ # We don't want to do any defaulting (including OpenAPI) anymore on API fields because we prefer
56+ # to have a clear signal on user intent. This also allows us to easily change the default behavior if necessary.
57+ - identifier : " kubebuilder:default"
58+ - identifier : " default"
59+ optionalfields :
60+ pointers :
61+ preference : WhenRequired # Always | WhenRequired # Whether to always require pointers, or only when required. Defaults to `Always`.
62+ policy : SuggestFix # SuggestFix | Warn # The policy for pointers in optional fields. Defaults to `SuggestFix`.
63+ omitempty :
64+ policy : SuggestFix # SuggestFix | Warn | Ignore # The policy for omitempty in optional fields. Defaults to `SuggestFix`.
2065 exclusions :
2166 generated : strict
2267 paths :
0 commit comments