From 8e8e24a81df7aef9f084cfbebe3cda1eb22e667e Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Mon, 18 Jul 2022 14:17:30 -0400 Subject: [PATCH] entrypoint: treat pkgs as a bash array Because the package name should be a proper "list" and is used in multiple places, take shellcheck's warning to heart and replace it with a proper bash array. Use a common function for generating said array. Signed-off-by: John Mulligan --- entrypoint.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 803c81d..a5fbcb0 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -263,14 +263,25 @@ pre_all_tests() { echo "mode: count" > "cover.out" } +find_pkgs() { + if [[ $1 = "--public" ]] ; then + skip='^(contrib|internal)' + else + skip='^contrib' + fi + # saves results in array named `pkgs` + readarray -t pkgs < <(go list ${BUILD_TAGS} ./... | \ + sed -e "s,^${PKG_PREFIX}/\?,," | \ + grep -vE "${skip}" | grep '.' ) +} + implements_tool() { mkdir -p "${RESULTS_DIR}" - pkgs=$(go list ${BUILD_TAGS} ./... | sed -e "s,^${PKG_PREFIX}/\?,," | \ - grep -v ^contrib | grep -v ^internal) + find_pkgs --public show ./implements --list \ --report-json "${RESULTS_DIR}/implements.json" \ --report-text "${RESULTS_DIR}/implements.txt" \ - ${pkgs} + "${pkgs[@]}" # output the brief summary info onto stdout grep '^[A-Z]' "${RESULTS_DIR}/implements.txt" } @@ -303,7 +314,7 @@ test_go_ceph() { return $? fi - pkgs=$(go list ${BUILD_TAGS} ./... | sed -e "s,^${PKG_PREFIX}/\?,," | grep -v ^contrib) + find_pkgs pre_all_tests if [[ ${WAIT_FILES} ]]; then # this is less gross looking than any other bash-native split-to-array code @@ -314,7 +325,7 @@ test_go_ceph() { setup_mirroring export MIRROR_CONF fi - for pkg in ${pkgs}; do + for pkg in "${pkgs[@]}"; do test_pkg "${pkg}" || test_failed "${pkg}" done post_all_tests