Adding --state and --tags filters to bk agent list
#561
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.
Primary purpose of this PR is to enable filtering via
--stateand--tags.--stateallows input of running, idle or paused.--tagswill match with AND logic, so if multiple tags are defined, both must resolve to true in order to display any agent(s). If the Agent has 3 tags and we match with 2 tags, that's also fine.The issue raised requesting this feature #544 requested a
--queueflag. However, due to the filtering capability that could be enabled by allowing multiple flags, I've opted for--tags, this would still allow--tags queue=defaultin this case.Tags can be filtered like so:
--tags queue=default--tags queue=default --tags os=linux--tags queue=default,os=linuxBoth filters implemented are client-side, as the API doesn't currently support server-side filtering for these attributes.
Tests added to validate states, validate invalid state input and test single/multiple tags.
Tested this locally, too. All works great.
Fixes #544