Skip to content

Commit 845aff1

Browse files
authored
Merge pull request #198 from JoelSpeed/update-nonpointerstructs-docs
Add note to nonpointerstructs that it is not necessary for CRD types
2 parents 1b3775c + c1da8c4 commit 845aff1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

docs/linters.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,10 @@ Non-pointer structs that contain no required fields are marked as optional.
523523
This linter is important for types validated in Go as there is no way to validate the optionality of the fields at runtime,
524524
aside from checking the fields within them.
525525

526+
This linter is NOT intended to be used to check for CRD types.
527+
The advice of this linter may be applied to CRD types, but it is not necessary for CRD types due to optionality being validated by openapi and no native Go code.
528+
For CRD types, the optionalfields and requiredfields linters should be used instead.
529+
526530
If a struct is marked required, this can only be validated by having a required field within it.
527531
If there are no required fields, the struct is implicitly optional and must be marked as so.
528532

pkg/analysis/nonpointerstructs/doc.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ Non-pointer structs that contain no required fields are marked as optional.
2121
This linter is important for types validated in Go as there is no way to validate the optionality of the fields at runtime,
2222
aside from checking the fields within them.
2323
24+
This linter is NOT intended to be used to check for CRD types.
25+
The advice of this linter may be applied to CRD types, but it is not necessary for CRD types due to optionality being validated by openapi and no native Go code.
26+
For CRD types, the optionalfields and requiredfields linters should be used instead.
27+
2428
If a struct is marked required, this can only be validated by having a required field within it.
2529
If there are no required fields, the struct is implicitly optional and must be marked as so.
2630

0 commit comments

Comments
 (0)