Skip to content

Commit b6383d3

Browse files
committed
templatize only Makefile include not makefile itself
Signed-off-by: Gerd Oberlechner <[email protected]>
1 parent 3830101 commit b6383d3

14 files changed

+97
-106
lines changed

backend/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Makefile
1+
config.mk

backend/Makefile.tmpl.mk backend/Makefile

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
SHELL = /bin/bash
2+
DEPLOY_ENV ?= personal-dev
3+
4+
$(shell ../templatize.sh $(DEPLOY_ENV) config.tmpl.mk config.mk)
5+
6+
include config.mk
27

38
COMMIT = $(shell git rev-parse --short=7 HEAD)
4-
ARO_HCP_BASE_IMAGE ?= {{ .acrName }}.azurecr.io
9+
ARO_HCP_BASE_IMAGE ?= ${ARO_HCP_IMAGE_ACR}.azurecr.io
510
ARO_HCP_BACKEND_IMAGE ?= $(ARO_HCP_BASE_IMAGE)/arohcpbackend:$(COMMIT)
611

712
backend:
813
go build -o aro-hcp-backend .
914

1015
run:
11-
./aro-hcp-backend --location {{ .region }} \
16+
./aro-hcp-backend --location ${LOCATION} \
1217
--clusters-service-url http://localhost:8000
1318

1419
clean:
@@ -24,20 +29,20 @@ push: image
2429

2530
deploy:
2631
BACKEND_MI_CLIENT_ID=$(shell az identity show \
27-
-g {{ .serviceClusterRG }} \
32+
-g ${RESOURCEGROUP} \
2833
-n backend \
2934
--query clientId);\
30-
ISTO_VERSION=$(shell az aks show -n {{ .aksName }} -g {{ .serviceClusterRG }} --query serviceMeshProfile.istio.revisions[-1] -o tsv) && \
35+
ISTO_VERSION=$(shell az aks show -n ${AKS_NAME} -g ${RESOURCEGROUP} --query serviceMeshProfile.istio.revisions[-1] -o tsv) && \
3136
kubectl create namespace aro-hcp --dry-run=client -o json | kubectl apply -f - && \
3237
kubectl label namespace aro-hcp "istio.io/rev=$${ISTO_VERSION}" --overwrite=true && \
3338
helm upgrade --install aro-hcp-backend-dev \
3439
deploy/helm/backend/ \
35-
--set configMap.databaseName={{ .frontendCosmosDBName }} \
36-
--set configMap.databaseUrl="https://{{ .frontendCosmosDBName }}.documents.azure.com:443/" \
40+
--set configMap.databaseName=${DB_NAME} \
41+
--set configMap.databaseUrl="https://${DB_NAME}.documents.azure.com:443/" \
3742
--set configMap.backendMiClientId="$${BACKEND_MI_CLIENT_ID}" \
3843
--set serviceAccount.workloadIdentityClientId="$${BACKEND_MI_CLIENT_ID}" \
3944
--set configMap.currentVersion=${ARO_HCP_BACKEND_IMAGE} \
40-
--set configMap.location={{ .region }} \
45+
--set configMap.location=${LOCATION} \
4146
--set deployment.imageName=${ARO_HCP_BACKEND_IMAGE} \
4247
--namespace aro-hcp
4348

backend/README.md

-11
This file was deleted.

backend/config.tmpl.mk

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ARO_HCP_IMAGE_ACR ?= {{ .acrName }}
2+
LOCATION ?= {{ .region }}
3+
RESOURCEGROUP ?= {{ .serviceClusterRG }}
4+
AKS_NAME ?= {{ .aksName }}
5+
DB_NAME ?= {{ .frontendCosmosDBName }}

backend/generate-makefile.sh

-12
This file was deleted.

cluster-service/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
deploy/tmp-provisioning-shard.yml
2-
Makefile
2+
config.mk

