diff --git a/go/ai-proxy/Makefile b/go/ai-proxy/Makefile index 444c8f1df..a547b6f43 100644 --- a/go/ai-proxy/Makefile +++ b/go/ai-proxy/Makefile @@ -57,7 +57,8 @@ docker: check: vet lint test ## run all code checks/tests .PHONY: goimports -goimports: install-goimports ## format code imports +goimports: TOOL = goimports +goimports: --tool ## format code imports @$(GOIMPORTS) -w ./ .PHONY: fmt @@ -69,11 +70,13 @@ vet: ## run go vet @go vet ./... .PHONY: lint -lint: install-golangci-lint ## run linters +lint: TOOL = golangci-lint +lint: --tool ## run linters @$(GOLANGCI_LINT) run ./... .PHONY: fix -fix: install-golangci-lint fmt ## fix issues found by linters +fix: TOOL = golangci-lint +fix: --tool fmt ## fix issues found by linters @$(GOLANGCI_LINT) run --fix ./... .PHONY: test diff --git a/go/client/Makefile b/go/client/Makefile index c44ceb712..e00a2a6be 100644 --- a/go/client/Makefile +++ b/go/client/Makefile @@ -9,7 +9,9 @@ include $(TOOLS_MAKEFILE) help: ## show help @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) -generate: install-gqlgenc ## generate Go client from GraphQL schema +.PHONY: generate: +generate: TOOL = gqlgenc +generate: --tool ## generate Go client from GraphQL schema @$(GQLGENC) release: ## create and push a tag with new client version diff --git a/go/controller/Makefile b/go/controller/Makefile index 120501a20..db71835a9 100644 --- a/go/controller/Makefile +++ b/go/controller/Makefile @@ -62,15 +62,18 @@ vet: ## run go vet against code @go vet ./... .PHONY: lint -lint: install-golangci-lint ## run linters +lint: TOOL = golangci-lint +lint: --tool ## run linters @$(GOLANGCI_LINT) run ./... .PHONY: fix -fix: install-golangci-lint ## fix issues found by linters +fix: TOOL = golangci-lint +fix: --tool ## fix issues found by linters @$(GOLANGCI_LINT) run --fix ./... .PHONY: test -test: install-envtest manifests generate genmock fmt vet ## run tests +test: TOOL = envtest controller-gen mockery +test: --tool manifests generate genmock fmt vet ## run tests @KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(BINARIES_DIR) -p path)" go test $$(go list ./... | grep -v /e2e) -v .PHONY: e2e @@ -83,20 +86,23 @@ e2e: ## run e2e tests codegen: manifests generate genmock codegen-helm codegen-crd-docs ## runs all codegen-related targets .PHONY: manifests -manifests: install-controller-gen ## generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects +manifests: ## generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects $(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true webhook paths="./..." output:crd:artifacts:config=config/crd/bases @$(MAKE) -s codegen-chart-crds .PHONY: generate -generate: install-controller-gen ## generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations +generate: TOOL = controller-gen +generate: --tool ## generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations $(CONTROLLER_GEN) object:headerFile=$(BOILERPLATE_FILE) paths="./..." .PHONY: genmock +genmock: TOOL = mockery genmock: ## generates mocks before running tests $(MOCKERY) .PHONY: codegen-helm -codegen-helm: install-kustomize install-helmify manifests ## generate controller helm chart with kustomize +codegen-helm: TOOL = kustomize helmify +codegen-helm: --tool manifests ## generate controller helm chart with kustomize @rm -rf tmp/ @$(KUSTOMIZE) build config/default | $(HELMIFY) -generate-defaults -image-pull-secrets -crd-dir tmp/charts/controller @find tmp/charts/controller -type f -exec sed -i 's/app.kubernetes.io\/managed-by: kustomize/app.kubernetes.io\/managed-by: helm/g' {} \; @@ -107,13 +113,15 @@ codegen-chart-crds: ## copy CRDs to the controller helm chart @cp -a $(CONTROLLER_CHART_DIR)/crds/. $(PLURAL_CONSOLE_CHART_DIR)/crds .PHONY: codegen-crd-docs -codegen-crd-docs: install-crd-ref-docs ## generate docs from the CRDs +codegen-crd-docs: TOOL = crd-ref-docs +codegen-crd-docs: --tool ## generate docs from the CRDs $(CRDDOCS) --source-path=./api --renderer=markdown --output-path=./docs/api.md --config=config.yaml ##@ Deployment .PHONY: deploy-crds-kustomize -deploy-crds-kustomize: install-kustomize manifests ## deploy CRDs into the K8s cluster specified in ~/.kube/config. +deploy-crds-kustomize: TOOL = kustomize +deploy-crds-kustomize: --tool manifests ## deploy CRDs into the K8s cluster specified in ~/.kube/config. $(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f - ifndef ignore-not-found @@ -121,15 +129,18 @@ ifndef ignore-not-found endif .PHONY: undeploy-crds-kustomize -undeploy-crds-kustomize: install-kustomize manifests ## undeploy CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. +undeploy-crds-kustomize: TOOL = kustomize +undeploy-crds-kustomize: --tool manifests ## undeploy CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. $(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f - .PHONY: deploy-kustomize -deploy-kustomize: install-kustomize manifests deploy-crds-kustomize ## deploy controller to the K8s cluster specified in ~/.kube/config. +deploy-kustomize: TOOL = kustomize +deploy-kustomize: --tool manifests deploy-crds-kustomize ## deploy controller to the K8s cluster specified in ~/.kube/config. $(KUSTOMIZE) build config/default | $(ENVSUBST) | $(KUBECTL) apply -f - .PHONY: undeploy-kustomize -undeploy-kustomize: install-kustomize manifests ## undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. +undeploy-kustomize: TOOL = kustomize +undeploy-kustomize: --tool manifests ## undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. $(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f - .PHONY: deploy-helm diff --git a/go/oci-auth/Makefile b/go/oci-auth/Makefile index e62123eaa..98ee44d22 100644 --- a/go/oci-auth/Makefile +++ b/go/oci-auth/Makefile @@ -40,11 +40,13 @@ release: lint test ## builds release version of the app, requires GoReleaser to ##@ Checks .PHONY: lint -lint: install-golangci-lint ## run linters +lint: TOOL = golangci-lint +lint: --tool ## run linters @$(GOLANGCI_LINT) run ./... .PHONY: fix -fix: install-golangci-lint ## run linters and fix found issues +fix: TOOL = golangci-lint +fix: --tool ## run linters and fix found issues @$(GOLANGCI_LINT) run --fix ./... .PHONY: test diff --git a/go/tools/Makefile b/go/tools/Makefile index cacf0fce3..666aa10b2 100644 --- a/go/tools/Makefile +++ b/go/tools/Makefile @@ -21,7 +21,8 @@ tools: --tool install-kubebuilder dependency=$$(echo $${tool} | cut -d'@' -f1) ;\ version=$$(echo $$tool | cut -d'@' -f2) ;\ for path in $(GO_INSTALL_TOOLS); do \ - if echo $${path} | grep -q "$(TOOL)"; then \ + match=$$(echo "$(TOOL)" | tr ' ' '|') ;\ + if echo $${path} | grep -qE "$${match}"; then \ if echo $${path} | grep -q $${dependency}; then \ echo Installing $${path}@$${version} ;\ GOBIN=$(BINARIES_DIR) go install $${path}@$${version} ;\