Skip to content

Commit

Permalink
Check for python module pyyaml when using kfctl.sh on platform GCP. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
IMBurbank authored and k8s-ci-robot committed Nov 20, 2018
1 parent 4240dfd commit 25dabab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scripts/kfctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ main() {
check_install ks
check_install kubectl

source "${ENV_FILE}"
if [ "${PLATFORM}" == "gcp" ]; then
checkInstallPy pyyaml yaml
fi

if [ "${COMMAND}" == "generate" ]; then
if [ "${WHAT}" == "platform" ] || [ "${WHAT}" == "all" ]; then
Expand Down
10 changes: 10 additions & 0 deletions scripts/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ check_install() {
fi
}

checkInstallPy() {
local PYPI=$1
local MOD=$2
if python -c "import pkgutil; exit(pkgutil.find_loader('${MOD}'))" &>/dev/null; then
echo "Failed to import python module ${MOD}."
echo "You don't have ${PYPI} installed. Please install ${PYPI}."
exit 1
fi
}

check_variable() {
if [[ -z "${1}" ]]; then
echo "'${2}' environment variable is not set. Please set it using export ${2}=value."
Expand Down

0 comments on commit 25dabab

Please sign in to comment.