diff --git a/.github/workflows/aro-hcp-dev-what-if.yml b/.github/workflows/aro-hcp-dev-what-if.yml index fcee54516..703d114b7 100644 --- a/.github/workflows/aro-hcp-dev-what-if.yml +++ b/.github/workflows/aro-hcp-dev-what-if.yml @@ -35,4 +35,5 @@ jobs: - name: 'Deployment What If' run: | - dev-infrastructure/make ${DEPLOY_ENV} what-if + cd dev-infrastructure/ + make what-if diff --git a/.github/workflows/cs-pr-what-if.yml b/.github/workflows/cs-pr-what-if.yml index fa38f3c08..0c073d04c 100644 --- a/.github/workflows/cs-pr-what-if.yml +++ b/.github/workflows/cs-pr-what-if.yml @@ -35,4 +35,5 @@ jobs: - name: 'Deployment What If' run: | - dev-infrastructure/make ${DEPLOY_ENV} what-if + cd dev-infrastructure/ + make what-if diff --git a/.github/workflows/dev-infrastructure.yml b/.github/workflows/dev-infrastructure.yml index 202e9de9e..2d52f2a5c 100644 --- a/.github/workflows/dev-infrastructure.yml +++ b/.github/workflows/dev-infrastructure.yml @@ -25,8 +25,8 @@ jobs: working-directory: './dev-infrastructure' run: | az bicep version - make -f Makefile.lint.mk fmt - make -f Makefile.lint.mk lint + make fmt + make lint - name: Check for uncommitted changes working-directory: './dev-infrastructure' diff --git a/Makefile b/Makefile index 6eb9570cc..e09b7c40b 100644 --- a/Makefile +++ b/Makefile @@ -30,31 +30,31 @@ fmt: $(GOIMPORTS) # infra.svc: - dev-infrastructure/make $(DEPLOY_ENV) svc.init + cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make svc.init infra.mgmt: - dev-infrastructure/make $(DEPLOY_ENV) mgmt.init + cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make mgmt.init infra.imagesync: - dev-infrastructure/make $(DEPLOY_ENV) imagesync + cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make imagesync infra.all: - dev-infrastructure/make $(DEPLOY_ENV) infra + cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make infra infra.svc.clean: - dev-infrastructure/make $(DEPLOY_ENV) svc.clean + cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) svc.clean infra.mgmt.clean: - dev-infrastructure/make $(DEPLOY_ENV) mgmt.clean + cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) mgmt.clean infra.region.clean: - dev-infrastructure/make $(DEPLOY_ENV) region.clean + cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) region.clean infra.imagesync.clean: - dev-infrastructure/make $(DEPLOY_ENV) imagesync.clean + cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) imagesync.clean infra.clean: - dev-infrastructure/make $(DEPLOY_ENV) clean + cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) clean # # Cluster Service @@ -112,4 +112,9 @@ deploy.mgmt.all: maestro.agent.deploy acm.deploy hypershift.deploy deploy.all: deploy.svc.all deploy.mgmt.all +list: + @grep '^[^#[:space:]].*:' Makefile +.PHONY: list + + .PHONY: all clean lint test fmt deploy.all deploy.svc.all deploy.mgmt.all acm.deploy hypershift.deploy rp.frontend.deploy rp.backend.deploy maestro.server.deploy maestro.agent.deploy maestro.registration.deploy maestro infra.svc infra.mgmt infra.imagesync infra.all infra.clean infra.region.clean infra.svc.clean infra.mgmt.clean diff --git a/dev-infrastructure/.gitignore b/dev-infrastructure/.gitignore index c388ebaaa..36806b6a7 100644 --- a/dev-infrastructure/.gitignore +++ b/dev-infrastructure/.gitignore @@ -1,4 +1,3 @@ -configurations/config.mk configurations/mgmt-cluster.bicepparam configurations/svc-cluster.bicepparam configurations/region.bicepparam @@ -7,3 +6,4 @@ configurations/acr-svc.bicepparam configurations/acr-ocp.bicepparam configurations/acr.bicepparam configurations/image-sync.bicepparam +config.mk diff --git a/dev-infrastructure/Makefile b/dev-infrastructure/Makefile index 33780cfde..6aba57096 100644 --- a/dev-infrastructure/Makefile +++ b/dev-infrastructure/Makefile @@ -1,7 +1,7 @@ SHELL = /bin/bash - -include configurations/config.mk -include Makefile.lint.mk +DEPLOY_ENV ?= personal-dev +$(shell ../templatize.sh $(DEPLOY_ENV) config.tmpl.mk config.mk) +include config.mk # Set SKIP_CONFIRM to a non-empty value to skip "what-if" confirmation prompts. ifndef SKIP_CONFIRM @@ -15,6 +15,24 @@ list: @grep '^[^#[:space:]].*:' Makefile .PHONY: list +fmt: + set -e; \ + FILES="$$(find . -type f -name "*.bicep*")"; \ + for file in $$FILES; do \ + echo "az bicep format --file $${file}"; \ + az bicep format --file $$file; \ + done +.PHONY: fmt + +lint: + set -e; \ + FILES="$$(find . -type f -name "*.bicep*")"; \ + for file in $$FILES; do \ + echo "az bicep lint --file $${file}"; \ + az bicep lint --file $$file; \ + done +.PHONY: lint + feature-registration: # hardcoded to eastus as this is a subscription deployment, not a resource group @az deployment sub create \ --name "feature-registration" \ diff --git a/dev-infrastructure/Makefile.lint.mk b/dev-infrastructure/Makefile.lint.mk deleted file mode 100644 index 97ed18694..000000000 --- a/dev-infrastructure/Makefile.lint.mk +++ /dev/null @@ -1,17 +0,0 @@ -fmt: - set -e; \ - FILES="$$(find . -type f \( -name "*.bicep" -o -name "*.bicepparam" \) ! -name "*.tmpl.bicepparam")"; \ - for file in $$FILES; do \ - echo "az bicep format --file $${file}"; \ - az bicep format --file $$file; \ - done -.PHONY: fmt - -lint: - set -e; \ - FILES="$$(find . -type f \( -name "*.bicep" -o -name "*.bicepparam" \) ! -name "*.tmpl.bicepparam")"; \ - for file in $$FILES; do \ - echo "az bicep lint --file $${file}"; \ - az bicep lint --file $$file; \ - done -.PHONY: lint diff --git a/dev-infrastructure/configurations/config.tmpl.mk b/dev-infrastructure/config.tmpl.mk similarity index 100% rename from dev-infrastructure/configurations/config.tmpl.mk rename to dev-infrastructure/config.tmpl.mk diff --git a/dev-infrastructure/docs/development-setup.md b/dev-infrastructure/docs/development-setup.md index 0161c50a1..655ae2080 100644 --- a/dev-infrastructure/docs/development-setup.md +++ b/dev-infrastructure/docs/development-setup.md @@ -93,9 +93,9 @@ Please not that these kubeconfig files require an active Azure CLI session (`az If you loose these files, you can recreate them by running ```bash - dev-infrastructure/make svc.aks.admin-access svc.aks.kubeconfig + make -f dev-infrastructure/Makefile svc.aks.admin-access svc.aks.kubeconfig or - dev-infrastructure/make mgmt.aks.admin-access mgmt.aks.kubeconfig + make -f dev-infrastructure/Makefile mgmt.aks.admin-access mgmt.aks.kubeconfig ``` > Freshly granted cluster admin permissions might not be effective immediately. If you get permission denied errors on your `kubectl` commands, consider waiting a couple of minutes for the permissons to be propagated diff --git a/dev-infrastructure/make b/dev-infrastructure/make deleted file mode 100755 index 96d767053..000000000 --- a/dev-infrastructure/make +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -e - -DEPLOY_ENV=$1 -cd $(dirname "$(realpath "${BASH_SOURCE[0]}")") -for tmpl_file in configurations/*.tmpl.*; do - output_file="${tmpl_file/.tmpl/}" - ../templatize.sh "$DEPLOY_ENV" "$tmpl_file" "$output_file" -done - -make "${@:2}" diff --git a/tooling/templatize/internal/config/config.go b/tooling/templatize/internal/config/config.go index 43e760658..d7004c6e3 100644 --- a/tooling/templatize/internal/config/config.go +++ b/tooling/templatize/internal/config/config.go @@ -2,6 +2,7 @@ package config import ( "bytes" + "fmt" "os" "text/template" @@ -47,6 +48,8 @@ func (cp *configProviderImpl) GetVariables(cloud, deployEnv string) (Variables, variables[k] = v } } + } else { + return nil, fmt.Errorf("the deployment env %s is not found under cloud %s in %s", deployEnv, cloud, cp.config) } } }