Skip to content

Commit 28b6469

Browse files
authored
Merge pull request #193 from ldez/fix/doc
docs: fix golangci-lint configuration examples
2 parents d94382a + 3263f85 commit 28b6469

File tree

2 files changed

+63
-56
lines changed

2 files changed

+63
-56
lines changed

README.md

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ go build -o ./bin ./cmd/golangci-lint-kube-api-linter
2121

2222
The binary builds a custom version of `golangci-lint` with Kube API Linter included as a module.
2323
See [Golangci-lint Moduule](#golangci-lint-module) for details on configuration of the module
24-
under `linter-settings`.
24+
under `settings`.
2525

2626
### Golangci-lint Module
2727

@@ -59,53 +59,57 @@ If you wish to only use the Kube API Linter rules, you can configure your `.gola
5959

6060
```yaml
6161
version: "2"
62-
linters-settings:
63-
custom:
64-
kubeapilinter:
65-
type: "module"
66-
description: Kube API Linter lints Kube like APIs based on API conventions and best practices.
67-
settings:
68-
linters: {}
69-
lintersConfig: {}
7062
7163
linters:
72-
disable-all: true
64+
default: none
7365
enable:
7466
- kubeapilinter
7567
76-
# To only run Kube API Linter on specific path
77-
issues:
78-
exclude-rules:
79-
- path-except: "api/*"
80-
linters:
81-
- kubeapilinter
68+
settings:
69+
custom:
70+
kubeapilinter:
71+
type: module
72+
description: Kube API Linter lints Kube like APIs based on API conventions and best practices.
73+
settings:
74+
linters: {}
75+
lintersConfig: {}
76+
77+
# To only run Kube API Linter on specific path
78+
exclusions:
79+
rules:
80+
- linters:
81+
- kubeapilinter
82+
path-except: api/*
83+
8284
```
8385

8486
If you wish to only run selected linters you can do so by specifying the linters you want to enable in the `linters` section:
8587

8688
```yaml
8789
version: "2"
88-
linters-settings:
89-
custom:
90-
kubeapilinter:
91-
type: "module"
92-
settings:
93-
linters:
94-
disable:
95-
- "*"
96-
enable:
97-
- requiredfields
98-
- statusoptional
99-
- statussubresource
90+
10091
linters:
10192
enable:
10293
- kubeapilinter
94+
95+
settings:
96+
custom:
97+
kubeapilinter:
98+
type: "module"
99+
settings:
100+
linters:
101+
disable:
102+
- "*"
103+
enable:
104+
- requiredfields
105+
- statusoptional
106+
- statussubresource
103107
```
104108

105109
The settings for Kube API Linter are based on the [GolangCIConfig][golangci-config-struct] struct and allow for finer control over the linter rules.
106110

107111
If you wish to use the Kube API Linter in conjunction with other linters, you can enable the Kube API Linter in the `.golangci.yml` file by ensuring that `kubeapilinter` is in the `linters.enabled` list.
108-
To provide further configuration, add the `custom.kubeapilinter` section to your `linter-settings` as per the example above.
112+
To provide further configuration, add the `custom.kubeapilinter` section to your `settings` as per the example above.
109113

110114
[golangci-config-struct]: https://pkg.go.dev/sigs.k8s.io/kube-api-linter/pkg/config#GolangCIConfig
111115

@@ -142,18 +146,20 @@ The `golangci-lint` configuration is similar to the module configuration, howeve
142146

143147
```yaml
144148
version: "2"
145-
linters-settings:
146-
custom:
147-
kubeapilinter:
148-
path: "bin/kube-api-linter.so"
149-
description: Kube API Linter lints Kube like APIs based on API conventions and best practices.
150-
original-url: sigs.k8s.io/kube-api-linter
151-
settings:
152-
linters: {}
153-
lintersConfig: {}
149+
154150
linters:
155151
enable:
156152
- kubeapilinter
153+
154+
settings:
155+
custom:
156+
kubeapilinter:
157+
path: "bin/kube-api-linter.so"
158+
description: Kube API Linter lints Kube like APIs based on API conventions and best practices.
159+
original-url: sigs.k8s.io/kube-api-linter
160+
settings:
161+
linters: {}
162+
lintersConfig: {}
157163
```
158164

159165
The rest of the configuration is the same as the module configuration, except the standard `golangci-lint` binary is invoked, rather than a custom binary.

doc.go

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,26 @@ The custom golangci-lint binary can be run with the `run` command, and the Kube
2525
2626
Example `.golangci.yml` configuration file:
2727
28-
linters-settings:
29-
custom:
30-
kubeapilinter::
31-
type: "module"
32-
description: Kube API Linter lints Kube like APIs based on API conventions and best practices.
33-
settings:
34-
linters:
35-
enabled: []
36-
disabled: []
37-
lintersConfig:
38-
jsonTags:
39-
jsonTagRegex: ""
40-
optionalOrRequired:
41-
preferredOptionalMarker: ""
42-
preferredRequiredMarker: ""
4328
linters:
44-
disable-all: true
45-
enable:
46-
- kubeapilinter
29+
default: none
30+
enable:
31+
- kubeapilinter
32+
33+
settings:
34+
custom:
35+
kubeapilinter::
36+
type: "module"
37+
description: Kube API Linter lints Kube like APIs based on API conventions and best practices.
38+
settings:
39+
linters:
40+
enabled: []
41+
disabled: []
42+
lintersConfig:
43+
jsonTags:
44+
jsonTagRegex: ""
45+
optionalOrRequired:
46+
preferredOptionalMarker: ""
47+
preferredRequiredMarker: ""
4748
4849
New linters can be added in the [sigs.k8s.io/kube-api-linter/pkg/analysis] package.
4950
*/

0 commit comments

Comments
 (0)