Skip to content

Commit

Permalink
Merge pull request #452 from w4andy/verify-fix-bastillefile-include
Browse files Browse the repository at this point in the history
add recursive verify for includes in Bastillefile
  • Loading branch information
cedwards authored Dec 9, 2021
2 parents 2327c6a + ce52faa commit 7c255d2
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions usr/local/share/bastille/verify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ verify_release() {
fi
}

handle_template_include() {
case ${TEMPLATE_INCLUDE} in
http?://*/*/*)
bastille bootstrap "${TEMPLATE_INCLUDE}"
;;
*/*)
BASTILLE_TEMPLATE_USER=$(echo "${TEMPLATE_INCLUDE}" | awk -F / '{ print $1 }')
BASTILLE_TEMPLATE_REPO=$(echo "${TEMPLATE_INCLUDE}" | awk -F / '{ print $2 }')
bastille verify "${BASTILLE_TEMPLATE_USER}/${BASTILLE_TEMPLATE_REPO}"
;;
*)
error_exit "Template INCLUDE content not recognized."
;;
esac
}

verify_template() {
_template_path=${bastille_templatesdir}/${BASTILLE_TEMPLATE}
_hook_validate=0
Expand All @@ -75,20 +91,8 @@ verify_template() {
echo
while read _include; do
info "[${_hook}]:[${_include}]:"

case ${_include} in
http?://*/*/*)
bastille bootstrap "${_include}"
;;
*/*)
BASTILLE_TEMPLATE_USER=$(echo "${_include}" | awk -F / '{ print $1 }')
BASTILLE_TEMPLATE_REPO=$(echo "${_include}" | awk -F / '{ print $2 }')
bastille verify "${BASTILLE_TEMPLATE_USER}/${BASTILLE_TEMPLATE_REPO}"
;;
*)
error_exit "Template INCLUDE content not recognized."
;;
esac
TEMPLATE_INCLUDE="${_include}"
handle_template_include
done < "${_path}"

## if tree; tree -a bastille_template/_dir
Expand All @@ -105,6 +109,18 @@ verify_template() {
fi
echo
done < "${_path}"
elif [ "${_hook}" = 'Bastillefile' ]; then
info "[${_hook}]:"
cat "${_path}"
while read _line; do
_cmd=$(echo "${_line}" | awk '{print tolower($1);}')
## if include; recursive verify
if [ "${_cmd}" = 'include' ]; then
TEMPLATE_INCLUDE=$(echo "${_line}" | awk '{print $2;}')
handle_template_include
fi
done < "${_path}"
echo
else
info "[${_hook}]:"
cat "${_path}"
Expand Down

0 comments on commit 7c255d2

Please sign in to comment.