This repository has been archived by the owner on Aug 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
267 lines (202 loc) · 7.47 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
# vim: set foldmarker={,} foldlevel=0 foldmethod=marker:
-include ./.env
VERSION ?= $(shell git describe --long --always --dirty)
PROFILE ?= inspr-stack
K8S_NAMESPACE ?= ${VERSION}
GOFLAGS ?=
RELEASE_NAME ?= ""
VALUES ?= stack-overwrites.yaml
INSPRD_VALUES ?= insprd-overwrites.yaml
UIDP_VALUES ?= uidp-overwrites.yaml
export
help:
@python3 ./scripts/makefile_help.py Makefile $C
# golang {
## downloads dependencies
go/download:
go mod download
## builds all binaries to the bin directory
go/build:
mkdir -p build/bin
go build ${GOFLAGS} -o build/bin ./...
## runs all tests on the repo
go/test:
go test ./...
## runs all tests tagged integration
go/test/integration:
go test ./... -tags=integration
## lints the repo with goling and staticcheck
go/lint:
staticcheck ./...
golint ./...
## gets tools necessary for development
go/init:
go get -u golang.org/x/lint/golint
go get -u github.com/ptcar2009/ptcwatcher/cmd/ptcwatcher
## runs coverage and exports coverage profile
go/coverage:
bash ./.github/scripts/unittest.sh
## watches the files and lints on changes
go/lint/watch:
ptcwatcher 'make go/lint' -w ./pkg -w ./cmd
## watches the files and builds on changes
go/build/watch:
ptcwatcher 'make go/build' -w ./pkg -w ./cmd
## watches the files and tests on changes
go/test/watch:
ptcwatcher 'make go/test' -w ./pkg -w ./cmd
# }
# CLI {
# insprctl {
## builds insprctl to the bin directory
cli/insprctl/build:
go build -o bin ./cmd/insprctl
## installs insprctl to $GOPATH/bin
cli/insprctl/install:
go install ./cmd/insprctl
# }
# inprov {
## builds inprov to the bin directory
cli/inprov/build:
go build -o bin ./cmd/uid_provider/inprov
## installs inprov to $GOPATH/bin
cli/inprov/install:
go install ./cmd/uid_provider/inprov
# }
# all {
## builds all CLI tools to the bin directory
cli/build: cli/insprctl/build cli/inprov/build
## installs all CLI tools to $GOPATH/bin
cli/install: cli/insprctl/install cli/inprov/install
# }
# }
# CI {
## runs all scripts regarding CI, including linting, coverage and initialization
ci/all: ci/init ci/lint ci/test ci/coverage
## initializes the environment for CI
ci/init: go/init helm/init semgrep/init
## lints the go src, helm templates and runs semgrep jobs
ci/lint: go/lint semgrep/run helm/lint
## runs all tests regarding golang
ci/test: go/test go/test/integration
## runs coverage on the repo and exports the profile
ci/coverage: go/coverage
## builds the CLI to all platforms and syncs to the repo
ci/release: ci/cli/push
# CLI {
## builds the CLI to all platforms and architectures
ci/cli/build:
bash ./.github/scripts/buildcli.sh
## pushes the built binaries to the CI repo
ci/cli/push: ci/cli/build
bash ./.github/scripts/pushcli.sh
# }
# }
# helm {
# uidp {
## packages the UIDP helm chart using the UIDP overrides file, which by default is uidp-overwrites.yaml
helm/uidp/package:
helm package ./build/uidp
## lints the UIDP helm chart using the UIDP overrides file.
helm/uidp/lint:
helm lint ./build/uidp
## runs the UIDP helm chart tests using the UIDP overrides file,
helm/uidp/test:
helm test ${RELEASE_NAME}-uidp -n ${K8S_NAMESPACE}
## installs the uidp helm chart to the K8S_NAMESPACE using the uidp overrides file.
helm/uidp/install:
helm upgrade -i ${RELEASE_NAME}-uidp ./build/uidp -f ${UIDP_VALUES} -n ${K8S_NAMESPACE}
## delete a helm release
helm/uidp/uninstall:
helm uninstall ${RELEASE_NAME}-uidp -n ${K8S_NAMESPACE}
# }
# insprd {
## packages the INSPRD helm chart using the INSPRD overrides file, which by default is insprd-overwrites.yaml
helm/insprd/package:
helm package ./build/insprd
## lints the INSPRD helm chart using the INSPRD overrides file.
helm/insprd/lint:
helm lint ./build/insprd
## runs the INSPRD helm chart tests using the INSPRD overrides file,
helm/insprd/test:
helm test ${RELEASE_NAME}-insprd -n ${K8S_NAMESPACE}
## installs the insprd helm chart to the K8S_NAMESPACE using the insprd overrides file.
helm/insprd/install:
helm upgrade -i ${RELEASE_NAME}-insprd ./build/insprd -f ${INSPRD_VALUES} -n ${K8S_NAMESPACE}
## delete a helm release
helm/insprd/uninstall:
helm uninstall ${RELEASE_NAME}-insprd -n ${K8S_NAMESPACE}
# }
# stack {
## packages the INSPR-STACK helm chart using the INSPR-STACK overrides file, which by default is stack-overwrites.yaml
helm/package:
helm package ./build/inspr-stack
## lints the INSPR-STACK helm chart using the INSPR-STACK overrides file.
helm/lint:
helm lint ./build/inspr-stack
## runs the INSPR-STACK helm chart tests using the INSPR-STACK overrides file,
helm/test:
helm test ${RELEASE_NAME}-stack -n ${K8S_NAMESPACE}
## installs the inspr-stack helm chart to the K8S_NAMESPACE using the inspr-stack overrides file.
helm/install:
helm upgrade -i ${RELEASE_NAME}-stack ./build/inspr-stack -f ${VALUES} -n ${K8S_NAMESPACE}
## delete a helm release
helm/uninstall:
helm uninstall ${RELEASE_NAME}-stack -n ${K8S_NAMESPACE}
# }
# }
# Skaffold {
## runs skaffold build with the PROFILE profile and outputs the image to OUTPUT_FILE if defined.
skaffold/build:
ifdef OUTPUT_FILE
skaffold build -p ${PROFILE} -o ${OUTPUT_FILE}
else
skaffold build -p ${PROFILE}
endif
## runs skaffold run with the PROFILE profile on the K8S_NAMESPACE namespace.
skaffold/run:
skaffold run -p ${PROFILE} -n ${K8S_NAMESPACE}
skaffold/dev:
skaffold dev -p ${PROFILE} -n ${K8S_NAMESPACE}
## Deletes the release and the namespace that it was created in
skaffold/delete:
skaffold delete -p ${PROFILE} -n ${K8S_NAMESPACE}
kubectl delete namespace ${K8S_NAMESPACE}
# }
# semgrep {
## downloads sempgrep and installs it using python3
semgrep/init:
python3 -m pip install semgrep
## runs the desired test suites for semgrep
semgrep/run:
semgrep --config "p/trailofbits"
# }
# secrets {
## gets and decodes the admin secret
secrets/uidp/admin:
@echo $(shell kubectl get secrets -n ${K8S_NAMESPACE} ${RELEASE_NAME}-init-secret -o jsonpath="{.data.ADMIN_PASSWORD}" | base64 --decode)
## gets and decodes the insprd init key secret
secrets/insprd/init:
@echo $(shell kubectl get secrets -n ${K8S_NAMESPACE} ${RELEASE_NAME}-insprd-init-key -o jsonpath="{.data.key}" | base64 --decode)
## gets and decodes the grafana admin password
secrets/grafana/password:
@echo $(shell kubectl get secrets -n ${K8S_NAMESPACE} ${RELEASE_NAME}-grafana-admin -o jsonpath="{.data.GF_SECURITY_ADMIN_PASSWORD}" | base64 --decode)
# }
# dashboards {
## port forwards grafana and opens a browser session with it
dashboards/grafana:
xdg-open http://localhost:3000
kubectl port-forward -n ${K8S_NAMESPACE} $(shell kubectl get pods --namespace ${K8S_NAMESPACE} -l "app.kubernetes.io/name=grafana" -o jsonpath="{.items[0].metadata.name}") 3000:3000
## port forwards prometheus and opens a browser session on it
dashboards/prometheus:
xdg-open http://localhost:9090
kubectl port-forward -n ${K8S_NAMESPACE} $(shell kubectl get pods --namespace ${K8S_NAMESPACE} -l "app.kubernetes.io/name=${RELEASE_NAME}-prometheus" -o jsonpath="{.items[0].metadata.name}") 9090:9090
# }
# port forwards {
pf/insprd:
kubectl port-forward -n ${K8S_NAMESPACE} $(shell kubectl get pods --namespace ${K8S_NAMESPACE} -l "app.kubernetes.io/name=insprd" -o jsonpath="{.items[0].metadata.name}") 8080:8080
pf/auth:
kubectl port-forward -n ${K8S_NAMESPACE} $(shell kubectl get pods --namespace ${K8S_NAMESPACE} -l "app.kubernetes.io/name=auth" -o jsonpath="{.items[0].metadata.name}") 8081:8081
pf/uidp:
kubectl port-forward -n ${K8S_NAMESPACE} $(shell kubectl get pods --namespace ${K8S_NAMESPACE} -l "app.kubernetes.io/name=uidp" -o jsonpath="{.items[0].metadata.name}") 9001:9001
# }