-
Notifications
You must be signed in to change notification settings - Fork 1.4k
🌱 Add KAL linter for linting API conventions #11733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
run: | ||
timeout: 10m | ||
go: "1.23" | ||
allow-parallel-runners: true | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- kal # linter for Kube API conventions | ||
|
||
linters-settings: | ||
custom: | ||
kal: | ||
type: "module" | ||
description: KAL is the Kube-API-Linter and lints Kube like APIs based on API conventions and best practices. | ||
settings: | ||
linters: | ||
enable: | ||
# Per discussion in July 2024, we are keeping phase fields for now. | ||
# See https://github.com/kubernetes-sigs/cluster-api/pull/10897#discussion_r1685929508 | ||
# and https://github.com/kubernetes-sigs/cluster-api/pull/10897#discussion_r1685919394. | ||
# - "nophase" # Phase fields are discouraged by the Kube API conventions, use conditions instead. | ||
|
||
# Linters below this line are disabled, pending conversation on how and when to enable them. | ||
# - "conditions" # Ensure conditions have the correct json tags and markers. | ||
# - "commentstart" # Ensure comments start with the serialized version of the field name. | ||
# - "integers" # Ensure only int32 and int64 are used for integers. | ||
# - "jsontags" # Ensure every field has a json tag. | ||
# - "maxlength" # Ensure all strings and arrays have maximum lengths/maximum items. | ||
# - "nobools" # Bools do not evolve over time, should use enums instead. | ||
# - "optionalorrequired" # Every field should be marked as `+optional` or `+required`. | ||
# - "requiredfields" # Required fields should not be pointers, and should not have `omitempty`. | ||
# - "statussubresource" # All root objects that have a `status` field should have a status subresource. | ||
disable: | ||
- "*" # We will manually enable new linters after understanding the impact. Disable all by default. | ||
lintersConfig: | ||
conditions: | ||
isFirstField: Warn # Require conditions to be the first field in the status struct. | ||
sbueringer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
usePatchStrategy: Forbid # Conditions should not use the patch strategy on CRDs. | ||
useProtobuf: Forbid # We don't use protobuf, so protobuf tags are not required. | ||
# jsonTags: | ||
# jsonTagRegex: "^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case. | ||
# optionalOrRequired: | ||
# preferredOptionalMarker: optional | kubebuilder:validation:Optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`. | ||
JoelSpeed marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# preferredRequiredMarker: required | kubebuilder:validation:Required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`. | ||
# requiredFields: | ||
# pointerPolicy: Warn | SuggestFix # Defaults to `SuggestFix`. We want our required fields to not be pointers. | ||
|
||
issues: | ||
exclude-files: | ||
- "zz_generated.*\\.go$" | ||
- "vendored_openapi\\.go$" | ||
# We don't want to invest time to fix new linter findings in old API types. | ||
- "internal/apis/.*" | ||
JoelSpeed marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- ".*_test.go" # Exclude test files. | ||
max-same-issues: 0 | ||
max-issues-per-linter: 0 | ||
exclude-rules: | ||
# KAL should only run on API folders. | ||
- path-except: "api/*" | ||
linters: | ||
- kal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: v1.63.4 | ||
name: golangci-lint-kal-v1.63.4 | ||
destination: ./bin | ||
plugins: | ||
- module: 'github.com/JoelSpeed/kal' | ||
JoelSpeed marked this conversation as resolved.
Show resolved
Hide resolved
|
||
version: v0.0.0-20250208110507-b94e5ede1177 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.