@@ -69,6 +69,16 @@ all: test manager
69
69
help : # # Display this help
70
70
@awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
71
71
72
+ # go-install-tool will 'go install' any package $2 and install it to $1.
73
+ PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST ) ) ) )
74
+ define go-install-tool
75
+ @[ -f $(1 ) ] || { \
76
+ set -e ;\
77
+ echo "Installing $(2 ) " ;\
78
+ GOBIN=$(PROJECT_DIR ) /bin go install $(2 ) ;\
79
+ }
80
+ endef
81
+
72
82
# # --------------------------------------
73
83
# # Testing
74
84
# # --------------------------------------
@@ -205,7 +215,7 @@ modules: ## Runs go mod to ensure modules are up to date.
205
215
.PHONY : docker-pull-prerequisites
206
216
docker-pull-prerequisites :
207
217
docker pull docker.io/docker/dockerfile:1.4
208
- docker pull docker.io/library/golang:1.20
218
+ docker pull docker.io/library/golang:1.20.2
209
219
docker pull gcr.io/distroless/static:latest
210
220
211
221
.PHONY : docker-build
@@ -329,11 +339,13 @@ goimports:
329
339
go install golang.org/x/tools/cmd/goimports@latest
330
340
goimports -w -local=" sigs.k8s.io/cluster-api-provider-kubevirt" $(shell find . -type f -name '* .go' ! -path "* /vendor/* " ! -path "./_kubevirtci/* " ! -path "* zz_generated* " )
331
341
342
+ GOLANGCI_LINT = $(shell pwd) /bin/golangci-lint
343
+ golangci-lint : # # Download golangci-lint locally if necessary.
344
+ $(call go-install-tool,$(GOLANGCI_LINT ) ,github.com/golangci/golangci-lint/cmd/[email protected] )
345
+
332
346
.PHONY : linter
333
- linter :
334
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
335
- # todo remove the exclude parameter when issue #85 is resolved
336
- golangci-lint run --timeout=5m -E ginkgolinter --exclude SA1019
347
+ linter : golangci-lint
348
+ $(GOLANGCI_LINT ) run --timeout=5m -v
337
349
338
350
.PHONY : sanity
339
351
sanity : linter goimports test
0 commit comments