From 2279cccb235c2c6b188396f64207859183568b11 Mon Sep 17 00:00:00 2001 From: Peter McConnell Date: Tue, 28 Sep 2021 15:08:46 +0100 Subject: [PATCH] improvement: modifying the cli tool so that it can accept API_URL 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. --- tools/bin/cli.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/bin/cli.sh b/tools/bin/cli.sh index b194155e293c..e4c7ccb3cbcd 100755 --- a/tools/bin/cli.sh +++ b/tools/bin/cli.sh @@ -8,10 +8,16 @@ 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" < "$LOCAL_RESTISH_PATH" < "$LOCAL_RESTISH_PATH" <