Skip to content

Commit c3da7d6

Browse files
committed
chore: Makefile improvements
Signed-off-by: András Jáky <ajaky@cisco.com>
1 parent 018fc22 commit c3da7d6

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

Makefile

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ run: ## Run manager from your host
7373
up: ## Start kind development environment
7474
$(KIND) create cluster --name $(TEST_KIND_CLUSTER)
7575
sleep 10
76-
helm upgrade --install vault-operator oci://ghcr.io/bank-vaults/helm-charts/vault-operator \
76+
$(HELM) upgrade --install vault-operator oci://ghcr.io/bank-vaults/helm-charts/vault-operator \
7777
--set image.tag=latest \
7878
--set image.bankVaultsTag=latest \
7979
--wait
80-
kubectl create namespace bank-vaults-infra --dry-run=client -o yaml | kubectl apply -f -
81-
kubectl apply -f $(shell pwd)/e2e/deploy/vault/
80+
$(KUBECTL) create namespace bank-vaults-infra --dry-run=client -o yaml | $(KUBECTL) apply -f -
81+
$(KUBECTL) apply -f $(shell pwd)/e2e/deploy/vault/
8282
sleep 60
83-
helm upgrade --install vault-secrets-webhook oci://ghcr.io/bank-vaults/helm-charts/vault-secrets-webhook \
83+
$(HELM) upgrade --install vault-secrets-webhook oci://ghcr.io/bank-vaults/helm-charts/vault-secrets-webhook \
8484
--set replicaCount=1 \
8585
--set image.tag=latest \
8686
--set image.pullPolicy=IfNotPresent \
@@ -124,22 +124,19 @@ generate: gen-helm-docs ## Generate manifests, code, and docs resources
124124

125125
.PHONY: deploy
126126
deploy: ## Deploy Reloader controller resources to the K8s cluster
127-
kubectl create namespace bank-vaults-infra --dry-run=client -o yaml | kubectl apply -f -
127+
$(KUBECTL) create namespace bank-vaults-infra --dry-run=client -o yaml | $(KUBECTL) apply -f -
128128
$(HELM) upgrade --install vault-secrets-reloader deploy/charts/vault-secrets-reloader \
129129
--set image.tag=dev \
130130
--set collectorSyncPeriod=30s \
131131
--set reloaderRunPeriod=1m \
132132
--namespace bank-vaults-infra
133133

134+
.PHONY: upload-kind
135+
upload-kind:
136+
$(KIND) load docker-image $(IMG) --name $(TEST_KIND_CLUSTER) ## Load docker image to kind cluster
137+
134138
.PHONY: deploy-kind
135-
deploy-kind: ## Deploy Reloder controller resources to the kind cluster
136-
kind load docker-image $(IMG) --name $(TEST_KIND_CLUSTER)
137-
kubectl create namespace bank-vaults-infra --dry-run=client -o yaml | kubectl apply -f -
138-
$(HELM) upgrade --install vault-secrets-reloader deploy/charts/vault-secrets-reloader \
139-
--set image.tag=dev \
140-
--set collectorSyncPeriod=30s \
141-
--set reloaderRunPeriod=1m \
142-
--namespace bank-vaults-infra
139+
deploy-kind: upload-kind deploy ## Deploy Reloder controller resources to the kind cluster
143140

144141
.PHONY: undeploy
145142
undeploy: ## Clean manager resources from the K8s cluster.
@@ -151,6 +148,7 @@ undeploy: ## Clean manager resources from the K8s cluster.
151148
GOLANGCI_VERSION = 1.53.3
152149
LICENSEI_VERSION = 0.8.0
153150
KIND_VERSION = 0.20.0
151+
KUBECTL_VERSION = 1.28.3
154152
HELM_DOCS_VERSION = 1.11.0
155153

