-
Notifications
You must be signed in to change notification settings - Fork 27
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
Generate JSON Schema for both Resolved Telemetry Schema and Resolved Registry #187
Generate JSON Schema for both Resolved Telemetry Schema and Resolved Registry #187
Conversation
…solvedRegistry and ResolvedTelemetrySchema TemplateRegistry had been renamed ResolvedRegistry.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #187 +/- ##
=======================================
- Coverage 75.0% 74.5% -0.6%
=======================================
Files 44 44
Lines 2871 2889 +18
=======================================
- Hits 2156 2155 -1
- Misses 715 734 +19 ☔ View full report in Codecov by Sentry. |
@@ -47,6 +47,9 @@ pub trait Logger { | |||
|
|||
/// Logs a message without icon. | |||
fn log(&self, message: &str); | |||
|
|||
/// Mute all the messages except for the warnings and errors. | |||
fn mute(&self); |
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.
Introduced this new function to fix #184 and to simplify testing.
@@ -3,7 +3,7 @@ | |||
//! Initializes a `diagnostic_templates` directory to define or override diagnostic output formats. | |||
|
|||
use crate::diagnostic::{Error, DEFAULT_DIAGNOSTIC_TEMPLATES}; | |||
use crate::DiagnosticArgs; | |||
use crate::{DiagnosticArgs, ExitDirectives}; |
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.
ExitDirectives is a way for commands to inform the main program on how it should behave once the command has been executed (e.g., suggested exit code, quiet mode).
|
||
/// Supported output formats for the resolved schema | ||
#[derive(Debug, Clone, ValueEnum)] | ||
pub(crate) enum Format { |
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.
Moved Format
in a more global location as this structure is now used from multiple sub-commands.
@@ -78,7 +65,10 @@ pub(crate) fn command( | |||
logger: impl Logger + Sync + Clone, | |||
cache: &Cache, | |||
args: &RegistryResolveArgs, | |||
) -> Result<(), DiagnosticMessages> { | |||
) -> Result<ExitDirectives, DiagnosticMessages> { |
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.
Now this command can only display the resolved registry. See weaver schema resolve
to display the resolved telemetry schema (this part is still experimental).
…dTelemetrySchema object.
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.
Are we declaring the difference between schema + registry the difference between using optimisation on attributes vs. not?
At this point, I'm still a bit confused on terminology and I think maybe we should discuss that first.
Also have a minor nit about threading choices.
Yes, I think the best way to discuss this is through chat or via Zoom. |
This PR uses schemars to automatically generate JSON schema from Serde-annotated Rust structs.
This PR will serve as a basis for future discussions and the generation of documentation on the topic of resolved registry and schema.
Two types of resolved assets coexist:
weaver registry resolve
can be used to generate this type of resolved asset. The commandweaver registry json-schema
generates the JSON Schema representation of aResolvedRegistry
data structure.versions
section. This type of schema is still in discussion.This PR also improves the output of commands such as
weaver registry resolve
, which can now be directly piped to ajq
command without having to use the--quiet
parameter (see #189).Note 1:
TemplateRegistry
andTemplateGroup
have been renamed toResolvedRegistry
andResolvedGroup
because it's a more logical name. This renaming has no impact on the templates and the policies. I might move these definitions into a dedicated crate.Note 2: A conversation has been initiated to talk about resolved registry and resolved telemetry schema, see https://cloud-native.slack.com/archives/C0697EXNTL3/p1717183349294419?thread_ts=1717104224.284179&cid=C0697EXNTL3