Skip to content

Commit b30eb4a

Browse files
bentitogrokspawn
andauthored
🐛 Check cluster is running for non-standalone Make targets (#437)
* Check Kind running for non-standalong Make targets Signed-off-by: Brett Tofel <[email protected]> * improve test-e2e comment Co-authored-by: Jordan Keister <[email protected]> * improve install comment Co-authored-by: Jordan Keister <[email protected]> * Change to generic check for cluster Signed-off-by: Brett Tofel <[email protected]> * Error on non-running cluster suggests what to do Signed-off-by: Brett Tofel <[email protected]> --------- Signed-off-by: Brett Tofel <[email protected]> Co-authored-by: Jordan Keister <[email protected]>
1 parent 4d6327f commit b30eb4a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Makefile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ FOCUS := $(if $(TEST),-v -focus "$(TEST)")
102102
ifeq ($(origin E2E_FLAGS), undefined)
103103
E2E_FLAGS :=
104104
endif
105-
test-e2e: $(GINKGO) ## Run the e2e tests
105+
test-e2e: check-cluster $(GINKGO) ## Run the e2e tests on existing cluster
106106
$(GINKGO) $(E2E_FLAGS) -trace -vv $(FOCUS) test/e2e
107107

108108
e2e: KIND_CLUSTER_NAME := catalogd-e2e
@@ -214,12 +214,12 @@ kind-cluster-cleanup: $(KIND) ## Delete the kind cluster
214214
$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)
215215

216216
.PHONY: kind-load
217-
kind-load: $(KIND) ## Load the built images onto the local cluster
217+
kind-load: check-cluster $(KIND) ## Load the built images onto the local cluster
218218
$(KIND) export kubeconfig --name $(KIND_CLUSTER_NAME)
219219
$(KIND) load docker-image $(IMAGE) --name $(KIND_CLUSTER_NAME)
220220

221221
.PHONY: install
222-
install: build-container kind-load deploy wait ## Install local catalogd
222+
install: check-cluster build-container kind-load deploy wait ## Install local catalogd to an existing cluster
223223

224224
.PHONY: deploy
225225
deploy: export MANIFEST="./catalogd.yaml"
@@ -229,7 +229,7 @@ deploy: $(KUSTOMIZE) ## Deploy Catalogd to the K8s cluster specified in ~/.kube/
229229
$(KUSTOMIZE) build $(KUSTOMIZE_OVERLAY) | sed "s/cert-git-version/cert-$(GIT_VERSION)/g" > catalogd.yaml
230230
envsubst '$$CERT_MGR_VERSION,$$MANIFEST,$$DEFAULT_CATALOGS' < scripts/install.tpl.sh | bash -s
231231

232-
.PHONY: only-deploy-manifest
232+
.PHONY: check-cluster only-deploy-manifest
233233
only-deploy-manifest: $(KUSTOMIZE) ## Deploy just the Catalogd manifest--used in e2e testing where cert-manager is installed in a separate step
234234
cd config/base/manager && $(KUSTOMIZE) edit set image controller=$(IMAGE)
235235
$(KUSTOMIZE) build $(KUSTOMIZE_OVERLAY) | kubectl apply -f -
@@ -267,3 +267,10 @@ quickstart: $(KUSTOMIZE) generate ## Generate the installation release manifests
267267
.PHONY: demo-update
268268
demo-update:
269269
hack/scripts/generate-asciidemo.sh
270+
271+
.PHONY: check-cluster
272+
check-cluster:
273+
if ! kubectl config current-context >/dev/null 2>&1; then \
274+
echo "Error: Could not get current Kubernetes context. Maybe use 'run' or 'e2e' targets first?"; \
275+
exit 1; \
276+
fi

0 commit comments

Comments
 (0)