Skip to content

Commit b85a8d2

Browse files
committed
enable optionalorrequired linter
Signed-off-by: sivchari <shibuuuu5@gmail.com>
1 parent d23093a commit b85a8d2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

.golangci-kal.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ linters-settings:
1818
enable:
1919
- "conditions" # Ensure conditions have the correct json tags and markers.
2020
- "integers" # Ensure only int32 and int64 are used for integers.
21+
- "optionalorrequired" # Every field should be marked as `+optional` or `+required`.
2122

2223
# Per discussion in July 2024, we are keeping phase fields for now.
2324
# See https://github.com/kubernetes-sigs/cluster-api/pull/10897#discussion_r1685929508
@@ -29,7 +30,6 @@ linters-settings:
2930
# - "jsontags" # Ensure every field has a json tag.
3031
# - "maxlength" # Ensure all strings and arrays have maximum lengths/maximum items.
3132
# - "nobools" # Bools do not evolve over time, should use enums instead.
32-
# - "optionalorrequired" # Every field should be marked as `+optional` or `+required`.
3333
# - "requiredfields" # Required fields should not be pointers, and should not have `omitempty`.
3434
# - "statussubresource" # All root objects that have a `status` field should have a status subresource.
3535
disable:
@@ -41,9 +41,6 @@ linters-settings:
4141
useProtobuf: Forbid # We don't use protobuf, so protobuf tags are not required.
4242
# jsonTags:
4343
# jsonTagRegex: "^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case.
44-
# optionalOrRequired:
45-
# preferredOptionalMarker: optional | kubebuilder:validation:Optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`.
46-
# preferredRequiredMarker: required | kubebuilder:validation:Required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`.
4744
# requiredFields:
4845
# pointerPolicy: Warn | SuggestFix # Defaults to `SuggestFix`. We want our required fields to not be pointers.
4946

@@ -58,7 +55,7 @@ issues:
5855
max-issues-per-linter: 0
5956
exclude-rules:
6057
# KAL should only run on API folders.
61-
- path-except: "api/*"
58+
- path-except: "api//*"
6259
linters:
6360
- kal
6461
- path: "api/v1beta1/*|api/v1alpha1/*"
@@ -73,3 +70,7 @@ issues:
7370
text: "field Prefix should not use an int, int8 or int16. Use int32 or int64 depending on bounding requirements"
7471
linters:
7572
- kal
73+
- path: "api/v1alpha1/*|api/v1alpha3/*|api/v1beta1/*"
74+
text: "optionalorrequired"
75+
linters:
76+
- kal

0 commit comments

Comments
 (0)