Skip to main content

Configuration Templating

Gate supports templating for all configuration file formats. This allows you to create flexible and reusable configurations.

For example, let's configure Gate to use port 8080:

configs/gate-variables.yaml
gate:
port_from_variable: "8080"
configs/gate.yaml
gate:
port_from_variable: "{{.gate.port_from_variable}}"

Running:

gate --yaml configs/gate-variables.yaml --yaml configs/gate.yaml

gate.port equals to "8080".

You can also use configuration files in different formats, such as:

configs/gate.yaml
gate:
port_from_variable: "{{.gate.port_from_variable}}"
GATE_PORT_FROM_VARIABLE=8080 gate --env --yaml configs/gate.yaml
info

You cannot reference a templating variable within the same file where it is defined.

caution

You can only reference variables defined in gate. Here's an example that will not work:

configs/gate-variables.yaml
this_is_not_available: "bar"
gate:
this_is_available: "foo"
configs/gate.yaml
gate:
port_from_variable: "{{.this_is_not_available}}"

Advanced templating

Under the hood, Gate's configuration templating uses Go's text/template package. You can use any option provided by this package.