11PROJECT_NAME := keep
2- GOLANGCI_LINT ?= golangci-lint
2+ GOLANGCI_LINT_VERSION ?= 1.64.8
33GOBIN := $(shell go env GOPATH) /bin
4+ GOLANGCI_LINT ?= $(GOBIN ) /golangci-lint
5+ GOIMPORTS ?= $(GOBIN ) /goimports
6+ GOVULNCHECK ?= $(GOBIN ) /govulncheck
7+ GOSEC ?= $(GOBIN ) /gosec
8+ OPA ?= opa
49export PATH := $(GOBIN ) :$(PATH )
510
611.PHONY : all tidy build test lint format lint-go lint-python format-go format-python docker-up docker-down docker-logs db-migrate opa-test cert-refresh setup-venv security
@@ -26,7 +31,7 @@ format: format-go format-python
2631format-go :
2732 @echo " Formatting Go code..."
2833 go fmt ./...
29- goimports -w -local github.com/EvalOps/keep .
34+ $( GOIMPORTS ) -w -local github.com/EvalOps/keep .
3035
3136format-python :
3237 @echo " Formatting Python code..."
@@ -65,7 +70,7 @@ db-migrate-status:
6570 go run ./cmd/migrate -version
6671
6772opa-test :
68- opa test ./policies
73+ $( OPA ) test ./policies
6974
7075cert-refresh :
7176 go run ./cmd/authz cert-refresh
@@ -74,7 +79,7 @@ cert-refresh:
7479install-tools :
7580 @echo " Installing Go tools..."
7681 mkdir -p $(GOBIN )
77- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
82+ GOPROXY=https://proxy.golang.org,direct go install github.com/golangci/golangci-lint/cmd/golangci-lint@v $( GOLANGCI_LINT_VERSION )
7883 go install golang.org/x/tools/cmd/goimports@v0.36.0
7984 go install golang.org/x/vuln/cmd/govulncheck@latest
8085 go install github.com/securego/gosec/v2/cmd/gosec@v2.22.6
@@ -120,10 +125,10 @@ dev-bootstrap:
120125
121126check-tools :
122127 @echo " Checking Go tools..."
123- @command -v golangci-lint > /dev/null 2>&1 || { echo " golangci-lint not found. Run 'make install-tools'" ; exit 1; }
124- @command -v goimports > /dev/null 2>&1 || { echo " goimports not found. Run 'make install-tools'" ; exit 1; }
125- @command -v govulncheck > /dev/null 2>&1 || { echo " govulncheck not found. Run 'make install-tools'" ; exit 1; }
126- @command -v gosec > /dev/null 2>&1 || { echo " gosec not found. Run 'make install-tools'" ; exit 1; }
128+ @test -x " $( GOLANGCI_LINT ) " || { echo " golangci-lint not found at $( GOLANGCI_LINT ) . Run 'make install-tools'" ; exit 1; }
129+ @test -x " $( GOIMPORTS ) " || { echo " goimports not found at $( GOIMPORTS ) . Run 'make install-tools'" ; exit 1; }
130+ @test -x " $( GOVULNCHECK ) " || { echo " govulncheck not found at $( GOVULNCHECK ) . Run 'make install-tools'" ; exit 1; }
131+ @test -x " $( GOSEC ) " || { echo " gosec not found at $( GOSEC ) . Run 'make install-tools'" ; exit 1; }
127132 @echo " Checking Python tools..."
128133 @command -v black > /dev/null 2>&1 || { echo " black not found. Run 'make install-tools'" ; exit 1; }
129134 @command -v flake8 > /dev/null 2>&1 || { echo " flake8 not found. Run 'make install-tools'" ; exit 1; }
@@ -134,11 +139,11 @@ check-tools:
134139security :
135140 @echo " Running govulncheck..."
136141 @# govulncheck currently fails due to golang.org/x/sync/semaphore type info missing via github.com/jackc/puddle/v2
137- @if ! govulncheck ./...; then \
142+ @if ! $( GOVULNCHECK ) ./...; then \
138143 echo " Warning: govulncheck encountered known issue (golang.org/x/sync/semaphore via github.com/jackc/puddle/v2); continuing" ; \
139144 fi
140145 @echo " Running gosec..."
141- gosec ./...
146+ $( GOSEC ) ./...
142147
143148# CI/CD targets
144149ci-lint : check-tools lint
0 commit comments