forked from kubernetes-sigs/jobset
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path.golangci-kal.yml
More file actions
214 lines (194 loc) · 8.7 KB
/
Copy path.golangci-kal.yml
File metadata and controls
214 lines (194 loc) · 8.7 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
version: "2"
run:
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" # Detects mutually exclusive markers on the same field
- "duplicatemarkers" # Ensure there are no exact duplicate markers. for types and fields.
- "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.
- "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"
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
rules:
## KAL should only run on API folders.
- path-except: "api/jobset/*"
linters:
- kubeapilinter
## Exclusions for existing API fields that intentionally violate conventions
## These are grandfathered in to maintain API compatibility
# JobSetSpec.ReplicatedJobs - all violations for this field
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "field JobSetSpec\\.ReplicatedJobs"
linters:
- kubeapilinter
# JobSetSpec policy fields - all violations
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "field JobSetSpec\\.(SuccessPolicy|FailurePolicy|StartupPolicy)"
linters:
- kubeapilinter
# JobSetSpec.ManagedBy - all violations
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "field JobSetSpec\\.ManagedBy"
linters:
- kubeapilinter
# JobSetStatus.Conditions - all violations
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "field JobSetStatus\\.Conditions"
linters:
- kubeapilinter
# JobSetStatus fields - all violations
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "field JobSetStatus\\.(Restarts|RestartsCountTowardsMax|TerminalState|ReplicatedJobsStatus)"
linters:
- kubeapilinter
# ReplicatedJobStatus fields - all violations
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "type ReplicatedJobStatus"
linters:
- kubeapilinter
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "field ReplicatedJobStatus\\.(Name|Ready|Succeeded|Failed|Active|Suspended)"
linters:
- kubeapilinter
# JobSet embedded metav1 types - all violations
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "field (ObjectMeta|Spec|Status)"
linters:
- kubeapilinter
# JobSet.Spec and JobSet.Status - specific field violations
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "field JobSet\\.(Spec|Status)"
linters:
- kubeapilinter
# ReplicatedJob fields - all violations
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "type ReplicatedJob"
linters:
- kubeapilinter
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "field ReplicatedJob\\.(Name|GroupName|Template|Replicas)"
linters:
- kubeapilinter
# DependsOn fields - all violations
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "type DependsOn"
linters:
- kubeapilinter
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "field DependsOn\\.(Name|Status)"
linters:
- kubeapilinter
# Network.Subdomain - all violations
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "field Network\\.Subdomain"
linters:
- kubeapilinter
# FailurePolicyRule fields - all violations
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "type FailurePolicyRule"
linters:
- kubeapilinter
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "field FailurePolicyRule\\.(Name|Action|OnJobFailureReasons|OnJobFailureMessagePatterns|TargetReplicatedJobs)"
linters:
- kubeapilinter
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "(OnJobFailureReasons|OnJobFailureMessagePatterns) should have a listType marker"
linters:
- kubeapilinter
# FailurePolicy fields - all violations
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "type FailurePolicy"
linters:
- kubeapilinter
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "field FailurePolicy\\.(MaxRestarts|RestartStrategy|Rules)"
linters:
- kubeapilinter
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "Rules should have a listType marker"
linters:
- kubeapilinter
# SuccessPolicy fields - all violations
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "type SuccessPolicy"
linters:
- kubeapilinter
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "field SuccessPolicy\\.(Operator|TargetReplicatedJobs)"
linters:
- kubeapilinter
# StartupPolicy fields - all violations
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "type StartupPolicy"
linters:
- kubeapilinter
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "field StartupPolicy\\.StartupPolicyOrder"
linters:
- kubeapilinter
# Coordinator fields - all violations
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "type Coordinator"
linters:
- kubeapilinter
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "field Coordinator\\.(ReplicatedJob|JobIndex|PodIndex)"
linters:
- kubeapilinter
# Embedded metav1.ObjectMeta - handle both embedded field and regular field violations
- path: "api/jobset/v1alpha2/jobset_types.go"
text: "embedded field"
linters:
- kubeapilinter
issues:
max-same-issues: 0