@@ -11,3 +11,164 @@ passes:
1111 as :
1212 kind : ref
1313 ref : { referred_pkg: common, referred_type: DataSourceRef }
14+
15+ # ############
16+ # Dashboard #
17+ # ############
18+
19+ # These fields are incorrectly set as non-required in the CUE schema.
20+ # Loading a dashboard with these set to null will fail.
21+ - fields_set_required :
22+ fields : [
23+ dashboard.Dashboard.annotations,
24+ dashboard.Dashboard.templating,
25+ ]
26+
27+ # Defined as an empty type in the CUE schemas.
28+ # It is also not used at all: references to this type are replaced by a "composable slot"
29+ - omit :
30+ objects : [
31+ dashboard.Target
32+ ]
33+
34+ - name_anonymous_struct :
35+ field : dashboard.Dashboard.timepicker
36+ as : TimePicker
37+
38+ # From: `panels: [...#Panel | #RowPanel | #GraphPanel | #HeatmapPanel]`
39+ # To: `panels: [...#Panel | #GraphPanel | #HeatmapPanel]`
40+ - retype_field :
41+ field : dashboard.Dashboard.panels
42+ as :
43+ kind : array
44+ array :
45+ value_type :
46+ kind : disjunction
47+ disjunction :
48+ branches :
49+ - { kind: ref, ref: { referred_pkg: dashboard, referred_type: Panel } }
50+ - { kind: ref, ref: { referred_pkg: dashboard, referred_type: RowPanel } }
51+ discriminator : type
52+ discriminator_mapping :
53+ row : RowPanel
54+ cog_discriminator_catch_all : Panel
55+
56+ - retype_field :
57+ field : dashboard.Panel.options
58+ as :
59+ kind : scalar
60+ scalar : { scalar_kind: any }
61+
62+ - retype_field :
63+ field : dashboard.FieldConfig.custom
64+ as :
65+ kind : scalar
66+ scalar : { scalar_kind: any }
67+
68+ - retype_field :
69+ field : dashboard.Panel.Targets
70+ as :
71+ kind : array
72+ array :
73+ value_type :
74+ kind : composable_slot
75+ composable_slot : { variant: dataquery }
76+
77+ # typed as `links?: [...]` in the original schema
78+ - retype_field :
79+ field : dashboard.FieldConfig.links
80+ as :
81+ kind : array
82+ array :
83+ value_type :
84+ kind : ref
85+ ref : { referred_pkg: dashboard, referred_type: DashboardLink }
86+
87+ # Add a few missing fields.
88+ # This is meant to be removed once the schema is updated.
89+ - add_fields :
90+ to : dashboard.AnnotationQuery
91+ fields :
92+ - name : expr
93+ type :
94+ kind : scalar
95+ scalar : { scalar_kind: string }
96+
97+ # ######################
98+ # Dashboard variables #
99+ # ######################
100+
101+ - add_fields :
102+ to : dashboard.VariableModel
103+ fields :
104+ - name : auto
105+ comments : [ 'Dynamically calculates interval by dividing time range by the count specified.' ]
106+ type :
107+ kind : scalar
108+ scalar : { scalar_kind: bool }
109+ default : false
110+ - name : auto_min
111+ comments : [ 'The minimum threshold below which the step count intervals will not divide the time.' ]
112+ type :
113+ kind : scalar
114+ default : ' 10s'
115+ scalar : { scalar_kind: string }
116+ - name : auto_count
117+ comments :
118+ - ' How many times the current time range should be divided to calculate the value, similar to the Max data points query option.'
119+ - ' For example, if the current visible time range is 30 minutes, then the auto interval groups the data into 30 one-minute increments.'
120+ type :
121+ kind : scalar
122+ default : 30
123+ scalar :
124+ scalar_kind : int32
125+ constraints :
126+ - { op: '>', args: [0] }
127+
128+ # ############
129+ # row panel #
130+ # ############
131+
132+ # From: `panels: [...#Panel | #RowPanel]`
133+ # To: `panels: [...#Panel]`
134+ - retype_field :
135+ field : dashboard.RowPanel.panels
136+ as :
137+ kind : array
138+ array :
139+ value_type :
140+ kind : ref
141+ ref : { referred_pkg: dashboard, referred_type: Panel }
142+
143+ # ###########
144+ # snapshot #
145+ # ###########
146+
147+ - add_fields :
148+ to : dashboard.Snapshot
149+ fields :
150+ - name : dashboard
151+ type :
152+ kind : ref
153+ ref : { referred_pkg: dashboard, referred_type: Dashboard }
154+
155+ # In the original `librarypanel.PanelModel` schema, the "model" field is left
156+ # mainly undefined but a comment indicates that it should be the same panel
157+ # schema defined in dashboard with a few fields omitted:
158+ # model: Omit<dashboard.Panel, 'gridPos' | 'id' | 'libraryPanel'>
159+ - duplicate_object :
160+ object : dashboard.Panel
161+ as : librarypanel.PanelModel
162+ omit_fields :
163+ - id
164+ - gridPos
165+ - libraryPanel
166+ - retype_field :
167+ field : librarypanel.LibraryPanel.model
168+ as :
169+ kind : ref
170+ ref : { referred_pkg: librarypanel, referred_type: PanelModel }
171+
172+ - omit :
173+ objects :
174+ - dashboard.HeatmapPanel
0 commit comments