Skip to content

Commit 3c40e98

Browse files
improvement: modifying the cli tool so that it can accept API_URL (#6507)
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.
1 parent eb8be95 commit 3c40e98

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tools/bin/cli.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,26 @@ IMAGE_RESTISH_PATH=/root/.restish/apis.json
88
DOWNLOADED_CONFIG_PATH=/tmp/downloaded-airbyte-api-config
99
IMAGE_CONFIG_PATH=/tmp/config.yaml
1010

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

14-
cat > "$LOCAL_RESTISH_PATH" <<EOL
20+
cat > "$LOCAL_RESTISH_PATH" <<EOL
1521
{
1622
"airbyte": {
1723
"base": "${API_URL}",
1824
"spec_files": ["${IMAGE_CONFIG_PATH}"]
1925
}
2026
}
2127
EOL
28+
else
29+
echo "using config file: $LOCAL_RESTISH_PATH"
30+
fi
2231

2332
docker run --rm \
2433
-v "$LOCAL_RESTISH_PATH":"$IMAGE_RESTISH_PATH" \

0 commit comments

Comments
 (0)