portainer-stack-utils
portainer-stack-utils copied to clipboard
Better flags
Flags should have a complete and a short form, something like --action and -a. This would help using and particularly reading them. A command like this one:
./psu -a deploy -u admin -p password -l http://portainer.local -n mystack -c /path/to/docker-compose.yml -g /path/to/env_vars_file
could also look like this one:
./psu --action deploy --user admin --password password --instance http://portainer.local --stack mystack --compose-file /path/to/docker-compose.yml --env-file /path/to/env_vars_file
Hi @greenled,
I've done some work on this issue, I'm going to share some code with you soon.
I think the action option should be an argument instead, like this:
psu deploy --user admin --password password --instance http://portainer.local --stack mystack --compose-file /path/to/docker-compose.yml --env-file /path/to/env_vars_file
Any thoughts/comments on this?
Have a good day, Tortue Torche
Hi @tortuetorche. I'm glad to hear you are working on something new! I agree the action should be an argument, but we should be careful with this change, as it would change the API in a way that could break some pipelines out there ;) I am setting some ground for these breaking changes (and more to come), see #9.
@tortuetorche see #12 for your action as an argument idea.
Hi @greenled,
but we should be careful with this change, as it would change the API in a way that could break some pipelines out there ;)
I'm totally agree with you, I think we can have both, <action> as an argument and -a|--action as a deprecated option to keep backward compatibility.
FYI, I just publish some work on my next branch of psu.
It's an alpha version, there is a lot of things to do and debug...
Here the output of the psu help command, who list the flags and options:
Portainer Stack Utils, version 0.2.0-alpha.2
Usage:
psu <action> [options]
Arguments:
action The name of the action to execute (possible values: 'deploy', 'undeploy', 'list', 'info', 'services', 'tasks', 'tasks_healthy', 'containers', 'status', 'help', 'version')
Options:
-u, --user=USERNAME Username
-p, --password=PASSWORD Password
-l, --url=URL URL to Portainer
-n, --name=STACK_NAME Stack name
-c, --compose-file=[FILE_PATH] Path to docker-compose file (required if action=deploy)
-g, --env-file Path to file with environment variables to be used by the stack (only used when action=deploy or action=update)
-e, --endpoint=[ENDPOINT_ID] Which Docker endpoint to use. Defaults to 1
-r, --prune Whether to prune unused containers or not. Defaults to false
-T, --timeout=[NUMBER_SECONDS] Status timeout, number of seconds before thrown an error (only used when action=status). Defaults to 100
-j, --detect-job=[true|false] Auto detect services who are jobs. Defaults to true
-S, --service[=SERVICE_NAME] Service name
-i, --insecure Skip the host's SSL certificate verification. Defaults to false
-v, --verbose Increase the verbosity of messages. Defaults to false
-d, --debug Print as much information as possible to help diagnosing a malfunction. Defaults to false
-q, --quiet Display the minimum of information or nothing, UNIX/Linux friendly. Defaults to false
-t, --strict Never updates an existent stack nor removes an unexistent one, and instead exits with an error. Defaults to false
-h, --help Display this help message
-V, --version Display the version of this program
-s, --secure[=yes|no] DEPRECATED: Use the --insecure option instead. Enable or disable the host's SSL certificate verification. Defaults to 'yes'
-a, --action=[ACTION_NAME] DEPRECATED: Use <action> argument instead. The name of the action to execute
Help:
You can deploy/update/undeploy/list... stacks in a Portainer instance easily with this tool!
What do you think about the name of these options?
I think it's 100% backward compatible with psu 0.1.0
They look good to me. And yes, so far it looks 100% backwards compatible. Nice job! I see you also changed the --secure flag to a --insecure flag without arguments, which is more intuitive.
This isue is being worked on in the several-changes branch. Should be closed once that branch is merged.