Skip to content

Commit

Permalink
fix(base): provide backfilling of missing schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
Duologic committed May 9, 2023
1 parent 0f9a684 commit 2c5a451
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions grafonnet-base/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,29 @@ local veneer = import './veneer/main.libsonnet';
{
local root = self,

// Used to fake render missing schemas
local genericSchema(title) =
root.restructure({
info: {
title: title,
},
components: {
schemas: {
[title]: {
type: 'object',
},
},
},
}),

new(schemas, version):
local dashboardSchema = std.filter(
function(schema) schema.info.title == 'dashboard',
schemas
)[0];

local allSchemaTitles = std.map(function(x) x.info.title, schemas);

local filteredSchemas = {
core: std.filterMap(
function(schema)
Expand All @@ -23,11 +40,21 @@ local veneer = import './veneer/main.libsonnet';
schemas
),

panel: std.filterMap(
function(schema) std.endsWith(schema.info.title, 'PanelCfg'),
function(schema) root.restructure(schema),
schemas
),
local missingPanelSchemas = [
'CandlestickPanelCfg',
'CanvasPanelCfg',
],
panel:
[
genericSchema(title)
for title in missingPanelSchemas
if !std.member(allSchemaTitles, title)
]
+ std.filterMap(
function(schema) std.endsWith(schema.info.title, 'PanelCfg'),
function(schema) root.restructure(schema),
schemas
),

query: std.filterMap(
function(schema) std.endsWith(schema.info.title, 'DataQuery'),
Expand Down

0 comments on commit 2c5a451

Please sign in to comment.