Fix helm scripts to deal with spaces near version
Joey added spaces between the word "version" and the colon in one of
the charts, which broke several scripts. I've updated them to be less
brittle, and also adapted his TODO for using bash string manipulation
rather than awk in chart_version_check.sh.
Signed-off-by: Eric Ball <eball@linuxfoundation.org>
Change-Id: Ie1047e7c963526cc848b0acbe2b94c920db61b51
diff --git a/chart_version_check.sh b/chart_version_check.sh
index 1d1b33c..5450da4 100755
--- a/chart_version_check.sh
+++ b/chart_version_check.sh
@@ -296,17 +296,16 @@
local line
for line in "${delta[@]}";
do
- # [TODO] Replace awk with string builtins to reduce shell overhead.
case "$line" in
- -version:*)
+ -version*:*)
modified=1
- readarray -t tmp < <(awk '/^\-version:/ { print $2 }' <<<"$line")
+ readarray -t tmp <<< "${line#*: }"
# shellcheck disable=SC2034
old_var="${tmp[0]}"
filter_codes 'old_var'
;;
- +version:*)
- readarray -t tmp < <(awk '/^\+version:/ { print $2 }' <<<"$line")
+ +version*:*)
+ readarray -t tmp <<< "${line#*: }"
# shellcheck disable=SC2034
new_var="${tmp[0]}"
filter_codes 'new_var'
diff --git a/helmrepo.sh b/helmrepo.sh
index c13388a..3d36595 100755
--- a/helmrepo.sh
+++ b/helmrepo.sh
@@ -264,9 +264,9 @@
## -version : 1.2.3
## +version : 4.5.6
if [[ ! -v ref['-version'] ]]; then
- msg='Modify version= to publish chart changes'
+ msg='Modify version to publish chart changes'
elif [[ ! -v ref["$new"] ]]; then
- msg="Failed to detect +${key}= change in attributes"
+ msg="Failed to detect +${key} change in attributes"
else
continue
fi
@@ -367,7 +367,7 @@
case "$line" in
# appVersion: "1.0.3"
# version: 1.2.3
- [-+]*[vV]ersion:*) getVersion versions "$line" ;;
+ [-+]*[vV]ersion*:*) getVersion versions "$line" ;;
esac
done