Skip to content

Pack Template Patterns

Charlie Voiselle edited this page Apr 14, 2022 · 1 revision

Nomad Pack templates leverage golang's text/template package and additional helper functions to create your desired output. Over the course of developing and reviewing Packs, here are some of the patterns that we have observed being frequently used.

Specifying a default value

The default function is useful way to provide a value in cases when a value is not specified or is the empty value—for example, the string "".

job "[[ default .my.job_name .nomad_pack.pack.name]]" {
...

You can also use the coalesce function to select the first non-empty value in a set of parameters.

...
      service "[[ default .my.custom_service_name .my.job_name .nomad_pack.pack.name]]" {
...
Clone this wiki locally