Usage and deprecation warnings in script
The usage is rearranged slightly to avoid wrapping at 80 characters.
This will tend to overestimate warnings, since it doesn't try very
hard to ignore values that are not intended to be options; in
particular, arguments that are intended for `docker run`. (Using `--`
to delimit these arguments would make this easier!)
It does ignore values that follow known options though, for instance
in
weave -nickname "-password"
(-nickname results in a deprecation warning, -password does not)
and
weave --password "-iprange"
(no deprecation warning, since -iprange is ignored)
This commit is contained in:
1 parent
379b8c4e6b
commit
ebbb5d379d
1 file changed
+90
-10
@@ -26,19 +26,19 @@ CIDR_REGEXP="$IP_REGEXP/[0-9]{1,2}"
|
||||
usage() {
|
||||
echo "Usage:"
|
||||
echo "weave setup"
|
||||
echo "weave launch [-password <password>] [-nickname <nickname>] [-nodiscovery]"
|
||||
echo " [-iprange <cidr> [-ipsubnet <cidr>]]"
|
||||
echo " [-initpeercount <count>] <peer> ..."
|
||||
echo "weave launch-router [-password <password>] [-nickname <nickname>] [-nodiscovery]"
|
||||
echo " [-iprange <cidr> [-ipsubnet <cidr>]]"
|
||||
echo " [-initpeercount <count>] <peer> ..."
|
||||
echo "weave launch [--password <password>] [--nickname <nickname>]"
|
||||
echo " [--ipalloc-range <cidr> [--ipalloc-default-subnet <cidr>]]"
|
||||
echo " [--no-discovery] [--init-peer-count <count>] <peer> ..."
|
||||
echo "weave launch-router [--password <password>] [--nickname <nickname>]"
|
||||
echo " [--ipalloc-range <cidr> [--ipalloc-default-subnet <cidr>]]"
|
||||
echo " [--no-discovery] [--init-peer-count <count>] <peer> ..."
|
||||
echo "weave launch-dns [<addr>]"
|
||||
echo "weave launch-proxy [-H <endpoint>] [--with-dns | --without-dns]"
|
||||
echo " [--no-default-ipalloc]"
|
||||
echo " [--no-default-ipalloc]"
|
||||
echo "weave connect [--replace] [<peer> ...]"
|
||||
echo "weave forget <peer> ..."
|
||||
echo "weave run [--with-dns | --without-dns] [<addr> ...]"
|
||||
echo " <docker run args> ..."
|
||||
echo " <docker run args> ..."
|
||||
echo "weave start [<addr> ...] <container_id>"
|
||||
echo "weave attach [<addr> ...] <container_id>"
|
||||
echo "weave detach [<addr> ...] <container_id>"
|
||||
@@ -1100,6 +1100,83 @@ DOCKER_VERSION_MAJOR=$(echo "$DOCKER_VERSION" | cut -d. -f 1)
|
||||
DOCKER_VERSION_MINOR=$(echo "$DOCKER_VERSION" | cut -d. -f 2)
|
||||
DOCKER_VERSION_PATCH=$(echo "$DOCKER_VERSION" | cut -d. -f 3)
|
||||
|
||||
deprecation_warning() {
|
||||
echo "Warning: ${1%=*} is deprecated; please use $2" >&2
|
||||
}
|
||||
|
||||
deprecation_warnings() {
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-password|-password=*)
|
||||
deprecation_warning $1 "--password"
|
||||
[ "$1" == "-password" ] && shift
|
||||
;;
|
||||
--password)
|
||||
shift
|
||||
;;
|
||||
-nickname|-nickname=*)
|
||||
deprecation_warning $1 "--nickname"
|
||||
[ "$1" == "-nickname" ] && shift
|
||||
;;
|
||||
--nickname)
|
||||
shift
|
||||
;;
|
||||
-nodiscovery|--nodiscovery)
|
||||
deprecation_warning $1 "--no-discovery"
|
||||
;;
|
||||
-iprange|--iprange|-iprange=*|--iprange=*)
|
||||
deprecation_warning $1 "--ipalloc-range"
|
||||
[ ${1#--} == "iprange" ] && shift
|
||||
;;
|
||||
--ipalloc-range)
|
||||
shift
|
||||
;;
|
||||
-ipsubnet|--ipsubnet|-ipsubnet=*|--ipsubnet=*)
|
||||
deprecation_warning $1 "--ipalloc-default-subnet"
|
||||
[ ${1#--} == "ipsubnet" ] && shift
|
||||
;;
|
||||
--ipalloc-default-subnet)
|
||||
shift
|
||||
;;
|
||||
-initpeercount|--initpeercount|-initpeercount=*|--initpeercount=*)
|
||||
deprecation_warning $1 "--init-peer-count"
|
||||
[ ${1#--} == "initpeercount" ] && shift
|
||||
;;
|
||||
--init-peer-count)
|
||||
shift
|
||||
;;
|
||||
-no-default-ipam|--no-default-ipam)
|
||||
deprecation_warning $1 "--no-default-ipalloc"
|
||||
;;
|
||||
--tlscacert|--tlscacert=*)
|
||||
deprecation_warning "--tlscacert" "--tls-cacert"
|
||||
[ "$1" == "--tlscacert" ] && shift
|
||||
;;
|
||||
--tls-cacert)
|
||||
shift
|
||||
;;
|
||||
--tlscert|--tlscert=*)
|
||||
deprecation_warning "--tlscert" "--tls-cert"
|
||||
[ "$1" == "--tlscert" ] && shift
|
||||
;;
|
||||
--tls-cert)
|
||||
shift
|
||||
;;
|
||||
--tlskey|--tlskey=*)
|
||||
deprecation_warning "--tlskey" "--tls-key"
|
||||
[ "$1" == "--tlskey" ] && shift
|
||||
;;
|
||||
--tls-key)
|
||||
shift
|
||||
;;
|
||||
--tlsverify)
|
||||
deprecation_warning "--tlsverify" "--tls-verify"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
[ $# -gt 0 ] || usage
|
||||
COMMAND=$1
|
||||
shift 1
|
||||
@@ -1116,6 +1193,7 @@ case "$COMMAND" in
|
||||
create_bridge --without-ethtool
|
||||
;;
|
||||
launch)
|
||||
deprecation_warnings "$@"
|
||||
check_not_running $CONTAINER_NAME $BASE_IMAGE
|
||||
check_not_running $DNS_CONTAINER_NAME $BASE_DNS_IMAGE
|
||||
check_not_running $PROXY_CONTAINER_NAME $EXEC_IMAGE
|
||||
@@ -1125,6 +1203,7 @@ case "$COMMAND" in
|
||||
launch_proxy $COMMON_ARGS
|
||||
;;
|
||||
launch-router)
|
||||
deprecation_warnings "$@"
|
||||
check_not_running $CONTAINER_NAME $BASE_IMAGE
|
||||
launch_router "$@"
|
||||
echo $CONTAINER
|
||||
@@ -1135,16 +1214,17 @@ case "$COMMAND" in
|
||||
echo $DNS_CONTAINER
|
||||
;;
|
||||
launch-proxy)
|
||||
deprecation_warnings "$@"
|
||||
check_not_running $PROXY_CONTAINER_NAME $EXEC_IMAGE
|
||||
launch_proxy "$@"
|
||||
echo $PROXY_CONTAINER
|
||||
;;
|
||||
env|proxy-env)
|
||||
[ "$COMMAND" = "env" ] || echo "$COMMAND is deprecated, please use 'weave env'" >&2
|
||||
[ "$COMMAND" = "env" ] || deprecation_warning "$COMMAND" "'weave env'"
|
||||
proxy_addr "export DOCKER_HOST="
|
||||
;;
|
||||
config|proxy-config)
|
||||
[ "$COMMAND" = "config" ] || echo "$COMMAND is deprecated, please use 'weave config'" >&2
|
||||
[ "$COMMAND" = "config" ] || deprecation_warning "$COMMAND" "'weave config'"
|
||||
proxy_addr "-H="
|
||||
;;
|
||||
connect)
|
||||
|
||||
Reference in new issue
Block a user