carvel-dev / ytt

YAML templating tool that works on YAML structure instead of text
https://carvel.dev/ytt
Apache License 2.0
1.66k stars 136 forks source link

loading data in data/values #485

Closed mhoshi-vm closed 3 years ago

mhoshi-vm commented 3 years ago

I am trying to do something like the following.

#@ load("@ytt:data", "data")
#@ load("@ytt:overlay", "overlay")
#@data/values
---
registry:
  username: #@ data.values.tanzunet_username
  password: #@ data.values.tanzunet_password

Of course I have another data yaml file that defines data.values.tanzunet_username but i fail with the following.

  Templating file 'acc-data-values.yaml':
- struct has no .tanzunet_username field or method
    in <toplevel>
      acc-data-values.yaml:9 |   username: #@ data.values.tanzunet_username

I am guessing you cannot load("@ytt:data", "data") in a data file, but is this correct and is there any workaround ?

groundnuty commented 3 years ago

I've hit the same block - would appreciate any comment on this.

gcheadle-vmware commented 3 years ago

Hi @groundnuty 👋

I am guessing you cannot load("@ytt:data", "data") in a data file, but is this correct and is there any workaround ?

You are correct, since you have a data values annotation, #@data/values, in the same file that you are referencing other data values, #@ data.values.tanzunet_username, ytt will error.

This issue, and a work around has been discussed in a previous thread: https://github.com/vmware-tanzu/carvel-ytt/issues/459 so I am marking this issue as duplicate, and closing. Please reopen and comment if you have any additional questions or if that work around does not work for you. Thank you!