Skip to content

Commit 97e5dbf

Browse files
committed
#754 Extract function to validate script args
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
1 parent c9af761 commit 97e5dbf

1 file changed

Lines changed: 21 additions & 17 deletions

File tree

bin/generate-docs.sh

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,25 @@ function error() {
2424
log >&2 "${COLOR_ERROR}ERROR${COLOR_RESET}: ${1}"
2525
}
2626

27-
if [[ -z "${DOC_TYPE}" ]]; then
28-
error "No doc type given as first parameter!"
29-
error "${USAGE}"
30-
exit 1
31-
fi
32-
33-
if [[ -z "${CHART_FILE}" ]]; then
34-
error "No chart file given as second parameter!"
35-
error "${USAGE}"
36-
exit 1
37-
fi
38-
39-
if [[ -z "${HELM_DOCS_DIR}" ]]; then
40-
error "No helm docs dir given as third parameter!"
41-
error "${USAGE}"
42-
exit 1
43-
fi
27+
function validate_args() {
28+
if [[ -z "${DOC_TYPE}" ]]; then
29+
error "No doc type given as first argument!"
30+
error "${USAGE}"
31+
exit 1
32+
fi
33+
34+
if [[ -z "${CHART_FILE}" ]]; then
35+
error "No chart file given as second argument!"
36+
error "${USAGE}"
37+
exit 1
38+
fi
39+
40+
if [[ -z "${HELM_DOCS_DIR}" ]]; then
41+
error "No helm docs dir given as third argument!"
42+
error "${USAGE}"
43+
exit 1
44+
fi
45+
}
4446

4547
function generate_docs() {
4648
local chart_search_root output_file base_template docs_template dockerhub_template
@@ -132,6 +134,8 @@ function generate_hook_docs() {
132134
}
133135

134136
function main() {
137+
validate_args
138+
135139
case "${DOC_TYPE}" in
136140
"--scanner")
137141
generate_scanner_docs

0 commit comments

Comments
 (0)