|
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
|
@@ -73,6 +74,42 @@ The `commentstart` linter can automatically fix comments that do not start with
|
73 | 74 |
|
74 | 75 | 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.
|
75 | 76 |
|
| 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 | + |
76 | 113 | ## DuplicateMarkers
|
77 | 114 |
|
78 | 115 | The duplicatemarkers linter checks for exact duplicates of markers for types and fields.
|
|
0 commit comments