Skip to content

Commit a72091c

Browse files
committed
Remove standalone binary and update readme
1 parent 530c2fa commit a72091c

File tree

12 files changed

+54
-1157
lines changed

12 files changed

+54
-1157
lines changed

.custom-gcl.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
version: v1.62.0
2-
name: golangci-kal
2+
name: golangci-kube-api-linter
33
destination: ./bin
44
plugins:
55
- module: 'sigs.k8s.io/kube-api-linter'

.github/workflows/go.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,5 @@ jobs:
2020
run: make verify-vendor
2121
- name: Build
2222
run: make build
23-
- name: Build GolangCI-Lint
24-
run: make build-golangci
2523
- name: Test
2624
run: make test

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,7 @@ unit: ## Run unit tests.
5757
##@ Build
5858

5959
.PHONY: build
60-
build: fmt vet ## Build KAL binary.
61-
go build -o bin/kal ./cmd/kal
62-
63-
.PHONY: build-golangci
64-
build-golangci: ## Run golangci-lint over the codebase.
60+
build: ## Build the golangci-lint custom plugin binary.
6561
${GOLANGCI_LINT} custom
6662

6763
.PHONY: verify-%

README.md

Lines changed: 32 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,16 @@
1-
# KAL - The Kubernetes API Linter
1+
# Kube API Linter
22

3-
KAL is a Golang based linter for Kubernetes API types. It checks for common mistakes and enforces best practices.
4-
The rules implemented by KAL, are based on the [Kubernetes API Conventions][api-conventions].
3+
Kube API Linter (KAL) is a Golang based linter for Kubernetes API types.
4+
It checks for common mistakes and enforces best practices.
5+
The rules implemented by the Kube API Linter, are based on the [Kubernetes API Conventions][api-conventions].
56

6-
KAL is aimed at being an assistant to API review, by catching the mechanical elements of API review, and allowing reviewers to focus on the more complex aspects of API design.
7+
Kube API Linter is aimed at being an assistant to API review, by catching the mechanical elements of API review, and allowing reviewers to focus on the more complex aspects of API design.
78

89
[api-conventions]: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md
910

1011
## Installation
1112

12-
KAL currently comes in two flavours, a standalone binary, and a golangci-lint plugin.
13-
14-
### Standalone Binary
15-
16-
To install the standalone binary, run the following command:
17-
18-
```shell
19-
go install sigs.k8s.io/kube-api-linter/cmd/kal@latest
20-
```
21-
22-
The standalone binary can be run with the following command:
23-
24-
```shell
25-
kal path/to/api/types
26-
```
27-
28-
`kal` currently accepts no complex configuration, and will run all checks considered to be default.
29-
30-
Individual linters can be disabled with the flag corresponding to the linter name. For example, to disable the `commentstart` linter, run the following command:
31-
32-
```shell
33-
kal -commentstart=false path/to/api/types
34-
```
35-
36-
Where fixes are available, these can be applied automatically with the `-fix` flag.
37-
Note, automatic fixing is currently only available via the standalone binary, and is not available via the `golangci-lint` plugin.
38-
39-
```shell
40-
kal -fix path/to/api/types
41-
```
42-
43-
Other standard Golang linter flags implemented by [multichecker][multichecker] based linters are also supported.
44-
45-
[multichecker]: https://pkg.go.dev/golang.org/x/tools/go/analysis/multichecker
13+
Kube API Linter ships as a golangci-lint plugin.
4614

4715
### Golangci-lint Plugin
4816

@@ -55,7 +23,7 @@ You will need to create a `.custom-gcl.yml` file to describe the custom linters
5523

5624
```yaml
5725
version: v1.62.0
58-
name: golangci-kal
26+
name: golangci-kube-api-linter
5927
destination: ./bin
6028
plugins:
6129
- module: 'sigs.k8s.io/kube-api-linter'
@@ -68,60 +36,65 @@ Once you have created the custom configuration file, you can run the following c
6836
golangci-lint custom
6937
```
7038

