carvel-dev / ytt

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

Hint at likely options when no matcher is supplied for array items #124

Closed pivotaljohn closed 2 years ago

pivotaljohn commented 4 years ago

Given a situation like this:

values.yml

#@data/values
---
ca_certs: []

output.yml

#@ load("@ytt:data", "data")

---
ca_certs: #@ data.values.ca_certs

overlay.yml

#@data/values
#@ load("@ytt:overlay", "overlay")

---
ca_certs:
- value1
- value2

The error message is:

Overlaying data values (in following order: values.yml, overlay.yml):
Document on line overlay.yml:4: Map item (key 'ca_certs') on line 
overlay.yml:5: Array item on line overlay.yml:6: Expected array item
 to have 'overlay/match' annotation

In general, we're missing a matcher, not specifically #@overlay/match.

Let's offer a hint that they likely mean #@overlay/append.

pivotaljohn commented 2 years ago

Moot since v0.38.0: the default action for array items is @overlay/append