Skip to content

Commit 024f5c8

Browse files
Add kube-api-linter
1 parent c5d9fed commit 024f5c8

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

.custom-gcl.yml

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

.golangci.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ linters:
2121
- unconvert
2222
- unparam
2323
- whitespace
24+
- kubeapilinter
2425
settings:
2526
errorlint:
2627
errorf: false
@@ -42,6 +43,17 @@ linters:
4243
alias: bsemver
4344
- pkg: ^github.com/operator-framework/operator-controller/internal/shared/util/([^/]+)$
4445
alias: ${1}util
46+
custom:
47+
kubeapilinter:
48+
type: module
49+
description: "Kube API Linter plugin"
50+
original-url: "sigs.k8s.io/kube-api-linter"
51+
settings:
52+
linters: {}
53+
lintersConfig:
54+
optionalfields:
55+
pointers:
56+
preference: WhenRequired
4557
exclusions:
4658
generated: lax
4759
presets:
@@ -53,6 +65,10 @@ linters:
5365
- third_party$
5466
- builtin$
5567
- examples$
68+
rules:
69+
- path-except: "^api/"
70+
linters:
71+
- kubeapilinter
5672
formatters:
5773
enable:
5874
- gci

Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,19 @@ help-extended: #HELP Display extended help.
117117

118118
#SECTION Development
119119

120+
GOLANGCI_LINT_KUBE_API := bin/golangci-lint-kube-api
121+
122+
$(GOLANGCI_LINT_KUBE_API): $(GOLANGCI_LINT) .custom-gcl.yml
123+
@echo "Building custom golangci-lint with kubeapilinter plugin..."
124+
@$(GOLANGCI_LINT) custom || { \
125+
echo "Failed to build custom golangci-lint."; \
126+
rm -f $(GOLANGCI_LINT_KUBE_API); \
127+
exit 1; \
128+
}
129+
120130
.PHONY: lint
121-
lint: lint-custom $(GOLANGCI_LINT) #HELP Run golangci linter.
122-
$(GOLANGCI_LINT) run --build-tags $(GO_BUILD_TAGS) $(GOLANGCI_LINT_ARGS)
131+
lint: lint-custom $(GOLANGCI_LINT_KUBE_API) #HELP Run golangci linter.
132+
$(GOLANGCI_LINT_KUBE_API) run --build-tags $(GO_BUILD_TAGS) $(GOLANGCI_LINT_ARGS)
123133

124134
lint-helm: $(HELM) #HELP Run helm linter
125135
helm lint helm/olmv1

0 commit comments

Comments
 (0)