[proxy] refactor tls arg parsing
This commit is contained in:
1 parent
127cffba6f
commit
bddf79855d
1 file changed
+12
-12
@@ -753,6 +753,12 @@ get_ipam_cidr() {
|
|||||||
|
|
||||||
# TODO: Handle relative paths for args
|
# TODO: Handle relative paths for args
|
||||||
# TODO: Handle args with spaces
|
# TODO: Handle args with spaces
|
||||||
|
tls_arg() {
|
||||||
|
filename=${3:-$2}
|
||||||
|
PROXY_VOLUMES="$PROXY_VOLUMES -v $1:/home/weave/tls/$filename.pem"
|
||||||
|
PROXY_ARGS="$PROXY_ARGS --tls$2 /home/weave/tls/$filename.pem"
|
||||||
|
}
|
||||||
|
|
||||||
proxy_args() {
|
proxy_args() {
|
||||||
PROXY_VOLUMES=""
|
PROXY_VOLUMES=""
|
||||||
PROXY_ARGS=""
|
PROXY_ARGS=""
|
||||||
@@ -760,30 +766,24 @@ proxy_args() {
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
--tlscacert)
|
--tlscacert)
|
||||||
shift
|
shift
|
||||||
PROXY_VOLUMES="$PROXY_VOLUMES -v $1:/home/weave/tls/ca.pem"
|
tls_arg "$1" cacert ca
|
||||||
PROXY_ARGS="$PROXY_ARGS --tlscacert /home/weave/tls/ca.pem"
|
|
||||||
;;
|
;;
|
||||||
--tlscacert=*)
|
--tlscacert=*)
|
||||||
PROXY_VOLUMES="$PROXY_VOLUMES -v ${1#*=}:/home/weave/tls/ca.pem"
|
tls_arg "${1#*=}" cacert ca
|
||||||
PROXY_ARGS="$PROXY_ARGS --tlscacert /home/weave/tls/ca.pem"
|
|
||||||
;;
|
;;
|
||||||
--tlscert)
|
--tlscert)
|
||||||
shift
|
shift
|
||||||
PROXY_VOLUMES="$PROXY_VOLUMES -v $1:/home/weave/tls/cert.pem"
|
tls_arg "$1" cert
|
||||||
PROXY_ARGS="$PROXY_ARGS --tlscert /home/weave/tls/cert.pem"
|
|
||||||
;;
|
;;
|
||||||
--tlscert=*)
|
--tlscert=*)
|
||||||
PROXY_VOLUMES="$PROXY_VOLUMES -v ${1#*=}:/home/weave/tls/cert.pem"
|
tls_arg "${1#*=}" cert
|
||||||
PROXY_ARGS="$PROXY_ARGS --tlscert /home/weave/tls/cert.pem"
|
|
||||||
;;
|
;;
|
||||||
--tlskey)
|
--tlskey)
|
||||||
shift
|
shift
|
||||||
PROXY_VOLUMES="$PROXY_VOLUMES -v $1:/home/weave/tls/key.pem"
|
tls_arg "$1" key
|
||||||
PROXY_ARGS="$PROXY_ARGS --tlskey /home/weave/tls/key.pem"
|
|
||||||
;;
|
;;
|
||||||
--tlskey=*)
|
--tlskey=*)
|
||||||
PROXY_VOLUMES="$PROXY_VOLUMES -v ${1#*=}:/home/weave/tls/key.pem"
|
tls_arg "${1#*=}" key
|
||||||
PROXY_ARGS="$PROXY_ARGS --tlskey /home/weave/tls/key.pem"
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
PROXY_ARGS="$PROXY_ARGS $1"
|
PROXY_ARGS="$PROXY_ARGS $1"
|
||||||
|
|||||||
Reference in new issue
Block a user