Skip to content

Commit

Permalink
update download url
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Brocker committed Jul 19, 2023
1 parent f73c093 commit d087020
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ jobs:
uses: asdf-vm/actions/plugin-test@v1
with:
command: cloud_sql_proxy --version
version: 2.6.0
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

# Dependencies

**TODO: adapt this section**

- `bash`, `curl`, `tar`: generic POSIX utilities.
- `brew`, `install`, `go`: Golang
- `SOME_ENV_VAR`: set this environment variable in your shell config to load the correct version of tool x.

# Install
Expand Down
32 changes: 28 additions & 4 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

# TODO: Ensure this is the correct GitHub homepage where releases can be downloaded for cloud-sql-proxy.
GH_REPO="https://github.com/GoogleCloudPlatform/cloud-sql-proxy"
TOOL_NAME="cloud-sql-proxy"
TOOL_NAME="cloud_sql_proxy"
TOOL_TEST="cloud_sql_proxy --version"

fail() {
Expand Down Expand Up @@ -36,13 +36,36 @@ list_all_versions() {
list_github_tags
}

get_platform() {
local os=$(uname)
if [[ "${os}" == "Darwin" ]]; then
echo "osx"
elif [[ "${os}" == "Linux" ]]; then
echo "linux"
else
echo >&2 "unsupported os: ${os}" && exit 1
fi
}

get_arch() {
local os=$(uname)
local arch=$(uname -m)
if [[ "${os}" == "Darwin" && "${arch}" == "arm64" ]]; then
echo "arm64"
elif [[ "${os}" == "Linux" && "${arch}" == "aarch64" ]]; then
echo "aarch_64"
else
echo "${arch}"
fi
}


download_release() {
local version filename url
version="$1"
filename="$2"

# TODO: Adapt the release URL convention for cloud-sql-proxy
url="$GH_REPO/archive/v${version}.tar.gz"
url="$GH_REPO/releases/download/v${version}/cloud-sql-proxy.$(get_platform).$(get_arch).tar.gz"

echo "* Downloading $TOOL_NAME release $version..."
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"
Expand All @@ -59,7 +82,8 @@ install_version() {

(
mkdir -p "$install_path"
cp -r "$ASDF_DOWNLOAD_PATH"/* "$install_path"
cp "$ASDF_DOWNLOAD_PATH/$TOOL_NAME" "$install_path/$TOOL_NAME"
# chmod +x "$install_path/$TOOL_NAME"

# TODO: Assert cloud-sql-proxy executable exists.
local tool_cmd
Expand Down

0 comments on commit d087020

Please sign in to comment.