forked from IBM/integrity-enforcer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
591 lines (470 loc) · 21.5 KB
/
Copy pathMakefile
File metadata and controls
591 lines (470 loc) · 21.5 KB
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
#
# Copyright 2020 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
SHELL=/bin/bash
# LOAD ENVIRNOMENT SETTINGS (must be done at first)
###########################
ifeq ($(ISHIELD_REPO_ROOT),)
$(error ISHIELD_REPO_ROOT is not set)
endif
ifeq ($(ISHIELD_ENV),)
$(error "ISHIELD_ENV is empty. Please set local or remote.")
endif
include .env
export $(shell sed 's/=.*//' .env)
ifeq ($(ENV_CONFIG),)
$(error ENV_CONFIG is not set)
endif
include $(ENV_CONFIG)
export $(shell sed 's/=.*//' $(ENV_CONFIG))
include $(SHIELD_OP_DIR)Makefile
ifeq ($(ISHIELD_TEMP_DIR),)
TMP_DIR = /tmp/
else
TMP_DIR = $(ISHIELD_TEMP_DIR)
$(shell mkdir -p $(TMP_DIR))
endif
# CICD BUILD HARNESS
####################
ifeq ($(ISHIELD_ENV), remote)
-include $(shell curl -s -H 'Authorization: token ${GITHUB_TOKEN}' -H 'Accept: application/vnd.github.v4.raw' -L https://api.github.com/repos/open-cluster-management/build-harness-extensions/contents/templates/Makefile.build-harness-bootstrap -o .build-harness-bootstrap; echo .build-harness-bootstrap)
endif
####################
.PHONY: default
default::
@echo "Build Harness Bootstrapped"
# Docker build flags
DOCKER_BUILD_FLAGS := --build-arg VCS_REF=$(GIT_COMMIT) $(DOCKER_BUILD_FLAGS)
# This repo is build in Travis-ci by default;
# Override this variable in local env.
TRAVIS_BUILD ?= 1
# Github host to use for checking the source tree;
# Override this variable ue with your own value if you're working on forked repo.
GIT_HOST ?= github.com/IBM
PWD := $(shell pwd)
BASE_DIR := $(shell basename $(PWD))
# Keep an existing GOPATH, make a private one if it is undefined
GOPATH_DEFAULT := $(PWD)/.go
export GOPATH ?= $(GOPATH_DEFAULT)
GOBIN_DEFAULT := $(GOPATH)/bin
export GOBIN ?= $(GOBIN_DEFAULT)
TESTARGS_DEFAULT := "-v"
export TESTARGS ?= $(TESTARGS_DEFAULT)
DEST ?= $(GOPATH)/src/$(GIT_HOST)/$(BASE_DIR)
LOCAL_OS := $(shell uname)
ifeq ($(LOCAL_OS),Linux)
TARGET_OS ?= linux
XARGS_FLAGS="-r"
else ifeq ($(LOCAL_OS),Darwin)
TARGET_OS ?= darwin
XARGS_FLAGS=
else
$(error "This system's OS $(LOCAL_OS) isn't recognized/supported")
endif
.PHONY: config int fmt lint test coverage build build-images build-cli
config:
@[ "${ENV_CONFIG}" ] && echo "Env config is all good" || ( echo "ENV_CONFIG is not set"; exit 1 )
############################################################
# format section
############################################################
# All available format: format-go format-protos format-python
# Default value will run all formats, override these make target with your requirements:
# eg: fmt: format-go format-protos
fmt: format-go
format-go:
@set -e; \
GO_FMT=$$(git ls-files *.go | grep -v 'vendor/' | grep -v 'third_party/' | xargs gofmt -d); \
if [ -n "$${GO_FMT}" ] ; then \
echo "Please run go fmt"; \
echo "$$GO_FMT"; \
exit 1; \
fi
############################################################
# check section
############################################################
check: lint
# All available linters: lint-dockerfiles lint-scripts lint-yaml lint-copyright-banner lint-go lint-python lint-helm lint-markdown lint-sass lint-typescript lint-protos
# Default value will run all linters, override these make target with your requirements:
# eg: lint: lint-go lint-yaml
lint: lint-init lint-verify lint-op-init lint-op-verify
lint-init:
cd $(SHIELD_DIR) && golangci-lint run --timeout 5m -D errcheck,unused,gosimple,deadcode,staticcheck,structcheck,ineffassign,varcheck > $(TMP_DIR)lint_results_ishield.txt
lint-verify:
$(eval FAILURES=$(shell cat $(TMP_DIR)lint_results_ishield.txt | grep "FAIL:"))
cat $(TMP_DIR)lint_results_ishield.txt
@$(if $(strip $(FAILURES)), echo "One or more linters failed. Failures: $(FAILURES)"; exit 1, echo "All linters are passed successfully."; exit 0)
lint-op-init:
cd $(SHIELD_OP_DIR) && golangci-lint run --timeout 5m -D errcheck,unused,gosimple,deadcode,staticcheck,structcheck,ineffassign,varcheck,govet > $(TMP_DIR)lint_results.txt
lint-op-verify:
$(eval FAILURES=$(shell cat $(TMP_DIR)lint_results.txt | grep "FAIL:"))
cat $(TMP_DIR)lint_results.txt
@$(if $(strip $(FAILURES)), echo "One or more linters failed. Failures: $(FAILURES)"; exit 1, echo "All linters are passed successfully."; exit 0)
############################################################
# images section
############################################################
build-images:
@if [ -z "$(NO_CACHE)" ]; then \
$(ISHIELD_REPO_ROOT)/build/build_images.sh false; \
else \
$(ISHIELD_REPO_ROOT)/build/build_images.sh $(NO_CACHE); \
fi
push-images:
${ISHIELD_REPO_ROOT}/build/push_images.sh
pull-images:
${ISHIELD_REPO_ROOT}/build/pull_images.sh
############################################################
# cli section
############################################################
build-cli:
cd ${CLI_DIR} && go mod tidy && go build -o build/ishieldctl main.go
############################################################
# bundle section
############################################################
build-bundle:
$(ISHIELD_REPO_ROOT)/build/build_bundle.sh
############################################################
# clean section
############################################################
clean::
############################################################
# check copyright section
############################################################
copyright-check:
- $(ISHIELD_REPO_ROOT)/build/copyright-check.sh $(TRAVIS_BRANCH)
############################################################
# unit test section
############################################################
test-prereq:
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh && fetch_envtest_tools ${ENVTEST_ASSETS_DIR} && setup_envtest_env ${ENVTEST_ASSETS_DIR}
test-unit: test-prereq test-init test-verify test-init-op test-init-cmd test-verify-op test-verify-cmd
test-init:
cd $(SHIELD_DIR) && go test -v $(shell cd $(SHIELD_DIR) && go list ./... | grep -v /vendor/ ) | tee $(TMP_DIR)results.txt
test-init-op:
cd $(SHIELD_OP_DIR) && go test -v $(shell cd $(SHIELD_OP_DIR) && go list ./... | grep -v /test ) | tee $(TMP_DIR)results_op.txt
test-init-cmd:
cd $(ISHIELD_REPO_ROOT)/cmd && go test -v $(shell cd $(ISHIELD_REPO_ROOT)/cmd && go list ./... ) | tee $(TMP_DIR)results_cmd.txt
test-verify:
$(eval FAILURES=$(shell cat $(TMP_DIR)results.txt | grep "FAIL:"))
# cat $(TMP_DIR)results.txt
@$(if $(strip $(FAILURES)), echo "One or more unit tests failed. Failures: $(FAILURES)"; exit 1, echo "All unit tests passed successfully."; exit 0)
test-verify-op:
$(eval FAILURES=$(shell cat $(TMP_DIR)results_op.txt | grep "FAIL:"))
# cat $(TMP_DIR)results_op.txt
@$(if $(strip $(FAILURES)), echo "One or more unit tests failed. Failures: $(FAILURES)"; exit 1, echo "All unit tests passed successfully."; exit 0)
test-verify-cmd:
$(eval FAILURES=$(shell cat $(TMP_DIR)results_cmd.txt | grep "FAIL:"))
@$(if $(strip $(FAILURES)), echo "One or more unit tests failed. Failures: $(FAILURES)"; exit 1, echo "All unit tests passed successfully."; exit 0)
############################################################
# e2e test section
############################################################
.PHONY: test-e2e test-e2e-kind test-e2e-remote test-e2e-common test-e2e-clean-common
.PHONY: check-kubeconfig create-kind-cluster setup-image pull-images push-images-to-local delete-kind-cluster
.PHONY: install-crds setup-ishield-env install-operator setup-tmp-cr setup-test-resources setup-test-env e2e-test delete-test-env delete-keyring-secret delete-operator clean-tmp delete-operator
.PHONY: create-ns create-key-ring tag-images-to-local
.PHONY: test-gpg-annotation
.EXPORT_ALL_VARIABLES:
TEST_SIGNERS=TestSigner
TEST_SIGNER_SUBJECT_EMAIL=signer@enterprise.com
TEST_SAMPLE_SIGNER_SUBJECT_EMAIL=test@enterprise.com
TEST_SECRET=keyring-secret
TEST_KEYCONFIG=test-keyconfig
TEST_SIGNERS2=TestSigner2
TEST_SIGNER_SUBJECT_EMAIL2=signer2@enterprise.com
TEST_SECRET2=keyring-secret-signer2
TEST_KEYCONFIG2=test-keyconfig-2
TMP_CR_FILE=$(TMP_DIR)apis_v1alpha1_integrityshield.yaml
TMP_CR_UPDATED_FILE=$(TMP_DIR)apis_v1alpha1_integrityshield_update.yaml
# export KUBE_CONTEXT_USERNAME=kind-test-managed
test-e2e: export KUBECONFIG=$(SHIELD_OP_DIR)kubeconfig_managed
# perform test in a kind cluster after creating the cluster
test-e2e: create-kind-cluster setup-image test-e2e-common test-e2e-clean-common delete-kind-cluster
# perform test in an existing kind cluster and do not clean
test-e2e-kind: push-images-to-local test-e2e-common
# perform test in an existing cluster (e.g. ROKS, OCP etc.)
test-e2e-remote: test-e2e-common test-e2e-clean-common
# common steps to do e2e test in an existing cluster
test-e2e-common: check-local-test check-kubeconfig install-crds setup-ishield-env install-operator setup-tmp-cr setup-test-resources setup-test-env e2e-test
# common steps to clean e2e test resources in an existing cluster
test-e2e-clean-common: delete-test-env delete-keyring-secret delete-operator clean-tmp
check-kubeconfig:
@if [ -z "$(KUBECONFIG)" ]; then \
echo KUBECONFIG is empty.; \
exit 1;\
fi
check-local-test:
@if [ -z "$(TEST_LOCAL)" ]; then \
echo TEST_LOCAL is empty. Please set true for local test.; \
exit 1;\
fi
create-kind-cluster:
@echo "creating cluster"
# kind create cluster --name test-managed
bash $(SHIELD_OP_DIR)test/create-kind-cluster.sh
kind get kubeconfig --name test-managed > $(SHIELD_OP_DIR)kubeconfig_managed
delete-kind-cluster:
@echo deleting cluster
kind delete cluster --name test-managed
setup-image: build-images push-images-to-local
tag-images-to-local:
@echo tag image for local registry
docker tag $(ISHIELD_SERVER_IMAGE_NAME_AND_VERSION) $(TEST_ISHIELD_SERVER_IMAGE_NAME_AND_VERSION)
docker tag $(ISHIELD_LOGGING_IMAGE_NAME_AND_VERSION) $(TEST_ISHIELD_LOGGING_IMAGE_NAME_AND_VERSION)
# docker tag $(ISHIELD_OBSERVER_IMAGE_NAME_AND_VERSION) $(TEST_ISHIELD_OBSERVER_IMAGE_NAME_AND_VERSION)
# docker tag $(ISHIELD_INSPECTOR_IMAGE_NAME_AND_VERSION) $(TEST_ISHIELD_INSPECTOR_IMAGE_NAME_AND_VERSION)
# docker tag $(ISHIELD_CHECKER_IMAGE_NAME_AND_VERSION) $(TEST_ISHIELD_CHECKER_IMAGE_NAME_AND_VERSION)
docker tag $(ISHIELD_OPERATOR_IMAGE_NAME_AND_VERSION) $(TEST_ISHIELD_OPERATOR_IMAGE_NAME_AND_VERSION)
push-images-to-local: tag-images-to-local
@echo push image into local registry
docker push $(TEST_ISHIELD_SERVER_IMAGE_NAME_AND_VERSION)
docker push $(TEST_ISHIELD_LOGGING_IMAGE_NAME_AND_VERSION)
# docker push $(TEST_ISHIELD_OBSERVER_IMAGE_NAME_AND_VERSION)
# docker push $(TEST_ISHIELD_INSPECTOR_IMAGE_NAME_AND_VERSION)
# docker push $(TEST_ISHIELD_CHECKER_IMAGE_NAME_AND_VERSION)
docker push $(TEST_ISHIELD_OPERATOR_IMAGE_NAME_AND_VERSION)
setup-test-env:
@echo
@echo creating test namespace
kubectl create ns $(TEST_NS)
kubectl create ns $(TEST_UNPROTECTED_NS)
delete-test-env:
@echo
@echo deleting test namespace
# $TEST_NS will be deleted in e2e test usually, so ignore not found error.
kubectl delete ns $(TEST_NS) --ignore-not-found=true
kubectl delete ns $(TEST_NS_NEW)
kubectl delete ns $(TEST_UNPROTECTED_NS)
setup-test-resources:
@echo
@echo prepare cr for updating test
cp $(TMP_CR_FILE) $(TMP_CR_UPDATED_FILE)
yq write -i $(TMP_CR_UPDATED_FILE) spec.signerConfig.signers[1].subjects[1].email $(TEST_SAMPLE_SIGNER_SUBJECT_EMAIL)
yq write -i $(TMP_CR_UPDATED_FILE) spec.shieldConfig.iShieldAdminUserName e2eTestUser
e2e-test:
@echo
@echo run test
$(ISHIELD_REPO_ROOT)/build/check_test_results.sh
test-gpg-annotation:
@echo
$(ISHIELD_REPO_ROOT)/build/run_unit_test_sign_script.sh $(TEST_SIGNER_SUBJECT_EMAIL) $(TMP_DIR)
############################################################
# setup ishield
############################################################
install-ishield: check-kubeconfig install-crds setup-ishield-env install-operator create-cr
uninstall-ishield: delete-webhook delete-cr delete-keyring-secret delete-operator
delete-webhook:
@echo deleting webhook
kubectl delete mutatingwebhookconfiguration ishield-webhook-config
setup-ishield-env: create-ns create-key-ring
create-ns:
@echo
@echo creating namespace
kubectl create ns $(ISHIELD_OP_NS)
create-key-ring:
@echo creating keyring-secret
kubectl create -f $(SHIELD_OP_DIR)test/deploy/keyring_secret.yaml -n $(ISHIELD_OP_NS)
kubectl create -f $(SHIELD_OP_DIR)test/deploy/keyring_secret2.yaml -n $(ISHIELD_OP_NS)
# kubectl create -f $(SHIELD_OP_DIR)test/deploy/certpool_secret.yaml -n $(ISHIELD_OP_NS)
install-crds:
@echo installing crds
kustomize build $(SHIELD_OP_DIR)config/crd | kubectl apply -f -
delete-crds:
@echo deleting crds
kustomize build $(SHIELD_OP_DIR)config/crd | kubectl delete -f -
delete-keyring-secret:
@echo
@echo deleting keyring-secret
kubectl delete -f $(SHIELD_OP_DIR)test/deploy/keyring_secret.yaml -n $(ISHIELD_OP_NS)
kubectl delete -f $(SHIELD_OP_DIR)test/deploy/keyring_secret2.yaml -n $(ISHIELD_OP_NS)
install-operator:
@echo
@echo setting image
cp $(SHIELD_OP_DIR)config/manager/kustomization.yaml $(TMP_DIR)kustomization.yaml #copy original file to tmp dir.
cd $(SHIELD_OP_DIR)config/manager && kustomize edit set image controller=$(TEST_ISHIELD_OPERATOR_IMAGE_NAME_AND_VERSION)
@echo installing operator
kustomize build $(SHIELD_OP_DIR)config/default | kubectl apply --validate=false -f -
cp $(TMP_DIR)kustomization.yaml $(SHIELD_OP_DIR)config/manager/kustomization.yaml #put back the original file from tmp dir.
delete-operator:
@echo
@echo deleting operator
kustomize build $(SHIELD_OP_DIR)config/default | kubectl delete -f -
create-cr:
kubectl apply -f ${SHIELD_OP_DIR}config/samples/apis_v1alpha1_integrityshield.yaml -n $(ISHIELD_OP_NS)
delete-cr:
kubectl delete -f ${SHIELD_OP_DIR}config/samples/apis_v1alpha1_integrityshield.yaml -n $(ISHIELD_OP_NS)
# create a temporary cr with update image names as well as signers
setup-tmp-cr:
@echo
@echo prepare cr
@echo copy cr into tmp dir
cp $(SHIELD_OP_DIR)config/samples/apis_v1alpha1_integrityshield_local.yaml $(TMP_CR_FILE)
@echo insert image
yq write -i $(TMP_CR_FILE) spec.logger.image $(TEST_ISHIELD_LOGGING_IMAGE_NAME_AND_VERSION)
yq write -i $(TMP_CR_FILE) spec.logger.imagePullPolicy Always
yq write -i $(TMP_CR_FILE) spec.server.image $(TEST_ISHIELD_SERVER_IMAGE_NAME_AND_VERSION)
yq write -i $(TMP_CR_FILE) spec.server.imagePullPolicy Always
yq write -i $(TMP_CR_FILE) spec.observer.image $(TEST_ISHIELD_OBSERVER_IMAGE_NAME_AND_VERSION)
yq write -i $(TMP_CR_FILE) spec.observer.imagePullPolicy Always
@echo setup keyring configs
yq write -i $(TMP_CR_FILE) spec.keyConfig[0].name $(TEST_KEYCONFIG)
yq write -i $(TMP_CR_FILE) spec.keyConfig[0].secretName $(TEST_SECRET)
yq write -i $(TMP_CR_FILE) spec.keyConfig[1].name $(TEST_KEYCONFIG2)
yq write -i $(TMP_CR_FILE) spec.keyConfig[1].secretName $(TEST_SECRET2)
@echo setup signer config
yq write -i $(TMP_CR_FILE) spec.signerConfig.policies[2].namespaces[0] $(TEST_NS)
yq write -i $(TMP_CR_FILE) spec.signerConfig.policies[2].namespaces[1] $(TEST_NS_NEW)
yq write -i $(TMP_CR_FILE) spec.signerConfig.policies[2].signers[0] $(TEST_SIGNERS)
yq write -i $(TMP_CR_FILE) spec.signerConfig.signers[1].name $(TEST_SIGNERS)
yq write -i $(TMP_CR_FILE) spec.signerConfig.signers[1].keyConfig $(TEST_KEYCONFIG)
yq write -i $(TMP_CR_FILE) spec.signerConfig.signers[1].subjects[0].email $(TEST_SIGNER_SUBJECT_EMAIL)
yq write -i $(TMP_CR_FILE) spec.signerConfig.signers[2].name $(TEST_SIGNERS2)
yq write -i $(TMP_CR_FILE) spec.signerConfig.signers[2].keyConfig $(TEST_KEYCONFIG2)
yq write -i $(TMP_CR_FILE) spec.signerConfig.signers[2].subjects[0].email $(TEST_SIGNER_SUBJECT_EMAIL2)
@if [ "$(TEST_LOCAL)" ]; then \
echo enable logAllResponse ; \
yq write -i $(TMP_CR_FILE) spec.shieldConfig.log.logLevel trace ;\
yq write -i $(TMP_CR_FILE) spec.shieldConfig.log.logAllResponse true ;\
yq write -i $(TMP_CR_FILE) spec.shieldConfig.iShieldAdminUserGroup "system:masters,system:cluster-admins" ;\
fi
create-tmp-cr:
kubectl apply -f $(TMP_CR_FILE) -n $(ISHIELD_OP_NS)
delete-tmp-cr:
kubectl delete -f $(TMP_CR_FILE) -n $(ISHIELD_OP_NS)
# list resourcesigningprofiles
list-rsp:
kubectl get resourcesigningprofiles.apis.integrityshield.io --all-namespaces
# show rule table
show-rt:
kubectl get cm ishield-rule-table-lock -n $(ISHIELD_NS) -o json | jq -r .binaryData.table | base64 -D | gzip -d
# show forwarder log
log-f:
bash $(ISHIELD_REPO_ROOT)/scripts/watch_events.sh
log-s:
bash $(ISHIELD_REPO_ROOT)/scripts/log_server.sh
log-o:
bash $(ISHIELD_REPO_ROOT)/scripts/log_operator.sh
clean-tmp:
@if [ -f "$(TMP_CR_FILE)" ]; then\
rm $(TMP_CR_FILE);\
fi
@if [ -f "$(TMP_CR_UPDATED_FILE)" ]; then\
rm $(TMP_CR_UPDATED_FILE);\
fi
.PHONY: sec-scan
sec-scan:
$(ISHIELD_REPO_ROOT)/build/sec_scan.sh
.PHONY: sonar-go-test-ishield sonar-go-test-op
sonar-go-test-ishield:
@if [ "$(ISHIELD_ENV)" = remote ]; then \
make go/gosec-install; \
fi
@echo "-> Starting sonar-go-test"
@echo "--> Starting go test"
cd $(SHIELD_DIR) && go test -coverprofile=coverage.out -json ./... | tee report.json | grep -v '"Action":"output"'
@echo "--> Running gosec"
gosec -fmt sonarqube -out gosec.json -no-fail ./...
@echo "---> gosec gosec.json"
@cat gosec.json
@if [ "$(ISHIELD_ENV)" = remote ]; then \
echo "--> Running sonar-scanner"; \
sonar-scanner --debug; \
fi
sonar-go-test-op:
@if [ "$(ISHIELD_ENV)" = remote ]; then \
make go/gosec-install; \
fi
@echo "-> Starting sonar-go-test"
@echo "--> Starting go test"
cd $(SHIELD_OP_DIR) && go test -coverprofile=coverage.out -json $(shell cd $(SHIELD_OP_DIR) && go list ./... | grep -v /test/) | tee report.json | grep -v '"Action":"output"'
@echo "--> Running gosec"
gosec -fmt sonarqube -out gosec.json -no-fail ./...
@echo "---> gosec gosec.json"
@cat gosec.json
@if [ "$(ISHIELD_ENV)" = remote ]; then \
echo "--> Running sonar-scanner"; \
sonar-scanner --debug; \
fi
.PHONY: publish
publish:
$(ISHIELD_REPO_ROOT)/build/publish_images.sh
$(ISHIELD_REPO_ROOT)/build/publish_bundle_ocm.sh
setup-demo:
@echo
@echo setting image
cp $(SHIELD_OP_DIR)config/manager/kustomization.yaml $(TMP_DIR)kustomization.yaml #copy original file to tmp dir.
cd $(SHIELD_OP_DIR)config/manager && kustomize edit set image controller=$(DEMO_ISHIELD_OP_IMAGE_NAME)
@echo installing operator
kustomize build $(SHIELD_OP_DIR)config/default | kubectl apply --validate=false -f -
cp $(TMP_DIR)kustomization.yaml $(SHIELD_OP_DIR)config/manager/kustomization.yaml
@echo prepare cr
@echo copy cr into tmp dir
cp $(SHIELD_OP_DIR)config/samples/apis_v1alpha1_integrityshield_local.yaml $(TMP_CR_FILE)
@echo insert image
yq write -i $(TMP_CR_FILE) spec.logger.image $(DEMO_ISHIELD_LOGGING_IMAGE_NAME)
yq write -i $(TMP_CR_FILE) spec.logger.imagePullPolicy Always
yq write -i $(TMP_CR_FILE) spec.server.image $(DEMO_ISHIELD_SERVER_IMAGE_NAME)
yq write -i $(TMP_CR_FILE) spec.server.imagePullPolicy Always
@echo setup keyring configs
yq write -i $(TMP_CR_FILE) spec.keyConfig[0].name $(TEST_KEYCONFIG)
yq write -i $(TMP_CR_FILE) spec.keyConfig[0].secretName $(TEST_SECRET)
yq write -i $(TMP_CR_FILE) spec.keyConfig[1].name $(TEST_KEYCONFIG2)
yq write -i $(TMP_CR_FILE) spec.keyConfig[1].secretName $(TEST_SECRET2)
@echo setup signer config
yq write -i $(TMP_CR_FILE) spec.signerConfig.policies[2].namespaces[0] $(TEST_NS)
yq write -i $(TMP_CR_FILE) spec.signerConfig.policies[2].signers[0] $(TEST_SIGNERS)
yq write -i $(TMP_CR_FILE) spec.signerConfig.signers[1].name $(TEST_SIGNERS)
yq write -i $(TMP_CR_FILE) spec.signerConfig.signers[1].keyConfig $(TEST_KEYCONFIG)
yq write -i $(TMP_CR_FILE) spec.signerConfig.signers[1].subjects[0].email $(TEST_SIGNER_SUBJECT_EMAIL)
yq write -i $(TMP_CR_FILE) spec.signerConfig.signers[2].name $(TEST_SIGNERS2)
yq write -i $(TMP_CR_FILE) spec.signerConfig.signers[2].keyConfig $(TEST_KEYCONFIG2)
yq write -i $(TMP_CR_FILE) spec.signerConfig.signers[2].subjects[0].email $(TEST_SIGNER_SUBJECT_EMAIL2)
kubectl apply -f $(TMP_CR_FILE) -n $(ISHIELD_OP_NS)
.PHONY: create-private-registry
create-private-registry:
$(ISHIELD_REPO_ROOT)/build/create-private-registry.sh
delete-private-registry:
$(ISHIELD_REPO_ROOT)/build/delete-private-registry.sh
.PHONY: update-version
# use this command to update VERSION after doing 'make build-bundle'
update-version:
$(ISHIELD_REPO_ROOT)/build/update-version.sh
# Before executing this target, change BUNDLE_REGISTRY
test-e2e-bundle:
make clean-e2e-test-log
make setup-olm-local
make setup-image # execute `make setup-image` for making sure new images exist
make build-bundle # Used for ISHIELD_ENV=local/remote
make deploy-bundle-local
make check-bundle-local
make bundle-test-local
deploy-bundle-local:
$(ISHIELD_REPO_ROOT)/build/deploy-bundle-local.sh
check-bundle-local:
$(ISHIELD_REPO_ROOT)/build/check-bundle-deployment-local.sh
test-e2e-bundle-clean-local:
make test-e2e-clean-common --ignore-errors
make clean-e2e-bundle-test-local
make clean-e2e-test-log
clean-e2e-bundle-test-local:
$(ISHIELD_REPO_ROOT)/build/clean-e2e-bundle-test-local.sh
clean-e2e-test-log:
$(ISHIELD_REPO_ROOT)/build/clean-e2e-test-log.sh
setup-olm-local:
$(ISHIELD_REPO_ROOT)/build/setup-olm-local.sh
bundle-test-local:
make create-key-ring
make setup-tmp-cr
make setup-test-resources
make setup-test-env
make e2e-test