[FEATURE] Add panel-level annotations to the data model - #61
Draft
nicolastakashi wants to merge 1 commit into
Draft
[FEATURE] Add panel-level annotations to the data model#61nicolastakashi wants to merge 1 commit into
nicolastakashi wants to merge 1 commit into
Conversation
Add an optional annotations block to PanelSpec so annotations can be configured per panel, following the two-level annotation design discussed in perses/perses#3001. PanelAnnotations carries an Enabled toggle for dashboard-level annotations (nil is treated as on) and a list of panel-local Definitions that reuse the existing AnnotationSpec type. Regenerate the CUE mirror and update the TypeScript and Java mirrors to match. Signed-off-by: Nicolas Takashi <nicolas.takashi@dash0.com>
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.
What this does
This adds an optional
annotationsblock toPanelSpecso annotations can be set per panel. It follows the two-level annotation design being discussed in perses/perses#3001. The dashboard-level half of that design already shipped, and this PR is the data model for the panel-level half.Enabledis a pointer so an omitted value means "on", which is the default-on behavior from the design.Definitionsreuses the existingAnnotationSpectype instead of a new parallel shape.Scope
This is the data model only. It does not touch backend validation, the frontend consumer hook, the panel editor, or Grafana migration, which I will send as separate follow-ups to keep this one small. I opened it as a draft because the shape is still under discussion on #3001, and I would rather agree on that before building the layers on top of it.
Mirrors
The Go types are the source of truth. I regenerated the CUE mirror with
make cue-gen(not hand-edited) and updated the TypeScript (ts/src/dashboard/panel.ts) and Java (.../dashboard/panel/PanelSpec.javaplus a newPanelAnnotations.java) mirrors by hand.Validation
Panel-local definitions get validated without any extra code.
AnnotationSpec.UnmarshalJSONalready callsvalidate(), which requires a non-empty name, and that runs when a definition is unmarshaled inside aPanelSpec. So I did not add validation toPanelSpecitself.Testing
go/dashboard/panel_test.gocovers JSON and YAML round-trips, the default-on case when the block is omitted, and rejection of a definition with an empty name.make cue-gen cue-eval: cleango test ./go/...: all passgofmt -l go/: cleanOne side note
Running
make cue-genon macOS hit a portability issue. The target uses GNU-stylesed -i, which fails on BSD/macOS sed, so the import-path rewrite step silently does not run. I worked around it locally. I can send a small separate PR to make thatsedcall portable if that is useful.Open questions
Same points I raised on #3001, repeated here for context:
Definitionsbe in this first iteration, or a follow-up after the toggle?annotationsobject as done here, or two flat fields onPanelSpec?