Skip to content

Commit 994e70e

Browse files
committed
docs: update linters documentation to include conflictingmarkers linter details
1 parent a472e92 commit 994e70e

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

docs/linters.md

Lines changed: 55 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,60 @@ 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 reports issues when markers from both sets of a conflict pair are present on the same field.
83+
It does NOT report issues when multiple markers from the same set are present - only when markers from
84+
different sets within the same conflict definition are found together.
85+
86+
The linter is configurable and allows users to define sets of conflicting markers.
87+
Each conflict set must specify:
88+
- A unique name for the conflict
89+
- Two sets of markers that are mutually exclusive
90+
- A description explaining why the markers conflict
91+
92+
### Configuration
93+
94+
```yaml
95+
lintersConfig:
96+
conflictingmarkers:
97+
conflicts:
98+
- name: "optional_vs_required"
99+
setA:
100+
- "optional"
101+
- "+kubebuilder:validation:Optional"
102+
- "+k8s:validation:optional"
103+
setB:
104+
- "required"
105+
- "+kubebuilder:validation:Required"
106+
- "+k8s:validation:required"
107+
description: "A field cannot be both optional and required"
108+
- name: "default_vs_required"
109+
setA:
110+
- "default"
111+
- "+kubebuilder:default"
112+
setB:
113+
- "required"
114+
- "+kubebuilder:validation:Required"
115+
- "+k8s:validation:required"
116+
description: "A field with a default value cannot be required"
117+
- name: "my_custom_conflict"
118+
setA:
119+
- "custom:marker1"
120+
- "custom:marker2"
121+
setB:
122+
- "custom:marker3"
123+
- "custom:marker4"
124+
description: "These markers conflict because..."
125+
```
126+
127+
**Note**: This linter is not enabled by default and must be explicitly enabled in the configuration.
128+
129+
The linter does not provide automatic fixes as it cannot determine which conflicting marker should be removed.
130+
76131
## DuplicateMarkers
77132

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

0 commit comments

Comments
 (0)