|
2 | 2 |
|
3 | 3 | - [Conditions](#conditions) - Checks that `Conditions` fields are correctly formatted
|
4 | 4 | - [CommentStart](#commentstart) - Ensures comments start with the serialized form of the type
|
| 5 | +- [ConflictingMarkers](#conflictingmarkers) - Detects mutually exclusive markers on the same field |
5 | 6 | - [DuplicateMarkers](#duplicatemarkers) - Checks for exact duplicates of markers
|
6 | 7 | - [Integers](#integers) - Validates usage of supported integer types
|
7 | 8 | - [JSONTags](#jsontags) - Ensures proper JSON tag formatting
|
@@ -74,6 +75,49 @@ The `commentstart` linter can automatically fix comments that do not start with
|
74 | 75 |
|
75 | 76 | 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.
|
76 | 77 |
|
| 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 | + |
77 | 121 | ## DuplicateMarkers
|
78 | 122 |
|
79 | 123 | The duplicatemarkers linter checks for exact duplicates of markers for types and fields.
|
@@ -378,6 +422,12 @@ lintersConfig:
|
378 | 422 | - ["default", "+kubebuilder:default"]
|
379 | 423 | - ["required", "+kubebuilder:validation:Required", "+k8s:validation:required"]
|
380 | 424 | 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" |
381 | 431 | - name: "mutually_exclusive_validation"
|
382 | 432 | sets:
|
383 | 433 | - ["optional", "+kubebuilder:validation:Optional"]
|
|
0 commit comments