Skip to content

Commit ecd247e

Browse files
KPA experimental install
1 parent 44eabd5 commit ecd247e

File tree

30 files changed

+454
-150
lines changed

30 files changed

+454
-150
lines changed

Makefile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,18 @@ yamllint:
131131
docker run --rm $$(tty -s && echo "-it" || echo) -v $(PWD):/data cytopia/yamllint:latest $$files -d "{extends: relaxed, rules: {line-length: {max: 120}}}" --no-warnings
132132

133133
.PHONY: golangci-lint
134-
golangci-lint:
135-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,${GOLANGCI_LINT_VERSION})
134+
golangci-lint: $(GOLANGCI_LINT)
135+
136+
$(GOLANGCI_LINT_BASE): $(LOCALBIN)
137+
$(call go-install-tool,$(GOLANGCI_LINT_BASE),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,${GOLANGCI_LINT_VERSION})
138+
139+
$(GOLANGCI_LINT): $(GOLANGCI_LINT_BASE) .custom-gcl.yml
140+
@echo "Installing custom golangci-lint plugins..."
141+
@$(GOLANGCI_LINT_BASE) custom || { \
142+
echo "golangci-lint custom failed. Cleaning up..."; \
143+
rm -f $(GOLANGCI_LINT_BASE); \
144+
exit 1; \
145+
}
136146

137147
.PHONY: apidiff
138148
apidiff: go-apidiff ## Run the go-apidiff to verify any API differences compared with origin/master
@@ -229,7 +239,8 @@ update-k8s-version: ## Update Kubernetes API version in version.go and .goreleas
229239

230240
## Tool Binaries
231241
GO_APIDIFF ?= $(LOCALBIN)/go-apidiff
232-
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
242+
GOLANGCI_LINT_BASE ?= $(LOCALBIN)/golangci-lint
243+
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint-kube-api
233244

234245
## Tool Versions
235246
GO_APIDIFF_VERSION ?= v0.6.1
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: v2.5.0
2+
name: golangci-lint-kube-api
3+
destination: ./bin
4+
5+
plugins:
6+
- module: sigs.k8s.io/kube-api-linter
7+
version: latest

docs/book/src/cronjob-tutorial/testdata/project/.github/workflows/lint.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ jobs:
1717
with:
1818
go-version-file: go.mod
1919

20+
- name: Check linter configuration
21+
run: make lint-config
22+
2023
- name: Run linter
2124
uses: golangci/golangci-lint-action@v8
2225
with:
2326
version: v2.5.0
27+
28+
- name: Run lint target
29+
run: make lint

