-
Notifications
You must be signed in to change notification settings - Fork 5
Add the install.sh script and upload it to S3 #54
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
Merged
+132
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -eu | ||
|
|
||
| XP_CHANNEL=${XP_CHANNEL:-stable} | ||
| XP_VERSION=${XP_VERSION:-current} | ||
|
|
||
| os=$(uname -s) | ||
| arch=$(uname -m) | ||
| OS=${OS:-"${os}"} | ||
| ARCH=${ARCH:-"${arch}"} | ||
| OS_ARCH="" | ||
| COMPRESSED=${COMPRESSED:-"False"} | ||
|
|
||
| BIN=${BIN:-crossplane} | ||
|
|
||
| # v2.3.0 was the first release from the crossplane/cli repository, whose | ||
| # artifacts go to the cli.crossplane.io bucket and uses the binary name | ||
| # "crossplane". Use the old releases.crossplane.io hostname and "crank" binary | ||
| # for older releases. | ||
|
|
||
| url_host="cli.crossplane.io" | ||
| bundle_name="crossplane-cli.tar.gz" | ||
|
|
||
| if [ "${XP_VERSION}" != "current" ]; then | ||
| _ver=$(echo "${XP_VERSION}" | sed 's/^v//' | sed 's/-.*//') | ||
| _major=$(echo "${_ver}" | cut -d. -f1) | ||
| _minor=$(echo "${_ver}" | cut -d. -f2) | ||
|
|
||
| if [ "${_major}" -lt 2 ] 2>/dev/null || | ||
| { [ "${_major}" -eq 2 ] 2>/dev/null && [ "${_minor}" -lt 3 ] 2>/dev/null; }; then | ||
|
|
||
| url_host="releases.crossplane.io" | ||
| bundle_name="crank.tar.gz" | ||
| BIN="crank" | ||
| fi | ||
| fi | ||
|
|
||
| unsupported_arch() { | ||
| os="$1" | ||
| arch="$2" | ||
| echo "Crossplane does not support $os / $arch at this time." | ||
| exit 1 | ||
| } | ||
|
|
||
| case $OS in | ||
| CYGWIN* | MINGW64* | Windows*) | ||
| if [ "$ARCH" = "x86_64" ]; then | ||
| OS_ARCH=windows_amd64 | ||
| BIN="${BIN}.exe" | ||
| else | ||
| unsupported_arch "$OS" "$ARCH" | ||
| fi | ||
| ;; | ||
| Darwin) | ||
| case $ARCH in | ||
| x86_64 | amd64) | ||
| OS_ARCH=darwin_amd64 | ||
| ;; | ||
| arm64) | ||
| OS_ARCH=darwin_arm64 | ||
| ;; | ||
| *) | ||
| unsupported_arch "$OS" "$ARCH" | ||
| ;; | ||
| esac | ||
| ;; | ||
| Linux) | ||
| case $ARCH in | ||
| x86_64 | amd64) | ||
| OS_ARCH=linux_amd64 | ||
| ;; | ||
| arm64 | aarch64) | ||
| OS_ARCH=linux_arm64 | ||
| ;; | ||
| *) | ||
| unsupported_arch "$OS" "$ARCH" | ||
| ;; | ||
| esac | ||
| ;; | ||
| *) | ||
| unsupported_arch "$OS" "$ARCH" | ||
| ;; | ||
| esac | ||
|
|
||
| _compr=$(echo "$COMPRESSED" | tr '[:upper:]' '[:lower:]') | ||
|
|
||
| if [ "${_compr}" = "true" ]; then | ||
| url_dir="bundle" | ||
| url_file="${bundle_name}" | ||
| url_error="a compressed file for " | ||
| else | ||
| url_dir="bin" | ||
| url_file="${BIN}" | ||
| url_error="" | ||
| fi | ||
|
|
||
| url="https://${url_host}/${XP_CHANNEL}/${XP_VERSION}/${url_dir}/${OS_ARCH}/${url_file}" | ||
|
|
||
| if ! curl -sfL "${url}" -o "${url_file}"; then | ||
| echo "Failed to download Crossplane CLI. Please make sure ${url_error}version ${XP_VERSION} exists on channel ${XP_CHANNEL}." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "${_compr}" = "true" ]; then | ||
| if ! tar xzf "${url_file}"; then | ||
| echo "Failed to unpack the Crossplane CLI compressed file." | ||
| exit 1 | ||
| fi | ||
| rm "${BIN}.sha256" "${url_file}" | ||
| fi | ||
| if [ "${BIN}" != "crossplane" ]; then | ||
| if ! mv "${BIN}" crossplane; then | ||
| echo "Failed to rename the Crossplane CLI binary: \"${BIN}\"." | ||
| exit 1 | ||
| fi | ||
| fi | ||
|
|
||
| chmod +x crossplane | ||
|
|
||
| echo "crossplane CLI downloaded successfully! Run the following commands to finish installing it:" | ||
| echo | ||
| echo sudo mv crossplane /usr/local/bin | ||
| echo crossplane --help | ||
| echo | ||
| echo "Visit https://crossplane.io to get started. 🚀" | ||
| printf "Have a nice day! 👋\n" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix potential failure when .sha256 file is missing from tarball.
Line 110 unconditionally removes
${BIN}.sha256, but withset -ein effect, the script will exit if this file doesn't exist in the extracted tarball. This could break installations if the tarball structure changes.Additionally, while the script removes the checksum file, it never validates it—a missed security opportunity. Would you like to either:
rm -fto ignore missing files?🛡️ Proposed fix options
Option 1: Make rm fail-safe (quick fix)
Option 2: Validate checksum before removal (more secure)
📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we should leave it as it is. If the checksum file is missing from the tarball, then we have a bigger problem to solve. Also, I'd like to introduce the validation functionality in a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tampakrap, that's a fair point — failing loudly when.sha256is absent is actually the safer behavior, since it signals a malformed release artifact rather than silently continuing. Happy to defer the full validation to a separate PR.Would you like me to open a GitHub issue to track the checksum validation work so it doesn't get lost?