forked from llm-d/llm-d-router
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.tools.mk
More file actions
66 lines (55 loc) · 2.1 KB
/
Copy pathMakefile.tools.mk
File metadata and controls
66 lines (55 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
##@ Tool Checks
.PHONY: check-all-tools
check-all-tools: check-container-tool check-kubectl check-kustomize check-envsubst helm-install yq kubectl-validate ## Check and install all required tools
@echo "All tools are available and ready!"
HELM_VERSION ?= v3.17.1
KUBECTL_VALIDATE_VERSION ?= v0.0.4
YQ_VERSION ?= v4.45.1
$(LOCALBIN):
[ -d $@ ] || mkdir -p $@
define go-install-tool
@[ -f "$(1)-$(3)" ] || { \
set -e; \
package=$(2)@$(3) ;\
echo "Downloading $${package}" ;\
rm -f $(1) || true ;\
GOBIN=$(LOCALBIN) go install $${package} ;\
mv $(1) $(1)-$(3) ;\
} ;\
ln -sf $(notdir $(1))-$(3) $(1)
endef
.PHONY: helm-install
helm-install: $(HELM) ## Download helm locally if necessary.
$(HELM): | $(LOCALBIN)
$(call go-install-tool,$(HELM),helm.sh/helm/v3/cmd/helm,$(HELM_VERSION))
.PHONY: kubectl-validate
kubectl-validate: $(KUBECTL_VALIDATE) ## Download kubectl-validate locally if necessary.
$(KUBECTL_VALIDATE): | $(LOCALBIN)
$(call go-install-tool,$(KUBECTL_VALIDATE),sigs.k8s.io/kubectl-validate,$(KUBECTL_VALIDATE_VERSION))
.PHONY: yq
yq: $(YQ) ## Download yq locally if necessary.
$(YQ): | $(LOCALBIN)
$(call go-install-tool,$(YQ),github.com/mikefarah/yq/v4,$(YQ_VERSION))
.PHONY: check-container-tool
check-container-tool:
@if [ -z "$(CONTAINER_RUNTIME)" ]; then \
echo "ERROR: No container tool detected. Please install docker or podman."; \
exit 1; \
else \
echo "Container tool '$(CONTAINER_RUNTIME)' found."; \
fi
.PHONY: check-kubectl
check-kubectl:
@command -v kubectl >/dev/null 2>&1 || { \
echo "ERROR: kubectl is not installed. Install it from https://kubernetes.io/docs/tasks/tools/"; exit 1; }
.PHONY: check-kustomize
check-kustomize:
@kubectl kustomize --help 2>&1 | grep -q -- '--enable-helm' || { \
echo "ERROR: kubectl kustomize does not support --enable-helm."; \
echo "Upgrade kubectl to v1.25 or later (https://kubernetes.io/docs/tasks/tools/)"; \
exit 1; }
.PHONY: check-envsubst
check-envsubst:
@command -v envsubst >/dev/null 2>&1 || { \
echo "ERROR: envsubst is not installed. It is part of gettext."; \
echo "Try: sudo apt install gettext OR brew install gettext"; exit 1; }