Skip to content

Commit

Permalink
feat: use asdf exec-env to set CLOUDSDK_PYTHON on each gcloud cmd… (#14)
Browse files Browse the repository at this point in the history
* feat: use asdf exec-env to set CLOUDSDK_PYTHON on each gcloud cmd use

* feat: enforce bash strict mode

* fix: unset var with bash strict mode
  • Loading branch information
jthegedus committed Mar 8, 2020
1 parent 71180e0 commit 0a30972
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@
# Dependencies

- `bash`, `curl`, `tar`, `python`
- `CLOUDSDK_PYTHON`: set this environment variable in your shell config to load the correct version of Python.

```shell
python_sdk="$(command -v python)"
export CLOUDSDK_PYTHON="${python_sdk}"
```

# Install

Expand Down
15 changes: 15 additions & 0 deletions bin/exec-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -euo pipefail

if [[ ! -x "$(command -v python)" ]]; then
printf "🚨 Python not found and is required for gcloud. Might I suggest https://github.com/danhper/asdf-python\\n"
exit 1
fi

# stolen from https://unix.stackexchange.com/a/56846/397902
if [ -z "${CLOUDSDK_PYTHON:+1}" ]; then
# undefined or defined and empty
python_sdk="$(command -v python)"
export CLOUDSDK_PYTHON=${python_sdk}
fi
1 change: 0 additions & 1 deletion bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ extract() {

install_gcloud() {
printf "🚧 installing...\\n"
printf " ⚠️ CLOUDSDK_PYTHON must be set in you shell profile\\n"
"${ASDF_INSTALL_PATH}/install.sh" --usage-reporting=false --path-update=false --quiet
printf "✅ gcloud %s installed!\\n" "${ASDF_INSTALL_VERSION}"
}
Expand Down

0 comments on commit 0a30972

Please sign in to comment.