Range and string in Go template

Viewed 40

I am writing a Go template to create a yaml config:

my yaml config

logs:
  - type: file
    path: /opt/nomad/data/alloc/*/alloc/logs/*App1.stderr.*
    service: App1
    source: nomad
  - type: file
    path: /opt/nomad/data/alloc/*/alloc/logs/*App2.stderr.*
    service: App2
    source: nomad

My go template

logs:
{{- range $value := . -}}
- type: file
path: /opt/nomad/data/alloc/*/alloc/logs/*{{$value.Task}}.stderr.*
exclude_paths: /opt/nomad/data/alloc/*/alloc/logs/*{{$value.Task}}.stderr.fifo
service: {{$value.Task}}
source: nomad
{{end}}

How i need to change the template to get my yaml config

1 Answers
Related