Query Templates#
Query Templates are appended to an incoming Squirro query. This functionality is typically used to implement access control logic.
Configuration#
To enable query templates, the /etc/squirro/topic.ini
configuration is modified to contain a [query_templates]
section:
[query_templates]
# Which projects should use a query template (space-separated)
project_ids = IgnLQDYqSta1dQUtOZh0xg I6JAxCjeRTWts8mwI3AA6A
# Where are the templates stored
directory = /etc/squirro/query_templates
Make sure, the specified directory exists. For reach project that was specified in the project_ids
a template file with the tmpl
extension should exists. In the example above, the following two templates are used on the disk:
/etc/squirro/query_templates/IgnLQDYqSta1dQUtOZh0xg.tmpl
/etc/squirro/query_templates/I6JAxCjeRTWts8mwI3AA6A.tmpl
If a template doesn’t exist, even though the project is listed in the query templates project IDs, then all queries in that project will return an error.
Template#
The query template is written as a Jinja template. A number of arguments are provided to the template.
In addition, all values passed into the user_information dictionary in the extauth service are available as top level attributes.