New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add two new actions 'info' and 'list' with an optional quiet mode #11
Conversation
The 'info' action with the 'quiet' mode enabled: psu -a info -u admin -p password -l http://portainer.local -n mystack Output the JSON object of the stack if it's already deployed: { "Id": "mystack_jpofkc0i9uo9wtx1zesuk649w", "Name": "mystack", "Type": "1", "EndpointID": "1", "EntryPoint": "docker-compose.yml", "SwarmID": "jpofkc0i9uo9wtx1zesuk649w", "ProjectPath": "/data/compose/mystack_jpofkc0i9uo9wtx1zesuk649w", "Env": [ { "name": "MYSQL_ROOT_PASSWORD", "value": "password" } ] } The 'info' action with the 'quiet' mode enabled: psu -a info -u admin -p password -l http://portainer.local -n mystack -q Output the stack name if it's already deployed: mystack The 'list' action with the 'quiet' mode enabled: psu -a list -u admin -p password -l http://portainer.local Output a JSON array of the stacks already deployed: [ { "Id": "mystack_jpofkc0i9uo9wtx1zesuk649w", "Name": "mystack", "Type": "1", "EndpointID": "1", "EntryPoint": "docker-compose.yml", "SwarmID": "jpofkc0i9uo9wtx1zesuk649w", "ProjectPath": "/data/compose/mystack_jpofkc0i9uo9wtx1zesuk649w", "Env": [ { "name": "MYSQL_ROOT_PASSWORD", "value": "password" } ] }, { "Id": "mysecondstack_i0649w9uo9wtx1zesujpofkck", "Name": "mysecondstack", "Type": "1", "EndpointID": "1", "EntryPoint": "docker-compose.yml", "SwarmID": "i0649w9uo9wtx1zesujpofkck", "ProjectPath": "/data/compose/mysecondstack_i0649w9uo9wtx1zesujpofkck" }, { "Id": "mythirdstack_w9uo9wtxi064ujpofkck91zes", "Name": "mythirdstack", "Type": "1", "EndpointID": "1", "EntryPoint": "docker-compose.yml", "SwarmID": "mythirdstack_w9uo9wtxi064ujpofkck91zes", "ProjectPath": "/data/compose/mythirdstack_mythirdstack_w9uo9wtxi064ujpofkck91zes" }, ] The 'list' action with the 'quiet' mode enabled: psu -a list -u admin -p password -l http://portainer.local -q Output the name of the stacks already deployed: mystack mysecondstack mythirdstack
Here a use case for the exist=$(psu -a info -u admin -p password -l http://portainer.local -n mystack -q)
if [ -n "$exist" ]; then
echo OK
else
echo KO
fi
# OR check the exit code of the last executed command:
status=$?
if $(exit $status); then
echo OK
else
echo KO
fi |
Hello again @tortuetorche! Thank you for your interest and your contributions to this project. I have also been playing for a while with the idea of "list" and "info" features, and I am glad someone else did too and even implemented them. The quiet mode (as proposed here), looks confusing to me: there already exists a verbose mode, which could be used with quiet mode. Both work different, but at first sight the terms could be confusing for new users. Moreover, the quiet mode would be relevant only for list and info actions, while the other modes work for all actions. Maybe a "mode" is not the most suitable place for this feature? Also, the same result could be obtained (with greater flexibility) just by piping the script output to jq and applying the As you are bringing several features here please, would you mind using separate pull requests? |
@tortuetorche sorry, I didn't notice yout comment about status and rollout actions until now. I like the idea. Please open two issues to shape the concepts better. |
Hi @greenled,
The quiet mode is inspired by the
I'm working on these new actions, right now, it looks promising but I need to clean up some code before publishing them Have a good day, |
Ok, I see your point. Let's have a quiet mode. |
Closing in favor of my upcoming pull request who add these two actions and even more... |
Hi,
Here two actions
info
andlist
, which can be useful in a Continuous Integration (CI)/Continuous Delivery CD workflow, with tool like GitLab CI:The
info
action:Output the JSON object of the stack if it's already deployed:
The
info
action with thequiet
mode enabled:Output the stack name if it's already deployed:
The
list
action:Output a JSON array of the stacks already deployed:
The
list
action with thequiet
mode enabled:Output the name of the stacks already deployed:
Feedback are welcome!
NB: I also plan to add two new actions
status
(borrowed from Helm) androllout
(borrowed from kubectl). But for services/tasks instead of stack centric with the help of theses resources: https://gist.github.com/deviantony/77026d402366b4b43fa5918d41bc42f8#execute-docker-queries-against-a-specific-endpoint and https://docs.docker.com/engine/api/v1.30/#operation/TaskListCheers,
Tortue Torche