|
| 1 | +version: "2" |
| 2 | + |
1 | 3 | run:
|
2 | 4 | timeout: 10m
|
3 | 5 | go: "1.22"
|
4 | 6 | allow-parallel-runners: true
|
5 | 7 |
|
6 | 8 | linters:
|
7 |
| - disable-all: true |
| 9 | + default: none |
8 | 10 | enable:
|
9 |
| - - kal # linter for Kube API conventions |
10 |
| - |
11 |
| -linters-settings: |
12 |
| - custom: |
13 |
| - kal: |
14 |
| - type: "module" |
15 |
| - description: KAL is the Kube-API-Linter and lints Kube like APIs based on API conventions and best practices. |
16 |
| - settings: |
17 |
| - linters: |
18 |
| - enable: |
19 |
| - #- "commentstart" # Ensure comments start with the serialized version of the field name. |
20 |
| - #- "conditions" # Ensure conditions have the correct json tags and markers. |
21 |
| - #- "integers" # Ensure only int32 and int64 are used for integers. |
22 |
| - #- "jsontags" # Ensure every field has a json tag. |
23 |
| - #- "maxlength" # Ensure all strings and arrays have maximum lengths/maximum items. |
24 |
| - #- "nobools" # Bools do not evolve over time, should use enums instead. |
25 |
| - - "nofloats" # Ensure floats are not used. |
26 |
| - #- "optionalorrequired" # Every field should be marked as `+optional` or `+required`. |
27 |
| - # - "requiredfields" # Required fields should not be pointers, and should not have `omitempty`. |
28 |
| - - "statussubresource" # All root objects that have a `status` field should have a status subresource. |
| 11 | + - kubeapilinter # linter for Kube API conventions |
| 12 | + settings: |
| 13 | + custom: |
| 14 | + kubeapilinter: |
| 15 | + type: "module" |
| 16 | + description: KAL is the Kube-API-Linter and lints Kube like APIs based on API conventions and best practices. |
| 17 | + settings: |
| 18 | + linters: |
| 19 | + enable: |
| 20 | + #- "commentstart" # Ensure comments start with the serialized version of the field name. |
| 21 | + #- "conditions" # Ensure conditions have the correct json tags and markers. |
| 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 | + #- "nofloats" # Ensure floats are not used. |
| 27 | + #- "optionalorrequired" # Every field should be marked as `+optional` or `+required`. |
| 28 | + # - "requiredfields" # Required fields should not be pointers, and should not have `omitempty`. |
| 29 | + - "statussubresource" # All root objects that have a `status` field should have a status subresource. |
29 | 30 |
|
30 |
| - # Linters below this line are disabled, pending conversation on how and when to enable them. |
31 |
| - disable: |
32 |
| - - "*" # We will manually enable new linters after understanding the impact. Disable all by default. |
33 |
| - lintersConfig: |
34 |
| - conditions: |
35 |
| - isFirstField: Warn # Require conditions to be the first field in the status struct. |
36 |
| - usePatchStrategy: Forbid # Conditions should not use the patch strategy on CRDs. |
37 |
| - useProtobuf: Forbid # We don't use protobuf, so protobuf tags are not required. |
38 |
| - # jsonTags: |
39 |
| - # jsonTagRegex: "^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case. |
40 |
| - # optionalOrRequired: |
41 |
| - # preferredOptionalMarker: optional | kubebuilder:validation:Optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`. |
42 |
| - # preferredRequiredMarker: required | kubebuilder:validation:Required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`. |
43 |
| - # requiredFields: |
44 |
| - # pointerPolicy: Warn | SuggestFix # Defaults to `SuggestFix`. We want our required fields to not be pointers. |
| 31 | + # Linters below this line are disabled, pending conversation on how and when to enable them. |
| 32 | + disable: |
| 33 | + - "*" # We will manually enable new linters after understanding the impact. Disable all by default. |
| 34 | + lintersConfig: |
| 35 | + conditions: |
| 36 | + isFirstField: Warn # Require conditions to be the first field in the status struct. |
| 37 | + usePatchStrategy: Forbid # Conditions should not use the patch strategy on CRDs. |
| 38 | + useProtobuf: Forbid # We don't use protobuf, so protobuf tags are not required. |
| 39 | + # jsonTags: |
| 40 | + # jsonTagRegex: "^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case. |
| 41 | + # optionalOrRequired: |
| 42 | + # preferredOptionalMarker: optional | kubebuilder:validation:Optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`. |
| 43 | + # preferredRequiredMarker: required | kubebuilder:validation:Required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`. |
| 44 | + # requiredFields: |
| 45 | + # pointerPolicy: Warn | SuggestFix # Defaults to `SuggestFix`. We want our required fields to not be pointers. |
45 | 46 |
|
46 |
| -issues: |
47 |
| - exclude-files: |
48 |
| - - "zz_generated.*\\.go$" |
49 |
| - - "vendored_openapi\\.go$" |
50 |
| - # We don't want to invest time to fix new linter findings in old API types. |
51 |
| - - "internal/apis/.*" |
52 |
| - - ".*_test.go" # Exclude test files. |
53 |
| - max-same-issues: 0 |
54 |
| - max-issues-per-linter: 0 |
55 |
| - exclude-rules: |
| 47 | +exclusions: |
| 48 | + generated: strict |
| 49 | + paths: |
| 50 | + - zz_generated.*\.go$ |
| 51 | + - ".*_test.go" # Exclude test files. |
| 52 | + rules: |
56 | 53 | # KAL should only run on API folders.
|
57 | 54 | - path-except: "api//*"
|
58 | 55 | linters:
|
59 |
| - - kal |
| 56 | + - kubeapilinter |
60 | 57 | - path: "api/v1beta1/*|api/v1alpha1/*"
|
61 | 58 | text: "Conditions field must be a slice of metav1.Condition"
|
62 | 59 | linters:
|
63 |
| - - kal |
| 60 | + - kubeapilinter |
64 | 61 | - path: "api/v1beta1/*"
|
65 | 62 | text: "type ClusterIPFamily should not use an int, int8 or int16. Use int32 or int64 depending on bounding requirements"
|
66 | 63 | linters:
|
67 |
| - - kal |
| 64 | + - kubeapilinter |
68 | 65 | - path: "exp/ipam/api/v1alpha1/*|exp/ipam/api/v1beta1/*"
|
69 | 66 | text: "field Prefix should not use an int, int8 or int16. Use int32 or int64 depending on bounding requirements"
|
70 | 67 | linters:
|
71 |
| - - kal |
| 68 | + - kubeapilinter |
72 | 69 | # clusterctl and Runtime Hooks can be fixed once we bump their apiVersion.
|
73 | 70 | - path: "cmd/clusterctl/api/v1alpha3|exp/runtime/hooks/api/v1alpha1"
|
74 | 71 | text: "maxlength"
|
75 | 72 | linters:
|
76 |
| - - kal |
| 73 | + - kubeapilinter |
77 | 74 | # controller-gen does not allow to add MaxItems to Schemaless fields
|
78 | 75 | - path: "api/v1beta1/*"
|
79 | 76 | text: "maxlength: field (AllOf|OneOf|AnyOf) must have a maximum items, add kubebuilder:validation:MaxItems marker"
|
80 | 77 | linters:
|
81 |
| - - kal |
| 78 | + - kubeapilinter |
82 | 79 | # It does not make sense to add a maxItems marker on the *List structs as they are not used to generate CRD YAMLs.
|
83 | 80 | # This exclude will be removed once https://github.com/JoelSpeed/kal/issues/38 is resolved.
|
84 | 81 | - path: "api/v1beta1/*|api/v1alpha1/*"
|
85 | 82 | text: "maxlength: field Items must have a maximum items, add kubebuilder:validation:MaxItems marker"
|
86 | 83 | linters:
|
87 |
| - - kal |
| 84 | + - kubeapilinter |
88 | 85 | - path: "api/v1alpha1/*|api/v1beta1/*"
|
89 | 86 | text: "nobools"
|
90 | 87 | linters:
|
91 |
| - - kal |
| 88 | + - kubeapilinter |
92 | 89 | # We follow the current CustomResourceDefinition field's json tag pattern.
|
93 | 90 | - path: "api/v1beta1/*"
|
94 | 91 | text: "field (XPreserveUnknownFields|XPreserveUnknownFields|XValidations|XMetadata|XIntOrString) json tag does not match pattern"
|
95 | 92 | linters:
|
96 |
| - - kal |
| 93 | + - kubeapilinter |
97 | 94 | # The following rules are disabled until we migrate to the new API.
|
98 | 95 | - path: "bootstrap/kubeadm/api/v1beta1/kubeadm_types.go"
|
99 | 96 | text: "field Token is marked as required, should not be a pointer"
|
100 | 97 | linters:
|
101 |
| - - kal |
| 98 | + - kubeapilinter |
102 | 99 | - path: "api/v1beta1/clusterclass_types.go"
|
103 | 100 | text: "field Ref is marked as required, should not be a pointer"
|
104 | 101 | linters:
|
105 |
| - - kal |
| 102 | + - kubeapilinter |
106 | 103 | - path: "api/v1alpha1/*|api/v1beta1/*|api/v1alpha3/*"
|
107 | 104 | text: "field Items must be marked as optional or required"
|
108 | 105 | linters:
|
109 |
| - - kal |
| 106 | + - kubeapilinter |
| 107 | + |
| 108 | +issues: |
| 109 | + max-same-issues: 0 |
| 110 | + max-issues-per-linter: 0 |
0 commit comments