Skip to content

Commit

Permalink
improvement: modifying the cli tool so that it can accept API_URL
Browse files Browse the repository at this point in the history
This solves the problem where you may be running airbyte on an endpoint
that isn't http://localhost:8001

Additionally it improves the error experience when this script can not
reach the API.
  • Loading branch information
Peter McConnell committed Sep 28, 2021
1 parent 8fa1571 commit 2279ccc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tools/bin/cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,26 @@ IMAGE_RESTISH_PATH=/root/.restish/apis.json
DOWNLOADED_CONFIG_PATH=/tmp/downloaded-airbyte-api-config
IMAGE_CONFIG_PATH=/tmp/config.yaml

API_URL=http://localhost:8001
curl -s "$API_URL"/api/v1/openapi -o "$DOWNLOADED_CONFIG_PATH"
if [ ! -f "$LOCAL_RESTISH_PATH" ]; then
API_URL="${API_URL:-http://localhost:8001}"
if ! curl -s "${API_URL}/api/v1/openapi" -o "$DOWNLOADED_CONFIG_PATH"; then
2>&1 echo "ERROR: failed to download config file from ${API_URL}/api/v1/openapi"
2>&1 echo " if the API is elsewhere you can specify it using:"
2>&1 echo " API_URL=XXX $0"
exit 1
fi

cat > "$LOCAL_RESTISH_PATH" <<EOL
cat > "$LOCAL_RESTISH_PATH" <<EOL
{
"airbyte": {
"base": "${API_URL}",
"spec_files": ["${IMAGE_CONFIG_PATH}"]
}
}
EOL
else
echo "using config file: $LOCAL_RESTISH_PATH"
fi

docker run --rm \
-v "$LOCAL_RESTISH_PATH":"$IMAGE_RESTISH_PATH" \
Expand Down

0 comments on commit 2279ccc

Please sign in to comment.