Compose error location#222
Open
maximeborges wants to merge 2 commits into
Open
Conversation
Split the crate into a library (`src/lib.rs`) and a thin binary (`src/main.rs`) so podlet can be used as a dependency. The library exposes a small, string-based public API for in-memory compose -> Quadlet/Kubernetes conversion, keeping internals private: - `compose_to_files(yaml, ComposeOptions) -> Vec<GeneratedFile>` - `Cli::try_into_generated_files()` for all subcommands - `GeneratedFile`, `ComposeOptions` Split `Compose::try_into_files` into an I/O part and a pure `into_files` that takes an already-parsed `compose_spec::Compose`. Patch `compose_spec` (k9withabone/compose_spec_rs#42) so absolute volume paths validate on non-Unix targets. Signed-off-by: Maxime Borges <contact@maximeborg.es>
Deserialize compose files directly from the source text so serde_yaml can
report the line, column, and field path of any error. Previously all parse
paths round-tripped through a serde_yaml::Value (needed to expand `<<` merge
keys), which discards source spans and left schema errors location-less
("invalid type: integer `8080`, expected a set").
The direct-parse path now handles the common case; it falls back to the
Value + apply_merge path only when the file actually uses merge keys, the one
case where a location cannot be recovered with serde_yaml.
Signed-off-by: Maxime Borges <contact@maximeborg.es>
Collaborator
|
@maximeborges You created a branch out of your branch for #219 and therefore this PR contains both features. |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add location for error so it's easier to track the origin in long files, e.g. :
instead of a bare
invalid type: integer 8080, expected a set.Previously every compose file was parsed through a
serde_yaml::Valueso we could expand<<merge keys, but that discards source spans and left all schema errors location-less.from_yaml()now deserializes straight from the text, falling back to theValue+apply_mergepath only when the file actually uses a merge key, for which we can't recover the error location properly anyway. Merge-key files produce identical output to before.Applies on top of #219