Service-Hub icon indicating copy to clipboard operation
Service-Hub copied to clipboard

Jinja

Open vadim-zabolotniy opened this issue 2 years ago • 1 comments

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.

vadim-zabolotniy avatar Feb 07 '23 09:02 vadim-zabolotniy

Found issues:

  • Jinja cant work with dashes in variables names. {{components.redis.manifest.Service.redis-master.status.loadBalancer.ingress.0.ip}} here redis-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 to jinja2.Template initializer, e.g. template = jinja2.Template('template', undefined=jinja2.StrictUndefined)

vadim-zabolotniy avatar Feb 07 '23 11:02 vadim-zabolotniy