Substitution (dynamic templates)
Substitution provides a powerful mechanism to dynamically transform application configuration that is tailored for each device.
Last updated
Was this helpful?
Substitution provides a powerful mechanism to dynamically transform application configuration that is tailored for each device.
Last updated
Was this helpful?
Synpse provides the ability to expand, or substitute, application and device metadata to facilitate dynamic application configurations.
Device environment variables (defined by user)
Synpse environment variables (automatically set,)
Most of the values in the application spec can be changed, for example:
Container name
Image name (you can adapt image name based on architecture)
Environment variables
Secrets
Volumes
On a regular amd64 (x86) machine it will be:
While on a 32-bit arm machine the spec will become:
Let's say you have set an environment variable on the device called:
Now, you can use that environment variable to create something else, for example a URL on which the device will be accessible by users (assuming you have configured domain, etc.):
And your application will then see an environment variable which equals
Synpse provides partial emulation for bash string operations. This can be used to manipulate string values prior to substitution.
Example variable substitution with substring:
Synpse emulates the below string operations:
If you do not want the system to evaluate an expression it must be escaped:
If your environment variable contains *
, it will be automatically quoted to avoid parsing issues. For example:
Where MY_DOMAIN=*.example.com
will be rendered as:
However, the following example
Will be rendered as:
Which can lead to issues in your applications. In these scenarios, try to avoid using environment variable substitution.
If you have an application that is deployed on multiple devices of various CPU architectures (amd64, arm, arm64), you can specify image substitution ():