-
Notifications
You must be signed in to change notification settings - Fork 21
📖 Update README.md - With instructions for GolangCI 2x #109
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
base: main
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: camilamacedo86 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
| ##### Enabling Specific Linters (Valid for Versions < 2.x) | ||
|
|
||
| > **Note**: The following configuration is only supported when using the **module integration** via `.custom-gcl.yml` and is **not valid in plugin mode** (`.so` files with `golangci-lint` v2.x+). |
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.
This isn't true, you can do exactly the same configuration between both versions
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.
I tried it, but it did not work out.
Now, with your message, I found: https://github.com/golangci/golangci-lint/blob/main/.custom-gcl.reference.yml
It might changed the format. I will try out after.
Thanks!
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.
I was trying but I could not make work yet see: kubernetes-sigs/kubebuilder#4941
(I will spend more effort on it later, but if you'd like, take a look. (Not sure what I am missing)
| linters-settings: | ||
| custom: | ||
| kubeapilinter: | ||
| path: "bin/kube-api-linter.so" | ||
| description: Kube API LInter lints Kube like APIs based on API conventions and best practices. | ||
| original-url: sigs.k8s.io/kube-api-linter | ||
| settings: | ||
| linters: {} | ||
| lintersConfig: {} |
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.
Looking at the diff above, it seems we just need to update this section slightly, and the rest remains true and the same?
| exclusions: | ||
| rules: | ||
| # Only run kubeapilinter inside the 'api/' directory | ||
| # Prevents running API-specific checks on unrelated packages like controllers or tests | ||
| - path-except: "^api/" | ||
| linters: | ||
| - kubeapilinter |
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.
Is the formatting off for the exclusions stanza here? It looks like it needs to be linters.exclusions when I was looking at integrating this linter in my repository that uses the 2.x golangci-lint version.
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.
Looks to me like this aligns with Cluster API which is also using golangci-lint version 2
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.
Right, that's what we have as well. In this example, the linters and exclusions fields are on the same level though. I think you'd have to indent the exclusions field once so it's nested under the linters field.
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.
Oh I get your point, yes, you're correct, this whole block from exclusions down needs indenting 2 spaces
|
|
||
| ```yaml | ||
| version: v1.64.8 | ||
| version: v1.64.8 # GolangCi version |
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.
fwiw, I had to update this value to v2.5.0 today, and along with prefixing with version: "2", that was I needed to get the current default configuration to work.
☸ kind-kind in ~
❯ cat .golangci.yml
version: "2"
linters:
disable-all: true
enable:
- kubeapilinter
settings:
custom:
kubeapilinter:
type: "module"
description: Kube API LInter lints Kube like APIs based on API conventions and best practices.
settings:
linters: {}
lintersConfig: {}
☸ kind-kind in ~
❯ cat .custom-gcl.yml
version: v2.5.0
name: golangci-kube-api-linter
destination: ./bin
plugins:
- module: 'sigs.k8s.io/kube-api-linter'
version: 'main' # Replace with the latest version
No description provided.