Add Handlebars helper for resolving system and environment variables
See original GitHub issueI’m looking to stand up a standalone version for load testing. One of the needs is to be able to replace values in the response template from system or environment variables. Based on https://github.com/tomakehurst/wiremock/issues/789, looks like it’s not currently possible without repackaging the code, although I’m not sure even in that case how’d I register the custom helper class.
I can imagine such a helper to be pretty useful, and will be happy to make a PR. I’m not super familiar with Handlebars, but I think the following should get the job done:
{{var key='something' scope='[sys|env]'}}
If scope
isn’t specified, the code will lookup in the system variables first, followed by environment variables. Any .
or -
in the key will be converted to a _
if scope=env
, as well as uppercased. For example, key=wire-mock.rocks
will be converted to WIRE_MOCK_ROCKS
. No such translation will be performed for scope=sys
.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:9 (3 by maintainers)
See PR #1085
@zkendall I agree this would be useful, and I’m happy for it to be added. If you’re up for a creating a PR that would make things happen much more quickly.