Skip to content
Merged
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
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,30 @@ The `crossplane-diff` tool helps you:

## Installation

### Download Pre-built Binary
### Installing the CLI

Download the latest release from the [releases page](https://github.com/crossplane-contrib/crossplane-diff/releases).
You can install the latest version of **crossplane-diff** automatically using the provided install script:

### Build from Source
```bash
curl -sL "https://raw.githubusercontent.com/crossplane-contrib/crossplane-diff/main/install.sh" | sh
```

The script detects your operating system and CPU architecture and downloads the latest release from GitHub.

### Installing the CLI with a specific Version

You can set the VERSION environment variable before running the script:

```bash
curl -sL "https://raw.githubusercontent.com/crossplane-contrib/crossplane-diff/main/install.sh" | VERSION=v0.3.1 sh
```

### Building the CLI

```bash
git clone https://github.com/crossplane-contrib/crossplane-diff.git
cd crossplane-diff
go build -o crossplane-diff ./cmd/diff
earthly -P +build
```

## Usage
Expand Down Expand Up @@ -202,7 +216,7 @@ The tool prioritizes **accuracy above all else**:
### Caveats

The tool does not take a snapshot of cluster state before processing, so changes made to the cluster during execution
may affect results.
may affect results.

## Documentation

Expand Down
73 changes: 46 additions & 27 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,96 @@

set -eu

XP_CHANNEL=${XP_CHANNEL:-stable}
XP_VERSION=${XP_VERSION:-current}
# Use "latest" if not specified, otherwise accept explicit tag like v0.3.1
VERSION=${VERSION:-latest}

os=$(uname -s)
arch=$(uname -m)
OS=${OS:-"${os}"}
ARCH=${ARCH:-"${arch}"}
OS_ARCH=""

BIN=${BIN:-crank}
BIN="crossplane-diff"

unsupported_arch() {
local os=$1
local arch=$2
echo "Crossplane does not support $os / $arch at this time."
echo "❌ crossplane-diff does not support $os / $arch at this time."
exit 1
}

# Detect OS/Architecture
case $OS in
CYGWIN* | MINGW64* | Windows*)
if [ $ARCH = "x86_64" ]
then
OS_ARCH=windows_amd64
BIN=crank.exe
if [ "$ARCH" = "x86_64" ]; then
OS_ARCH="windows_amd64.exe"
BIN="crossplane-diff.exe"
else
unsupported_arch $OS $ARCH
unsupported_arch "$OS" "$ARCH"
fi
;;
Darwin)
case $ARCH in
x86_64|amd64)
OS_ARCH=darwin_amd64
OS_ARCH="darwin_amd64"
;;
arm64)
OS_ARCH=darwin_arm64
OS_ARCH="darwin_arm64"
;;
*)
unsupported_arch $OS $ARCH
unsupported_arch "$OS" "$ARCH"
;;
esac
;;
Linux)
case $ARCH in
x86_64|amd64)
OS_ARCH=linux_amd64
OS_ARCH="linux_amd64"
;;
arm64|aarch64)
OS_ARCH=linux_arm64
OS_ARCH="linux_arm64"
;;
arm)
OS_ARCH="linux_arm"
;;
ppc64le)
OS_ARCH="linux_ppc64le"
;;
*)
unsupported_arch $OS $ARCH
unsupported_arch "$OS" "$ARCH"
;;
esac
;;
*)
unsupported_arch $OS $ARCH
unsupported_arch "$OS" "$ARCH"
;;
esac

url="https://releases.crossplane.io/${XP_CHANNEL}/${XP_VERSION}/bin/${OS_ARCH}/${BIN}"
if ! curl -sfLo crossplane "${url}"; then
echo "Failed to download Crossplane CLI. Please make sure version ${XP_VERSION} exists on channel ${XP_CHANNEL}."
# Choose correct URL pattern
if [ "$VERSION" = "latest" ]; then
url="https://github.com/crossplane-contrib/crossplane-diff/releases/latest/download/crossplane-diff_${OS_ARCH}"
else
url="https://github.com/crossplane-contrib/crossplane-diff/releases/download/${VERSION}/crossplane-diff_${OS_ARCH}"
fi

echo "πŸ“¦ Downloading crossplane-diff (${VERSION}) for ${OS_ARCH}..."
echo "➑️ ${url}"
echo

# Download the binary
if ! curl -sfLo "${BIN}" "${url}"; then
echo "❌ Failed to download crossplane-diff version '${VERSION}'."
echo "Please check available versions at:"
echo " https://github.com/crossplane-contrib/crossplane-diff/releases"
exit 1
fi

chmod +x crossplane
chmod +x "${BIN}"

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. πŸš€"
echo "Have a nice day! πŸ‘‹\n"
echo "βœ… crossplane-diff downloaded successfully!"
echo
echo "To finish installation, run:"
echo " sudo mv ${BIN} /usr/local/bin/"
echo " crossplane-diff --help"
echo
echo "Visit https://github.com/crossplane-contrib/crossplane-diff for more info πŸš€"
Loading