@@ -92,10 +92,39 @@ cert-refresh:
9292# Tool installation and checks
9393install-tools :
9494 @echo " Installing Go tools..."
95+ mkdir -p $(GOBIN )
9596 go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
9697 go install golang.org/x/tools/cmd/goimports@latest
9798 go install golang.org/x/vuln/cmd/govulncheck@latest
9899 go install github.com/securego/gosec/v2/cmd/gosec@latest
100+ @echo " Ensuring OPA CLI is available..."
101+ @NEED_OPA=1; \
102+ if command -v opa > /dev/null 2>&1 ; then \
103+ if opa version > /dev/null 2>&1 ; then \
104+ echo " OPA already installed" ; \
105+ NEED_OPA=0; \
106+ else \
107+ echo " Existing OPA binary is unusable. Reinstalling..." ; \
108+ fi ; \
109+ fi ; \
110+ if [ $$ NEED_OPA -eq 1 ]; then \
111+ OPA_OS=$$(uname | tr '[:upper:]' '[:lower:]' ) ; \
112+ OPA_ARCH=$$(uname -m ) ; \
113+ case $$ OPA_ARCH in \
114+ x86_64) OPA_ARCH=amd64 ;; \
115+ aarch64| arm64) OPA_ARCH=arm64 ;; \
116+ * ) echo " Unsupported architecture: $$ OPA_ARCH" >&2 ; exit 1 ;; \
117+ esac ; \
118+ case $$ OPA_OS in \
119+ linux| darwin) ;; \
120+ * ) echo " Unsupported OS: $$ OPA_OS" >&2 ; exit 1 ;; \
121+ esac ; \
122+ OPA_URL=" https://github.com/open-policy-agent/opa/releases/latest/download/opa_$$ {OPA_OS}_$$ {OPA_ARCH}_static" ; \
123+ echo " Downloading OPA from $$ OPA_URL" ; \
124+ curl -fsSL -o $(GOBIN ) /opa.tmp " $$ OPA_URL" ; \
125+ chmod +x $(GOBIN ) /opa.tmp; \
126+ mv $(GOBIN ) /opa.tmp $(GOBIN ) /opa; \
127+ fi
99128 @echo " Installing Python tools..."
100129 $(PIP_BIN ) install black flake8 isort mypy
101130
0 commit comments