Cosmetic cleanups + copyright
chart_version_check.sh
hart_versions.sh
helmlint.sh
helmrepo.sh
wait_for_jobs.sh
wait_for_pods.sh
----------------------
o Indentation erratic so use editor formatting to set a clean baseline.
o Update copyright notice to span 2024.
Change-Id: I21e3cd8fd997c24d6fcd03edc1caef5315bb7f63
diff --git a/chart_version_check.sh b/chart_version_check.sh
index a192f52..d428473 100755
--- a/chart_version_check.sh
+++ b/chart_version_check.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# ---------------------------------------------------------------------------
-# Copyright 2018-2022 Open Networking Foundation (ONF) and the ONF Contributors
+# Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -74,8 +74,8 @@
## Set summary display string
## --------------------------
case "$exit_code" in
- 0) status='PASS' ;;
- *) status='FAIL' ;;
+ 0) status='PASS' ;;
+ *) status='FAIL' ;;
esac
[[ $# -gt 0 ]] && formatStream "$@"
@@ -110,24 +110,24 @@
{
local indent=''
while [ $# -gt 0 ]; do
- local arg="$1"
- case "$arg" in
- -*banner) shift; echo "$1" ;;
- -*indent) shift; indent="$1" ;;
- -*tab-2) echo -n ' ' ;;
- -*tab-4) echo -n ' ' ;;
- -*tab-6) echo -n ' ' ;;
- -*tab-8) echo -n ' ' ;;
- -*newline) echo; ;;
- -*tab) echo -n ' ' ;;
- *) break ;;
- esac
- shift
+ local arg="$1"
+ case "$arg" in
+ -*banner) shift; echo "$1" ;;
+ -*indent) shift; indent="$1" ;;
+ -*tab-2) echo -n ' ' ;;
+ -*tab-4) echo -n ' ' ;;
+ -*tab-6) echo -n ' ' ;;
+ -*tab-8) echo -n ' ' ;;
+ -*newline) echo; ;;
+ -*tab) echo -n ' ' ;;
+ *) break ;;
+ esac
+ shift
done
for line in "$@";
do
- echo -e " ${indent}$line"
+ echo -e " ${indent}$line"
done
return
}
@@ -186,35 +186,35 @@
local modified=0
if [ ${#delta[@]} -gt 0 ]; then # modified
- #----------------------------------------
- # diff --git a/voltha-adapter-openolt/Chart.yaml [...]
- # --- a/voltha-adapter-openolt/Chart.yaml
- # +++ b/voltha-adapter-openolt/Chart.yaml
- # @@ -14,7 +14,7 @@
- # ---
- # -version: "2.11.3" (====> 2.11.3)
- # +version: "2.11.8" (====> 2.11.8)
- #----------------------------------------
- local line
- for line in "${delta[@]}";
- do
- # [TODO] Replace awk with string builtins to reduce shell overhead.
- case "$line" in
- -version:*)
- modified=1
- readarray -t tmp < <(awk '/^\-version:/ { print $2 }' <<<"$line")
- # shellcheck disable=SC2034
- old_var="${tmp[0]}"
- filter_codes 'old_var'
- ;;
- +version:*)
- readarray -t tmp < <(awk '/^\+version:/ { print $2 }' <<<"$line")
- # shellcheck disable=SC2034
- new_var="${tmp[0]}"
- filter_codes 'new_var'
- ;;
- esac
- done
+ #----------------------------------------
+ # diff --git a/voltha-adapter-openolt/Chart.yaml [...]
+ # --- a/voltha-adapter-openolt/Chart.yaml
+ # +++ b/voltha-adapter-openolt/Chart.yaml
+ # @@ -14,7 +14,7 @@
+ # ---
+ # -version: "2.11.3" (====> 2.11.3)
+ # +version: "2.11.8" (====> 2.11.8)
+ #----------------------------------------
+ local line
+ for line in "${delta[@]}";
+ do
+ # [TODO] Replace awk with string builtins to reduce shell overhead.
+ case "$line" in
+ -version:*)
+ modified=1
+ readarray -t tmp < <(awk '/^\-version:/ { print $2 }' <<<"$line")
+ # shellcheck disable=SC2034
+ old_var="${tmp[0]}"
+ filter_codes 'old_var'
+ ;;
+ +version:*)
+ readarray -t tmp < <(awk '/^\+version:/ { print $2 }' <<<"$line")
+ # shellcheck disable=SC2034
+ new_var="${tmp[0]}"
+ filter_codes 'new_var'
+ ;;
+ esac
+ done
fi
[ $modified -ne 0 ] # set $? for if/then/elif use: "if version_diff; then"
@@ -232,14 +232,14 @@
local idx
for (( idx=0; idx<${#varname[@]}; idx++ ));
do
- local val="${varname[idx]}"
- if [ ${#val} -lt 2 ]; then continue; fi
+ local val="${varname[idx]}"
+ if [ ${#val} -lt 2 ]; then continue; fi
- # Normalize: remove './' to support path comparison
- if [[ "${val:0:2}" == './' ]]; then
- varname[idx]="${val:2:${#val}}"
- [[ -v debug ]] && echo "[$idx] ${varname[$idx]}"
- fi
+ # Normalize: remove './' to support path comparison
+ if [[ "${val:0:2}" == './' ]]; then
+ varname[idx]="${val:2:${#val}}"
+ [[ -v debug ]] && echo "[$idx] ${varname[$idx]}"
+ fi
done
[[ -v debug ]] && declare -p varname
@@ -269,22 +269,22 @@
declare -a found=()
for val in "${varname[@]}";
do
- case "$val" in
- */Chart.yaml) ;; # special case
- "${dir}"*) found+=("$val") ;;
- esac
+ case "$val" in
+ */Chart.yaml) ;; # special case
+ "${dir}"*) found+=("$val") ;;
+ esac
done
## --------------------------------------------
## Display results when modified files detected
## --------------------------------------------
if [ ${#found[@]} -gt 0 ]; then
- declare -a stream=()
- stream+=('--tab-4')
- stream+=('--banner' "Files Changed: $dir")
- stream+=('--tab-6') # really --tab-8
- stream+=("${found[@]}")
- displayList "${stream[@]}"
+ declare -a stream=()
+ stream+=('--tab-4')
+ stream+=('--banner' "Files Changed: $dir")
+ stream+=('--tab-6') # really --tab-8
+ stream+=("${found[@]}")
+ displayList "${stream[@]}"
fi
[ ${#found[@]} -gt 0 ] # set $? for if/else
@@ -336,12 +336,12 @@
old=''
new=''
if version_diff "$chart" "$COMPARISON_BRANCH" 'old' 'new'; then
- suffix="($old => $new)" # display verion deltas in the right margin
- printf '[CHART] %-60s %s\n' "$chart" "$suffix"
- chart_modified=1
+ suffix="($old => $new)" # display verion deltas in the right margin
+ printf '[CHART] %-60s %s\n' "$chart" "$suffix"
+ chart_modified=1
else
- suffix="($old)"
- printf '[CHART] %s\n' "$chart"
+ suffix="($old)"
+ printf '[CHART] %s\n' "$chart"
fi
## -----------------------------------
@@ -352,9 +352,9 @@
combo_list+=("${untracked_files[@]}")
if report_modified "$chart" 'combo_list';
then
- if [ $chart_modified -eq 0 ]; then
- error "Chart modified but version unchanged: ${chart_dir}"
- fi
+ if [ $chart_modified -eq 0 ]; then
+ error "Chart modified but version unchanged: ${chart_dir}"
+ fi
fi
done
@@ -364,9 +364,9 @@
## ---------------------------
if [[ -x changes_remote ]] && [ ${#changes_remote} -gt 0 ]; then # local_edits
displayList \
- '--newline' \
- '--banner' 'Changed Files:' \
- "${changes_remote[@]}"
+ '--newline' \
+ '--banner' 'Changed Files:' \
+ "${changes_remote[@]}"
fi
## -------------------------------
@@ -374,9 +374,9 @@
## -------------------------------
if [ ${#untracked_files[@]} -gt 0 ]; then
displayList \
- '--newline' \
- '--banner' 'Untracked Files:' \
- "${untracked_files[@]}"
+ '--newline' \
+ '--banner' 'Untracked Files:' \
+ "${untracked_files[@]}"
fi
## ---------------------------------
@@ -385,9 +385,9 @@
declare -a -g error_stream
if [ ${#error_stream[@]} -gt 0 ]; then
displayList \
- '--newline' \
- '--banner' 'Error Sumamry:' \
- "${error_stream[@]}"
+ '--newline' \
+ '--banner' 'Error Sumamry:' \
+ "${error_stream[@]}"
fi
summary_status_with_exit $?
diff --git a/compare_service_chart_versions.sh b/compare_service_chart_versions.sh
index 8bc8746..096ca9a 100755
--- a/compare_service_chart_versions.sh
+++ b/compare_service_chart_versions.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# Copyright 2018-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -28,11 +28,11 @@
case $SVCNAME in
volt)
- SVCNAME=olt-service
- ;;
+ SVCNAME=olt-service
+ ;;
kubernetes)
- SVCNAME=kubernetes-service
- ;;
+ SVCNAME=kubernetes-service
+ ;;
esac
if [ ! -e "$REPODIR/orchestration/xos-services/$SVCNAME/VERSION" ]
diff --git a/helmlint.sh b/helmlint.sh
index f9614c9..f26ea5b 100755
--- a/helmlint.sh
+++ b/helmlint.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# -----------------------------------------------------------------------
-# Copyright 2018-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -42,8 +42,8 @@
# if [[ $# -gt 0 ]] && [[ "$1" = 'clean' ]]; then <--- allow set -u
if [ "$1" = "clean" ]
then
- echo "Removing any downloaded charts"
- find "${WORKSPACE}" -type d -name 'charts' -exec rm -rf {} \;
+ echo "Removing any downloaded charts"
+ find "${WORKSPACE}" -type d -name 'charts' -exec rm -rf {} \;
fi
# now that $1 is checked, error on undefined vars
@@ -52,51 +52,51 @@
# loop on result of 'find -name Chart.yaml'
while IFS= read -r -d '' chart
do
- chartdir=$(dirname "${chart}")
+ chartdir=$(dirname "${chart}")
- echo "Checking chart: $chartdir"
+ echo "Checking chart: $chartdir"
- # update dependencies (if any)
- if ! helm dependency update "${chartdir}";
- then
- fail_lint=1
- failed_deps+=("${chartdir}")
- fi
-
- # lint the chart (with values.yaml if it exists)
- if [ -f "${chartdir}/values.yaml" ]; then
- helm lint --strict --values "${chartdir}/values.yaml" "${chartdir}"
- else
- helm lint --strict "${chartdir}"
- fi
-
- rc=$?
- if [[ $rc != 0 ]]; then
- fail_lint=1
- failed_lint+=("${chartdir}")
- fi
-
- # -----------------------------------------------------------------------
- # check that requirements are available if they're specified
- # how is this check different than helm dep up above ?
- # -----------------------------------------------------------------------
- # later helm versions allow requirements.yaml to be defined directly in
- # Chart.yaml so an explicit check may no longer be needed.
- #
- # Should we err when requirements.yaml detected to cleanup old code ?
- # -----------------------------------------------------------------------
- if [ -f "${chartdir}/requirements.yaml" ];
- then
- echo "Chart has requirements.yaml, checking availability"
- if ! helm dependency update "${chartdir}"; then
- fail_lint=1
- failed_reqs+=("${chartdir}")
+ # update dependencies (if any)
+ if ! helm dependency update "${chartdir}";
+ then
+ fail_lint=1
+ failed_deps+=("${chartdir}")
fi
- # remove charts dir after checking for availability, as this chart might be
- # required by other charts in the next loop
- rm -rf "${chartdir}/charts"
- fi
+ # lint the chart (with values.yaml if it exists)
+ if [ -f "${chartdir}/values.yaml" ]; then
+ helm lint --strict --values "${chartdir}/values.yaml" "${chartdir}"
+ else
+ helm lint --strict "${chartdir}"
+ fi
+
+ rc=$?
+ if [[ $rc != 0 ]]; then
+ fail_lint=1
+ failed_lint+=("${chartdir}")
+ fi
+
+ # -----------------------------------------------------------------------
+ # check that requirements are available if they're specified
+ # how is this check different than helm dep up above ?
+ # -----------------------------------------------------------------------
+ # later helm versions allow requirements.yaml to be defined directly in
+ # Chart.yaml so an explicit check may no longer be needed.
+ #
+ # Should we err when requirements.yaml detected to cleanup old code ?
+ # -----------------------------------------------------------------------
+ if [ -f "${chartdir}/requirements.yaml" ];
+ then
+ echo "Chart has requirements.yaml, checking availability"
+ if ! helm dependency update "${chartdir}"; then
+ fail_lint=1
+ failed_reqs+=("${chartdir}")
+ fi
+
+ # remove charts dir after checking for availability, as this chart might be
+ # required by other charts in the next loop
+ rm -rf "${chartdir}/charts"
+ fi
done < <(find "${WORKSPACE}" -name Chart.yaml -print0)
@@ -109,36 +109,36 @@
EOM
# echo "Charts that failed to lint: $failed_lint"
- if [ ${#failed_lint[@]} -gt 0 ]; then
- echo "Charts that failed to lint:"
- for chart in "${failed_lint[@]}";
- do
- echo " $chart"
- done
- fi
+ if [ ${#failed_lint[@]} -gt 0 ]; then
+ echo "Charts that failed to lint:"
+ for chart in "${failed_lint[@]}";
+ do
+ echo " $chart"
+ done
+ fi
- if [ ${#failed_deps[@]} -gt 0 ]; then
- echo "Charts that failed helm dependency update:"
- for chart in "${failed_deps[@]}";
- do
- echo " $chart"
- done
- fi
+ if [ ${#failed_deps[@]} -gt 0 ]; then
+ echo "Charts that failed helm dependency update:"
+ for chart in "${failed_deps[@]}";
+ do
+ echo " $chart"
+ done
+ fi
- if [ ${#failed_reqs[@]} -gt 0 ]; then
- echo "Charts with failures in requirements.yaml:"
- for chart in "${failed_reqs[@]}";
- do
- echo " $chart"
- done
- fi
+ if [ ${#failed_reqs[@]} -gt 0 ]; then
+ echo "Charts with failures in requirements.yaml:"
+ for chart in "${failed_reqs[@]}";
+ do
+ echo " $chart"
+ done
+ fi
- echo
- echo "See Also:"
- echo " o https://wiki.opennetworking.org/display/VOLTHA/make+lint-helm"
-
- echo
- exit 1
+ echo
+ echo "See Also:"
+ echo " o https://wiki.opennetworking.org/display/VOLTHA/make+lint-helm"
+
+ echo
+ exit 1
fi
echo "# helmlint.sh Success! - all charts linted and have valid requirements.yaml #"
diff --git a/helmrepo.sh b/helmrepo.sh
index 90c8195..d0c0c1d 100755
--- a/helmrepo.sh
+++ b/helmrepo.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# Copyright 2018-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -66,15 +66,15 @@
# ---------------------------------------------
for package_path in "${package_paths[@]}";
do
- package="${package_path##*/}" # basename
-
- if [ -f "${OLD_REPO_DIR}/${package}" ]; then
- echo
- echo "PACKAGE: $package"
- /bin/ls -l "$package_path"
- /bin/ls -l "${OLD_REPO_DIR}/${package}"
- error "Package: ${package} with same version already exists in ${OLD_REPO_DIR}"
- fi
+ package="${package_path##*/}" # basename
+
+ if [ -f "${OLD_REPO_DIR}/${package}" ]; then
+ echo
+ echo "PACKAGE: $package"
+ /bin/ls -l "$package_path"
+ /bin/ls -l "${OLD_REPO_DIR}/${package}"
+ error "Package: ${package} with same version already exists in ${OLD_REPO_DIR}"
+ fi
done
return
@@ -127,9 +127,9 @@
local dest="$1"; shift # helm --destination
if [[ -v dry_run ]]; then
- func_echo "helm package --dependency-update --destination $dest $chartdir"
+ func_echo "helm package --dependency-update --destination $dest $chartdir"
else
- helm package --dependency-update --destination "$dest" "$chartdir"
+ helm package --dependency-update --destination "$dest" "$chartdir"
fi
return
}
@@ -142,24 +142,24 @@
local repo_dir="$1"; shift # helm --destination
if [[ -v dry_run ]]; then
- func_echo "helm repo index $repo_dir --url https://${PUBLISH_URL}"
+ func_echo "helm repo index $repo_dir --url https://${PUBLISH_URL}"
elif [[ -v no_publish ]]; then
- func_echo "[SKIP] helm publishing due to --no-publish"
-
+ func_echo "[SKIP] helm publishing due to --no-publish"
+
else
- ## ------------------------------------------------
- ## Helm updates are guarded by jenkins
- ## Revision control should reinforce that assertion
- ## ------------------------------------------------
- case "$USER" in
- jenkins)
- helm repo index "$repo_dir" --url https://"${PUBLISH_URL}"
- ;;
- *)
- func_echo "[SKIP] helm publishing due to ($USER != jenkins)"
- ;;
- esac
+ ## ------------------------------------------------
+ ## Helm updates are guarded by jenkins
+ ## Revision control should reinforce that assertion
+ ## ------------------------------------------------
+ case "$USER" in
+ jenkins)
+ helm repo index "$repo_dir" --url https://"${PUBLISH_URL}"
+ ;;
+ *)
+ func_echo "[SKIP] helm publishing due to ($USER != jenkins)"
+ ;;
+ esac
fi
return
@@ -179,9 +179,9 @@
cmd+=('--merge' "${old_repo}/index.yaml" "$new_repo")
if [[ -v dry_run ]]; then
- func_echo "${cmd[@]}"
+ func_echo "${cmd[@]}"
else
- "${cmd[@]}"
+ "${cmd[@]}"
fi
return
}
@@ -193,13 +193,13 @@
{
local val="$1" ; shift
-# shellcheck disable=SC2178
- declare -n ref=$1 ; shift # indirect var
+ # shellcheck disable=SC2178
+ declare -n ref=$1 ; shift # indirect var
val="${val%/Chart.yaml}" # dirname: prune /Chart.yaml
val="${val##*/}" # basename: test directory
-# shellcheck disable=SC2034,SC2178
+ # shellcheck disable=SC2034,SC2178
ref="$val" # Return value to caller
return
}
@@ -220,14 +220,14 @@
local chart
for chart in "${charts[@]}";
do
- echo
- func_echo "Chart.yaml: $chart"
+ echo
+ func_echo "Chart.yaml: $chart"
- chartdir=''
- chart_path_to_test_dir "$chart" chartdir
- func_echo " Chart.dir: $chartdir"
+ chartdir=''
+ chart_path_to_test_dir "$chart" chartdir
+ func_echo " Chart.dir: $chartdir"
- helm_deps_update "${repo_dir}"
+ helm_deps_update "${repo_dir}"
done
helm_index_publish "${repo_dir}"
@@ -242,7 +242,7 @@
## -----------------------------------------------------------------------
function validate_changes()
{
- local chart="$1"; shift
+ local chart="$1"; shift
# shellcheck disable=SC2178
local -n ref=$1; shift
@@ -254,24 +254,24 @@
local key0
for key0 in "${!ref[@]}";
do
- local key="${key0:1}"
- # shellcheck disable=SC2034
- local old="-${key}"
- local new="+${key}"
+ local key="${key0:1}"
+ # shellcheck disable=SC2034
+ local old="-${key}"
+ local new="+${key}"
- ## Key/val paris are diff deltas:
- ## -version : 1.2.3
- ## +version : 4.5.6
- if [[ ! -v ref['-version'] ]]; then
- msg='Modify version= to publish chart changes'
- elif [[ ! -v ref["$new"] ]]; then
- msg="Failed to detect +${key}= change in attributes"
- else
- continue
- fi
+ ## Key/val paris are diff deltas:
+ ## -version : 1.2.3
+ ## +version : 4.5.6
+ if [[ ! -v ref['-version'] ]]; then
+ msg='Modify version= to publish chart changes'
+ elif [[ ! -v ref["$new"] ]]; then
+ msg="Failed to detect +${key}= change in attributes"
+ else
+ continue
+ fi
- local -i failed=1
- cat <<ERR
+ local -i failed=1
+ cat <<ERR
** -----------------------------------------------------------------------
** Chart dir: $chartdir
@@ -279,13 +279,13 @@
** Error: $msg
** -----------------------------------------------------------------------
ERR
- func_echo "$(declare -p versions | sed -e 's/\[/\n\[/g')"
+ func_echo "$(declare -p versions | sed -e 's/\[/\n\[/g')"
done
if [[ -v failed ]]; then
- false
+ false
else
- true
+ true
fi
return
@@ -299,19 +299,19 @@
arg="$1"; shift
case "$arg" in
- -*debug) declare -g -i debug=1 ;;
- -*dry*) declare -g -i dry_run=1 ;;
- -*no-publish) declare -g -i no_publish=1 ;;
- -*help)
- cat <<EOH
+ -*debug) declare -g -i debug=1 ;;
+ -*dry*) declare -g -i dry_run=1 ;;
+ -*no-publish) declare -g -i no_publish=1 ;;
+ -*help)
+ cat <<EOH
Usage: $0
--debug Enable debug mode
--dry-run Simulate helm calls
EOH
- ;;
+ ;;
- -*) echo "[SKIP] unknown switch [$arg]" ;;
- *) echo "[SKIP] unknown argument [$arg]" ;;
+ -*) echo "[SKIP] unknown switch [$arg]" ;;
+ *) echo "[SKIP] unknown argument [$arg]" ;;
esac
done
@@ -330,99 +330,99 @@
echo "# helmrepo.sh Success! Generated new repo index in ${NEW_REPO_DIR}"
else
- # OLD_REPO_DIR exists, check for new charts and update only with changes
- echo "Found existing helm repo: ${OLD_REPO_DIR}, attempting update"
+ # OLD_REPO_DIR exists, check for new charts and update only with changes
+ echo "Found existing helm repo: ${OLD_REPO_DIR}, attempting update"
- # Loop and create chart packages, only if changed
- declare -a charts=()
- get_chart_yaml "$WORKSPACE" charts
+ # Loop and create chart packages, only if changed
+ declare -a charts=()
+ get_chart_yaml "$WORKSPACE" charts
- for chart in "${charts[@]}";
- do
- echo
- func_echo "Chart.yaml: $chart"
+ for chart in "${charts[@]}";
+ do
+ echo
+ func_echo "Chart.yaml: $chart"
- chartdir=''
- chart_path_to_test_dir "$chart" chartdir
- func_echo " Chart.dir: $chartdir"
+ chartdir=''
+ chart_path_to_test_dir "$chart" chartdir
+ func_echo " Chart.dir: $chartdir"
- # See if chart version changed from previous HEAD commit
- readarray -t chart_yaml_diff < <(git diff -p HEAD^ -- "$chart")
+ # See if chart version changed from previous HEAD commit
+ readarray -t chart_yaml_diff < <(git diff -p HEAD^ -- "$chart")
- if [[ ! -v chart_yaml_diff ]]; then
- echo "Chart unchanged, not packaging: '${chartdir}'"
+ if [[ ! -v chart_yaml_diff ]]; then
+ echo "Chart unchanged, not packaging: '${chartdir}'"
- # -------------------------------------------------------------------
- # Assumes that helmlint.sh and chart_version_check.sh have been run
- # pre-merge, which ensures that all charts are valid and have their
- # version updated in Chart.yaml
- # -------------------------------------------------------------------
- elif [ ${#chart_yaml_diff} -gt 0 ]; then
- declare -A versions=()
- for line in "${chart_yaml_diff[@]}";
- do
- [[ -v debug ]] && func_echo "$line"
+ # -------------------------------------------------------------------
+ # Assumes that helmlint.sh and chart_version_check.sh have been run
+ # pre-merge, which ensures that all charts are valid and have their
+ # version updated in Chart.yaml
+ # -------------------------------------------------------------------
+ elif [ ${#chart_yaml_diff} -gt 0 ]; then
+ declare -A versions=()
+ for line in "${chart_yaml_diff[@]}";
+ do
+ [[ -v debug ]] && func_echo "$line"
- case "$line" in
- # appVersion: "1.0.3"
- # version: 1.2.3
- [-+]*[vV]ersion:*) getVersion versions "$line" ;;
- esac
- done
+ case "$line" in
+ # appVersion: "1.0.3"
+ # version: 1.2.3
+ [-+]*[vV]ersion:*) getVersion versions "$line" ;;
+ esac
+ done
- # ---------------------------------------------------------------
- # [TODO] -- versions['-version']='version string change required'
- # ---------------------------------------------------------------
- # version: string change initiates a delta forcing helm to update.
- # Should it be required by every checkin ? For ex: release may
- # accumulate several version edits then publish all when finished.
- #
- # Danger would be chart changes are not published/tested when
- # a dev forgets to update the chart version string.
- # ---------------------------------------------------------------
+ # ---------------------------------------------------------------
+ # [TODO] -- versions['-version']='version string change required'
+ # ---------------------------------------------------------------
+ # version: string change initiates a delta forcing helm to update.
+ # Should it be required by every checkin ? For ex: release may
+ # accumulate several version edits then publish all when finished.
+ #
+ # Danger would be chart changes are not published/tested when
+ # a dev forgets to update the chart version string.
+ # ---------------------------------------------------------------
- ## ---------------------------------------------------------------
- ## Check for required version change and stray attribute deletions
- ## We are comparing diff output [-+]verison : x.y
- ## +{key} indicates a required attribute exists and was modified
- ## ---------------------------------------------------------------
- if ! validate_changes "$chart" versions; then
- declare -g -i failed=1
- continue
- fi
+ ## ---------------------------------------------------------------
+ ## Check for required version change and stray attribute deletions
+ ## We are comparing diff output [-+]verison : x.y
+ ## +{key} indicates a required attribute exists and was modified
+ ## ---------------------------------------------------------------
+ if ! validate_changes "$chart" versions; then
+ declare -g -i failed=1
+ continue
+ fi
- # Always query, version string may not have changed
- readarray -t ver < <(grep -oP '(?<= version: )\S+' "$chart")
- declare -p ver
+ # Always query, version string may not have changed
+ readarray -t ver < <(grep -oP '(?<= version: )\S+' "$chart")
+ declare -p ver
- echo "Detected new version of chart ${chartdir}, creating package: ${ver[*]}"
+ echo "Detected new version of chart ${chartdir}, creating package: ${ver[*]}"
- helm_deps_update "${NEW_REPO_DIR}"
+ helm_deps_update "${NEW_REPO_DIR}"
- else
- echo "Chart unchanged, not packaging: '${chartdir}'"
- fi
- done
+ else
+ echo "Chart unchanged, not packaging: '${chartdir}'"
+ fi
+ done
- check_packages "$NEW_REPO_DIR"
+ check_packages "$NEW_REPO_DIR"
- ## -----------------------------------------------------------------------
- ## -----------------------------------------------------------------------
- # only update index when new charts are added
- if [ ${#package_paths[@]} -gt 0 ]; then
+ ## -----------------------------------------------------------------------
+ ## -----------------------------------------------------------------------
+ # only update index when new charts are added
+ if [ ${#package_paths[@]} -gt 0 ]; then
- # Create updated index.yaml (new version created in NEW_REPO_DIR)
- helm_index_merge "${OLD_REPO_DIR}" "${NEW_REPO_DIR}"
+ # Create updated index.yaml (new version created in NEW_REPO_DIR)
+ helm_index_merge "${OLD_REPO_DIR}" "${NEW_REPO_DIR}"
- # move over packages and index.yaml
- mv "${NEW_REPO_DIR}"/*.tgz "${OLD_REPO_DIR}/"
- mv "${NEW_REPO_DIR}/index.yaml" "${OLD_REPO_DIR}/index.yaml"
+ # move over packages and index.yaml
+ mv "${NEW_REPO_DIR}"/*.tgz "${OLD_REPO_DIR}/"
+ mv "${NEW_REPO_DIR}/index.yaml" "${OLD_REPO_DIR}/index.yaml"
- echo "# helmrepo.sh Success! Updated existing repo index in ${OLD_REPO_DIR}"
+ echo "# helmrepo.sh Success! Updated existing repo index in ${OLD_REPO_DIR}"
- else
- echo "# helmrepo.sh Success! No new charts added."
- fi
+ else
+ echo "# helmrepo.sh Success! No new charts added."
+ fi
fi
exit 0
diff --git a/wait_for_jobs.sh b/wait_for_jobs.sh
index ee32c42..dbb35da 100755
--- a/wait_for_jobs.sh
+++ b/wait_for_jobs.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# Copyright 2018-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -36,46 +36,46 @@
prev_job_count=0
while true; do
- NOW=$(date +%s)
+ NOW=$(date +%s)
- # handle timeout without completion
- if [ "$NOW" -gt "$END_TIME" ]
- then
- echo "Jobs didn't complete before timeout of ${JOBS_TIMEOUT} seconds"
- fail_wfj=1
- break
- fi
+ # handle timeout without completion
+ if [ "$NOW" -gt "$END_TIME" ]
+ then
+ echo "Jobs didn't complete before timeout of ${JOBS_TIMEOUT} seconds"
+ fail_wfj=1
+ break
+ fi
- # get list of active jobs, and count of them
- # jsonpath is picky about string vs comparison quoting, so have to have:
- # shellcheck disable=SC2026,SC2086
- active_jobs=$(kubectl get jobs $KUBECTL_ARGS -o=jsonpath='{range .items[?(@.status.active=='1')]}{.metadata.name}{"\n"}{end}')
+ # get list of active jobs, and count of them
+ # jsonpath is picky about string vs comparison quoting, so have to have:
+ # shellcheck disable=SC2026,SC2086
+ active_jobs=$(kubectl get jobs $KUBECTL_ARGS -o=jsonpath='{range .items[?(@.status.active=='1')]}{.metadata.name}{"\n"}{end}')
- # this always is 1 or more, as echo leaves a newline in the output which wc
- # counts as a line
- active_job_count=$(echo -n "${active_jobs}" | wc -l)
+ # this always is 1 or more, as echo leaves a newline in the output which wc
+ # counts as a line
+ active_job_count=$(echo -n "${active_jobs}" | wc -l)
- # if no jobs active, print runtime and break
- if [ -z "$active_jobs" ]
- then
- runtime=$((NOW - START_TIME))
- echo ""
- echo "All jobs completed in $runtime seconds"
- break
- fi
+ # if no jobs active, print runtime and break
+ if [ -z "$active_jobs" ]
+ then
+ runtime=$((NOW - START_TIME))
+ echo ""
+ echo "All jobs completed in $runtime seconds"
+ break
+ fi
- # deal with changes in number of jobs
- if [ "$active_job_count" -ne "$prev_job_count" ]
- then
- echo ""
- echo "Number of active jobs changed - current jobs:"
- echo "$active_jobs"
- fi
- prev_job_count=$active_job_count
+ # deal with changes in number of jobs
+ if [ "$active_job_count" -ne "$prev_job_count" ]
+ then
+ echo ""
+ echo "Number of active jobs changed - current jobs:"
+ echo "$active_jobs"
+ fi
+ prev_job_count=$active_job_count
- # print number of remaining jobs every $CHECK_INTERVAL
- echo -n "$active_job_count "
- sleep "$CHECK_INTERVAL"
+ # print number of remaining jobs every $CHECK_INTERVAL
+ echo -n "$active_job_count "
+ sleep "$CHECK_INTERVAL"
done
echo ""
diff --git a/wait_for_pods.sh b/wait_for_pods.sh
index 25ff43a..e5fa613 100755
--- a/wait_for_pods.sh
+++ b/wait_for_pods.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# Copyright 2018-2023 Open Networking Foundation (ONF) and the ONF Contributors
+# Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -30,12 +30,12 @@
# use namespace if passed as first arg, or "all" for all namespaces
if [ -n "$1" ]
then
- if [[ "$1" == "all" ]]
- then
- KUBECTL_ARGS+=" --all-namespaces"
- else
- KUBECTL_ARGS+=" --namespace=$1"
- fi
+ if [[ "$1" == "all" ]]
+ then
+ KUBECTL_ARGS+=" --all-namespaces"
+ else
+ KUBECTL_ARGS+=" --namespace=$1"
+ fi
fi
set -u
@@ -49,68 +49,68 @@
prev_total_unready=0
while true; do
- NOW=$(date +%s)
+ NOW=$(date +%s)
- # handle timeout without completion
- if [ "$NOW" -gt "$END_TIME" ]
- then
- echo "Pods/Containers/Jobs not ready before timeout of ${PODS_TIMEOUT} seconds"
- fail_wfp=1
- break
- fi
+ # handle timeout without completion
+ if [ "$NOW" -gt "$END_TIME" ]
+ then
+ echo "Pods/Containers/Jobs not ready before timeout of ${PODS_TIMEOUT} seconds"
+ fail_wfp=1
+ break
+ fi
- # get list of uncompleted items with jsonpath, then count them with wc
- # ref: https://kubernetes.io/docs/reference/kubectl/jsonpath/
- # jsonpath is picky about string vs comparison quoting, so may need to
- # disable SC2026 for these lines. SC2086 allows for multiple args.
+ # get list of uncompleted items with jsonpath, then count them with wc
+ # ref: https://kubernetes.io/docs/reference/kubectl/jsonpath/
+ # jsonpath is picky about string vs comparison quoting, so may need to
+ # disable SC2026 for these lines. SC2086 allows for multiple args.
- # shellcheck disable=SC2026,SC2086
- pending_pods=$(kubectl get pods ${KUBECTL_ARGS} -o=jsonpath='{range .items[?(@.status.phase=="Pending")]}{.metadata.name}{"\n"}{end}')
- # check for empty string before counting lines, echo adds a newline
- if [ -z "$pending_pods" ]; then
- pending_pod_count=0
- else
- pending_pod_count=$( echo "$pending_pods" | wc -l)
- fi
+ # shellcheck disable=SC2026,SC2086
+ pending_pods=$(kubectl get pods ${KUBECTL_ARGS} -o=jsonpath='{range .items[?(@.status.phase=="Pending")]}{.metadata.name}{"\n"}{end}')
+ # check for empty string before counting lines, echo adds a newline
+ if [ -z "$pending_pods" ]; then
+ pending_pod_count=0
+ else
+ pending_pod_count=$( echo "$pending_pods" | wc -l)
+ fi
- # shellcheck disable=SC2026,SC2086
- unready_containers=$(kubectl get pods ${KUBECTL_ARGS} -o=jsonpath='{range .items[?(@.status.phase=="Running")]}{range .status.containerStatuses[?(@.ready==false)]}{.name}: {.ready}{"\n"}{end}{end}')
- if [ -z "$unready_containers" ]; then
- unready_container_count=0
- else
- unready_container_count=$(echo "$unready_containers" | wc -l)
- fi
+ # shellcheck disable=SC2026,SC2086
+ unready_containers=$(kubectl get pods ${KUBECTL_ARGS} -o=jsonpath='{range .items[?(@.status.phase=="Running")]}{range .status.containerStatuses[?(@.ready==false)]}{.name}: {.ready}{"\n"}{end}{end}')
+ if [ -z "$unready_containers" ]; then
+ unready_container_count=0
+ else
+ unready_container_count=$(echo "$unready_containers" | wc -l)
+ fi
- # shellcheck disable=SC2026,SC2086
- active_jobs=$(kubectl get jobs $KUBECTL_ARGS -o=jsonpath='{range .items[?(@.status.active=='1')]}{.metadata.name}{"\n"}{end}')
- if [ -z "$active_jobs" ]; then
- active_job_count=0
- else
- active_job_count=$(echo "$active_jobs" | wc -l)
- fi
+ # shellcheck disable=SC2026,SC2086
+ active_jobs=$(kubectl get jobs $KUBECTL_ARGS -o=jsonpath='{range .items[?(@.status.active=='1')]}{.metadata.name}{"\n"}{end}')
+ if [ -z "$active_jobs" ]; then
+ active_job_count=0
+ else
+ active_job_count=$(echo "$active_jobs" | wc -l)
+ fi
- total_unready=$((pending_pod_count + unready_container_count + active_job_count))
+ total_unready=$((pending_pod_count + unready_container_count + active_job_count))
- # if everything is ready, print runtime and break
- if [ "$total_unready" -eq 0 ]
- then
- runtime=$((NOW - START_TIME))
- echo ""
- echo "All pods ready in $runtime seconds"
- break
- fi
+ # if everything is ready, print runtime and break
+ if [ "$total_unready" -eq 0 ]
+ then
+ runtime=$((NOW - START_TIME))
+ echo ""
+ echo "All pods ready in $runtime seconds"
+ break
+ fi
- # deal with changes in number of jobs
- if [ "$total_unready" -ne "$prev_total_unready" ]
- then
- echo ""
- echo "Change in unready pods - Pending Pods: $pending_pod_count, Unready Containers: $unready_container_count, Active Jobs: $active_job_count"
- fi
- prev_total_unready=$total_unready
+ # deal with changes in number of jobs
+ if [ "$total_unready" -ne "$prev_total_unready" ]
+ then
+ echo ""
+ echo "Change in unready pods - Pending Pods: $pending_pod_count, Unready Containers: $unready_container_count, Active Jobs: $active_job_count"
+ fi
+ prev_total_unready=$total_unready
- # print number of unready pods every $CHECK_INTERVAL
- echo -n "$total_unready "
- sleep "$CHECK_INTERVAL"
+ # print number of unready pods every $CHECK_INTERVAL
+ echo -n "$total_unready "
+ sleep "$CHECK_INTERVAL"
done
exit ${fail_wfp}