From b30ce04ace904fd784b3648d47bc7cceec2f3bfe Mon Sep 17 00:00:00 2001 From: Simon Emms Date: Wed, 21 Aug 2024 13:17:25 +0000 Subject: [PATCH] feat: generate the repository This is not a production system, but a useful way to allow gitops-templates developer to check the files that are generated. --- .gitignore | 3 ++- Makefile | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1763e7908..b585f7940 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ .vscode .DS_Store deprecated-* -kubeconfig-* \ No newline at end of file +kubeconfig-* +tmp diff --git a/Makefile b/Makefile index 9b64c4520..5cf106c34 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +CLOUD_PROVIDER ?= +VCS_PROVIDER ?= + default: help .PHONY: help @@ -15,3 +18,27 @@ validate: ## terraform validate terraform -chdir=$$dir init -backend=false || exit 1; \ terraform -chdir=$$dir validate || exit 1; \ done + +.PHONY: generate +generate: + @rm -Rf tmp + @mkdir tmp + +ifeq ($(CLOUD_PROVIDER), ) + @echo "CLOUD_PROVIDER envvar must be set" + @exit 1 +endif + +ifeq ($(VCS_PROVIDER), ) + @echo "VCS_PROVIDER envvar must be set" + @exit 1 +endif + + @if ! test -d common/cloud/${CLOUD_PROVIDER}; then echo "Cannot find directory: common/cloud/${CLOUD_PROVIDER}" && exit 1; fi + @if ! test -d common/vcs/${VCS_PROVIDER}; then echo "Cannot find directory: common/vcs/${VCS_PROVIDER}" && exit 1; fi + @if ! test -d templates/${CLOUD_PROVIDER}-${VCS_PROVIDER}; then echo "Cannot find directory: templates/${CLOUD_PROVIDER}-${VCS_PROVIDER}" && exit 1; fi + + @cp -r common/templates/* tmp + @cp -r common/cloud/${CLOUD_PROVIDER}/* tmp + @cp -r common/vcs/${VCS_PROVIDER}/* tmp + @cp -r templates/${CLOUD_PROVIDER}-${VCS_PROVIDER}/* tmp