156154
## Location to install dependencies to
@@ -166,17 +164,6 @@ GOLANGCI_LINT ?= $(or $(shell which golangci-lint),$(LOCALBIN)/golangci-lint)
166164
$(GOLANGCI_LINT): $(LOCALBIN)
167165
test -s $(LOCALBIN)/golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- v${GOLANGCI_VERSION}
168166

169-
LICENSEI ?= $(or $(shell which licensei),$(LOCALBIN)/licensei)
170-
$(LICENSEI): $(LOCALBIN)
171-
test -s $(LOCALBIN)/licensei || curl -sfL https://raw.githubusercontent.com/goph/licensei/master/install.sh | bash -s -- v${LICENSEI_VERSION}
172-
173-
KIND ?= $(or $(shell which kind),$(LOCALBIN)/kind)
174-
$(KIND): $(LOCALBIN)
175-
@if [ ! -s "$(LOCALBIN)/kind" ]; then \
176-
curl -Lo $(LOCALBIN)/kind https://kind.sigs.k8s.io/dl/v${KIND_VERSION}/kind-$(shell uname -s | tr '[:upper:]' '[:lower:]')-$(shell uname -m | sed -e "s/aarch64/arm64/; s/x86_64/amd64/"); \
177-
chmod +x $(LOCALBIN)/kind; \
178-
fi
179-
180167
HELM ?= $(or $(shell which helm),$(LOCALBIN)/helm)
181168
$(HELM): $(LOCALBIN)
182169
test -s $(LOCALBIN)/helm || curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | USE_SUDO=false HELM_INSTALL_DIR=$(LOCALBIN) bash
@@ -188,9 +175,27 @@ $(HELM_DOCS): $(LOCALBIN)
188175
chmod +x $(LOCALBIN)/helm-docs; \
189176
fi
190177

178+
KIND ?= $(or $(shell which kind),$(LOCALBIN)/kind)
179+
$(KIND): $(LOCALBIN)
180+
@if [ ! -s "$(LOCALBIN)/kind" ]; then \
181+
curl -Lo $(LOCALBIN)/kind https://kind.sigs.k8s.io/dl/v${KIND_VERSION}/kind-$(shell uname -s | tr '[:upper:]' '[:lower:]')-$(shell uname -m | sed -e "s/aarch64/arm64/; s/x86_64/amd64/"); \
182+
chmod +x $(LOCALBIN)/kind; \
183+
fi
184+
185+
KUBECTL ?= $(or $(shell which kubectl),$(LOCALBIN)/kubectl)
186+
$(KUBECTL): $(LOCALBIN)
187+
@if [ ! -s "$(LOCALBIN)/kubectl" ]; then \
188+
curl -Lo $(LOCALBIN)/kubectl https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/$(shell uname -s | tr '[:upper:]' '[:lower:]')/$(shell uname -m | sed -e "s/aarch64/arm64/; s/x86_64/amd64/")/kubectl; \
189+
chmod +x $(LOCALBIN)/kubectl; \
190+
fi
191+
192+
LICENSEI ?= $(or $(shell which licensei),$(LOCALBIN)/licensei)
193+
$(LICENSEI): $(LOCALBIN)
194+
test -s $(LOCALBIN)/licensei || curl -sfL https://raw.githubusercontent.com/goph/licensei/master/install.sh | bash -s -- v${LICENSEI_VERSION}
195+
191196
# TODO: add support for hadolint and yamllint dependencies
192197
HADOLINT ?= hadolint
193198
YAMLLINT ?= yamllint
194199

195200
.PHONY: deps
196-
deps: $(HELM) $(HELM_DOCS) $(ENVTEST) $(GOLANGCI_LINT) $(LICENSEI) $(KIND) ## Download and install dependencies
201+
deps: $(ENVTEST) $(GOLANGCI_LINT) $(HELM) $(HELM_DOCS) $(KIND) $(KUBECTL) $(LICENSEI) ## Download and install dependencies

0 commit comments

Comments
 (0)