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 135 forks source link

Output full path in errors for a given file #895

Open blakebarnett opened 7 months ago

blakebarnett commented 7 months ago

Currently if you have a nested directory structure for YTT files, whenever there's an error it currently only outputs whatever filename it was parsing when the error occurred. If you have multiple files with the same or similar name across many directories it can be confusing/frustrating to track it down.

It would be extremely helpful to include the relative full path to the file or an option to enable that behavior.


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.

prembhaskal commented 7 months ago

Is it possible to share the config to quickly reproduce the error?

blakebarnett commented 7 months ago

There's no specific error. It's more about what the output is when there is any error parsing files.

Here's a contrived (but realistic) layout:

envs
├── development
│   ├── overlays.yaml
│   └── values.yaml
├── integration
│   ├── overlays.yaml
│   └── values.yaml
└── production
    ├── overlays.yaml
    └── values.yaml
apps
├── example
│   ├── base-values.yaml
│   ├── development
│   │   ├── image-tag.yaml
│   │   └── values.yaml
│   ├── integration
│   │   ├── image-tag.yaml
│   │   └── values.yaml
│   └── production
│       ├── image-tag.yaml
│       └── values.yaml
└── grpc-example
    ├── base-overlays.yaml
    ├── base-values.yaml
    ├── development
    │   ├── image-tag.yaml
    │   └── values.yaml
    ├── integration
    │   ├── image-tag.yaml
    │   └── values.yaml
    ├── production
    │   ├── image-tag.yaml
    │   └── values.yaml

Here's an example error:

❯ ytt -f envs/development/values.yaml -f apps/example/development/values.yaml
ytt: Error: Unmarshaling YAML template 'values.yaml': yaml: line 3: mapping values are not allowed in this context

Which makes figuring out which values.yaml it's referring to here annoying. We're currently getting around this by naming files excessively descriptively like env-development-values.yaml and so on, but it gets very odd looking as the structure is more nested and/or the files need ever more descriptive names. This also affects the --files-inspect option:

❯ ytt -f envs/development/values.yaml -f apps/example/development/values.yaml --files-inspect
- values.yaml
- values.yaml
renuy commented 6 months ago

@blakebarnett , Thanks for bringing this up. Feel free to raise a PR for this, and we can prioritize the review for the same.