Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from TakeoffTech/feature/SRE-3752
Browse files Browse the repository at this point in the history
SRE-3752: use gnu parallel and GLOB for ignore
  • Loading branch information
josephhholmes authored Nov 30, 2020
2 parents f593ae4 + af4d35f commit 00e5fb3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/hrval-all.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env bash

set -o errexit
shopt -s extglob

DIR=${1}
IGNORE_VALUES=${2-false}
KUBE_VER=${3-master}
HELM_VER=${4-v2}
IGNORE_EXPRESSION=${5-.*}
IGNORE_EXPRESSION=${5}
HRVAL="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/hrval.sh"

if [[ ${HELM_VER} == "v2" ]]; then
Expand Down Expand Up @@ -38,17 +39,17 @@ function isHelmRelease {
DIR_PATH=$(echo ${DIR} | sed "s/^\///;s/\/$//")
FILES_TESTED=0
for f in `find ${DIR} -type f -name '*.yaml' -or -name '*.yml'`; do
if [[ ${f} =~ ${IGNORE_EXPRESSION} ]]; then
echo "Skipping file by ignore expression"
if [[ -n ${IGNORE_EXPRESSION} && ${f} = ${IGNORE_EXPRESSION} ]]; then
>&2 echo "Skipping file ${f} by ignore expression"
continue
fi
if [[ $(isHelmRelease ${f}) == "true" ]]; then
${HRVAL} ${f} ${IGNORE_VALUES} ${KUBE_VER} ${HELM_VER}
echo ${f}
FILES_TESTED=$(( FILES_TESTED+1 ))
else
echo "Ignoring ${f} not a HelmRelease"
>&2 echo "Ignoring ${f} not a HelmRelease"
fi
done
done | parallel "${HRVAL} {} \"${IGNORE_VALUES}\" ${KUBE_VER} ${HELM_VER}"

# This will set the GitHub actions output 'numFilesTested'
echo "::set-output name=numFilesTested::${FILES_TESTED}"

0 comments on commit 00e5fb3

Please sign in to comment.