Skip to content

Commit 8bb3a51

Browse files
committed
#754 Extend dco generator script to enable various doc types
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
1 parent dc73ca5 commit 8bb3a51

2 files changed

Lines changed: 27 additions & 8 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ hook-docs: ## Generate documentation for hooks.
8585
.PHONY: scanner-docs
8686
scanner-docs: ## Generate documentation for scanners.
8787
@for chart in $(SCANNERS_CHART_LIST); do \
88-
$(BIN_DIR)/generate-docs.sh "$${chart}" $(HELM_DOCS_DIR); \
88+
$(BIN_DIR)/generate-docs.sh --scanner "$${chart}" $(HELM_DOCS_DIR); \
8989
done
9090

9191
# FIXME: #754 Remove .ONESHELL which is unsupported on some systems

bin/generate-docs.sh

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ COLOR_PREFIX="\e[32m"
1010
COLOR_ERROR="\e[31m"
1111
COLOR_RESET="\e[0m"
1212

13-
USAGE="$(basename "${0}") path/to/scanner/Chart.yaml path/to/.helm-docs"
13+
USAGE="$(basename "${0}") --scanner path/to/scanner/Chart.yaml path/to/.helm-docs"
1414

15-
CHART_FILE="${1:-}"
16-
HELM_DOCS_DIR="${2:-}"
15+
DOC_TYPE="${1:-}"
16+
CHART_FILE="${2:-}"
17+
HELM_DOCS_DIR="${3:-}"
1718

1819
function log() {
1920
echo -e "${COLOR_PREFIX}SCB${COLOR_RESET} ${1}"
@@ -23,14 +24,20 @@ function error() {
2324
log >&2 "${COLOR_ERROR}ERROR${COLOR_RESET}: ${1}"
2425
}
2526

27+
if [[ -z "${DOC_TYPE}" ]]; then
28+
error "No doc type given as first parameter!"
29+
error "${USAGE}"
30+
exit 1
31+
fi
32+
2633
if [[ -z "${CHART_FILE}" ]]; then
27-
error "No chart file file given as first parameter!"
34+
error "No chart file given as second parameter!"
2835
error "${USAGE}"
2936
exit 1
3037
fi
3138

3239
if [[ -z "${HELM_DOCS_DIR}" ]]; then
33-
error "No helm docs dir given as second parameter!"
40+
error "No helm docs dir given as third parameter!"
3441
error "${USAGE}"
3542
exit 1
3643
fi
@@ -52,8 +59,8 @@ function generate_docs() {
5259
--template-files="${dockerhub_template}"
5360
}
5461

55-
function main() {
56-
log "Generating docs for ${CHART_FILE}..."
62+
function generate_scanner_docs() {
63+
log "Generating scanner docs for ${CHART_FILE}..."
5764

5865
local scanner_dir docs_dir parser_dir scanner_image_dir
5966

@@ -99,4 +106,16 @@ function main() {
99106
"${HELM_DOCS_DIR}/README.ArtifactHub.md.gotmpl"
100107
}
101108

109+
function main() {
110+
case "${DOC_TYPE}" in
111+
"--scanner")
112+
generate_scanner_docs
113+
;;
114+
*)
115+
error "Unsupported doc type: ${DOC_TYPE}!"
116+
error "${USAGE}"
117+
;;
118+
esac
119+
}
120+
102121
main

0 commit comments

Comments
 (0)