Tag Filter
The Tag Filter can be used in multiple Terramate features:
- stack.after
- stack.before
terramate --tags <filter>
The filter returns a list of stacks containing tags
which satisfies the filter query. The query language is best explained with some examples but a formal definition can be found here.
Let's say the project has multiple stacks and some of them having the tag abc
, others having the tag xyz
and some having of them having both.
Then:
abc
selects the stacks containing the tagabc
.xyz
selects the stacks containing the tagxyz
.abc:xyz
selects the stacks containing bothabc
andxyz
tags.abc,xyz
selects the stacks containingabc
orxyz
tags.
The :
character defines the AND operation and the ,
character the OR operation. They can be freely combined but no explicit grouping is supported (yet).
Examples:
tf,pulumi,cfn
selects the stacks containing the tagstf
orpulumi
orcfn
.app:k8s:frontend
selects only stacks containing the three tags:app
&&k8s
&&frontend
.app:k8s,app:nomad
selects only stacks containing the both the tagsapp
ANDk8s
or stacks containing both the tagsapp
ANDnomad
.
Filter Grammar
Below is the formal grammar definition:
ebnf
query ::= or_term {',' or_term}
or_term ::= and_term {':' and_term}
and_term ::= tagname
tagname ::= ident
ident ::= allowedchars { allowedchars } | allowedchars
allowedchars ::= lowercase | digit | '-' | '_'
digit ::= '0' ... '9'
lowercase ::= 'a' | 'b' | ... | 'z'
The ident
definition is a simplification and you should refer to stack.tags for the correct definition (in prose) for the expected declaration of tag names.