forked from secureCodeBox/secureCodeBox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
153 lines (141 loc) · 6.25 KB
/
Makefile
File metadata and controls
153 lines (141 loc) · 6.25 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
# SPDX-FileCopyrightText: 2021 iteratec GmbH
#
# SPDX-License-Identifier: Apache-2.0
all: help
.PHONY:
npm-ci-all: ## Runs npm ci in all node module subfolders.
# This find construct is based on https://stackoverflow.com/questions/4210042/how-to-exclude-a-directory-in-find-command/4210072#4210072
find . \( \
-name '.git' -o \
-name '.github' -o \
-name '.idea' -o \
-name '.reuse' -o \
-name '.vagrant' -o \
-name '.vscode' -o \
-name 'bin' -o \
-name 'docs' -o \
-name 'LICENSES' -o \
-name 'coverage' -o \
-name 'dist' -o \
-name 'node_modules' -o \
-name target \) \
-prune \
-false \
-o -type f \
-iname package.json \
-execdir npm ci \;
.PHONY:
npm-test-all: ## Runs all Jest based test suites.
npm test -- --testPathIgnorePatterns "/integration-tests/"
test-all: ## Runs all makefile based test suites.
@echo ".: ⚙ Installing the operator for makefile based testing."
cd ./operator && $(MAKE) -s docker-build docker-export kind-import helm-deploy
@echo ".: ⚙ Running make test for all scanner and hook modules."
for dir in scanners/*/ hooks/*/ ; do \
cd $$dir; \
echo ".: ⚙ Running make test for '$$dir'."; \
$(MAKE) -s test || exit 1 ; \
cd -; \
done;
.PHONY:
readme:
# Generate README.md based on Chart.yaml and template
@echo ".: ⚙ Generate Helm Docs."
helm-docs --template-files=./.helm-docs/templates.gotmpl --template-files=.helm-docs.gotmpl --template-files=./.helm-docs/README.md.gotmpl
.PHONY: hook-docs
.ONESHELL:
hook-docs:
@echo ".: ⚙ Generate Helm Docs."
# Start in the hooks folder
cd hooks
# https://github.com/koalaman/shellcheck/wiki/SC2044
find . -type f -name Chart.yaml -print0 | while IFS= read -r -d '' chart; do
(
dir="$$(dirname "$${chart}")"
echo "Processing Helm Chart in $$dir"
cd "$${dir}" || exit
if [ -d "docs" ]; then
echo "Docs Folder found at: $${dir}/docs"
helm-docs --template-files=./../../.helm-docs/templates.gotmpl --template-files=.helm-docs.gotmpl --template-files=./../../.helm-docs/README.DockerHub-Hook.md.gotmpl --output-file=docs/README.DockerHub-Hook.md
helm-docs --template-files=./../../.helm-docs/templates.gotmpl --template-files=.helm-docs.gotmpl --template-files=./../../.helm-docs/README.ArtifactHub.md.gotmpl --output-file=docs/README.ArtifactHub.md
else
echo "Ignoring Docs creation process for Chart $$dir, because no `docs` folder found at: $${dir}/docs"
fi
)
done
.PHONY: scanner-docs
.ONESHELL:
scanner-docs:
# Start in the scanners folder
cd scanners
# https://github.com/koalaman/shellcheck/wiki/SC2044
find . -type f -name Chart.yaml -print0 | while IFS= read -r -d '' chart; do
(
dir="$$(dirname "$${chart}")"
echo "Processing Helm Chart in $$dir"
cd "$${dir}" || exit
if [ -d "docs" ]; then
echo "Docs Folder found at: $${dir}/docs"
if [ -d "parser" ]; then
echo "Parser found at: $${dir}/parser"
helm-docs --template-files=./../../.helm-docs/templates.gotmpl --template-files=.helm-docs.gotmpl --template-files=./../../.helm-docs/README.DockerHub-Parser.md.gotmpl --output-file=docs/README.DockerHub-Parser.md
fi
if [ -d "scanner" ]; then
echo "Scanner found at: $${dir}/parser"
helm-docs --template-files=./../../.helm-docs/templates.gotmpl --template-files=.helm-docs.gotmpl --template-files=./../../.helm-docs/README.DockerHub-Scanner.md.gotmpl --output-file=docs/README.DockerHub-Scanner.md
fi
helm-docs --template-files=./../../.helm-docs/templates.gotmpl --template-files=.helm-docs.gotmpl --template-files=./../../.helm-docs/README.ArtifactHub.md.gotmpl --output-file=docs/README.ArtifactHub.md
else
echo "Ignoring Docs creation process for Chart $$dir, because no `docs` folder found at: $${dir}/docs"
fi
)
done
.PHONY: operator-docs
.ONESHELL:
operator-docs:
# Start in the operator folder
cd operator
if [ -d "docs" ]; then
echo "Docs Folder found at: operator/docs"
helm-docs --template-files=./../.helm-docs/templates.gotmpl --template-files=.helm-docs.gotmpl --template-files=./../.helm-docs/README.DockerHub-Core.md.gotmpl --output-file=docs/README.DockerHub-Core.md
helm-docs --template-files=./../.helm-docs/templates.gotmpl --template-files=.helm-docs.gotmpl --template-files=./../.helm-docs/README.ArtifactHub.md.gotmpl --output-file=docs/README.ArtifactHub.md
else
echo "Ignoring Docs creation process for Chart $$dir, because no `docs` folder found at: operator/docs"
fi
.PHONY: auto-discovery-docs
.ONESHELL:
auto-discovery-docs:
cd auto-discovery/kubernetes
if [ -d "docs" ]; then
echo "Docs Folder found at: auto-discovery/kubernetes/docs"
helm-docs --template-files=./../../.helm-docs/templates.gotmpl --template-files=.helm-docs.gotmpl --template-files=./../../.helm-docs/README.DockerHub-Core.md.gotmpl --output-file=docs/README.DockerHub-Core.md
helm-docs --template-files=./../../.helm-docs/templates.gotmpl --template-files=.helm-docs.gotmpl --template-files=./../../.helm-docs/README.ArtifactHub.md.gotmpl --output-file=docs/README.ArtifactHub.md
else
echo "Ignoring Docs creation process for Chart $$dir, because no `docs` folder found at: auto-discovery/kubernetes/docs"
fi
.PHONY: demo-apps-docs
.ONESHELL:
demo-apps-docs:
# Start in the hooks folder
cd demo-targets
# https://github.com/koalaman/shellcheck/wiki/SC2044
find . -type f -name Chart.yaml -print0 | while IFS= read -r -d '' chart; do
(
dir="$$(dirname "$${chart}")"
echo "Processing Helm Chart in $$dir"
cd "$${dir}" || exit
if [ -d "docs" ]; then
echo "Docs Folder found at: $${dir}/docs"
helm-docs --template-files=./../../.helm-docs/templates.gotmpl --template-files=.helm-docs.gotmpl --template-files=./../../.helm-docs/README.DockerHub-Target.md.gotmpl --output-file=docs/README.DockerHub-Target.md
helm-docs --template-files=./../../.helm-docs/templates.gotmpl --template-files=.helm-docs.gotmpl --template-files=./../../.helm-docs/README.ArtifactHub.md.gotmpl --output-file=docs/README.ArtifactHub.md
else
echo "Ignoring Docs creation process for Chart $$dir, because no `docs` folder found at: $${dir}/docs"
fi
)
done
.PHONY: docs
docs: readme hook-docs scanner-docs operator-docs auto-discovery-docs demo-apps-docs
.PHONY:
help: ## Display this help screen.
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'