This utility currently only supports filling your config with contents from environmental variables or files (called templating).
TIP: The concept was heavily inspired by Druids configuration interpolation.
Imagine the following example.xml
:
cat > example.xml << 'EOF'
<credentials>
<username>${env:EXAMPLE_USERNAME}</username>
<password>${file:UTF-8:example-password}</password>
</credentials>
EOF
and the following example-password
:
echo 'example-password <123>!' > example-password
You can run the following command to replace both placeholders:
export EXAMPLE_USERNAME=my-user
config-utils template example.xml
Afterwards the XML looks like
<credentials>
<username>my-user</username>
<password>example-password <123>!</password>
</credentials>
config-utils
did the following steps to achieve the result:
- Use the file extension to determine the file type (XML in this case). You can also specify the file type manually as a CLI argument.
- Read the env var
EXAMPLE_USERNAME
, xml-escape it and insert it - Read the contents of the file
example-password
, xml-escape it and insert it
Please note that config-utils
also supports nested templating, so the name of the file to read can come from an env var (or even another file as well).
This looks something like ${env:${env:ENV_TEST_PASSWORD_ENV_NAME}}
.properties
files- XML files