-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More flexible registry generate
command
#45
More flexible registry generate
command
#45
Conversation
…ation more flexible
… + jaq (jq-like filters)
|
||
### Attributes | ||
|
||
{% for attribute in group.attributes %} | ||
{% for attribute in ctx.attributes %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for moving from group to ctx
) | ||
.expect("Failed to generate registry assets"); | ||
let template_registry = | ||
TemplateRegistry::try_from_resolved_registry(&schema.registries[0], &schema.catalog) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a huge fun of always indexing the first registry here. Did you have a bug open to clean that up at some point or alter the representation?
I think you could even just pass the entire &schema
directly to try_from_resolved_registry
to hide that complexity until we clean it up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will open an issue to improve this as it's indeed far from optimal. It was like an intermediary/unfinished step, the final goal being at some point to support multiple registries from the same app telemetry schema (e.g. OTel official registry + 0 to n vendor or internal registries).
This PR integrates
MiniJinja
withjaq
filters (a jq-compatible Rust implementation) to specify what to extract and process from the resolved registry, as well as how to apply theJinja2
templates.All errors are collected and displayed at the end of the command execution. For each error, the command shows the location in the file, the reason for the error, and the content of the evaluation context. This information helps template authors understand the issues. Similar errors are grouped together.
Note 1: I had to update multiple files not related to this PR in order to make the last version of Clippy happy.
Note 2: Why use
jaq
filters instead ofJSONPath
or similar selectors?jaq
filters are extremely powerful; they can be used to sort or group registry signals (e.g., by prefix) and much more. Such features are not supported byJSONPath
.Example of error returned by the command.