Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapt error handling #40

Merged
merged 2 commits into from
May 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
odra marked this conversation as resolved.
Show resolved Hide resolved
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