Repository navigation
feat(st2client): allow delete commands to accept multiple ids - #6411
Open
Yusuf-Hussien wants to merge 1 commit into
Open
Yusuf-Hussien wants to merge 1 commit into
Yusuf-Hussien wants to merge 1 commit into
Conversation
All st2 <resource> delete commands now accept multiple positional ids, e.g. st2 action-alias delete id1 id2 id3. Existing single id behavior is unchanged; when deleting multiple ids, resources which are not found are reported and the command exits with a non-zero return code after attempting to delete the remaining resources. Fixes StackStorm#4729 Signed-off-by: Yusuf Hussien <yhussien01@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Closes #4729.
st2 <resource> deleteonly accepted a single positional id, so bulk removal (e.g. after installing a testing pack with many action aliases) required one invocation per resource:Changes
ResourceDeleteCommandnow takesnargs="+"and loops over the provided ids, mirroring howst2 <resource> getalready handles multiple ids.<Resource> "<id>" is not found.message; the remaining ids are still attempted and the command exits with a non-zero return code afterwards, so partial bulk deletes are visible to scripts.ActionDeleteCommandandKeyValuePairDeleteCommandwere refactored to override the newdelete_resource()hook instead ofrun(), so they automatically support multiple ids too. As a side effect,st2 action delete <missing-id>now exits non-zero like the other delete commands (it previously exited 0).Testing
st2client/tests/unit/test_commands.py:pytest st2client/tests/unitlocally (Python 3.11): 241 passed; the only failures are 4 pre-existing environment-related failures which also fail on unmodifiedmaster.black --checkandflake8(repo config) are clean on the changed files.Drafted with AI assistance; reviewed and tested locally.