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

Check for python module pyyaml when using kfctl.sh on platform GCP. #1975

Merged
merged 1 commit into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion scripts/kfctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,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