VirtusLab / render

Universal data-driven template for generating textual output, as a static binary and a library
Apache License 2.0
141 stars 24 forks source link

ERRO Unexpected error: error (ExecError) #18

Closed bndw closed 5 years ago

bndw commented 5 years ago

Hi, I'm attempting to generate --var flags from a file before invoking render but am hitting a strange error.

I have a source kubernetes volume.yaml file with one template replacement {{ .main_volume }}:

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: myVolume
spec:
  awsElasticBlockStore:
    fsType: ext4
    volumeID: {{ .main_volume }}
---

I'm sourcing the variable replacement from a file called vars.env

main_volume=vol-xxxxxxxxx
secondary_volume=vol-yyyyyyyy

I'm using awk to convert this file into --var flags for render:

cat vars.env | awk '{printf " --var \"%s=%s\"", $1, $3}'
 --var "main_volume=vol-xxxxxxxxx" --var "secondary_volume=vol-yyyyyyyy"

All together:

render --in volume.yaml $(cat vars.env | awk '{printf " --var \"%s=%s\"", $1, $3}')
INFO Version unknown-unknown
INFO Variables:
    "main_volume=vol-0534a398c42265a31"
    "secondary_volume=vol-333333534a398c42265a31"
INFO Rendering 'volume.yaml' -> 'stdout'
ERRO Unexpected error: error (ExecError) evaluating the template named 'volume.yaml': template: volume.yaml:16:17: executing "volume.yaml" at <.main_volume>: map has no entry for key "main_volume"; hint: go templates does not evaluate missing keys in dot notation, for more details see: https://github.com/VirtusLab/render/issues/11

Any help would be appreciated!

render --version
render version unknown-unknown

Not sure what's up with the version, I just did a fresh install on a go 1.13.1 machine with go get -u github.com/VirtusLab/render

pawelprazak commented 4 years ago

FYI there is a problem with go get https://github.com/VirtusLab/render/issues/15

as for now it's better to use the binaries