Templates: How to access tuple key/value

I’m wondering how to access keys & values in tuples.

For this job I want to iterate through all Nomad variables and output them in a KEY=value format to access them as environment variables inside the task. According to the docs the variables are available in Keys, Values, and Tuples.

template {
  destination = "local/test.env"
  env         = true
  data        = <<EOH
{{ with nomadVar "nomad/jobs/example-job/example-group }}
  {{ range .Tuples }}
    {{ . }}
  {{ end }}
{{ end }}
EOH
}

With a variable SOME_VAR and value foobar This produces the output:

{SOME_VAR foobar}

I’ve already tried

  • {{ .Key }} / {{ .Value }},
  • {{ .[0] }}
  • {{ call .At 0 }} - If the type would be the go tuple I should be able to access the values by calling the At(i int) function.

inside the loop block.

Using key/value pairs also won’t work.

{{ with nomadVar "nomad/jobs/example-job/example-group" }}
  {{ range $key, $value := .Tuples }}
    {{ $key }}={{ $value }}
  {{ end }}
{{ end }}

Thanks!