Error when a non-template annotation is used for setting the value of a node
- Dominant language
- Go
- Stars
- 1.9k
- Forks
- 167
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the problem/challenge you have**
When I accidentally write non-template-code for an inline comment in my template, the resulting value is `null`.
Example:
```
#@ load("@ytt:data", "data")
---
akoOperator:
config:
avi_control_plane_ha_provider: #@ data.values.AVI_CONTROL_PLANE_HA_PROVIDER
#@ if data.values.AVI_NSXT_T1LR:
avi_nsxt_t1_lr: #@data.values.AVI_NSXT_T1LR
#@ end
```
yields:
```
akoOperator:
config:
avi_control_plane_ha_provider: true
avi_nsxt_t1_lr: null
```
_(from: https://carvel.dev/ytt/#gist:https://gist.github.com/XudongLiuHarold/d99b14e347601b9254e86330e99aa9ad)_
This is a bad experience because `ytt` returns a value giving me the impression that the template was well-formed and valid.
**Describe the solution you'd like**
Report an error when any other annotation _other_ than `@template/code` or `@template/value` (or their short-hand `@ `) is provided for an inline comment.
Bonus points if we can _reliably_ detect cases like the one above and be able to suggest ("Did you mean `avi_nsxt_t1_lr: #@ data.values.AVI_NSXT_T1LR`?")
**Anything else you would like to add:**
Consider: should we have a list of "reserved" annotations that are not allowed. e.g. @for, @if, @data.values, @end ... and detect these generally?
---
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.
Contributor guide
Research direction
Start by reproducing the inline-comment example from the issue in ytt and inspect the annotation handling path that turns the non-template annotation into null. Determine how inline annotations are distinguished from @template/code, @template/value, and shorthand @ forms. Done means invalid inline annotations produce an error, with tests covering the example and any reserved-annotation behavior agreed by the project.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, yaml
- Domain
- cli, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100