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
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
_If verifying a migration done via [mongosync](https://www.mongodb.com/docs/cluster-to-cluster-sync/current/), please check if it is possible to use the
[embedded verifier](https://www.mongodb.com/docs/cluster-to-cluster-sync/current/reference/verification/embedded/#std-label-c2c-embedded-verifier) as that is the preferred approach for verification._

# To build


# Obtaining
To fetch the latest release:
```
curl -sSL https://raw.githubusercontent.com/mongodb-labs/migration-verifier/refs/heads/main/download_latest.sh | sh
```
… or, if you prefer to build locally, just do:
```
./build.sh
```
Expand Down
43 changes: 43 additions & 0 deletions download_latest.sh
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is more complex than it needs to be. Once you know the filename you want to download, you can download this: https://github.com/mongodb-labs/migration-verifier/releases/latest/download/$FILENAME

There's no need to hit the API and parse the response.

This does mean you need to calculate the filename directly instead of getting it from the API response, but it seems a lot simpler. You can see how I do this for ubi at https://github.com/houseabsolute/ubi/blob/master/bootstrap/bootstrap-ubi.sh

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I’d rather not build in a dependency on the filename format.

OK to keep as-is?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure, that's fine. But I'd note that we do control the filename!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You know that & I know that, but the next maintainer may be a new hire or intern.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh

set -o errexit

filename=migration_verifier

RELEASE_URL="https://api.github.com/repos/mongodb-labs/migration-verifier/releases/latest"

OS=$(uname -o | tr '[:upper:]' '[:lower:]' | sed 's|gnu/||')
ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ]; then
ARCH=arm64
fi

echo "Looks like you’re running $OS on $ARCH."

MANIFEST=$(curl -sSL "$RELEASE_URL")

VERSION=$(printf "%s" "$MANIFEST" | jq -r .name)

echo "Latest release: $VERSION"

ALL_URLS=$(printf "%s" "$MANIFEST" \
| jq -r '.assets[] | .browser_download_url' \
)

DOWNLOAD_URL=$(echo "$ALL_URLS" \
| grep "_${OS}_" | grep "_$ARCH" ||: \
)

if [ -z "$DOWNLOAD_URL" ]; then
echo >&2 "No download URL found for $OS/$ARCH:"
echo >&2 "$ALL_URLS"
exit 1
fi

echo "Downloading $DOWNLOAD_URL …"

curl -sSL "$DOWNLOAD_URL" > "$filename"

chmod +x "$filename"

echo "✅ Migration Verifier $VERSION is now saved as $filename."