docs/book/src/cronjob-tutorial/testdata/project/.golangci.yml

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,37 @@ linters:
2121
- unconvert
2222
- unparam
2323
- unused
24-
settings:
25-
revive:
26-
rules:
27-
- name: comment-spacings
28-
- name: import-shadowing
29-
exclusions:
30-
generated: lax
24+
- kubeapilinter
25+
linters-settings:
26+
revive:
3127
rules:
32-
- linters:
33-
- lll
34-
path: api/*
35-
- linters:
36-
- dupl
37-
- lll
38-
path: internal/*
39-
paths:
40-
- third_party$
41-
- builtin$
42-
- examples$
28+
- name: comment-spacings
29+
- name: import-shadowing
30+
custom:
31+
kubeapilinter:
32+
type: module
33+
description: "Kube API Linter plugin"
34+
original-url: "sigs.k8s.io/kube-api-linter"
35+
settings:
36+
linters: {}
37+
lintersConfig: {}
38+
exclusions:
39+
generated: lax
40+
rules:
41+
- linters:
42+
- lll
43+
path: api/*
44+
- linters:
45+
- dupl
46+
- lll
47+
path: internal/*
48+
- path-except: "^api/"
49+
linters:
50+
- kubeapilinter
51+
paths:
52+
- third_party$
53+
- builtin$
54+
- examples$
4355
formatters:
4456
enable:
4557
- gofmt

docs/book/src/cronjob-tutorial/testdata/project/Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ KIND ?= kind
188188
KUSTOMIZE ?= $(LOCALBIN)/kustomize
189189
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
190190
ENVTEST ?= $(LOCALBIN)/setup-envtest
191-
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
191+
GOLANGCI_LINT_BASE = $(LOCALBIN)/golangci-lint
192+
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-kube-api
192193

193194
## Tool Versions
194195
KUSTOMIZE_VERSION ?= v5.7.1
@@ -230,8 +231,17 @@ $(ENVTEST): $(LOCALBIN)
230231

231232
.PHONY: golangci-lint
232233
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
233-
$(GOLANGCI_LINT): $(LOCALBIN)
234-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
234+
235+
$(GOLANGCI_LINT_BASE): $(LOCALBIN)
236+
$(call go-install-tool,$(GOLANGCI_LINT_BASE),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
237+
238+
$(GOLANGCI_LINT): $(GOLANGCI_LINT_BASE) .custom-gcl.yml
239+
@echo "Running golangci-lint custom..."
240+
@$(GOLANGCI_LINT_BASE) custom || { \
241+
echo "golangci-lint failed. Cleaning up..."; \
242+
rm -f $(GOLANGCI_LINT_BASE); \
243+
exit 1; \
244+
}
235245

236246
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
237247
# $1 - target path with name of binary
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: v2.5.0
2+
name: golangci-lint-kube-api
3+
destination: ./bin
4+
5+
plugins:
6+
- module: sigs.k8s.io/kube-api-linter
7+
version: latest

docs/book/src/getting-started/testdata/project/.github/workflows/lint.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ jobs:
1717
with:
1818
go-version-file: go.mod
1919

20+
- name: Check linter configuration
21+
run: make lint-config
22+
2023
- name: Run linter
2124
uses: golangci/golangci-lint-action@v8
2225
with:
2326
version: v2.5.0
27+
28+
- name: Run lint target
29+
run: make lint

docs/book/src/getting-started/testdata/project/.golangci.yml

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,37 @@ linters:
2121
- unconvert
2222
- unparam
2323
- unused
24-
settings:
25-
revive:
26-
rules:
27-
- name: comment-spacings
28-
- name: import-shadowing
29-
exclusions:
30-
generated: lax
24+
- kubeapilinter
25+
linters-settings:
26+
revive:
3127
rules:
32-
- linters:
33-
- lll
34-
path: api/*
35-
- linters:
36-
- dupl
37-
- lll
38-
path: internal/*
39-
paths:
40-
- third_party$
41-
- builtin$
42-
- examples$
28+
- name: comment-spacings
29+
- name: import-shadowing
30+
custom:
31+
kubeapilinter:
32+
type: module
33+
description: "Kube API Linter plugin"
34+
original-url: "sigs.k8s.io/kube-api-linter"
35+
settings:
36+
linters: {}
37+
lintersConfig: {}
38+
exclusions:
39+
generated: lax
40+
rules:
41+
- linters:
42+
- lll
43+
path: api/*
44+
- linters:
45+
- dupl
46+
- lll
47+
path: internal/*
48+
- path-except: "^api/"
49+
linters:
50+
- kubeapilinter
51+
paths:
52+
- third_party$
53+
- builtin$
54+
- examples$
4355
formatters:
4456
enable:
4557
- gofmt

docs/book/src/getting-started/testdata/project/Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ KIND ?= kind
184184
KUSTOMIZE ?= $(LOCALBIN)/kustomize
185185
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
186186
ENVTEST ?= $(LOCALBIN)/setup-envtest
187-
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
187+
GOLANGCI_LINT_BASE = $(LOCALBIN)/golangci-lint
188+
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-kube-api
188189

189190
## Tool Versions
190191
KUSTOMIZE_VERSION ?= v5.7.1
@@ -226,8 +227,17 @@ $(ENVTEST): $(LOCALBIN)
226227

227228
.PHONY: golangci-lint
228229
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
229-
$(GOLANGCI_LINT): $(LOCALBIN)
230-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
230+
231+
$(GOLANGCI_LINT_BASE): $(LOCALBIN)
232+
$(call go-install-tool,$(GOLANGCI_LINT_BASE),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))
233+
234+
$(GOLANGCI_LINT): $(GOLANGCI_LINT_BASE) .custom-gcl.yml
235+
@echo "Running golangci-lint custom..."
236+
@$(GOLANGCI_LINT_BASE) custom || { \
237+
echo "golangci-lint failed. Cleaning up..."; \
238+
rm -f $(GOLANGCI_LINT_BASE); \
239+
exit 1; \
240+
}
231241

232242
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
233243
# $1 - target path with name of binary
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: v2.5.0
2+
name: golangci-lint-kube-api
3+
destination: ./bin
4+
5+
plugins:
6+
- module: sigs.k8s.io/kube-api-linter
7+
version: latest

0 commit comments

Comments
 (0)