Skip to content

Commit 63ae91a

Browse files
Add custom make target for running sigs.k8s.io/kube-api-linter
See: https://github.com/kubernetes-sigs/kube-api-linter
1 parent 120467d commit 63ae91a

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

.custom-gcl.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: v2.5.0
2+
name: golangci-lint-kube-api-linter
3+
destination: ./bin
4+
plugins:
5+
- module: 'sigs.k8s.io/kube-api-linter'
6+
version: 'v0.0.0-20251103104136-5fca1e8b5e9f'

.golangci-kal.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company
2+
# SPDX-License-Identifier: Apache-2.0
3+
version: "2"
4+
linters:
5+
default: none
6+
enable:
7+
- kubeapilinter # linter for Kube API conventions
8+
settings:
9+
custom:
10+
kubeapilinter:
11+
type: module
12+
description: KAL is the Kube-API-Linter and lints Kube like APIs based on API conventions and best practices.
13+
settings:
14+
linters: {}
15+
lintersConfig:
16+
conditions:
17+
useProtobuf: Forbid
18+
optionalfields:
19+
pointers:
20+
preference: WhenRequired
21+
22+
exclusions:
23+
generated: strict
24+
paths:
25+
- ".*_test.go"
26+
- "zz_generated.*.go"
27+
rules:
28+
- path-except: "^api/"
29+
linters:
30+
- kubeapilinter
31+
issues:
32+
max-same-issues: 0
33+
max-issues-per-linter: 0

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ fmt: FORCE install-gofumpt
5353
@printf "\e[1;36m>> gofumpt -l -w .\e[0m\n"
5454
@gofumpt -l -w $(shell git ls-files '*.go' | grep -v '^internal/provider/openconfig')
5555

56+
bin/golangci-lint-kube-api-linter:
57+
@printf "\e[1;36m>> Installing golangci-lint-kube-api-linter...\e[0m\n"
58+
@golangci-lint custom
59+
60+
lint-api: FORCE bin/golangci-lint-kube-api-linter
61+
@printf "\e[1;36m>> bin/golangci-lint-kube-api-linter run --config=.golangci-kal.yaml\e[0m\n"
62+
@bin/golangci-lint-kube-api-linter config verify --config=.golangci-kal.yaml
63+
@bin/golangci-lint-kube-api-linter run --config=.golangci-kal.yaml
64+
5665
# Run the e2e tests against a k8s cluster.
5766
test-e2e: FORCE
5867
@command -v kind >/dev/null 2>&1 || { \

Makefile.maker.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ verbatim: |
8080
@printf "\e[1;36m>> gofumpt -l -w .\e[0m\n"
8181
@gofumpt -l -w $(shell git ls-files '*.go' | grep -v '^internal/provider/openconfig')
8282
83+
bin/golangci-lint-kube-api-linter:
84+
@printf "\e[1;36m>> Installing golangci-lint-kube-api-linter...\e[0m\n"
85+
@golangci-lint custom
86+
87+
lint-api: FORCE bin/golangci-lint-kube-api-linter
88+
@printf "\e[1;36m>> bin/golangci-lint-kube-api-linter run --config=.golangci-kal.yaml\e[0m\n"
89+
@bin/golangci-lint-kube-api-linter config verify --config=.golangci-kal.yaml
90+
@bin/golangci-lint-kube-api-linter run --config=.golangci-kal.yaml
91+
8392
# Run the e2e tests against a k8s cluster.
8493
test-e2e: FORCE
8594
@command -v kind >/dev/null 2>&1 || { \

0 commit comments

Comments
 (0)