This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
/
Makefile
319 lines (264 loc) · 9.3 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# Set up a system-agnostic in-place sed command
IS_GNU_SED = $(shell sed --version 1>/dev/null 2>&1 && echo true || echo false)
PLUGINS ?= teleport-event-handler \
teleport-discord \
teleport-jira \
teleport-mattermost \
teleport-msteams \
teleport-slack \
teleport-pagerduty \
teleport-email \
terraform-provider-teleport
ifeq ($(IS_GNU_SED),true)
SED = sed -i
else
SED = sed -i ''
endif
.PHONY: access-slack
access-slack:
$(MAKE) -C access/slack
.PHONY: access-discord
access-discord:
$(MAKE) -C access/discord
.PHONY: access-jira
access-jira:
$(MAKE) -C access/jira
.PHONY: access-mattermost
access-mattermost:
$(MAKE) -C access/mattermost
.PHONY: access-msteams
access-msteams:
$(MAKE) -C access/msteams
.PHONY: access-pagerduty
access-pagerduty:
$(MAKE) -C access/pagerduty
.PHONY: access-email
access-email:
$(MAKE) -C access/email
# Build specific access plugin with docker
.PHONY: docker-build-access-%
docker-build-access-%:
$(MAKE) -C access/$* docker-build
# Build all access plugins with docker
.PHONY: docker-build-access-plugins
docker-build-access-plugins: docker-build-access-email \
docker-build-access-discord \
docker-build-access-jira \
docker-build-access-mattermost \
docker-build-access-msteams \
docker-build-access-pagerduty \
docker-build-access-slack
# Push specific access plugin with docker to ECR
.PHONY: docker-push-access-%
docker-push-access-%: docker-build-access-%
$(MAKE) -C access/$* docker-push
# Push all access plugins with docker to ECR
.PHONY: docker-push-access-all
docker-push-access-all: docker-push-access-email \
docker-push-access-discord \
docker-push-access-jira \
docker-push-access-mattermost \
docker-push-access-msteams \
docker-push-access-pagerduty \
docker-push-access-slack
# Pulls and pushes image from ECR to ECR-public.
.PHONY: docker-promote
docker-promote: docker-promote-event-handler \
docker-promote-access-discord \
docker-promote-access-jira \
docker-promote-access-mattermost \
docker-promote-access-msteams \
docker-promote-access-pagerduty \
docker-promote-access-slack \
docker-promote-access-email
.PHONY: docker-promote-access-%
docker-promote-access-%:
$(MAKE) -C access/$* docker-promote
# Build event-handler plugin with docker
.PHONY: docker-build-event-handler
docker-build-event-handler:
$(MAKE) -C event-handler docker-build
.PHONY: docker-push-event-handler
docker-push-event-handler: docker-build-event-handler
$(MAKE) -C event-handler docker-push
.PHONY: docker-promote-event-handler
docker-promote-event-handler:
$(MAKE) -C event-handler docker-promote
.PHONY: helm-package-charts
helm-package-charts:
mkdir -p packages
helm package -d packages charts/access/email
helm package -d packages charts/access/discord
helm package -d packages charts/access/jira
helm package -d packages charts/access/slack
helm package -d packages charts/access/pagerduty
helm package -d packages charts/access/mattermost
helm package -d packages charts/access/msteams
helm package -d packages charts/event-handler
.PHONY: terraform
terraform:
$(MAKE) -C terraform
.PHONY: terraform-gen-tfschema
terraform-gen-tfschema:
$(MAKE) -C terraform gen-tfschema
.PHONY: test-terraform
test-terraform:
$(MAKE) -C terraform test
.PHONY: event-handler
event-handler:
$(MAKE) -C event-handler
# Run all tests
.PHONY: test
test: test-tooling test-unit test-terraform
@echo Testing plugins against Teleport $(shell teleport version)
go test -race -count 1 $(shell go list ./... | grep -v -e '/terraform/' -e '/tooling/' -e '/lib')
.PHONY: test-tooling
test-tooling:
(cd tooling; go test -v -race ./...)
.PHONY: test-unit
test-unit: test-tooling test-access test-event-handler
.PHONY: test-access
test-access:
(cd access; go test -v -race ./...)
.PHONY: test-event-handler
test-event-handler:
(cd event-handler; go test -v -race ./...)
# Individual releases
.PHONY: release/access-slack
release/access-slack:
$(MAKE) -C access/slack release
.PHONY: release/access-discord
release/access-discord:
$(MAKE) -C access/discord release
.PHONY: release/access-jira
release/access-jira:
$(MAKE) -C access/jira release
.PHONY: release/access-mattermost
release/access-mattermost:
$(MAKE) -C access/mattermost release
.PHONY: release/access-msteams
release/access-msteams:
$(MAKE) -C access/msteams release
.PHONY: release/access-pagerduty
release/access-pagerduty:
$(MAKE) -C access/pagerduty release
.PHONY: release/access-email
release/access-email:
$(MAKE) -C access/email release
.PHONY: release/terraform
release/terraform:
$(MAKE) -C terraform release
.PHONY: release/event-handler
release/event-handler:
$(MAKE) -C event-handler release
# Run all releases
.PHONY: releases
releases: release/access-slack release/access-discord release/access-jira release/access-mattermost release/access-msteams release/access-pagerduty release/access-email
.PHONY: build-all
build-all: access-slack access-discord access-jira access-mattermost access-msteams access-pagerduty access-email terraform event-handler
.PHONY: update-version
update-version:
# Make sure VERSION is set on the command line "make update-version VERSION=x.y.z".
@test $(VERSION)
$(SED) '1s/.*/VERSION?=$(VERSION)/' event-handler/Makefile
$(SED) '1s/.*/VERSION?=$(VERSION)/' access/discord/Makefile
$(SED) '1s/.*/VERSION?=$(VERSION)/' access/jira/Makefile
$(SED) '1s/.*/VERSION?=$(VERSION)/' access/mattermost/Makefile
$(SED) '1s/.*/VERSION?=$(VERSION)/' access/msteams/Makefile
$(SED) '1s/.*/VERSION?=$(VERSION)/' access/slack/Makefile
$(SED) '1s/.*/VERSION?=$(VERSION)/' access/pagerduty/Makefile
$(SED) '1s/.*/VERSION?=$(VERSION)/' access/email/Makefile
$(SED) '1s/.*/VERSION?=$(VERSION)/' terraform/install.mk
$(MAKE) update-helm-version
$(MAKE) update-teleport-dep-version
$(MAKE) terraform-gen-tfschema
# Update all charts to VERSION
.PHONY: update-helm-version
update-helm-version:
$(MAKE) update-helm-version-access-email
$(MAKE) update-helm-version-access-discord
$(MAKE) update-helm-version-access-jira
$(MAKE) update-helm-version-access-slack
$(MAKE) update-helm-version-access-pagerduty
$(MAKE) update-helm-version-access-mattermost
$(MAKE) update-helm-version-access-msteams
$(MAKE) update-helm-version-event-handler
# Update specific chart
.PHONY: update-helm-version-%
update-helm-version-%:
$(SED) 's/appVersion: .*/appVersion: "$(VERSION)"/' charts/$(subst access-,access/,$*)/Chart.yaml
$(SED) 's/version: .*/version: "$(VERSION)"/' charts/$(subst access-,access/,$*)/Chart.yaml
# Update snapshots
@helm unittest -u -3 charts/$(subst access-,access/,$*) || { echo "Please install unittest as described in .cloudbuild/helm-unittest.yaml" ; exit 1; }
.PHONY: update-teleport-dep-version
update-teleport-dep-version:
./update_teleport_dep_version.sh v$(VERSION)
.PHONY: update-goversion
update-goversion:
# Make sure GOVERSION is set on the command line "make update-goversion GOVERSION=x.y.z".
@test $(GOVERSION)
$(SED) 's/^toolchain go.*/toolchain go$(GOVERSION)/' go.mod
$(SED) 's/^toolchain go.*/toolchain go$(GOVERSION)/' tooling/go.mod
$(SED) 's/^ARG RUNTIME="go.*/ARG RUNTIME="go$(GOVERSION)"/' docker/plugins/Dockerfile
$(SED) 's/^RUNTIME ?= go.*/RUNTIME ?= go$(GOVERSION)/' docker/Makefile
$(SED) '2s/.*/GO_VERSION=$(GOVERSION)/' access/discord/Makefile
$(SED) '2s/.*/GO_VERSION=$(GOVERSION)/' access/jira/Makefile
$(SED) '2s/.*/GO_VERSION=$(GOVERSION)/' access/mattermost/Makefile
$(SED) '2s/.*/GO_VERSION=$(GOVERSION)/' access/msteams/Makefile
$(SED) '2s/.*/GO_VERSION=$(GOVERSION)/' access/slack/Makefile
$(SED) '2s/.*/GO_VERSION=$(GOVERSION)/' access/pagerduty/Makefile
$(SED) '2s/.*/GO_VERSION=$(GOVERSION)/' access/email/Makefile
$(SED) '2s/.*/GO_VERSION=$(GOVERSION)/' event-handler/Makefile
$(SED) '2s/.*/GO_VERSION=$(GOVERSION)/' event-handler/build.assets/Makefile
$(SED) 's/^RUNTIME ?= go.*/RUNTIME ?= go$(GOVERSION)/' docker/Makefile
# Lint the project
# Currently lints the go files and license headers in most files.
.PHONY: lint
lint: lint-go lint-license
#
# Lint the Go code.
# By default lint scans the entire repo. Pass GO_LINT_FLAGS='--new' to only scan local
# changes (or last commit).
#
.PHONY: lint-go
lint-go: GO_LINT_FLAGS ?=
lint-go:
golangci-lint run -c .golangci.yml $(GO_LINT_FLAGS)
GOPATH ?= $(shell go env GOPATH)
ADDLICENSE := $(GOPATH)/bin/addlicense
ADDLICENSE_ARGS := -c 'Gravitational, Inc' -l apache \
-ignore '**/Dockerfile' \
-ignore '**/*.xml' \
-ignore '**/*.tf' \
-ignore '**/*.js' \
-ignore '**/*.sh' \
-ignore '**/*.java' \
-ignore '**/*.yaml' \
-ignore '**/*.yml'
.PHONY: lint-license
lint-license: $(ADDLICENSE)
$(ADDLICENSE) $(ADDLICENSE_ARGS) -check * 2>/dev/null
.PHONY: fix-license
fix-license: $(ADDLICENSE)
$(ADDLICENSE) $(ADDLICENSE_ARGS) * 2>/dev/null
$(ADDLICENSE):
cd && go install github.com/google/addlicense@v1.0.0
GCI := $(GOPATH)/bin/gci
$(GCI):
cd && go install github.com/daixiang0/gci@latest
.PHONY: fix-imports
fix-imports: $(GCI)
$(GCI) write -s standard -s default -s 'prefix(github.com/gravitational/teleport-plugins)' --skip-generated .
.PHONY: test-helm-%
test-helm-%:
helm unittest -3 ./charts/$(subst access-,access/,$*)
.PHONY: test-helm
test-helm:
$(MAKE) test-helm-access-email
$(MAKE) test-helm-access-discord
$(MAKE) test-helm-access-jira
$(MAKE) test-helm-access-slack
$(MAKE) test-helm-access-pagerduty
$(MAKE) test-helm-access-mattermost
$(MAKE) test-helm-access-msteams
$(MAKE) test-helm-event-handler