OPENSHIFT_4_AWS_GITHUB_USER ?= $(GITHUB_USER)
OPENSHIFT_4_AWS_GITHUB_TOKEN ?= $(GITHUB_TOKEN)
OPENSHIFT_4_AWS_GIT_TF_DEPLOY_PROJECT ?= "https://$(OPENSHIFT_4_AWS_GITHUB_USER):$(OPENSHIFT_4_AWS_GITHUB_TOKEN)@github.com/open-cluster-management/tf_openshift_4.git"
OPENSHIFT_4_AWS_GIT_TF_DEPLOY_BRANCH ?= master
OPENSHIFT_4_AWS_DEPLOY_DIR ?= .deploy-openshift4-aws/
OPENSHIFT_4_AWS_TERRAFORM_VARS_FILE ?= .deploy-openshift4-aws.tfvars
OPENSHIFT_4_AWS_TERRAFORM_VERSION ?= 0.12.18

.PHONY: deploy/openshift4/aws
## Deploy openshift on aws
deploy/openshift4/aws:
	@$(GIT) clone -b $(OPENSHIFT_4_AWS_GIT_TF_DEPLOY_BRANCH) $(OPENSHIFT_4_AWS_GIT_TF_DEPLOY_PROJECT) $(OPENSHIFT_4_AWS_DEPLOY_DIR)
	@$(SELF) terraform:apply TERRAFORM_VARS_FILE=$(OPENSHIFT_4_AWS_TERRAFORM_VARS_FILE) TERRAFORM_DIR=$(OPENSHIFT_4_AWS_DEPLOY_DIR)/aws-ipi TERRAFORM_VER=$(OPENSHIFT_4_AWS_TERRAFORM_VERSION)

.PHONY: deploy/openshift4/aws/destroy
## Destroy openshift on aws deployment resources
deploy/openshift4/aws/destroy: %destroy:
	@$(SELF) terraform:destroy TERRAFORM_VARS_FILE=$(OPENSHIFT_4_AWS_TERRAFORM_VARS_FILE) TERRAFORM_DIR=$(OPENSHIFT_4_AWS_DEPLOY_DIR)/aws-ipi TERRAFORM_VER=$(OPENSHIFT_4_AWS_TERRAFORM_VERSION)

.PHONY: deploy/openshift4/aws/clean
## Clean up all openshift on aws deployment resources
deploy/openshift4/aws/clean: %clean: %destroy
ifeq ($(shell test -d $(OPENSHIFT_4_AWS_DEPLOY_DIR) && echo -n yes),yes)
	@rm -rf $(OPENSHIFT_4_AWS_DEPLOY_DIR)
endif
