forked from kubernetes-sigs/cluster-api-provider-vsphere
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.golangci-kal.yml
More file actions
110 lines (102 loc) · 5.83 KB
/
.golangci-kal.yml
File metadata and controls
110 lines (102 loc) · 5.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
version: "2"
run:
go: "1.25"
allow-parallel-runners: true
linters:
default: none
enable:
- kubeapilinter # linter for Kube API conventions
settings:
custom:
kubeapilinter:
type: module
description: KAL is the Kube-API-Linter and lints Kube like APIs based on API conventions and best practices.
settings:
linters:
enable:
- "commentstart" # Ensure comments start with the serialized version of the field name.
- "conditions" # Ensure conditions have the correct json tags and markers.
- "conflictingmarkers"
- "duplicatemarkers" # Ensure there are no exact duplicate markers. for types and fields.
- "forbiddenmarkers" # Ensure that types and fields do not contain any markers that are forbidden.
- "integers" # Ensure only int32 and int64 are used for integers.
- "jsontags" # Ensure every field has a json tag.
- "maxlength" # Ensure all strings and arrays have maximum lengths/maximum items.
- "nobools" # Bools do not evolve over time, should use enums instead.
- "nodurations" # Prevents usage of `Duration` types.
- "nofloats" # Ensure floats are not used.
- "nomaps" # Ensure maps are not used.
- "nonullable" # Ensure that types and fields do not have the nullable marker.
- "notimestamp" # Prevents usage of 'Timestamp' fields
- "optionalfields" # Ensure that all fields marked as optional adhere to being pointers and
# having the `omitempty` value in their `json` tag where appropriate.
- "optionalorrequired" # Every field should be marked as `+optional` or `+required`.
- "requiredfields" # Required fields should not be pointers, and should not have `omitempty`.
- "ssatags" # Ensure array fields have the appropriate listType markers
- "statusoptional" # Ensure all first children within status should be optional.
- "statussubresource" # All root objects that have a `status` field should have a status subresource.
- "uniquemarkers" # Ensure that types and fields do not contain more than a single definition of a marker that should only be present once.
# Per discussion in July 2024, we are keeping phase fields for now.
# See https://github.com/kubernetes-sigs/cluster-api/pull/10897#discussion_r1685929508
# and https://github.com/kubernetes-sigs/cluster-api/pull/10897#discussion_r1685919394.
# - "nophase" # Phase fields are discouraged by the Kube API conventions, use conditions instead.
# Linters below this line are disabled, pending conversation on how and when to enable them.
disable:
- "*" # We will manually enable new linters after understanding the impact. Disable all by default.
lintersConfig:
conflictingmarkers:
conflicts:
- name: "default_vs_required"
sets:
- ["default", "kubebuilder:default"]
- ["required", "kubebuilder:validation:Required", "k8s:required"]
description: "A field with a default value cannot be required"
forbiddenmarkers:
markers:
# We don't want to do any defaulting (including OpenAPI) anymore on API fields because we prefer
# to have a clear signal on user intent. This also allows us to easily change the default behavior if necessary.
- identifier: "kubebuilder:default"
- identifier: "default"
conditions:
isFirstField: Warn # Require conditions to be the first field in the status struct.
usePatchStrategy: Forbid # Forbid patchStrategy markers on the Conditions field.
useProtobuf: Forbid # We don't use protobuf, so protobuf tags are not required.
optionalfields:
pointers:
preference: WhenRequired # Always | WhenRequired # Whether to always require pointers, or only when required. Defaults to `Always`.
policy: SuggestFix # SuggestFix | Warn # The policy for pointers in optional fields. Defaults to `SuggestFix`.
omitempty:
policy: SuggestFix # SuggestFix | Warn | Ignore # The policy for omitempty in optional fields. Defaults to `SuggestFix`.
exclusions:
generated: strict
paths:
- zz_generated.*\.go$
- ".*_test.go" # Exclude test files.
rules:
## KAL should only run on API folders.
- path-except: "^api//*"
linters:
- kubeapilinter
## Excludes for old apiVersions that can be removed once the apiVersions are dropped (we don't want to make any changes to these APIs).
- path: "api/govmomi/v1beta1|api/supervisor/v1beta1"
linters:
- kubeapilinter
## Excludes for current apiVersions that can be removed once v1beta1 is removed.
# .status.deprecated.v1beta1.conditions fields are using v1beta1.Condition types.
- path: "api/govmomi/v1beta2|api/supervisor/v1beta2"
text: "Conditions field in .*V1Beta1DeprecatedStatus must be a slice of metav1.Condition"
linters:
- kubeapilinter
## Removal of bool fields of existing types requires further discussion
- path: "api/govmomi/v1beta2|api/supervisor/v1beta2"
text: "nobools"
linters:
- kubeapilinter
## Ignore nomaps findings on VSphereMachineVolume.capacity and VSphereMachineTemplate.status.capacity
- path: "api/supervisor/v1beta2/vspheremachine_types.go|api/supervisor/v1beta2/vspheremachinetemplate_types.go"
text: "nomaps: Capacity should not use a map type"
linters:
- kubeapilinter
issues:
max-same-issues: 0
max-issues-per-linter: 0