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

fix: gcloud sdk install script #88

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/bash/scripts/eval/set-gcloud-path
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ __am_prompt_set_gcloud_path() {
fi

# add gcloud to the path
export PATH="$AM_PROMPT_USER/.gcloud/bin:$PATH"
export PATH="$AM_PROMPT_USER/bin/gcloud/bin/:$PATH"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patrickserrano Do we want this to be in the prompt user folder. I think we back this folder up every update. I guess there could be advantages but would we have to reinstall each time a user updated prompt?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmccaffery isn't this why we are installing bins to the $HOME dir so updates do not effect what is installed on the user system

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjk07 it looks like it was changed in the last PR to install to prompt/user/bin.

That said, I could have misinterpreted it given the inconsistent paths.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patrickserrano hmm... we'll have to look into this unless @dmccaffery can give us some insight into the original change.

This is a blocker for me for releasing v8.3; I don't want to introduce multiple bins of gcloud or other installs when upgrading to the new version of prompt. (unless there is a reason for such a change)

imo upgrading prompt should have nothing to do with other installs on the users system unless they are prompt dependencies (there should be very few). things that are dependent can live in the prompt folder and be backed up incase an upgrade fails.

Lets figure out what we missed in the last updated 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you merged my WIP -- I was midstream in some things, including this...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmccaffery my bad, I didn't realize that was still WIP!

fi

GCLOUD_CMD=$(command -v gcloud)
Expand Down
11 changes: 8 additions & 3 deletions src/sh/scripts/install-gcloud
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ __am_prompt_gcloud_install() {
rm -rf "$HOME"/.gcloud 1>/dev/null
fi

if [ -d "$AM_PROMPT_USER"/gcloud ]; then
if [ -d "$AM_PROMPT_USER"/bin/gcloud ]; then
rm -rf "$HOME"/gcloud 1>/ev/null
fi
;;
Expand All @@ -36,15 +36,20 @@ __am_prompt_gcloud_install() {
return
fi

temp=$(mktemp -d)
temp="$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')"
platform=$(uname | tr "[:upper:]" "[:lower:]")
arch=$(uname -m)

print-success "downloading gcloud-sdk..."
curl -Lso "$temp"/gcloud.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-"$version"-"$platform"-"$arch".tar.gz

# tar will fail if the directory doesn't exist
if [ ! -d "$AM_PROMPT_USER"/bin/gcloud ]; then
mkdir "$AM_PROMPT_USER"/bin/gcloud
fi

# extract the executable
tar -xfC "$temp" --strip-components=1 --directory "$AM_PROMPT_USER"/gcloud gcloud.tar.gz 1>/dev/null
tar -xf "$temp"/gcloud.tar.gz --strip-components=1 --directory="$AM_PROMPT_USER"/bin/gcloud 1>/dev/null

# remove the temp directory
rm -rf "$temp"
Expand Down
4 changes: 2 additions & 2 deletions src/zsh/scripts/eval/set-gcloud-path
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ __am_prompt_set_gcloud_path() {
if ! command -v gcloud 1>/dev/null 2>&1; then

# attempt to discover the path
if [ ! -f "$HOME/.gcloud/bin/gcloud" ]; then
if [ ! -f "$AM_PROMPT_USER/bin/gcloud/bin/gcloud" ]; then

# no gcloud installed
return
fi

# add gcloud to the path
export PATH="$HOME/.gcloud/bin":$PATH
export PATH="$AM_PROMPT_USER/bin/gcloud/bin/":$PATH
fi

GCLOUD_CMD=$(command -v gcloud)
Expand Down