Service-Hub
Service-Hub copied to clipboard
Jinja
Consider replacement of current template engine(Pystache/Chevron) by Jinja. Requirements:
- [x]
{{
}}
- template variable markers. - [x] Getting list item by numeric index(need for case with IP in service ingress).
- [x] Skipping of invalid variable placeholder error(need on 1st render when application Kubernetes entities wasn't created yet).
- [x] Error rising when variable placeholder is invalid(need on 2nd render when application successfully deployed and context is complete).
- [ ] Optional Keep template variable place holder if it can't be found in context.
Found issues:
- Jinja cant work with dashes in variables names.
{{components.redis.manifest.Service.redis-master.status.loadBalancer.ingress.0.ip}}
hereredis-master
causes error. As workaround we can specify such keys in quotes('
or"
)Service["redis-master"]
. This is because Jinja applies to variables same rules as Python to own variables.
Notes:
- To rise error when template variable is absent pass
jinja2.StrictUndefined
policy tojinja2.Template
initializer, e.g.template = jinja2.Template('template', undefined=jinja2.StrictUndefined)