Skip to content

Commit

Permalink
add --kube-version opt to helm lint hook (#116)
Browse files Browse the repository at this point in the history
Co-authored-by: James Kwon <96548424+hongil0316@users.noreply.github.com>
  • Loading branch information
james03160927 and james03160927 authored Jul 22, 2024
1 parent 630cb7c commit a2d2016
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions hooks/helmlint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,30 @@ chart_path() {
# An array to keep track of which charts we already linted
seen_chart_paths=()

# A variable to store helm lint opts
helm_lint_opts=""

# An array to store file names after flags have been processed
files=()

handle_options() {
while [ $# -gt 0 ]; do
case $1 in
--kube-version)
helm_lint_opts+="$1 $2"
shift
;;
*)
files+=( "$1" )
;;
esac
shift
done
}

handle_options "$@"
debug "Passed args: $helm_lint_opts"

for file in "$@"; do
debug "Checking $file"
file_chart_path=$(chart_path "$file")
Expand All @@ -123,11 +147,11 @@ for file in "$@"; do
if contains_element "$file_chart_path" "${seen_chart_paths[@]}"; then
debug "Already linted $file_chart_path"
elif [[ -z "$linter_values_arg" ]]; then
helm lint "$file_chart_path"
helm lint $helm_lint_opts "$file_chart_path"
seen_chart_paths+=( "$file_chart_path" )
else
# Combine both linter_values.yaml and values.yaml
helm lint -f "$file_chart_path/values.yaml" -f "$linter_values_arg" "$file_chart_path"
helm lint $helm_lint_opts -f "$file_chart_path/values.yaml" -f "$linter_values_arg" "$file_chart_path"
seen_chart_paths+=( "$file_chart_path" )
fi
fi
Expand Down

0 comments on commit a2d2016

Please sign in to comment.