cluster-service/Makefile

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
SHELL = /bin/bash
2+
DEPLOY_ENV ?= personal-dev
3+
4+
$(shell ../templatize.sh $(DEPLOY_ENV) config.tmpl.mk config.mk)
5+
6+
include config.mk
7+
8+
TENANT_ID=$(shell az account show --query tenantId --output tsv)
9+
ZONE_RESOURCE_ID ?= $(shell az network dns zone show -n ${DNS_ZONE_NAME} -g ${REGIONAL_RESOURCEGROUP} --query id -o tsv)
10+
11+
deploy:
12+
sed -e "s#ZONE_RESOURCE_ID#${ZONE_RESOURCE_ID}#g" -e "s/REGION/${REGION}/g" -e "s/CONSUMER_NAME/${CONSUMER_NAME}/g" deploy/mvp-provisioning-shards.yml > deploy/tmp-provisioning-shard.yml
13+
14+
ISTO_VERSION=$(shell az aks show -n ${AKS_NAME} -g ${RESOURCEGROUP} --query serviceMeshProfile.istio.revisions[-1] -o tsv) && \
15+
oc process --local -f deploy/openshift-templates/arohcp-namespace-template.yml \
16+
-p ISTIO_VERSION=$${ISTO_VERSION} | oc apply -f -
17+
kubectl apply -f deploy/istio.yml
18+
19+
oc process --local -f deploy/openshift-templates/arohcp-db-template.yml | oc apply -f -
20+
oc process --local -f deploy/openshift-templates/arohcp-secrets-template.yml \
21+
-p PROVISION_SHARDS_CONFIG="$$( base64 -i deploy/tmp-provisioning-shard.yml)" | oc apply -f -
22+
23+
CS_MI_CLIENT_ID=$(shell az identity show -g ${RESOURCEGROUP} -n clusters-service --query clientId -o tsv) && \
24+
CS_SERVICE_PRINCIPAL_CREDS_BASE64='$(shell az keyvault secret show --vault-name "${SERVICE_KV}" --name "aro-hcp-dev-sp-cs" | jq .value -r | base64 | tr -d '\n')' && \
25+
OIDC_BLOB_SERVICE_ENDPOINT=$(shell az storage account show -n ${OIDC_STORAGE_ACCOUNT} -g ${RESOURCEGROUP} --query primaryEndpoints.blob -o tsv) && \
26+
OIDC_WEB_SERVICE_ENDPOINT=$(shell az storage account show -n ${OIDC_STORAGE_ACCOUNT} -g ${RESOURCEGROUP} --query primaryEndpoints.web -o tsv) && \
27+
oc process --local -f deploy/openshift-templates/arohcp-service-template.yml \
28+
-p AZURE_CS_MI_CLIENT_ID=$${CS_MI_CLIENT_ID} \
29+
-p TENANT_ID=${TENANT_ID} \
30+
-p REGION=${REGION} \
31+
-p SERVICE_KEYVAULT_NAME=${SERVICE_KV} \
32+
-p CS_SERVICE_PRINCIPAL_CREDS_BASE64=$${CS_SERVICE_PRINCIPAL_CREDS_BASE64} \
33+
-p IMAGE_REGISTRY=${ACR_NAME}.azurecr.io \
34+
-p IMAGE_REPOSITORY=${IMAGE_REPO} \
35+
-p AZURE_FIRST_PARTY_APPLICATION_CLIENT_ID=${FPA_CLIENT_ID} \
36+
-p FPA_CERT_NAME=${FPA_CERT_NAME} \
37+
-p IMAGE_TAG=${IMAGE_TAG} | oc apply -f -
38+
39+
deploy-pr-env-deps:
40+
oc process --local -f deploy/integration/cluster-service-namespace.yaml \
41+
-p CLIENT_ID=${CS_MI_CLIENT_ID} | oc apply -f -
42+
43+
# for local development
44+
provision-shard:
45+
sed -e "s#ZONE_RESOURCE_ID#${ZONE_RESOURCE_ID}#g" -e "s/REGION/${REGION}/g" -e "s/CONSUMER_NAME/${CONSUMER_NAME}/g" deploy/dev-provisioning-shards.yml
46+
47+
.PHONY: deploy deploy-integ provision-shard

cluster-service/Makefile.tmpl.mk

-44
This file was deleted.

cluster-service/config.tmpl.mk

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
REGION ?= {{ .region }}
2+
CONSUMER_NAME ?= {{ .maestroConsumerName }}
3+
RESOURCEGROUP ?= {{ .serviceClusterRG }}
4+
REGIONAL_RESOURCEGROUP ?= {{ .regionRG }}
5+
AKS_NAME ?= {{ .aksName }}
6+
SERVICE_KV ?= {{ .serviceKeyVaultName }}
7+
OIDC_STORAGE_ACCOUNT ?= {{ .oidcStorageAccountName }}
8+
IMAGE_REPO ?= {{ .clusterServiceImageRepo }}
9+
IMAGE_TAG ?= {{ .clusterServiceImageTag }}
10+
ACR_NAME ?= {{ .acrName }}
11+
FPA_CLIENT_ID ?= {{ .firstPartyAppClientId }}
12+
DNS_ZONE_NAME ?= {{ .regionalDNSSubdomain }}.{{ .baseDnsZoneName }}
13+
FPA_CERT_NAME ?= firstPartyCert

