hairyhenderson/gomplate

Why does index work here where coll.Index fails?

ArcticSnowman opened this issue · 1 comments

Given a YAML datasource like this

---
ranges:
  alpha:
    dev: 10.0.0.1/24
    test: 10.0.0.2/24
    prod: 10.0.0.4/24
  beta:
    dev: 10.0.1.1/24
    test: 10.0.1.2/24
    prod: 10.0.1.4/24

Why does this work?

$> gomplate -d ranges=./ranges.yaml -i '{{ $ranges := (ds "ranges").ranges }}{{ $zone := index $ranges "alpha" }}{{ index $zone "test" }}'
10.0.0.2/24

but this does not

$> gomplate -d ranges=./ranges.yaml -i '{{ $ranges := (ds "ranges").ranges }}{{ coll.Index "alpha" "test" $ranges }}'

18:08:15 FTL  error="template: <arg>:1:40: executing \"<arg>\" at <coll>: can't evaluate field Index in type *funcs.CollFuncs"

coll.Index is not in a released build yet unfortunately - it's documented because the docs are based on the current state of main.

You could try the latest gomplate by compiling it for yourself - https://docs.gomplate.ca/installing/#install-with-go-install - otherwise you'll need to wait for v4.