71-
The output binary will be a combination of the initial `golangci-lint` binary and the KAL linters.
72-
This means that you can use any of the standard `golangci-lint` configuration or flags to run the binary, but may also include the KAL linters.
39+
The output binary will be a combination of the initial `golangci-lint` binary and the Kube API linter plugin.
40+
This means that you can use any of the standard `golangci-lint` configuration or flags to run the binary, but may also include the Kube API Linter rules.
7341

74-
If you wish to only use the KAL linters, you can configure your `.golangci.yml` file to only run the KAL linters:
42+
If you wish to only use the Kube API Linter rules, you can configure your `.golangci.yml` file to only run the Kube API Linter:
7543

7644
```yaml
7745
linters-settings:
7846
custom:
79-
kal:
47+
kubeapilinter:
8048
type: "module"
81-
description: KAL is the Kube-API-Linter and lints Kube like APIs based on API conventions and best practices.
49+
description: Kube API LInter lints Kube like APIs based on API conventions and best practices.
8250
settings:
8351
linters: {}
8452
lintersConfig: {}
8553
linters:
8654
disable-all: true
8755
enable:
88-
- kal
56+
- kubeapilinter
8957
90-
# To only run KAL on specific path
58+
# To only run Kube API Linter on specific path
9159
issues:
9260
exclude-rules:
9361
- path-except: "api/*"
9462
linters:
95-
- kal
63+
- kubeapilinter
9664
```
9765

98-
The settings for KAL are based on the [GolangCIConfig][golangci-config-struct] struct and allow for finer control over the linter rules.
99-
The finer control over linter rules is not currently avaialable outside of the plugin based version of KAL.
66+
The settings for Kube API Linter are based on the [GolangCIConfig][golangci-config-struct] struct and allow for finer control over the linter rules.
10067

101-
If you wish to use the KAL linters in conjunction with other linters, you can enable the KAL linters in the `.golangci.yml` file by ensuring that `kal` is in the `linters.enabled` list.
102-
To provide further configuration, add the `custom.kal` section to your `linter-settings` as per the example above.
68+
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.
69+
To provide further configuration, add the `custom.kubeapilinter` section to your `linter-settings` as per the example above.
10370

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

73+
Where fixes are available within a rule, these can be applied automatically with the `--fix` flag.
74+
75+
```shell
76+
golangci-kube-api-linter run path/to/api/types --fix
77+
```
78+
10679
#### VSCode integration
10780

10881
Since VSCode already integrates with `golangci-lint` via the [Go][vscode-go] extension, you can use the `golangci-kal` binary as a linter in VSCode.
10982
If your project authors are already using VSCode and have the configuration to lint their code when saving, this can be a seamless integration.
11083

111-
Ensure that your project setup includes building the `golangci-kal` binary, and then configure the `go.lintTool` and `go.alternateTools` settings in your project `.vscode/settings.json` file.
84+
Ensure that your project setup includes building the `golangci-kube-api-linter` binary, and then configure the `go.lintTool` and `go.alternateTools` settings in your project `.vscode/settings.json` file.
11285

11386
[vscode-go]: https://code.visualstudio.com/docs/languages/go
11487

11588
```json
11689
{
11790
"go.lintTool": "golangci-lint",
11891
"go.alternateTools": {
119-
"golangci-lint": "${workspaceFolder}/bin/golangci-kal",
92+
"golangci-lint": "${workspaceFolder}/bin/golangci-kube-api-linter",
12093
}
12194
}
12295
```
12396

124-
Alternatively, you can also replace the binary with a script that runs the `golangci-kal` binary,
97+
Alternatively, you can also replace the binary with a script that runs the `golangci-kube-api-linter` binary,
12598
allowing for customisation or automatic copmilation of the project should it not already exist.
12699

