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

"#@data.values" [no space after @] should error with a helpful hint #532

Open cppforlife opened 3 years ago

cppforlife commented 3 years ago

Describe the problem/challenge you have users may accidentally forget to have a space in foo: #@data.values after @ and be confused why the data value is not showing up in the output.

(https://twitter.com/stylishandy/status/1455051198935957514?s=20)


Vote on this request

This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.

👍 "I would like to see this addressed as soon as possible" 👎 "There are other more important things to focus on right now"

We are also happy to receive and review Pull Requests if you want to help working on this issue.

pivotaljohn commented 3 years ago

I'm tempted to generalize this issue as, "Whenever there's an unrecognized annotation, ytt should error; in some set of common situations include a hint."

"Common Situations" could include:

Where the hint could note the needed space:

ytt: Error: Overlaying data values (in following order: overlay.yml):
  Document on line overlay.yml:7:
    Map item (key 'foo') on line overlay.yml:9:
      Unknown annotation '@data.values.replicas' (did you mean '@ data...`, with a space after the '@'?)

Thoughts?

cppforlife commented 3 years ago

i like where you going with it. this does make me think about backwards and forwards compatibility. do we get a benefit for being able to use unknown annotations today? (e.g. if some data values passed in i can use newer ytt functionality otherwise fall back? if we check annotations early enough this would become problematic...)

there is something to be said about possibility of doing short-term hinting and then potentially filling in more comprehensive changes.

pivotaljohn commented 3 years ago

this does make me think about backwards and forwards compatibility.

Ditto. I'm thinking of putting a feature flag on it (as in the user-facing feature flag). It would be more ytt-ish if we'd be stricter by default and be able to relax with the flag.

Something like... idonno... --ignore-unknown-annotations 😁 .

pivotaljohn commented 3 years ago

This idea is an aspect of #114