- Add "list" action to print all stacks.
- Add "info" action to print information about a stack.
- Add "services" action to print a list of stack services.
- Add "tasks" action to print a list of stack service tasks.
- Add "PORTAINER_SERVICE_NAME" environment variable (string) to specify which stack service tasks wil be printed.
- Add "-S, --service" flag (string) to specify which stack service tasks wil be printed.
- Add "tasks_healthy" action. Like "tasks", but only prints **healthy** stack service tasks.
- Add "status" action to print stack tasks statuses.
- Add "AUTO_DETECT_JOB" environment variable (true|false) to autodetect services which are jobs.
- Add "-j, --detect-job" flag (true|false) to autodetect services which are jobs.
- Add quiet mode to limit output to the minimal.
- In "list", "info", "services" actions shows only stack/service name.
- In "tasks", "tasks_healthy" actions shows only task name.
- Add "QUIET_MODE" environment variable (true|false) to enable/disable quiet mode.
- Add "-q, --quiet" flag (true|false) to enable/disable quiet mode.
- Add "ROLLOUT_STATUS_TIMEOUT" environment variable to set a maximum waiting time for requests.
- Add "-T, --timeout" flag to set a maximum waiting time for requests.
- Add "-i, --insecure" flag (bool) to replace "-s, --secure" flag.
- Add "version" action to print script version.
- Add "-V, --version" flag (bool) to print script version.
- Add "help" action to print script usage.
- Add "--action", "--secure", "--strict", "--debug", "--verbose", "--prune", "--endpoint", "--env-file", "--compose-file", "--name", "--url", "--password" and "--user" long name version flags for existing "-a", "-s", "-t", "-d", "-v", "-r", "-e", "-g", "-c", "-n", "-l", "-p" and "-u" flags.
- Add argument to specify the action to execute without the need to use the "-a, --action" flag.
Without this commit:
This command works correctly:
psu -a deploy -u admin -p password -l http://portainer.local -n mystack -c /path/to/docker-compose.yml -g ./env_vars
But this command doesn't work correctly:
psu -a deploy -u admin -p password -l http://portainer.local -n mystack -c /path/to/docker-compose.yml -g env_vars
If you have a `.env` file with some environment variables who contains spaces, like this:
DB_INITIALIZE="cd /app && RAILS_ENV=production bin/setup"
DB_MIGRATE="cd /app && RAILS_ENV=production bin/update"
Prior to this pull request `psu` script act like this:
Stack env vars are set in the `deploy()` function. When a new stack is deployed it gets no env vars, and when an existing one is updated its envvars are reused (extracted from its stack definition into the stack_envvars variable and set back again).
For the first case this pull request load the content of the env vars file and transform it into JSON using a `jq` command and set it as the `stack_envvars` value.
For the second case, though, the script update the current stack env vars rather than setting them from scratch, keeping any value not previously set in the env file.
The environment variables file path is customizable with the environment variable `$ENVIRONMENT_VARIABLES_FILE` or the `-g` flag, like this:
```bash
export ACTION="deploy"
export PORTAINER_USER="admin"
export PORTAINER_PASSWORD="password"
export PORTAINER_URL="http://portainer.local"
export PORTAINER_STACK_NAME="mystack"
export DOCKER_COMPOSE_FILE="/path/to/docker-compose.yml"
export ENVIRONMENT_VARIABLES_FILE="/path/to/env_vars_file"
./psu
```
Or with flags:
```bash
./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
```
close#7