github.com/kubevela/workflow@v0.6.0/makefiles/dependency.mk (about) 1 ##@ Build Dependencies 2 3 ## Location to install dependencies to 4 LOCALBIN ?= $(shell pwd)/bin 5 $(LOCALBIN): 6 mkdir -p $(LOCALBIN) 7 8 ## Tool Binaries 9 KUSTOMIZE ?= $(LOCALBIN)/kustomize 10 CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen 11 ENVTEST ?= $(LOCALBIN)/setup-envtest 12 13 ## Tool Versions 14 KUSTOMIZE_VERSION ?= 4.5.5 15 CONTROLLER_TOOLS_VERSION ?= v0.9.0 16 17 KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" 18 .PHONY: kustomize 19 kustomize: 20 ifneq (, $(shell kustomize version | grep $(KUSTOMIZE_VERSION))) 21 KUSTOMIZE=$(shell which kustomize) 22 else 23 @{ \ 24 set -eo pipefail ;\ 25 echo $(shell kustomize version);\ 26 echo $(KUSTOMIZE_VERSION);\ 27 echo $(shell kustomize version | grep $(KUSTOMIZE_VERSION));\ 28 echo "installing kustomize-v$(KUSTOMIZE_VERSION) into $(shell pwd)/bin" ;\ 29 mkdir -p $(shell pwd)/bin ;\ 30 rm -f $(KUSTOMIZE) ;\ 31 curl -sS https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh | bash -s $(KUSTOMIZE_VERSION) $(shell pwd)/bin;\ 32 echo 'Install succeed' ;\ 33 } 34 endif 35 36 .PHONY: staticchecktool 37 staticchecktool: 38 ifeq (, $(shell which staticcheck)) 39 @{ \ 40 set -e ;\ 41 echo 'installing honnef.co/go/tools/cmd/staticcheck ' ;\ 42 go install honnef.co/go/tools/cmd/staticcheck@2022.1 ;\ 43 } 44 STATICCHECK=$(GOBIN)/staticcheck 45 else 46 STATICCHECK=$(shell which staticcheck) 47 endif 48 49 .PHONY: goimports 50 goimports: 51 ifeq (, $(shell which goimports)) 52 @{ \ 53 set -e ;\ 54 go install golang.org/x/tools/cmd/goimports@latest ;\ 55 } 56 GOIMPORTS=$(GOBIN)/goimports 57 else 58 GOIMPORTS=$(shell which goimports) 59 endif 60 61 GOLANGCILINT_VERSION ?= v1.46.0 62 63 .PHONY: golangci 64 golangci: 65 ifneq ($(shell which golangci-lint),) 66 @$(OK) golangci-lint is already installed 67 GOLANGCILINT=$(shell which golangci-lint) 68 else ifeq (, $(shell which $(GOBIN)/golangci-lint)) 69 @{ \ 70 set -e ;\ 71 echo 'installing golangci-lint-$(GOLANGCILINT_VERSION)' ;\ 72 curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) $(GOLANGCILINT_VERSION) ;\ 73 echo 'Successfully installed' ;\ 74 } 75 GOLANGCILINT=$(GOBIN)/golangci-lint 76 else 77 @$(OK) golangci-lint is already installed 78 GOLANGCILINT=$(GOBIN)/golangci-lint 79 endif 80 81 .PHONY: helmdoc 82 helmdoc: 83 ifeq (, $(shell which readme-generator)) 84 @{ \ 85 set -e ;\ 86 echo 'installing readme-generator-for-helm' ;\ 87 npm install -g readme-generator-for-helm ;\ 88 } 89 else 90 @$(OK) readme-generator-for-helm is already installed 91 HELMDOC=$(shell which readme-generator) 92 endif 93 94 .PHONY: controller-gen 95 controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. 96 $(CONTROLLER_GEN): $(LOCALBIN) 97 GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) 98 99 .PHONY: envtest 100 envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. 101 $(ENVTEST): $(LOCALBIN) 102 GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest