mirror of
https://github.com/bitnami/charts.git
synced 2026-03-06 15:10:15 +08:00
Add support for ci folder
This commit is contained in:
@@ -10,24 +10,29 @@ for chart_name in $( cut -d'/' -f1,2 <<< "$files_to_push" | uniq ); do
|
||||
if [[ $chart_name = bitnami/* ]]; then
|
||||
printf '\033[01;33mValidating %s with helm lint:\n\033[0m' "$chart_name"
|
||||
chart_path="$(git rev-parse --show-toplevel)"/"$chart_name"
|
||||
|
||||
printf '\033[0;34m- Running helm lint %s\n\033[0m' "$chart_path"
|
||||
printf '\033[0;34m- Running helm lint %s\n\033[0m' "$chart_name"
|
||||
if helm lint "$chart_path"; then
|
||||
printf '\033[0;32m\U00002705 helm lint %s\n\n\033[0m' "$chart_path"
|
||||
printf '\033[0;32m\U00002705 helm lint %s\n\n\033[0m' "$chart_name"
|
||||
else
|
||||
printf '\033[0;31m\U0001F6AB helm lint %s failed. Push cancelled.\n\n\033[0m' "$chart_path"
|
||||
printf '\033[0;31m\U0001F6AB helm lint %s failed. Push cancelled.\n\n\033[0m' "$chart_name"
|
||||
failed=1
|
||||
fi
|
||||
for values_file in "$chart_path"/values.yaml "$chart_path"/ci/*.yaml; do
|
||||
if [[ ! -f "$values_file" ]];then
|
||||
continue
|
||||
fi
|
||||
values_file_display=${values_file#$chart_path/}
|
||||
|
||||
printf '\033\033[0;34m- Running helm template %s\n\033[0m' "$chart_path"
|
||||
helm repo add bitnami https://charts.bitnami.com/bitnami >> /dev/null
|
||||
helm dependency update "$chart_path" >> /dev/null
|
||||
if helm template "$chart_path" >> /dev/null; then
|
||||
printf '\033[0;32m\U00002705 helm template %s\n\n\033[0m' "$chart_path"
|
||||
else
|
||||
printf '\033[0;31m\U0001F6AB helm template %s failed. Push cancelled.\n\n\033[0m' "$chart_path"
|
||||
failed=1
|
||||
fi
|
||||
printf '\033\033[0;34m- Running helm template --values %s %s\n\033[0m' "$values_file_display" "$chart_name"
|
||||
helm repo add bitnami https://charts.bitnami.com/bitnami >> /dev/null
|
||||
helm dependency update "$chart_path" >> /dev/null
|
||||
if helm template --values "$values_file" "$chart_path" >> /dev/null; then
|
||||
printf '\033[0;32m\U00002705 helm template --values %s %s\n\n\033[0m' "$values_file_display" "$chart_name"
|
||||
else
|
||||
printf '\033[0;31m\U0001F6AB helm template --values %s %s failed. Push cancelled.\n\n\033[0m' "$values_file_display" "$chart_path"
|
||||
failed=1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
@@ -19,14 +19,20 @@ for chart_name in $( cut -d'/' -f1,2 <<< "$files_to_push" | uniq ); do
|
||||
if [[ $chart_name = bitnami/* ]]; then
|
||||
printf '\033[01;33mValidating %s with kubeval:\n\033[0m' "$chart_name"
|
||||
chart_path="$(git rev-parse --show-toplevel)"/"$chart_name"
|
||||
for values_file in "$chart_path"/values.yaml "$chart_path"/ci/*.yaml; do
|
||||
if [[ ! -f "$values_file" ]];then
|
||||
continue
|
||||
fi
|
||||
values_file_display=${values_file#$chart_path/}
|
||||
|
||||
printf '\033[0;34m- Running helm template %s | kubeval\n\033[0m' "$chart_path"
|
||||
if helm template "$chart_path" | kubeval; then
|
||||
printf '\033[0;32m\U00002705 helm template %s | kubeval\n\n\033[0m' "$chart_path"
|
||||
else
|
||||
printf '\033[0;31m\U0001F6AB helm template %s | kubeval failed. Push cancelled.\n\n\033[0m' "$chart_path"
|
||||
failed=1
|
||||
fi
|
||||
printf '\033[0;34m- Running helm template --values %s %s | kubeval\n\033[0m' "$values_file_display" "$chart_name"
|
||||
if helm template --values "$values_file" "$chart_path" | kubeval; then
|
||||
printf '\033[0;32m\U00002705 helm template --values %s %s | kubeval\n\n\033[0m' "$values_file_display" "$chart_name"
|
||||
else
|
||||
printf '\033[0;31m\U0001F6AB helm template --values %s %s | kubeval failed. Push cancelled.\n\n\033[0m' "$values_file_display" "$chart_name"
|
||||
failed=1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
@@ -10,15 +10,17 @@ failed=0
|
||||
render_and_yaml_lint() {
|
||||
local -r chart_path="${1:?missing_chart}"
|
||||
local -r path="${2:?missing_file}"
|
||||
local -r display_path=${1#"$repo_path/"}
|
||||
local -r values="${3:?missing_values}"
|
||||
local -r display_chart_path=${1#"$repo_path/"}
|
||||
local -r display_values=${3#"$chart_path/"}
|
||||
local -r lint_rules="{extends: default, rules: {line-length: disable, trailing-spaces: disable, truthy: enable, document-start: disable, empty-lines: {max-end: 2} }}"
|
||||
printf '\033[0;34m- Running yamllint on %s/%s\n\033[0m' "$display_path" "$path"
|
||||
printf '\033[0;34m- Running yamllint on %s/%s (values: %s)\n\033[0m' "$display_chart_path" "$path" "$display_values"
|
||||
|
||||
if ! helm template "$chart_path" -x "$path" | yamllint -s -d "$lint_rules" -; then
|
||||
printf '\033[0;31m\\U0001F6AB (helm template %s -x %s | yamllint -s -d "%s" -) failed\n\n\033[0m' "$chart_path" "$path" "$lint_rules"
|
||||
if ! helm template --values "$values" "$chart_path" -x "$path" | yamllint -s -d "$lint_rules" -; then
|
||||
printf '\033[0;31m\\U0001F6AB (helm template --values %s %s -x %s | yamllint -s -d "%s" -) failed\n\n\033[0m' "$display_values" "$display_chart_path" "$path" "$lint_rules"
|
||||
false
|
||||
else
|
||||
printf '\033[0;32m\U00002705 %s/%s\n\n\033[0m' "$display_path" "$path"
|
||||
printf '\033[0;32m\U00002705 %s/%s (values: %s)\n\n\033[0m' "$display_chart_path" "$path" "$display_values"
|
||||
true
|
||||
fi
|
||||
}
|
||||
@@ -29,10 +31,10 @@ yaml_lint_file() {
|
||||
local -r display_path=${1#"$repo_path/"}
|
||||
printf '\033[0;34m- Running yamllint on %s\n' "$display_path"
|
||||
if ! yamllint -s -d "$lint_rules" "$path"; then
|
||||
printf '\033[0;31m\U0001F6AB yamllint -s -d "%s" %s failed\n\n\033[0m' "$lint_rules" "$path"
|
||||
printf '\033[0;31m\U0001F6AB yamllint -s -d "%s" %s failed\n\n\033[0m' "$lint_rules" "$display_path"
|
||||
false
|
||||
else
|
||||
printf '\033[0;32m\U00002705 %s\n\n\033[0m' "$path"
|
||||
printf '\033[0;32m\U00002705 %s\n\n\033[0m' "$display_path"
|
||||
true
|
||||
fi
|
||||
}
|
||||
@@ -55,17 +57,22 @@ for chart_name in $( cut -d'/' -f1,2 <<< "$files_to_push" | uniq ); do
|
||||
printf '\033[01;33mLinting yaml of %s:\n\033[0m' "$chart_name"
|
||||
chart_path="$repo_path"/"$chart_name"
|
||||
|
||||
for yaml_file in values.yaml values-production.yaml requirements.yaml Chart.yaml; do
|
||||
if [[ -f "$chart_path"/"$yaml_file" ]] && ! yaml_lint_file "$chart_path"/"$yaml_file"; then
|
||||
for yaml_file in "$chart_path"/values.yaml "$chart_path"/values-production.yaml "$chart_path"/requirements.yaml "$chart_path"/Chart.yaml "$chart_path"/ci/*; do
|
||||
if [[ -f "$yaml_file" ]] && ! yaml_lint_file "$yaml_file"; then
|
||||
failed=1
|
||||
fi
|
||||
done
|
||||
|
||||
for yaml_file in "$chart_path"/templates/*.yaml; do
|
||||
path_basename=templates/$(basename "$yaml_file")
|
||||
if ! render_and_yaml_lint "$chart_path" "$path_basename"; then
|
||||
failed=1
|
||||
for values_file in "$chart_path"/values.yaml "$chart_path"/ci/*.yaml; do
|
||||
if [[ ! -f "$values_file" ]];then
|
||||
continue
|
||||
fi
|
||||
for yaml_file in "$chart_path"/templates/*.yaml; do
|
||||
path_basename=templates/$(basename "$yaml_file")
|
||||
if ! render_and_yaml_lint "$chart_path" "$path_basename" "$values_file"; then
|
||||
failed=1
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user