forked from gravitational/teleport-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
316 lines (270 loc) · 10.2 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
# Set up a system-agnostic in-place sed command
IS_GNU_SED = $(shell sed --version 1>/dev/null 2>&1 && echo true || echo false)
DRONE ?= drone
DRONE_REPO ?= gravitational/teleport-plugins
DRONE_PROMOTE_ENV ?= production
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-example
access-example:
go build -o build/access-example ./access/example
.PHONY: access-email
access-email:
go build -o build/access-email ./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
# Pulls and pushes image from ECR to quay.
.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 $(TELEPORT_GET_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:
(cd lib; go test -v -race ./...)
# Individual releases
.PHONY: release/access-slack
release/access-slack:
make -C access/slack clean release
.PHONY: release/access-discord
release/access-discord:
make -C access/discord clean release
.PHONY: release/access-jira
release/access-jira:
make -C access/jira clean release
.PHONY: release/access-mattermost
release/access-mattermost:
make -C access/mattermost clean release
.PHONY: release/access-msteams
release/access-msteams:
make -C access/msteams clean release
.PHONY: release/access-pagerduty
release/access-pagerduty:
make -C access/pagerduty clean release
.PHONY: release/access-email
release/access-email:
make -C access/email clean release
.PHONY: release/terraform
release/terraform:
make -C terraform clean release
.PHONY: release/event-handler
release/event-handler:
make -C event-handler clean 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) 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 charts/$(subst access-,access/,$*) || { echo "Please install unittest as described in .cloudbuild/helm-unittest.yaml" ; exit 1; }
.PHONY: update-tag
update-tag:
# Make sure VERSION is set on the command line "make update-tag VERSION=x.y.z".
@test $(VERSION)
# Tag all releases first locally.
git tag teleport-event-handler-v$(VERSION)
git tag teleport-discord-v$(VERSION)
git tag teleport-jira-v$(VERSION)
git tag teleport-mattermost-v$(VERSION)
git tag teleport-msteams-v$(VERSION)
git tag teleport-slack-v$(VERSION)
git tag teleport-pagerduty-v$(VERSION)
git tag teleport-email-v$(VERSION)
git tag terraform-provider-teleport-v$(VERSION)
git tag v$(VERSION)
# Push all releases to origin.
git push origin teleport-event-handler-v$(VERSION)
git push origin teleport-discord-v$(VERSION)
git push origin teleport-jira-v$(VERSION)
git push origin teleport-mattermost-v$(VERSION)
git push origin teleport-msteams-v$(VERSION)
git push origin teleport-slack-v$(VERSION)
git push origin teleport-pagerduty-v$(VERSION)
git push origin teleport-email-v$(VERSION)
git push origin terraform-provider-teleport-v$(VERSION)
git push origin v$(VERSION)
# promote-tag executes Drone promotion pipeline for the plugins.
#
# It has to be run after tag builds triggered by the "update-tag" target have
# been completed. Requires "drone" executable to be available and configured
# to talk to our Drone cluster.
#
# To promote all plugins:
# VERSION=10.2.6 make promote-tag
#
# To promote a particular plugin:
# VERSION=10.2.6 PLUGINS=teleport-slack make promote-tag
.PHONY: promote-tag
promote-tag:
@test $(VERSION)
@for PLUGIN in $(PLUGINS); do \
BUILD=$$($(DRONE) build ls --status success --event tag --format "{{.Number}} {{.Ref}}" $(DRONE_REPO) | grep $${PLUGIN}-v$(VERSION) | cut -d ' ' -f1); \
if [ "$${BUILD}" = "" ]; then \
echo "Failed to find Drone build number for $${PLUGIN}-v$(VERSION)" && exit 1; \
else \
echo "\n\n --> Promoting build $${BUILD} for plugin $${PLUGIN}" to $(DRONE_PROMOTE_ENV); \
$(DRONE) build promote $(DRONE_REPO) $${BUILD} $(DRONE_PROMOTE_ENV); \
fi; \
done
.PHONY: update-goversion
update-goversion:
# Make sure GOVERSION is set on the command line "make update-goversion GOVERSION=x.y.z".
@test $(GOVERSION)
$(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) 's/^RUNTIME ?= go.*/RUNTIME ?= go$(GOVERSION)/' docker/Makefile
$(SED) 's/- name: golang:.*/- name: golang:$(GOVERSION)/' .cloudbuild/ci/unit-tests-linux.yaml
$(SED) 's/Setup Go .*/Setup Go $(GOVERSION)/g' .github/workflows/unit-tests.yaml
$(SED) 's/Setup Go .*/Setup Go $(GOVERSION)/g' .github/workflows/integration-tests.yaml
$(SED) 's/Setup Go .*/Setup Go $(GOVERSION)/g' .github/workflows/terraform-tests.yaml
$(SED) 's/Setup Go .*/Setup Go $(GOVERSION)/g' .github/workflows/lint.yaml
$(SED) "s/go-version: '.*/go-version: '$(GOVERSION)'/g" .github/workflows/unit-tests.yaml
$(SED) "s/go-version: '.*/go-version: '$(GOVERSION)'/g" .github/workflows/integration-tests.yaml
$(SED) "s/go-version: '.*/go-version: '$(GOVERSION)'/g" .github/workflows/terraform-tests.yaml
$(SED) "s/go-version: '.*/go-version: '$(GOVERSION)'/g" .github/workflows/lint.yaml
$(SED) 's/image: golang:.*/image: golang:$(GOVERSION)/g' .drone.yml
$(SED) 's/GO_VERSION: go.*/GO_VERSION: go$(GOVERSION)/g' .drone.yml
@echo Please sign .drone.yml before staging and committing the changes
#
# 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
lint: GO_LINT_FLAGS ?=
lint:
golangci-lint run -c .golangci.yml $(GO_LINT_FLAGS)
.PHONY: test-helm-%
test-helm-%:
helm unittest ./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