Skip to content

Commit 6448538

Browse files
committed
docs: update linters documentation to include conflictingmarkers linter details
1 parent e954fbf commit 6448538

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

docs/linters.md

Lines changed: 50 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
@@ -74,6 +75,49 @@ The `commentstart` linter can automatically fix comments that do not start with
7475

7576
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.
7677

78+
## ConflictingMarkers
79+
80+
The `conflictingmarkers` linter detects and reports when mutually exclusive markers are used on the same field.
81+
This prevents common configuration errors and unexpected behavior in Kubernetes API types.
82+
83+
The linter reports issues when markers from two or more sets of a conflict definition are present on the same field.
84+
It does NOT report issues when multiple markers from the same set are present - only when markers from
85+
different sets within the same conflict definition are found together.
86+
87+
The linter is configurable and allows users to define sets of conflicting markers.
88+
Each conflict set must specify:
89+
- A unique name for the conflict
90+
- Multiple sets of markers that are mutually exclusive with each other (at least 2 sets)
91+
- A description explaining why the markers conflict
92+
93+
### Configuration
94+
95+
```yaml
96+
lintersConfig:
97+
conflictingmarkers:
98+
conflicts:
99+
- name: "optional_vs_required"
100+
sets:
101+
- ["optional", "+kubebuilder:validation:Optional", "+k8s:validation:optional"]
102+
- ["required", "+kubebuilder:validation:Required", "+k8s:validation:required"]
103+
description: "A field cannot be both optional and required"
104+
- name: "default_vs_required"
105+
sets:
106+
- ["default", "+kubebuilder:default"]
107+
- ["required", "+kubebuilder:validation:Required", "+k8s:validation:required"]
108+
description: "A field with a default value cannot be required"
109+
- name: "three_way_conflict"
110+
sets:
111+
- ["marker5", "marker6"]
112+
- ["marker7", "marker8"]
113+
- ["marker9", "marker10"]
114+
description: "Three-way conflict between marker sets"
115+
```
116+
117+
**Note**: This linter is not enabled by default and must be explicitly enabled in the configuration.
118+
119+
The linter does not provide automatic fixes as it cannot determine which conflicting marker should be removed.
120+
77121
## DuplicateMarkers
78122

79123
The duplicatemarkers linter checks for exact duplicates of markers for types and fields.
@@ -378,6 +422,12 @@ lintersConfig:
378422
- ["default", "+kubebuilder:default"]
379423
- ["required", "+kubebuilder:validation:Required", "+k8s:validation:required"]
380424
description: "A field with a default value cannot be required"
425+
- name: "three_way_conflict"
426+
sets:
427+
- ["marker5", "marker6"]
428+
- ["marker7", "marker8"]
429+
- ["marker9", "marker10"]
430+
description: "Three-way conflict between marker sets"
381431
- name: "mutually_exclusive_validation"
382432
sets:
383433
- ["optional", "+kubebuilder:validation:Optional"]

0 commit comments

Comments
 (0)