Skip to content

Commit

Permalink
Merge pull request #40 from integr8ly/fix-resources-error-handling
Browse files Browse the repository at this point in the history
adapt error handling
  • Loading branch information
pb82 committed May 15, 2019
2 parents 82901a8 + 956819a commit 7fe7fdd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions image/tools/lib/component/resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ function backup_resource {
local type=$1
local ns=$2
local dest=$3
local loop=$4
local loop=${4-default}

# Disable extended error checks. The check_resource function relies on a non-zero
# return code, which is interpreted as a failed command and causes the script to be
# terminated with the '-e' option
set +eo pipefail
check_resource ${type} ${ns}
if [ "$?" -eq "0" ]; then
echo "==> backing up $type in $ns"
if [[ "$loop" ]]; then
if [ "$loop" == "y" ]; then
echo '---' > /tmp/${type}.yaml
for obj in $(oc get ${type} -n ${ns} | tr -s ' ' | cut -d ' ' -f 1 | tail -n +2); do
echo '-' >> /tmp/${type}.yaml
Expand All @@ -42,6 +47,8 @@ function backup_resource {
oc get ${type} -n ${ns} -o yaml --export | gzip > ${dest}/archives/${ns}-${type}.yaml.gz
fi
fi
# Re-enable extended error checks
set -eo pipefail
}

# Backs up a namespace
Expand Down

0 comments on commit 7fe7fdd

Please sign in to comment.