-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathMakefile
160 lines (126 loc) · 5.12 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
include ./.bingo/Variables.mk
SHELL = /bin/bash
# This build tag is currently leveraged by tooling/image-sync
# https://github.com/containers/image?tab=readme-ov-file#building
GOTAGS?='containers_image_openpgp'
TOOLS_BIN_DIR := tooling/bin
DEPLOY_ENV ?= personal-dev
.DEFAULT_GOAL := all
all: test lint
.PHONY: all
# There is currently no convenient way to run tests against a whole Go workspace
# https://github.com/golang/go/issues/50745
test:
go list -f '{{.Dir}}/...' -m |RUN_TEMPLATIZE_E2E=true xargs go test -timeout 1200s -tags=$(GOTAGS) -cover
.PHONY: test
mocks: install-tools
MOCKGEN=${MOCKGEN} go generate ./internal/mocks
.PHONY: mocks
install-tools: $(BINGO)
$(BINGO) get
.PHONY: install-tools
# There is currently no convenient way to run golangci-lint against a whole Go workspace
# https://github.com/golang/go/issues/50745
MODULES := $(shell go list -f '{{.Dir}}/...' -m | xargs)
lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run -v --build-tags=$(GOTAGS) $(MODULES)
.PHONY: lint
fmt: $(GOIMPORTS)
$(GOIMPORTS) -w -local github.com/Azure/ARO-HCP $(shell go list -f '{{.Dir}}' -m | xargs)
.PHONY: fmt
#
# Infra
#
infra.region:
@cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make region
.PHONY: infra.region
infra.svc:
@cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make svc.init
.PHONY: infra.svc
infra.svc.aks.kubeconfigfile:
@cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make -s svc.aks.kubeconfigfile
.PHONY: infra.svc.aks.kubeconfigfile
infra.mgmt:
@cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make mgmt.init
.PHONY: infra.mgmt
infra.mgmt.aks.kubeconfigfile:
@cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make -s mgmt.aks.kubeconfigfile
.PHONY: infra.mgmt.aks.kubeconfigfile
infra.imagesync:
@cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make imagesync
.PHONY: infra.imagesync
infra.all:
@cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make infra
.PHONY: infra.all
infra.svc.clean:
@cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make svc.clean
.PHONY: infra.svc.clean
infra.mgmt.clean:
@cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make mgmt.clean
.PHONY: infra.mgmt.clean
infra.region.clean:
@cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make region.clean
.PHONY: infra.region.clean
infra.imagesync.clean:
@cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make imagesync.clean
.PHONY: infra.imagesync.clean
infra.clean:
@cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make clean
.PHONY: infra.clean
#
# Services
#
# Service Deployment Conventions:
#
# - Services are deployed in aks clusters (either svc or mgmt), which are
# provisioned via infra section above
# - Makefile targets to deploy services ends with ".deploy" suffix
# - To deploy all services on svc or mgmt cluster, we have special targets
# `svc.deployall` and `mgmt.deployall`, and `deployall` deploys everithing.
# - Placement of a service is controlled via services_svc and services_mgmt
# variables
# - If the name of the service contains a dot, it's interpreted as directory
# separator "/" (used for maestro only).
# Services deployed on "svc" aks cluster
services_svc = maestro.registration
# Services deployed on "mgmt" aks cluster(s)
services_mgmt =
# List of all services
services_all = $(join services_svc,services_mgmt)
.PHONY: $(addsuffix .deploy, $(services_all)) deployall svc.deployall mgmt.deployall listall list clean
# Service deployment on either svc or mgmt aks cluster, a service name
# needs to be listed either in services_svc or services_mgmt variable (wich
# defines where it will be deployed).
%.deploy:
$(eval export dirname=$(subst .,/,$(basename $@)))
@if [ $(words $(filter $(basename $@), $(services_svc))) = 1 ]; then\
./svc-deploy.sh $(DEPLOY_ENV) $(dirname) svc;\
elif [ $(words $(filter $(basename $@), $(services_mgmt))) = 1 ]; then\
./svc-deploy.sh $(DEPLOY_ENV) $(dirname) mgmt;\
else\
echo "'$(basename $@)' is not to be deployed on neither svc nor mgmt cluster";\
exit 1;\
fi
# Pipelines section
# This sections is used to reference pipeline runs and should replace
# the usage of `svc-deploy.sh` script in the future.
services_svc_pipelines = istio acrpull metrics backend frontend cluster-service maestro.server
services_mgmt_pipelines = hypershiftoperator maestro.agent acm
%.deploy_pipeline:
$(eval export dirname=$(subst .,/,$(basename $@)))
./templatize.sh $(DEPLOY_ENV) -p ./$(dirname)/pipeline.yaml -s deploy -P run -c public
%.dry_run:
$(eval export dirname=$(subst .,/,$(basename $@)))
./templatize.sh $(DEPLOY_ENV) -p ./$(dirname)/pipeline.yaml -s deploy -P run -c public -d
svc.deployall: $(addsuffix .deploy_pipeline, $(services_svc_pipelines)) $(addsuffix .deploy, $(services_svc))
mgmt.deployall: $(addsuffix .deploy, $(services_mgmt)) $(addsuffix .deploy_pipeline, $(services_mgmt_pipelines))
deployall: svc.deployall mgmt.deployall
acrpull.mgmt.deploy:
./templatize.sh $(DEPLOY_ENV) -p ./acrpull/pipeline.yaml -s deploy-mgmt -P run -c public
acrpull.mgmt.dry_run:
./templatize.sh $(DEPLOY_ENV) -p ./acrpull/pipeline.yaml -s deploy-mgmt -P run -c public -d
listall:
@echo svc: ${services_svc}
@echo mgmt: ${services_mgmt}
list:
@grep '^[^#[:space:]].*:' Makefile