-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional functions in template #93
base: master
Are you sure you want to change the base?
Conversation
…"requiredEmpty" functions that treat empty string same as nil
I'd love to see more utility methods in the templating, this is a place where confd really shines by comparison. |
These functions are very useful indeed. @jwilder please merge this. This addresses some pain points. |
Maintenance and development now happens in fork https://github.com/powerman/dockerize.
$ unset UNSET; EMPTY="" SPACE=" " dockerize -template /dev/stdin <<'EOF'
[{{ default "unset" .Env.UNSET }}]
[{{ default "empty" .Env.EMPTY }}]
[{{ default "space" .Env.SPACE }}]
EOF
[unset]
[empty]
[ ]
These can be added, but to me it looks like right way to get error because of non-existing environment variable is to enable Also current version provides empty and fail functions which you may find useful too. Feel free to open PR at https://github.com/powerman/dockerize if you need something else and proposed flag and
This one is unique enough, but there are other functions which may do similar things:
If proposed alternatives won't work for you then we can add |
Sorry for off-topic, but I have a concern against extending template functions. Ideally we need support of custom template functions loaded from user-provided files like j2cli supports (refer to Almost every time when one fills templates, he needs to think about quoting (to support whitespaces and to prevent configuration injection) and escaping (because of configuration file format and because of quoting). This sort of transformation can be complex. Here is an example of escaping for JBoss EAP / Wildlfy configuration - mabrarov/dockerfile-test/hollow-image/src/main/resources/rootfs/app/bin/filters.py. So my personal preference would be to implement feature like j2cli provides - defining and loading external user-defined functions which could be used in dockerize template engine. |
Hi. I created some functions that were helpful in creation custom images. For example we can pass multiple datasources by environment variables to tomcat xml configuration.
`
WEB-INF/web.xml ${catalina.base}/conf/web.xml`