Skip to content

Commit 94616c0

Browse files
committed
docs: update linters documentation to include conflictingmarkers linter details
1 parent 085e0f9 commit 94616c0

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

docs/linters.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- [Conditions](#conditions) - Checks that `Conditions` fields are correctly formatted
44
- [CommentStart](#commentstart) - Ensures comments start with the serialized form of the type
5+
- [ConflictingMarkers](#conflictingmarkers) - Detects mutually exclusive markers on the same field
56
- [DuplicateMarkers](#duplicatemarkers) - Checks for exact duplicates of markers
67
- [Integers](#integers) - Validates usage of supported integer types
78
- [JSONTags](#jsontags) - Ensures proper JSON tag formatting
@@ -73,6 +74,42 @@ The `commentstart` linter can automatically fix comments that do not start with
7374

7475
When the `json` tag is present, and matches the first word of the field comment in all but casing, the linter will suggest that the comment be updated to match the `json` tag.
7576

77+
## ConflictingMarkers
78+
79+
The `conflictingmarkers` linter detects and reports when mutually exclusive markers are used on the same field.
80+
This prevents common configuration errors and unexpected behavior in Kubernetes API types.
81+
82+
The linter includes built-in checks for the following conflicts:
83+
84+
1. **Optional vs Required**:
85+
- Set A: `+optional`, `+kubebuilder:validation:Optional`, `+k8s:optional`
86+
- Set B: `+required`, `+kubebuilder:validation:Required`, `+k8s:required`
87+
- A field cannot be both optional and required
88+
89+
2. **Default vs Required**:
90+
- Set A: `+default`, `+kubebuilder:default`
91+
- Set B: `+required`, `+kubebuilder:validation:Required`
92+
- A field with a default value cannot be required
93+
94+
### Configuration
95+
96+
The linter is configurable and allows users to define their own custom sets of conflicting markers.
97+
Each custom conflict set must specify a name, two sets of markers, and a description of why they conflict.
98+
99+
```yaml
100+
lintersConfig:
101+
conflictingmarkers:
102+
customConflicts:
103+
- name: "my_custom_conflict"
104+
setA:
105+
- "custom:marker1"
106+
- "custom:marker2"
107+
setB:
108+
- "custom:marker3"
109+
- "custom:marker4"
110+
description: "These markers conflict because..."
111+
```
112+
76113
## DuplicateMarkers
77114

78115
The duplicatemarkers linter checks for exact duplicates of markers for types and fields.

0 commit comments

Comments
 (0)