You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .golangci.yml
+79-6Lines changed: 79 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,7 @@ linters:
23
23
- govet
24
24
- importas
25
25
- ineffassign
26
+
- kubeapilinter
26
27
- lll
27
28
- misspell
28
29
- nolintlint
@@ -74,8 +75,55 @@ linters:
74
75
- github.com/onsi/gomega
75
76
testifylint:
76
77
enable-all: true
78
+
custom:
79
+
kubeapilinter:
80
+
type: module
81
+
description: KAL is the Kube-API-Linter and lints Kube like APIs based on API conventions and best practices.
82
+
settings:
83
+
linters:
84
+
enable:
85
+
# - "commentstart" # Ensure comments start with the serialized version of the field name.
86
+
# - "conditions" # Ensure conditions have the correct json tags and markers.
87
+
- "duplicatemarkers"# Ensure there are no exact duplicate markers. for types and fields.
88
+
- "integers"# Ensure only int32 and int64 are used for integers.
89
+
- "jsontags"# Ensure every field has a json tag.
90
+
- "maxlength"# Ensure all strings and arrays have maximum lengths/maximum items.
91
+
- "nobools"# Bools do not evolve over time, should use enums instead.
92
+
- "nofloats"# Ensure floats are not used.
93
+
# - "nomaps" # Ensure maps are not used.
94
+
# - "nophase" # Ensure phases are not used, as they are not extensible.
95
+
- "optionalfields"# Ensure that all fields marked as optional adhere to being pointers and
96
+
# having the `omitempty` value in their `json` tag where appropriate.
97
+
- "optionalorrequired"# Every field should be marked as `+optional` or `+required`.
98
+
- "requiredfields"# Required fields should not be pointers, and should not have `omitempty`.
99
+
# - "ssatags" # Ensure array fields have the appropriate listType markers
100
+
# - "statusoptional" # Ensure all first children within status should be optional.
101
+
# - "statussubresource" # All root objects that have a `status` field should have a status subresource.
102
+
- "uniquemarkers"# Ensure that types and fields do not contain more than a single definition of a marker that should only be present once.
103
+
104
+
# Linters below this line are disabled, pending conversation on how and when to enable them.
105
+
disable:
106
+
- "*"# We will manually enable new linters after understanding the impact. Disable all by default.
107
+
lintersConfig:
108
+
optionalfields:
109
+
pointers:
110
+
preference: WhenRequired # Always | WhenRequired # Whether to always require pointers, or only when required. Defaults to `Always`.
111
+
jsontags:
112
+
jsonTagRegex: "^[a-z][a-z0-9-]*(?:[A-Z][a-z0-9]*)*$"# The default regex is appropriate for our use case.
113
+
optionalorrequired:
114
+
preferredOptionalMarker: kubebuilder:validation:Optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`.
115
+
preferredRequiredMarker: kubebuilder:validation:Required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`.
77
116
exclusions:
78
-
generated: lax
117
+
generated: strict
118
+
paths:
119
+
# Ignore generated files.
120
+
- zz_generated.*\.go$
121
+
# Ignore external API packages.
122
+
- external/
123
+
# Ignore test files.
124
+
- '.+_test\.go$'
125
+
# Ignore aggregate types.
126
+
- 'aggregate_types\.go$'
79
127
presets:
80
128
- comments
81
129
- common-false-positives
@@ -103,11 +151,36 @@ linters:
103
151
- gocritic
104
152
path: internal/test/envtest
105
153
text: 'hugeParam: input is heavy'
106
-
paths:
107
-
- external
108
-
- third_party$
109
-
- builtin$
110
-
- examples$
154
+
155
+
# START kube-api-linter rules
156
+
- path: ".*"
157
+
text: "optionalorrequired: embedded field must be marked as kubebuilder:validation:Optional or kubebuilder:validation:Required"
158
+
linters:
159
+
- kubeapilinter
160
+
161
+
# kube-api-linter does not handle formats correctly yet.
162
+
- path: '/addon_types\.go$'
163
+
text: "maxlength: field (Start|End) must have a maximum length, add kubebuilder:validation:MaxLength marker"
164
+
linters:
165
+
- kubeapilinter
166
+
- path: '/common_types\.go$'
167
+
text: "maxlength: field Address must have a maximum length, add kubebuilder:validation:MaxLength marker"
168
+
linters:
169
+
- kubeapilinter
170
+
171
+
# kube-api-linter does not handle patterns correctly yet.
172
+
- path: '/aws_(clusterconfig|node)_types\.go$'
173
+
text: "maxlength: field (ID|IAMInstanceProfile|InstanceType|Org) must have a maximum length, add kubebuilder:validation:MaxLength marker"
174
+
linters:
175
+
- kubeapilinter
176
+
- path: '/(nutanix_)?(clusterconfig)_types\.go$'
177
+
text: "maxlength: field (URL|Tag) must have a maximum length, add kubebuilder:validation:MaxLength marker"
Copy file name to clipboardExpand all lines: api/v1alpha1/addon_types.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -284,7 +284,7 @@ type StorageClassConfig struct {
284
284
285
285
// If the storage class should allow volume expanding
286
286
// +kubebuilder:validation:Optional
287
-
AllowExpansionbool`json:"allowExpansion,omitempty"`//nolint:kubeapilinter,lll // Leave as bool for backward compatibility and this comment makes it a long line.
0 commit comments