Skip to content

Commit 5eefb0d

Browse files
fix(Makefile): golang-ci installation
1 parent 626c48b commit 5eefb0d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ $(KUSTOMIZE): $(LOCALBIN)
7878
fi
7979
test -s $(LOCALBIN)/kustomize || GOBIN=$(LOCALBIN) GO111MODULE=on go install sigs.k8s.io/kustomize/kustomize/v5@$(KUSTOMIZE_VERSION)
8080

81+
$(GOLANGCILINT): $(LOCALBIN)
82+
@if test -x $(LOCALBIN)/golangci-lint && ! $(LOCALBIN)/golangci-lint version | grep -q $(GOLANGCILINT_VERSION); then \
83+
echo "$(LOCALBIN)/golangci-lint version is not expected $(GOLANGCILINT_VERSION). Removing it before installing."; \
84+
rm -rf $(LOCALBIN)/golangci-lint; \
85+
fi
86+
test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) GO111MODULE=on go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCILINT_VERSION)
87+
8188
.PHONY: controller-gen
8289
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
8390
$(CONTROLLER_GEN): $(LOCALBIN)
@@ -104,7 +111,7 @@ lint: $(GOLANGCILINT) ## Run golangci-lint against code.
104111
$(GOLANGCILINT) run ./...
105112

106113
.PHONY: lint-fix
107-
lint-fix: ## Run golangci-lint with --fix option to automatically fix issues.
114+
lint-fix: $(GOLANGCILINT) ## Run golangci-lint with --fix option to automatically fix issues.
108115
$(GOLANGCILINT) run --fix
109116

110117
#----------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)