|
| 1 | +# Copyright 2025 Nutanix. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +version: "2" |
| 5 | +linters: |
| 6 | + default: none |
| 7 | + enable: |
| 8 | + - kubeapilinter # linter for Kube API conventions |
| 9 | + settings: |
| 10 | + custom: |
| 11 | + kubeapilinter: |
| 12 | + type: module |
| 13 | + description: KAL is the Kube-API-Linter and lints Kube like APIs based on API conventions and best practices. |
| 14 | + settings: |
| 15 | + linters: |
| 16 | + 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 | + - "duplicatemarkers" # Ensure there are no exact duplicate markers. for types and fields. |
| 20 | + - "integers" # Ensure only int32 and int64 are used for integers. |
| 21 | + - "jsontags" # Ensure every field has a json tag. |
| 22 | + - "maxlength" # Ensure all strings and arrays have maximum lengths/maximum items. |
| 23 | + - "nobools" # Bools do not evolve over time, should use enums instead. |
| 24 | + - "nofloats" # Ensure floats are not used. |
| 25 | + - "nomaps" # Ensure maps are not used. |
| 26 | + # "nophase" # Ensure phases are not used, as they are not extensible. |
| 27 | + - "optionalfields" # Ensure that all fields marked as optional adhere to being pointers and |
| 28 | + # having the `omitempty` value in their `json` tag where appropriate. |
| 29 | + - "optionalorrequired" # Every field should be marked as `+optional` or `+required`. |
| 30 | + - "requiredfields" # Required fields should not be pointers, and should not have `omitempty`. |
| 31 | + # - "ssatags" # Ensure array fields have the appropriate listType markers |
| 32 | + # - "statusoptional" # Ensure all first children within status should be optional. |
| 33 | + # - "statussubresource" # All root objects that have a `status` field should have a status subresource. |
| 34 | + - "uniquemarkers" # Ensure that types and fields do not contain more than a single definition of a marker that should only be present once. |
| 35 | + |
| 36 | + # Linters below this line are disabled, pending conversation on how and when to enable them. |
| 37 | + disable: |
| 38 | + - "*" # We will manually enable new linters after understanding the impact. Disable all by default. |
| 39 | + lintersConfig: |
| 40 | + optionalfields: |
| 41 | + pointers: |
| 42 | + preference: WhenRequired # Always | WhenRequired # Whether to always require pointers, or only when required. Defaults to `Always`. |
| 43 | + # jsontags: |
| 44 | + # jsonTagRegex: "^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case. |
| 45 | + optionalorrequired: |
| 46 | + preferredOptionalMarker: kubebuilder:validation:Optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`. |
| 47 | + preferredRequiredMarker: kubebuilder:validation:Required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`. |
| 48 | + |
| 49 | + exclusions: |
| 50 | + generated: strict |
| 51 | + paths: |
| 52 | + # Ignore generated files. |
| 53 | + - zz_generated.*\.go$ |
| 54 | + # Ignore external API packages. |
| 55 | + - external/ |
| 56 | + # Ignore test files. |
| 57 | + - '.+_test\.go$' |
| 58 | + |
| 59 | +issues: |
| 60 | + max-same-issues: 0 |
| 61 | + max-issues-per-linter: 0 |
0 commit comments