.DEFAULT_GOAL := help

include utils/*.mk

.PHONY: check-machine
check-machine: ## Check your local machine setup to be prepared for the installation
	command -v kubectl >/dev/null
	command -v ansible >/dev/null
	command -v flux >/dev/null
	command -v sops >/dev/null
	command -v terraform >/dev/null

.PHONY: cli
cli: ## Install koolbox CLI (Contains all tools used in this project)
	cd ./cli && make install

.PHONY: cli-config
cli-config: ## Configure koolbox CLI (To setup terraform values as well was tokens)
	cd ./cli && make config

.PHONY: deploy
deploy: check-machine ## Deploy infrastructure on Hetzner Cloud
	cd ./terraform && make apply
	date
	sleep 300
	make kubernetes-install

.PHONY: destroy
destroy: check-machine ## Destroy infrastructure on Hetzner Cloud
	cd ./terraform && make destroy
	for i in cp0{1..3}.$(TF_VAR_dns_domain); do ssh-keygen -R "$$i"; done