127100
```json
@@ -164,7 +137,7 @@ lintersConfig:
164137
usePatchStrategy: SuggestFix | Warn | Ignore | Forbid # The policy for the patchStrategy tag on the Conditions field. Defaults to `SuggestFix`.
165138
```
166139
167-
### Fixes (via standalone binary only)
140+
### Fixes
168141
169142
The `conditions` linter can automatically fix the tags on the `Conditions` field.
170143
When they do not match the expected format, the linter will suggest to update the tags to match the expected format.
@@ -184,7 +157,7 @@ When `usePatchStrategy` is set to `Forbid`, the linter will suggest to remove th
184157
The `commentstart` linter checks that all comments in the API types start with the serialized form of the type they are commenting on.
185158
This helps to ensure that generated documentation reflects the most common usage of the field, the serialized YAML form.
186159

187-
### Fixes (via standalone binary only)
160+
### Fixes
188161

189162
The `commentstart` linter can automatically fix comments that do not start with the serialized form of the type.
190163

@@ -276,7 +249,7 @@ lintersConfig:
276249
preferredRequiredMarker: required | kubebuilder:validation:Required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`.
277250
```
278251
279-
### Fixes (via standalone binary only)
252+
### Fixes
280253
281254
The `optionalorrequired` linter can automatically fix fields that are using the incorrect form of either the optional or required marker.
282255

@@ -295,7 +268,7 @@ lintersConfig:
295268
pointerPolicy: Warn | SuggestFix # The policy for pointers in required fields. Defaults to `SuggestFix`.
296269
```
297270

298-
### Fixes (via standalone binary only)
271+
### Fixes
299272

300273
The `requiredfields` linter can automatically fix fields that are marked as required, but are pointers.
301274

@@ -313,7 +286,7 @@ OR when the `kubebuilder:subresource:status` marker is present on the struct the
313286

314287
This linter is not enabled by default as it is only applicable to CustomResourceDefinitions.
315288

316-
### Fixes (via standalone binary only)
289+
### Fixes
317290

318291
In the case where there is a status field present but no `kubebuilder:subresource:status` marker, the
319292
linter will suggest adding the comment `// +kubebuilder:subresource:status` above the struct.

cmd/kal/main.go

Lines changed: 0 additions & 33 deletions
This file was deleted.

doc.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,36 @@ limitations under the License.
1515
*/
1616

1717
/*
18-
KAL is a linter for Kubernetes API types, that implements API conventions and best practices.
18+
Kube API Linter (KAL) is a linter for Kubernetes API types, that implements API conventions and best practices.
1919
2020
This package provides a GolangCI-Lint plugin that can be used to build a custom linter for Kubernetes API types.
21-
The custom golangci-lint binary can be built by checking out the KAL repository and running `make build-golangci`.
21+
The custom golangci-lint binary can be built by checking out the Kube API Linter repository and running `make build`.
2222
This will generate a custom golangci-lint binary in the `bin` directory.
2323
24-
The custom golangci-lint binary can be run with the `run` command, and the KAL linters can be enabled by setting the `kal` linter in the `.golangci.yml` configuration file.
24+
The custom golangci-lint binary can be run with the `run` command, and the Kube API Linter rules can be enabled by setting the `kube-api-linter` linter in the `.golangci.yml` configuration file.
2525
2626
Example `.golangci.yml` configuration file:
2727
2828
linters-settings:
2929
custom:
30-
kal:
31-
type: "module"
32-
description: KAL is the Kube-API-Linter and 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: ""
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: ""
4343
linters:
4444
disable-all: true
4545
enable:
46-
- kal
46+
- kubeapilinter
4747
4848
New linters can be added in the [sigs.k8s.io/kube-api-linter/pkg/analysis] package.
4949
*/
50-
package kal
50+
package kubeapilinter

plugin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
package kal
16+
package kubeapilinter
1717

1818
import (
1919
"fmt"
@@ -27,7 +27,7 @@ import (
2727
)
2828

2929
func init() {
30-
register.Plugin("kal", New)
30+
register.Plugin("kubeapilinter", New)
3131
}
3232

3333
// New creates a new golangci-lint plugin based on the KAL analyzers.

vendor/golang.org/x/tools/go/analysis/multichecker/multichecker.go

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)