colmena icon indicating copy to clipboard operation
colmena copied to clipboard

Tag selector improvements

Open afics opened this issue 1 year ago • 2 comments

Hi,

are you open to a pull request that implements more advanced tag handling for use with the --on option? This is relevant to #67.

I am thinking about something like:

  • @foo | @bar to select hosts matching either foo or bar
  • keeping @foo,@bar which is identical to @foo | @bar for backwards compatibility, so basically aliasing , and |
  • @foo & @bar to select hosts matching both
  • @foo & !@bar to select hosts matching foo but not bar

A more sophisticated example might be @env:prod & @role:webserver & !@ha-group:a which selects host matching @env:prod and @role:webserver but not @ha-group:a.

Globbing should be allowed just as before. I would evaluate these statements in order, no special precedence. While nesting such statements using braces could be implemented I am not seeing enough benefit, so I would skip that.

Please let me know what you think. Any input is appreciated!

afics avatar Apr 29 '23 10:04 afics

It would be great to implement this idea, but it's important to keep in mind that in the Linux shell, the characters | and & have specific meanings. So, to avoid any confusion, it might be better to use and, or, and not instead.

otavio avatar Apr 29 '23 13:04 otavio

I thought about that but did not like the verbosity. Also I assumed the input string would be quoted anyways, so it gets passed as a single argument.

afics avatar Apr 29 '23 15:04 afics