Ad '--compose-file' flag which deprecates --stack-file flag

This commit is contained in:
Tortue Torche 2019-08-10 23:22:06 -04:00 committed by Tortue Torche
parent 8f3aa9b254
commit 13b466d2f4

15
psu
View File

@ -33,7 +33,7 @@ main() {
"user;-u;--user=USERNAME;Username of the Portainer instance" "user;-u;--user=USERNAME;Username of the Portainer instance"
"password;-p;--password=PASSWORD;Password of the Portainer instance" "password;-p;--password=PASSWORD;Password of the Portainer instance"
"name;-n;--name=STACK_NAME;Stack name" "name;-n;--name=STACK_NAME;Stack name"
"compose-file;-c;--compose-file=[FILE_PATH];Path to docker-compose file (required if action=deploy)" "stack-file;-f;--stack-file=[FILE_PATH];Path to docker-stack file (required if action=deploy)"
"env-file;-g;--env-file;Path to file with environment variables to be used by the stack (only used when action=deploy|update)" "env-file;-g;--env-file;Path to file with environment variables to be used by the stack (only used when action=deploy|update)"
"endpoint;-e;--endpoint=[ENDPOINT_ID];Which Docker endpoint to use. Defaults to 1" "endpoint;-e;--endpoint=[ENDPOINT_ID];Which Docker endpoint to use. Defaults to 1"
"prune;-r;--prune;Whether to prune unused containers or not (only used when action=deploy). Defaults to false" "prune;-r;--prune;Whether to prune unused containers or not (only used when action=deploy). Defaults to false"
@ -49,11 +49,12 @@ main() {
"version;-V;--version;Display the version of this program" "version;-V;--version;Display the version of this program"
"secure;-s;--secure[=yes|no];DEPRECATED: Use the --insecure option instead. Enable or disable the host's SSL certificate verification. Defaults to 'yes'" "secure;-s;--secure[=yes|no];DEPRECATED: Use the --insecure option instead. Enable or disable the host's SSL certificate verification. Defaults to 'yes'"
"action;-a;--action=[ACTION_NAME];DEPRECATED: Use <action> argument instead. The name of the action to execute" "action;-a;--action=[ACTION_NAME];DEPRECATED: Use <action> argument instead. The name of the action to execute"
"compose-file;-c;--compose-file=[FILE_PATH];DEPRECATED: Use '--stack-file' option instead. Path to docker-compose file (required if action=deploy)"
) )
ACTIONS_TABLE=( ACTIONS_TABLE=(
# action_name;description[;required_option_key1|required_option_key2...][;optional_option_key1|optional_option_key2...] # action_name;description[;required_option_key1|required_option_key2...][;optional_option_key1|optional_option_key2...]
"deploy;Deploy the stack;url|user|password|name|compose-file;endpoint|env-file|prune|insecure|verbose|debug|strict" "deploy;Deploy the stack;url|user|password|name|stack-file;endpoint|env-file|prune|insecure|verbose|debug|strict"
"undeploy;Undeploy/remove the stack;url|user|password|name;endpoint|insecure|verbose|debug|strict" "undeploy;Undeploy/remove the stack;url|user|password|name;endpoint|insecure|verbose|debug|strict"
"list;Lists of the stacks already deployed;url|user|password;endpoint|quiet|insecure|verbose|debug|help" "list;Lists of the stacks already deployed;url|user|password;endpoint|quiet|insecure|verbose|debug|help"
"info;Stack information;url|user|password|name;endpoint|quiet|insecure|verbose|debug" "info;Stack information;url|user|password|name;endpoint|quiet|insecure|verbose|debug"
@ -396,7 +397,7 @@ set_globals() {
check_argument "$PORTAINER_URL" "portainer url" "PORTAINER_URL" "l" "url" check_argument "$PORTAINER_URL" "portainer url" "PORTAINER_URL" "l" "url"
fi fi
if [ "$ACTION" == "deploy" ]; then if [ "$ACTION" == "deploy" ]; then
check_argument "$DOCKER_COMPOSE_FILE" "docker compose file" "DOCKER_COMPOSE_FILE" "c" "compose-file" check_argument "$DOCKER_COMPOSE_FILE" "docker stack file" "DOCKER_COMPOSE_FILE" "f" "stack-file"
if [ -n "$ENVIRONMENT_VARIABLES_FILE" ] && [[ ! -f "$ENVIRONMENT_VARIABLES_FILE" ]]; then if [ -n "$ENVIRONMENT_VARIABLES_FILE" ] && [[ ! -f "$ENVIRONMENT_VARIABLES_FILE" ]]; then
echo_error "Error: File path \"$ENVIRONMENT_VARIABLES_FILE\" not found for \"ENVIRONMENT_VARIABLES_FILE\" environment variable or the \"-g\" flag or the \"--env-file\" option." echo_error "Error: File path \"$ENVIRONMENT_VARIABLES_FILE\" not found for \"ENVIRONMENT_VARIABLES_FILE\" environment variable or the \"-g\" flag or the \"--env-file\" option."
exit 1 exit 1
@ -438,7 +439,15 @@ inputs() {
shift shift
fi fi
;; ;;
-f=*|--stack-file=*|-f|--stack-file)
DOCKER_COMPOSE_FILE=$(input_option "$1" "$2")
if [ -n "$2" ] && [[ ! $2 =~ ^-.+$ ]] ; then
# When the second argument is the value of the current option
shift
fi
;;
-c=*|--compose-file=*|-c|--compose-file) -c=*|--compose-file=*|-c|--compose-file)
echo_verbose "DEPRECATED: Use '--stack-file' option, instead of this '$1' option"
DOCKER_COMPOSE_FILE=$(input_option "$1" "$2") DOCKER_COMPOSE_FILE=$(input_option "$1" "$2")
if [ -n "$2" ] && [[ ! $2 =~ ^-.+$ ]] ; then if [ -n "$2" ] && [[ ! $2 =~ ^-.+$ ]] ; then
# When the second argument is the value of the current option # When the second argument is the value of the current option