Skip to content

Commit 963d989

Browse files
committed
update golangci-lint to v2.5.0
Signed-off-by: dongjiang <[email protected]>
1 parent 8f0c1b1 commit 963d989

File tree

8 files changed

+43
-39
lines changed

8 files changed

+43
-39
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ jobs:
3333
- name: golangci-lint
3434
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # tag=v8.0.0
3535
with:
36-
version: v2.4.0
36+
version: v2.5.0
3737
args: --output.text.print-linter-name=true --output.text.colors=true --timeout 10m
3838
working-directory: ${{matrix.working-directory}}

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ linters:
2424
- goconst
2525
- gocritic
2626
- gocyclo
27+
- godoclint
2728
- goprintffuncname
2829
- govet
2930
- importas
3031
- ineffassign
32+
- iotamixing
3133
- makezero
3234
- misspell
3335
- nakedret

pkg/applyconfiguration/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// Package applyconfigurations generates types for constructing declarative apply configurations.
17+
// Package applyconfiguration generates types for constructing declarative apply configurations.
1818
package applyconfiguration

pkg/crd/known_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16+
1617
package crd
1718

1819
import (

pkg/crd/markers/validation.go

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -164,95 +164,94 @@ func init() {
164164
AllDefinitions = append(AllDefinitions, ValidationIshMarkers...)
165165
}
166166

167-
// +controllertools:marker:generateHelp:category="CRD validation"
168167
// Maximum specifies the maximum numeric value that this field can have.
168+
// +controllertools:marker:generateHelp:category="CRD validation"
169169
type Maximum float64
170170

171171
func (m Maximum) Value() float64 {
172172
return float64(m)
173173
}
174174

175-
// +controllertools:marker:generateHelp:category="CRD validation"
176175
// Minimum specifies the minimum numeric value that this field can have. Negative numbers are supported.
176+
// +controllertools:marker:generateHelp:category="CRD validation"
177177
type Minimum float64
178178

179179
func (m Minimum) Value() float64 {
180180
return float64(m)
181181
}
182182

183-
// +controllertools:marker:generateHelp:category="CRD validation"
184183
// ExclusiveMinimum indicates that the minimum is "up to" but not including that value.
184+
// +controllertools:marker:generateHelp:category="CRD validation"
185185
type ExclusiveMinimum bool
186186

187-
// +controllertools:marker:generateHelp:category="CRD validation"
188187
// ExclusiveMaximum indicates that the maximum is "up to" but not including that value.
188+
// +controllertools:marker:generateHelp:category="CRD validation"
189189
type ExclusiveMaximum bool
190190

191-
// +controllertools:marker:generateHelp:category="CRD validation"
192191
// MultipleOf specifies that this field must have a numeric value that's a multiple of this one.
192+
// +controllertools:marker:generateHelp:category="CRD validation"
193193
type MultipleOf float64
194194

195195
func (m MultipleOf) Value() float64 {
196196
return float64(m)
197197
}
198198

199-
// +controllertools:marker:generateHelp:category="CRD validation"
200199
// MaxLength specifies the maximum length for this string.
200+
// +controllertools:marker:generateHelp:category="CRD validation"
201201
type MaxLength int
202202

203-
// +controllertools:marker:generateHelp:category="CRD validation"
204203
// MinLength specifies the minimum length for this string.
204+
// +controllertools:marker:generateHelp:category="CRD validation"
205205
type MinLength int
206206

207-
// +controllertools:marker:generateHelp:category="CRD validation"
208207
// Pattern specifies that this string must match the given regular expression.
208+
// +controllertools:marker:generateHelp:category="CRD validation"
209209
type Pattern string
210210

211-
// +controllertools:marker:generateHelp:category="CRD validation"
212211
// MaxItems specifies the maximum length for this list.
212+
// +controllertools:marker:generateHelp:category="CRD validation"
213213
type MaxItems int
214214

215-
// +controllertools:marker:generateHelp:category="CRD validation"
216215
// MinItems specifies the minimum length for this list.
216+
// +controllertools:marker:generateHelp:category="CRD validation"
217217
type MinItems int
218218

219-
// +controllertools:marker:generateHelp:category="CRD validation"
220219
// UniqueItems specifies that all items in this list must be unique.
220+
// +controllertools:marker:generateHelp:category="CRD validation"
221221
type UniqueItems bool
222222

223-
// +controllertools:marker:generateHelp:category="CRD validation"
224223
// MaxProperties restricts the number of keys in an object
224+
// +controllertools:marker:generateHelp:category="CRD validation"
225225
type MaxProperties int
226226

227-
// +controllertools:marker:generateHelp:category="CRD validation"
228227
// MinProperties restricts the number of keys in an object
228+
// +controllertools:marker:generateHelp:category="CRD validation"
229229
type MinProperties int
230230

231-
// +controllertools:marker:generateHelp:category="CRD validation"
232231
// Enum specifies that this (scalar) field is restricted to the *exact* values specified here.
232+
// +controllertools:marker:generateHelp:category="CRD validation"
233233
type Enum []interface{}
234234

235-
// +controllertools:marker:generateHelp:category="CRD validation"
236235
// Format specifies additional "complex" formatting for this field.
237236
//
238237
// For example, a date-time field would be marked as "type: string" and
239238
// "format: date-time".
239+
// +controllertools:marker:generateHelp:category="CRD validation"
240240
type Format string
241241

242-
// +controllertools:marker:generateHelp:category="CRD validation"
243242
// Type overrides the type for this field (which defaults to the equivalent of the Go type).
244243
//
245244
// This generally must be paired with custom serialization. For example, the
246245
// metav1.Time field would be marked as "type: string" and "format: date-time".
246+
// +controllertools:marker:generateHelp:category="CRD validation"
247247
type Type string
248248

249-
// +controllertools:marker:generateHelp:category="CRD validation"
250249
// Nullable marks this field as allowing the "null" value.
251250
//
252251
// This is often not necessary, but may be helpful with custom serialization.
252+
// +controllertools:marker:generateHelp:category="CRD validation"
253253
type Nullable struct{}
254254

255-
// +controllertools:marker:generateHelp:category="CRD validation"
256255
// Default sets the default value for this field.
257256
//
258257
// A default value will be accepted as any value valid for the
@@ -261,23 +260,23 @@ type Nullable struct{}
261260
// "delete"}`). Defaults should be defined in pruned form, and only best-effort
262261
// validation will be performed. Full validation of a default requires
263262
// submission of the containing CRD to an apiserver.
263+
// +controllertools:marker:generateHelp:category="CRD validation"
264264
type Default struct {
265265
Value interface{}
266266
}
267267

268-
// +controllertools:marker:generateHelp:category="CRD validation"
269268
// Title sets the title for this field.
270269
//
271270
// The title is metadata that makes the OpenAPI documentation more user-friendly,
272271
// making the schema more understandable when viewed in documentation tools.
273272
// It's a metadata field that doesn't affect validation but provides
274273
// important context about what the schema represents.
274+
// +controllertools:marker:generateHelp:category="CRD validation"
275275
type Title struct {
276276
Value interface{}
277277
}
278278

279-
// +controllertools:marker:generateHelp:category="CRD validation"
280-
// Default sets the default value for this field.
279+
// KubernetesDefault sets the default value for this field.
281280
//
282281
// A default value will be accepted as any value valid for the field.
283282
// Only JSON-formatted values are accepted. `ref(...)` values are ignored.
@@ -286,11 +285,11 @@ type Title struct {
286285
// "delete"}`). Defaults should be defined in pruned form, and only best-effort
287286
// validation will be performed. Full validation of a default requires
288287
// submission of the containing CRD to an apiserver.
288+
// +controllertools:marker:generateHelp:category="CRD validation"
289289
type KubernetesDefault struct {
290290
Value interface{}
291291
}
292292

293-
// +controllertools:marker:generateHelp:category="CRD validation"
294293
// Example sets the example value for this field.
295294
//
296295
// An example value will be accepted as any value valid for the
@@ -299,12 +298,12 @@ type KubernetesDefault struct {
299298
// "delete"}`). Examples should be defined in pruned form, and only best-effort
300299
// validation will be performed. Full validation of an example requires
301300
// submission of the containing CRD to an apiserver.
301+
// +controllertools:marker:generateHelp:category="CRD validation"
302302
type Example struct {
303303
Value interface{}
304304
}
305305

306-
// +controllertools:marker:generateHelp:category="CRD processing"
307-
// PreserveUnknownFields stops the apiserver from pruning fields which are not specified.
306+
// XPreserveUnknownFields stops the apiserver from pruning fields which are not specified.
308307
//
309308
// By default the apiserver drops unknown fields from the request payload
310309
// during the decoding step. This marker stops the API server from doing so.
@@ -316,33 +315,34 @@ type Example struct {
316315
// NB: The kubebuilder:validation:XPreserveUnknownFields variant is deprecated
317316
// in favor of the kubebuilder:pruning:PreserveUnknownFields variant. They function
318317
// identically.
318+
// +controllertools:marker:generateHelp:category="CRD processing"
319319
type XPreserveUnknownFields struct{}
320320

321-
// +controllertools:marker:generateHelp:category="CRD validation"
322-
// EmbeddedResource marks a fields as an embedded resource with apiVersion, kind and metadata fields.
321+
// XEmbeddedResource marks a fields as an embedded resource with apiVersion, kind and metadata fields.
323322
//
324323
// An embedded resource is a value that has apiVersion, kind and metadata fields.
325324
// They are validated implicitly according to the semantics of the currently
326325
// running apiserver. It is not necessary to add any additional schema for these
327326
// field, yet it is possible. This can be combined with PreserveUnknownFields.
327+
// +controllertools:marker:generateHelp:category="CRD validation"
328328
type XEmbeddedResource struct{}
329329

330-
// +controllertools:marker:generateHelp:category="CRD validation"
331-
// IntOrString marks a fields as an IntOrString.
330+
// XIntOrString marks a fields as an IntOrString.
332331
//
333332
// This is required when applying patterns or other validations to an IntOrString
334333
// field. Known information about the type is applied during the collapse phase
335334
// and as such is not normally available during marker application.
335+
// +controllertools:marker:generateHelp:category="CRD validation"
336336
type XIntOrString struct{}
337337

338-
// +controllertools:marker:generateHelp:category="CRD validation"
339338
// Schemaless marks a field as being a schemaless object.
340339
//
341340
// Schemaless objects are not introspected, so you must provide
342341
// any type and validation information yourself. One use for this
343342
// tag is for embedding fields that hold JSONSchema typed objects.
344343
// Because this field disables all type checking, it is recommended
345344
// to be used only as a last resort.
345+
// +controllertools:marker:generateHelp:category="CRD validation"
346346
type Schemaless struct{}
347347

348348
func hasNumericType(schema *apiext.JSONSchemaProps) bool {
@@ -357,12 +357,12 @@ func isIntegral(value float64) bool {
357357
return value == math.Trunc(value) && !math.IsNaN(value) && !math.IsInf(value, 0)
358358
}
359359

360-
// +controllertools:marker:generateHelp:category="CRD validation"
361360
// XValidation marks a field as requiring a value for which a given
362361
// expression evaluates to true.
363362
//
364363
// This marker may be repeated to specify multiple expressions, all of
365364
// which must evaluate to true.
365+
// +controllertools:marker:generateHelp:category="CRD validation"
366366
type XValidation struct {
367367
Rule string
368368
Message string `marker:",optional"`
@@ -372,22 +372,22 @@ type XValidation struct {
372372
OptionalOldSelf *bool `marker:"optionalOldSelf,optional"`
373373
}
374374

375-
// +controllertools:marker:generateHelp:category="CRD validation"
376375
// AtMostOneOf adds a validation constraint that allows at most one of the specified fields.
377376
//
378377
// This marker may be repeated to specify multiple AtMostOneOf constraints that are mutually exclusive.
378+
// +controllertools:marker:generateHelp:category="CRD validation"
379379
type AtMostOneOf []string
380380

381-
// +controllertools:marker:generateHelp:category="CRD validation"
382381
// ExactlyOneOf adds a validation constraint that allows at exactly one of the specified fields.
383382
//
384383
// This marker may be repeated to specify multiple ExactlyOneOf constraints that are mutually exclusive.
384+
// +controllertools:marker:generateHelp:category="CRD validation"
385385
type ExactlyOneOf []string
386386

387-
// +controllertools:marker:generateHelp:category="CRD validation"
388387
// AtLeastOneOf adds a validation constraint that allows at least one of the specified fields.
389388
//
390389
// This marker may be repeated to specify multiple AtLeastOneOf constraints that are mutually exclusive.
390+
// +controllertools:marker:generateHelp:category="CRD validation"
391391
type AtLeastOneOf []string
392392

393393
func (m Maximum) ApplyToSchema(schema *apiext.JSONSchemaProps) error {
@@ -561,7 +561,7 @@ func (m Nullable) ApplyToSchema(schema *apiext.JSONSchemaProps) error {
561561
return nil
562562
}
563563

564-
// Defaults are only valid CRDs created with the v1 API
564+
// ApplyToSchema defaults are only valid CRDs created with the v1 API
565565
func (m Default) ApplyToSchema(schema *apiext.JSONSchemaProps) error {
566566
marshalledDefault, err := json.Marshal(m.Value)
567567
if err != nil {
@@ -601,7 +601,7 @@ func (m *KubernetesDefault) ParseMarker(_ string, _ string, restFields string) e
601601
return json.Unmarshal([]byte(restFields), &m.Value)
602602
}
603603

604-
// Defaults are only valid CRDs created with the v1 API
604+
// ApplyToSchema defaults are only valid CRDs created with the v1 API
605605
func (m KubernetesDefault) ApplyToSchema(schema *apiext.JSONSchemaProps) error {
606606
if m.Value == nil {
607607
// only apply to the schema if we have a non-nil default value

pkg/crd/spec.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16+
1617
package crd
1718

1819
import (

pkg/deepcopy/traverse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (c *codeWriter) If(setup string, block func()) {
6161
c.Line("}")
6262
}
6363

64-
// If writes if and else statements with the given setup/condition clause, executing
64+
// IfElse writes if and else statements with the given setup/condition clause, executing
6565
// the given functions to write the contents of the blocks.
6666
func (c *codeWriter) IfElse(setup string, ifBlock func(), elseBlock func()) {
6767
c.Linef("if %s {", setup)

pkg/markers/parse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ type RawArguments []byte
8080
type ArgumentType int
8181

8282
const (
83-
// Invalid represents a type that can't be parsed, and should never be used.
83+
// InvalidType represents a type that can't be parsed, and should never be used.
8484
InvalidType ArgumentType = iota
8585
// IntType is an int
8686
IntType

0 commit comments

Comments
 (0)