Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.

Commit

Permalink
Implements docs and get-tce-release script to work for public repo (#…
Browse files Browse the repository at this point in the history
…1926)

Signed-off-by: John McBride <[email protected]>
  • Loading branch information
jpmcb authored Oct 4, 2021
1 parent b16d48e commit c55620b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
3 changes: 1 addition & 2 deletions docs/site/content/docs/assets/cli-install-linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
1. _[Alternative]_ Download the release using the CLI. You may download a release using the provided remote script piped into bash.

```sh
curl -H "Authorization: token ${GITHUB_TOKEN}" \
-H "Accept: application/vnd.github.v3.raw" \
curl -H "Accept: application/vnd.github.v3.raw" \
-L https://api.github.com/repos/vmware-tanzu/community-edition/contents/hack/get-tce-release.sh | \
bash -s <RELEASE-VERSION> <RELEASE-OS-DISTRIBUTION>
```
Expand Down
19 changes: 9 additions & 10 deletions hack/get-tce-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ set -e
# Script to download asset file from tag release using GitHub API v3.
# Inspired by: http://stackoverflow.com/a/35688093/55075

# Validate GitHub access token
if [ -z "$GITHUB_TOKEN" ]; then
echo "Error: Please define GITHUB_TOKEN variable!"
exit 1
fi

# Should have two arguments, release-tag and file name
if [ $# -ne 2 ]; then
echo "Usage: $0 [tag] [name]"
Expand All @@ -35,11 +29,16 @@ name=$2
GH_API="https://api.github.com"
GH_REPO="$GH_API/repos/vmware-tanzu/community-edition"
GH_TAGS="$GH_REPO/releases/tags/$tag"
AUTH="Authorization: token $GITHUB_TOKEN"
AUTH=""
CURL_ARGS="-LJO#"

# Validate GH token.
curl -o /dev/null -sH "$AUTH" $GH_REPO || { echo "Error: Unauthenticated token or network issue!"; exit 1; }
# Validate GitHub access token
if [ -z "${GITHUB_TOKEN:-}" ]; then
echo "Warning: No GITHUB_TOKEN variable defined - requests to the GitHub API may be rate limited"
else
AUTH="Authorization: token $GITHUB_TOKEN"
curl -o /dev/null -sH "$AUTH" $GH_REPO || { echo "Error: Unauthenticated token or network issue!"; exit 1; }
fi

# Read asset tags
assets=$(curl -sH "$AUTH" "$GH_TAGS")
Expand All @@ -65,5 +64,5 @@ GH_ASSET="$GH_REPO/releases/assets/$id"

# Download asset file
echo "Downloading asset ..."
curl $CURL_ARGS -H "Authorization: token $GITHUB_TOKEN" -H 'Accept: application/octet-stream' "$GH_ASSET"
curl $CURL_ARGS -H "$AUTH" -H "Accept: application/octet-stream" "$GH_ASSET"

0 comments on commit c55620b

Please sign in to comment.