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/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