Skip to content

Commit a2d2016

Browse files
authored
add --kube-version opt to helm lint hook (#116)
Co-authored-by: James Kwon <96548424+hongil0316@users.noreply.github.com>
1 parent 630cb7c commit a2d2016

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

hooks/helmlint.sh

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,30 @@ chart_path() {
105105
# An array to keep track of which charts we already linted
106106
seen_chart_paths=()
107107

108+
# A variable to store helm lint opts
109+
helm_lint_opts=""
110+
111+
# An array to store file names after flags have been processed
112+
files=()
113+
114+
handle_options() {
115+
while [ $# -gt 0 ]; do
116+
case $1 in
117+
--kube-version)
118+
helm_lint_opts+="$1 $2"
119+
shift
120+
;;
121+
*)
122+
files+=( "$1" )
123+
;;
124+
esac
125+
shift
126+
done
127+
}
128+
129+
handle_options "$@"
130+
debug "Passed args: $helm_lint_opts"
131+
108132
for file in "$@"; do
109133
debug "Checking $file"
110134
file_chart_path=$(chart_path "$file")
@@ -123,11 +147,11 @@ for file in "$@"; do
123147
if contains_element "$file_chart_path" "${seen_chart_paths[@]}"; then
124148
debug "Already linted $file_chart_path"
125149
elif [[ -z "$linter_values_arg" ]]; then
126-
helm lint "$file_chart_path"
150+
helm lint $helm_lint_opts "$file_chart_path"
127151
seen_chart_paths+=( "$file_chart_path" )
128152
else
129153
# Combine both linter_values.yaml and values.yaml
130-
helm lint -f "$file_chart_path/values.yaml" -f "$linter_values_arg" "$file_chart_path"
154+
helm lint $helm_lint_opts -f "$file_chart_path/values.yaml" -f "$linter_values_arg" "$file_chart_path"
131155
seen_chart_paths+=( "$file_chart_path" )
132156
fi
133157
fi

0 commit comments

Comments
 (0)