-
Notifications
You must be signed in to change notification settings - Fork 40.9k
golangci plugin for sorting feature gates #132438
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
golangci plugin for sorting feature gates #132438
Conversation
b16f761
to
2c847d2
Compare
/area code-organization |
/priority important-soon This is a good time to add this as we just had the enhancement freeze and we have about 30+ days before code freeze. |
1bd4fde
to
6dfdc9d
Compare
/retest |
6dfdc9d
to
dc1015e
Compare
@pohly here's the output after i unsorted a few things in pkg/features/features.go
|
@pohly please see output above. I think it is good enough to land now so i have removed the WIP. thanks! |
/triage accepted |
dc1015e
to
fd9b598
Compare
/retest |
Signed-off-by: Davanum Srinivas <[email protected]>
7211621
to
4e47e2c
Compare
Signed-off-by: Davanum Srinivas <[email protected]>
4e47e2c
to
d50e1a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
|
||
## How It Works | ||
|
||
The linter analyzes const and var blocks in specified files, extracts feature declarations, and checks if they are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO (later): document support for maps.
@@ -0,0 +1,137 @@ | |||
# SortedFeatures Linter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO (later): remove the "feature" part of the linter and turn it into a generic "sorted" linter:
- rename to "sorted"
- remove all references to "feature" from the doc and code
} | ||
|
||
// Report the issue with the diff | ||
pass.Reportf(decl.Pos(), "not sorted alphabetically:\n%s\n", stripHeader(diffText, 3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO (later): "not sorted alphabetically (-got, +want):"
Example:
ERROR: test/e2e/feature/feature.go:27:1: not sorted alphabetically:
ERROR: var (
ERROR: + // TODO: document the feature (owning SIG, when to use this feature for a test)
ERROR: + APIServerIdentity = value
ERROR: +
ERROR: // Owner: sig-lifecycle
ERROR: // This label is used for tests which need the following controllers to be enabled:
ERROR: // - bootstrap-signer-controller
ERROR: @@ -6,62 +9,11 @@
ERROR: BootstrapTokens = value
ERROR:
ERROR: // TODO: document the feature (owning SIG, when to use this feature for a test)
ERROR: - APIServerIdentity = value
ERROR: -
ERROR: - // TODO: document the feature (owning SIG, when to use this feature for a test)
ERROR: BoundServiceAccountTokenVolume = value
ERROR:
ERROR: // Owner: sig-api-machinery
ERROR: // Marks tests that exercise the CBOR data format for serving or storage.
ERROR: CBOR = value
LGTM label has been added. Git tree hash: ef7b67b9237f9df0bff5032cfdc409799174fbcb
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dims, pohly The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
1 similar comment
/retest |
We have a bunch of files where we want the
var
orconst
block with a bunch of variables/constants that need to be in the correct order for longer term maintainability.In this PR, we are adding a golangci based linter in the following files:
There is an additional commit that sorts all the above files as well to ensure a clean run of the linter for posterity.
What type of PR is this?
xref: #130779
/kind cleanup
What this PR does / why we need it:
Which issue(s) this PR is related to:
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: