Improvements for tools/airship

- Add proxy support for Promenade
 - Fix error handling
 - Add help command

Change-Id: I9297d690803dfc6e96619d3c31ea02a299a65e05
This commit is contained in:
Kaspars Skels 2019-04-24 11:27:31 -05:00
parent c9ccc7d0fa
commit 0d817133a4
1 changed files with 28 additions and 8 deletions

View File

@ -1,13 +1,10 @@
#!/usr/bin/env bash
# mkdir -p collect certs bundle
# tools/airship pegleg site -r /target collect airsloop -s collect
# tools/airship promenade generate-certs -o /target/certs /target/collect/*.yaml
# tools/airship promenade build-all -o /target/bundle /target/collect/*.yaml /target/certs/*.yaml
# tools/shipyard get actions
: ${TERM_OPTS:='-it'}
# Python YAML module required to read versions.yaml
dpkg -s python3-yaml &> /dev/null || apt -y install python3-yaml
ENV_FILE=$(mktemp)
trap "{ rm -f $ENV_FILE; }" EXIT
@ -64,7 +61,9 @@ else:
sys.exit(1)" 2>&1` || FAIL=true
if [[ $FAIL = true ]] && [[ $allow_fail != true ]]; then
die "Lookup failed for schema '$schema', metadata.name '$mdata_name', key path '$key_path'"
echo "error: Lookup failed for schema '$schema', \
metadata.name '$mdata_name', key path '$key_path'" >&2
exit 1
fi
}
@ -76,6 +75,17 @@ versions_lookup() {
}
help() {
echo -n "Usage: airship <pegleg|promenade|shipyard> [OPTION]...
Examples:
tools/airship pegleg site -r /target collect airsloop -s collect
tools/airship promenade generate-certs -o /target/certs /target/collect/*.yaml
tools/airship promenade build-all -o /target/bundle /target/collect/*.yaml /target/certs/*.yaml
tools/airship shipyard get actions
"
}
pegleg() {
versions_lookup "['data']['images']['ucp']['pegleg']['pegleg']"
@ -92,6 +102,16 @@ promenade() {
versions_lookup "['data']['images']['ucp']['promenade']['promenade']"
# support proxy for pulling k8s binary
cat >> $ENV_FILE << EOF
http_proxy=${http_proxy:-}
https_proxy=${https_proxy:-}
no_proxy=${no_proxy:-}
HTTP_PROXY=${HTTP_PROXY:-}
HTTPS_PROXY=${HTTPS_PROXY:-}
NO_PROXY=${NO_PROXY:-}
EOF
docker run --rm --net=host $TERM_OPTS \
-w /target \
-v $(pwd):/target \
@ -122,7 +142,7 @@ case "$1" in
'shipyard')
shipyard $@
;;
*) echo "Invalid option"
*) help
exit 1
;;
esac