diff --git a/.gitignore b/.gitignore index 8b720626..06628693 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ testbin/* *~ testdata/.remediators/ .history/* +.tools/ diff --git a/Makefile b/Makefile index 354942b2..fc7a3c8d 100644 --- a/Makefile +++ b/Makefile @@ -540,3 +540,22 @@ container-push: ## Push containers (NOTE: catalog can't be build before bundle .PHONY: build-and-run build-and-run: container-build-ocp container-push bundle-run + +# Shared dev environment +# Uses a local sibling checkout if available (e.g. ../tools), +# otherwise downloads the tools repo into .tools/ on first dev-* target use. +TOOLS_DIR ?= $(shell cd .. && pwd)/tools +DEV_MK := $(TOOLS_DIR)/dev/dev.mk +ifeq ($(wildcard $(DEV_MK)),) + TOOLS_DIR := $(shell pwd)/.tools + DEV_MK := $(TOOLS_DIR)/dev/dev.mk +endif +-include $(DEV_MK) +ifeq ($(wildcard $(DEV_MK)),) +dev-%: + @echo "Downloading medik8s/tools into $(TOOLS_DIR)..." + @if [ -d $(TOOLS_DIR) ]; then echo " Removing stale $(TOOLS_DIR)..."; rm -rf $(TOOLS_DIR); fi + @git clone --depth 1 https://github.com/medik8s/tools.git $(TOOLS_DIR) + @test -f $(DEV_MK) || { echo "Error: $(DEV_MK) not found after clone."; exit 1; } + @$(MAKE) $@ +endif