Skip to content
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

[WIP] [RFC] Allow user to retrieve more than one resource using "st2 resource get" CLI command #4912

Open
wants to merge 1 commit into
base: master
from

Conversation

@Kami
Copy link
Member

@Kami Kami commented Apr 18, 2020

This pull request addresses one of my biggest minor annoyances with StackStorm CLI.

A lot of times when I'm debugging / troubleshooting things, I need to view multiple resources at once to see what is going on.

This means that currently I need to run more than one command to achieve that.

For example:

st2 execution get id1
st2 execution get id2
st2 execution get id3

This slows things down and means more typing (yes, I can use a bash alias or function, but that's not ideal and it's not available out of the box).

With this change, user can now view more than one resource using the get command.

The same pattern is already available with st2 execution cancel command (I added it a while ago).

For example:

st2 execution get id1 id2 id3

Example output:

st2 action get packs.unload packs.show
+---------------+--------------------------------------+
| Property      | Value                                |
+---------------+--------------------------------------+
| id            | 5e9ae3535550f016857e19f9             |
| uid           | action:packs:unload                  |
| ref           | packs.unload                         |
| pack          | packs                                |
| name          | unload                               |
| description   | Unregisters all content from a pack. |
| enabled       | True                                 |
| entry_point   | pack_mgmt/unload.py                  |
| runner_type   | python-script                        |
| parameters    | {                                    |
|               |     "packs": {                       |
|               |         "items": {                   |
|               |             "type": "string"         |
|               |         },                           |
|               |         "required": true,            |
|               |         "type": "array"              |
|               |     }                                |
|               | }                                    |
| metadata_file | actions/unload.yaml                  |
| notify        |                                      |
| output_schema |                                      |
| tags          |                                      |
+---------------+--------------------------------------+
+---------------+--------------------------------------------------------------+
| Property      | Value                                                        |
+---------------+--------------------------------------------------------------+
| id            | 5e9ae3535550f016857e19f7                                     |
| uid           | action:packs:show                                            |
| ref           | packs.show                                                   |
| pack          | packs                                                        |
| name          | show                                                         |
| description   | Get detailed information about pack from the remote          |
|               | StackStorm exchange index.                                   |
| enabled       | True                                                         |
| entry_point   | pack_mgmt/show_remote.py                                     |
| runner_type   | python-script                                                |
| parameters    | {                                                            |
|               |     "pack": {                                                |
|               |         "required": true,                                    |
|               |         "type": "string",                                    |
|               |         "description": "Name of pack to lookup"              |
|               |     }                                                        |
|               | }                                                            |
| metadata_file | actions/show.yaml                                            |
| notify        |                                                              |
| output_schema |                                                              |
| tags          |                                                              |
+---------------+--------------------------------------------------------------+

Open Questions / To Decide

Currently when a single source id is provided, the command behaves exactly in the same manner as it did before - it's fully backward compatible.

When retrieving multiple resources, if one of the provided resources is not found, we simply print that, but we don't immediately exit with non-zero status code and print other resources which were found.

As far as using the existing command name goes - I think that's better than adding yet another command (e.g. st2 <resource> get-more or similar) - the whole idea is that it's simple and it works out of the box so any other change which would make it less simple (e.g. new argument or filter to list command, etc.) is a no go.

TODO

  • (Once agreed on the approach) Implement it for other non-resource "get" commands
  • (Once agreed on the approach) Add tests
@Kami Kami added the CLI label Apr 18, 2020
@pull-request-size pull-request-size bot added the size/M label Apr 18, 2020
@armab armab added this to the 3.3.0 milestone Apr 18, 2020
@armab armab removed this from the 3.3.0 milestone Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.