mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-29 05:35:43 +01:00
861ca553df
Signed-off-by: Soumik Majumder <soumikm@vmware.com> Signed-off-by: Soumik Majumder <soumikm@vmware.com>
19 lines
575 B
Python
19 lines
575 B
Python
import json
|
|
|
|
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
|
from .misc import mark_file
|
|
|
|
jinja_env = Environment(loader=FileSystemLoader('/'), trim_blocks=True, lstrip_blocks=True, autoescape = select_autoescape())
|
|
|
|
def to_json(value):
|
|
return json.dumps(value)
|
|
|
|
jinja_env.filters['to_json'] = to_json
|
|
|
|
|
|
def render_jinja(src, dest,mode=0o640, uid=0, gid=0, **kw):
|
|
t = jinja_env.get_template(src)
|
|
with open(dest, 'w') as f:
|
|
f.write(t.render(**kw))
|
|
mark_file(dest, mode, uid, gid)
|
|
print("Generated configuration file: %s" % dest) |