frontend/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Makefile
1+
config.mk

frontend/Makefile.tmpl.mk frontend/Makefile

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
SHELL = /bin/bash
2+
DEPLOY_ENV ?= personal-dev
3+
4+
$(shell ../templatize.sh $(DEPLOY_ENV) config.tmpl.mk config.mk)
5+
6+
include config.mk
27

38
COMMIT = $(shell git rev-parse --short=7 HEAD)
4-
ARO_HCP_BASE_IMAGE ?= {{ .acrName }}.azurecr.io
9+
ARO_HCP_BASE_IMAGE ?= ${ARO_HCP_IMAGE_ACR}.azurecr.io
510
ARO_HCP_FRONTEND_IMAGE ?= $(ARO_HCP_BASE_IMAGE)/arohcpfrontend:$(COMMIT)
611

712
frontend:
813
go build -o aro-hcp-frontend .
914

1015
run:
11-
./aro-hcp-frontend --use-cache --location {{ .region }} \
16+
./aro-hcp-frontend --use-cache --location ${LOCATION} \
1217
--clusters-service-url http://localhost:8000 \
1318
--cluster-service-provision-shard 1 \
1419
--cluster-service-noop-provision \
@@ -29,20 +34,20 @@ push: image
2934

3035
deploy:
3136
FRONTEND_MI_CLIENT_ID=$(shell az identity show \
32-
-g {{ .serviceClusterRG }} \
37+
-g ${RESOURCEGROUP} \
3338
-n frontend \
3439
--query clientId);\
35-
ISTO_VERSION=$(shell az aks show -n {{ .aksName }} -g {{ .serviceClusterRG }} --query serviceMeshProfile.istio.revisions[-1] -o tsv) && \
40+
ISTO_VERSION=$(shell az aks show -n ${AKS_NAME} -g ${RESOURCEGROUP} --query serviceMeshProfile.istio.revisions[-1] -o tsv) && \
3641
kubectl create namespace aro-hcp --dry-run=client -o json | kubectl apply -f - && \
3742
kubectl label namespace aro-hcp "istio.io/rev=$${ISTO_VERSION}" --overwrite=true && \
3843
helm upgrade --install aro-hcp-frontend-dev \
3944
deploy/helm/frontend/ \
40-
--set configMap.databaseName={{ .frontendCosmosDBName }} \
41-
--set configMap.databaseUrl="https://{{ .frontendCosmosDBName }}.documents.azure.com:443/" \
45+
--set configMap.databaseName=${DB_NAME} \
46+
--set configMap.databaseUrl="https://${DB_NAME}.documents.azure.com:443/" \
4247
--set configMap.frontendMiClientId="$${FRONTEND_MI_CLIENT_ID}" \
4348
--set serviceAccount.workloadIdentityClientId="$${FRONTEND_MI_CLIENT_ID}" \
4449
--set configMap.currentVersion=${ARO_HCP_FRONTEND_IMAGE} \
45-
--set configMap.location={{ .region }} \
50+
--set configMap.location=${LOCATION} \
4651
--set deployment.imageName=${ARO_HCP_FRONTEND_IMAGE} \
4752
--namespace aro-hcp
4853

frontend/README.md

-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
# ARO-HCP-FRONTEND
22

3-
## Prerequisite
4-
5-
The `Makefile` is templated based on the ARO HCP environment to interact with.
6-
7-
Run the following command to generate a `Makefile` for personal development.
8-
9-
```bash
10-
./generate-makefile.sh personal-dev
11-
```
12-
133
## Build frontend binary for local testing
144
```
155
make frontend

frontend/config.tmpl.mk

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ARO_HCP_IMAGE_ACR ?= {{ .acrName }}
2+
LOCATION ?= {{ .region }}
3+
RESOURCEGROUP ?= {{ .serviceClusterRG }}
4+
AKS_NAME ?= {{ .aksName }}
5+
DB_NAME ?= {{ .frontendCosmosDBName }}

frontend/generate-makefile.sh

-12
This file was deleted.

0 commit comments

Comments
 (0)