coremodels: Remove "Model" prefix from Go types (#53801)

Using the prefix "Model" on all generated types was adding more
verbosity to already lengthy generated types. This removed that prefix,
only replacing the base generated struct with the literal "Model" to
avoid a redundant name, e.g. dashboard.Dashboard.
pull/53825/head
sam boyer 3 years ago committed by GitHub
parent 81957732ab
commit 8ef6820f06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 29
      pkg/codegen/coremodel.go
  2. 224
      pkg/coremodel/dashboard/dashboard_gen.go

@ -182,8 +182,7 @@ func (ls *ExtractedLineage) GenerateGoCoremodel(path string) (WriteDiffer, error
if err != nil { if err != nil {
return nil, fmt.Errorf("generated go file parsing failed: %w", err) return nil, fmt.Errorf("generated go file parsing failed: %w", err)
} }
m := makeReplacer(lin.Name()) ast.Walk(prefixDropper(strings.Title(lin.Name())), gf)
ast.Walk(m, gf)
var buf bytes.Buffer var buf bytes.Buffer
err = format.Node(&buf, fset, gf) err = format.Node(&buf, fset, gf)
@ -223,7 +222,7 @@ func (ls *ExtractedLineage) GenerateTypescriptCoremodel(path string) (WriteDiffe
return nil, fmt.Errorf("cuetsy parts gen failed: %w", err) return nil, fmt.Errorf("cuetsy parts gen failed: %w", err)
} }
top, err := cuetsy.GenerateSingleAST(string(makeReplacer(ls.Lineage.Name())), schv, cuetsy.TypeInterface) top, err := cuetsy.GenerateSingleAST(strings.Title(ls.Lineage.Name()), schv, cuetsy.TypeInterface)
if err != nil { if err != nil {
return nil, fmt.Errorf("cuetsy top gen failed: %w", err) return nil, fmt.Errorf("cuetsy top gen failed: %w", err)
} }
@ -260,25 +259,19 @@ func (ls *ExtractedLineage) GenerateTypescriptCoremodel(path string) (WriteDiffe
return wd, nil return wd, nil
} }
type modelReplacer string type prefixDropper string
func makeReplacer(name string) modelReplacer { func (d prefixDropper) Visit(n ast.Node) ast.Visitor {
return modelReplacer(fmt.Sprintf("%s%s", string(strings.ToUpper(name)[0]), name[1:])) asstr := string(d)
}
func (m modelReplacer) Visit(n ast.Node) ast.Visitor {
switch x := n.(type) { switch x := n.(type) {
case *ast.Ident: case *ast.Ident:
x.Name = m.replacePrefix(x.Name) if x.Name != asstr {
} x.Name = strings.TrimPrefix(x.Name, asstr)
return m } else {
} x.Name = "Model"
}
func (m modelReplacer) replacePrefix(str string) string {
if len(str) >= len(m) && str[:len(m)] == string(m) {
return strings.Replace(str, string(m), "Model", 1)
} }
return str return d
} }
// GenerateCoremodelRegistry produces Go files that define a registry with // GenerateCoremodelRegistry produces Go files that define a registry with

@ -17,139 +17,139 @@ import (
// Defines values for DashboardGraphTooltip. // Defines values for DashboardGraphTooltip.
const ( const (
ModelGraphTooltipN0 ModelGraphTooltip = 0 GraphTooltipN0 GraphTooltip = 0
ModelGraphTooltipN1 ModelGraphTooltip = 1 GraphTooltipN1 GraphTooltip = 1
ModelGraphTooltipN2 ModelGraphTooltip = 2 GraphTooltipN2 GraphTooltip = 2
) )
// Defines values for DashboardStyle. // Defines values for DashboardStyle.
const ( const (
ModelStyleDark ModelStyle = "dark" StyleDark Style = "dark"
ModelStyleLight ModelStyle = "light" StyleLight Style = "light"
) )
// Defines values for DashboardTimezone. // Defines values for DashboardTimezone.
const ( const (
ModelTimezoneBrowser ModelTimezone = "browser" TimezoneBrowser Timezone = "browser"
ModelTimezoneEmpty ModelTimezone = "" TimezoneEmpty Timezone = ""
ModelTimezoneUtc ModelTimezone = "utc" TimezoneUtc Timezone = "utc"
) )
// Defines values for DashboardDashboardCursorSync. // Defines values for DashboardDashboardCursorSync.
const ( const (
ModelDashboardCursorSyncN0 ModelDashboardCursorSync = 0 DashboardCursorSyncN0 DashboardCursorSync = 0
ModelDashboardCursorSyncN1 ModelDashboardCursorSync = 1 DashboardCursorSyncN1 DashboardCursorSync = 1
ModelDashboardCursorSyncN2 ModelDashboardCursorSync = 2 DashboardCursorSyncN2 DashboardCursorSync = 2
) )
// Defines values for DashboardDashboardLinkType. // Defines values for DashboardDashboardLinkType.
const ( const (
ModelDashboardLinkTypeDashboards ModelDashboardLinkType = "dashboards" DashboardLinkTypeDashboards DashboardLinkType = "dashboards"
ModelDashboardLinkTypeLink ModelDashboardLinkType = "link" DashboardLinkTypeLink DashboardLinkType = "link"
) )
// Defines values for DashboardFieldColorModeId. // Defines values for DashboardFieldColorModeId.
const ( const (
ModelFieldColorModeIdContinuousGrYlRd ModelFieldColorModeId = "continuous-GrYlRd" FieldColorModeIdContinuousGrYlRd FieldColorModeId = "continuous-GrYlRd"
ModelFieldColorModeIdFixed ModelFieldColorModeId = "fixed" FieldColorModeIdFixed FieldColorModeId = "fixed"
ModelFieldColorModeIdPaletteClassic ModelFieldColorModeId = "palette-classic" FieldColorModeIdPaletteClassic FieldColorModeId = "palette-classic"
ModelFieldColorModeIdPaletteSaturated ModelFieldColorModeId = "palette-saturated" FieldColorModeIdPaletteSaturated FieldColorModeId = "palette-saturated"
ModelFieldColorModeIdThresholds ModelFieldColorModeId = "thresholds" FieldColorModeIdThresholds FieldColorModeId = "thresholds"
) )
// Defines values for DashboardFieldColorSeriesByMode. // Defines values for DashboardFieldColorSeriesByMode.
const ( const (
ModelFieldColorSeriesByModeLast ModelFieldColorSeriesByMode = "last" FieldColorSeriesByModeLast FieldColorSeriesByMode = "last"
ModelFieldColorSeriesByModeMax ModelFieldColorSeriesByMode = "max" FieldColorSeriesByModeMax FieldColorSeriesByMode = "max"
ModelFieldColorSeriesByModeMin ModelFieldColorSeriesByMode = "min" FieldColorSeriesByModeMin FieldColorSeriesByMode = "min"
) )
// Defines values for DashboardGraphPanelType. // Defines values for DashboardGraphPanelType.
const ( const (
ModelGraphPanelTypeGraph ModelGraphPanelType = "graph" GraphPanelTypeGraph GraphPanelType = "graph"
) )
// Defines values for DashboardHeatmapPanelType. // Defines values for DashboardHeatmapPanelType.
const ( const (
ModelHeatmapPanelTypeHeatmap ModelHeatmapPanelType = "heatmap" HeatmapPanelTypeHeatmap HeatmapPanelType = "heatmap"
) )
// Defines values for DashboardPanelRepeatDirection. // Defines values for DashboardPanelRepeatDirection.
const ( const (
ModelPanelRepeatDirectionH ModelPanelRepeatDirection = "h" PanelRepeatDirectionH PanelRepeatDirection = "h"
ModelPanelRepeatDirectionV ModelPanelRepeatDirection = "v" PanelRepeatDirectionV PanelRepeatDirection = "v"
) )
// Defines values for DashboardRowPanelType. // Defines values for DashboardRowPanelType.
const ( const (
ModelRowPanelTypeRow ModelRowPanelType = "row" RowPanelTypeRow RowPanelType = "row"
) )
// Defines values for DashboardThresholdsConfigMode. // Defines values for DashboardThresholdsConfigMode.
const ( const (
ModelThresholdsConfigModeAbsolute ModelThresholdsConfigMode = "absolute" ThresholdsConfigModeAbsolute ThresholdsConfigMode = "absolute"
ModelThresholdsConfigModePercentage ModelThresholdsConfigMode = "percentage" ThresholdsConfigModePercentage ThresholdsConfigMode = "percentage"
) )
// Defines values for DashboardThresholdsMode. // Defines values for DashboardThresholdsMode.
const ( const (
ModelThresholdsModeAbsolute ModelThresholdsMode = "absolute" ThresholdsModeAbsolute ThresholdsMode = "absolute"
ModelThresholdsModePercentage ModelThresholdsMode = "percentage" ThresholdsModePercentage ThresholdsMode = "percentage"
) )
// Defines values for DashboardVariableModelType. // Defines values for DashboardVariableModelType.
const ( const (
ModelVariableModelTypeAdhoc ModelVariableModelType = "adhoc" VariableModelTypeAdhoc VariableModelType = "adhoc"
ModelVariableModelTypeConstant ModelVariableModelType = "constant" VariableModelTypeConstant VariableModelType = "constant"
ModelVariableModelTypeCustom ModelVariableModelType = "custom" VariableModelTypeCustom VariableModelType = "custom"
ModelVariableModelTypeDatasource ModelVariableModelType = "datasource" VariableModelTypeDatasource VariableModelType = "datasource"
ModelVariableModelTypeInterval ModelVariableModelType = "interval" VariableModelTypeInterval VariableModelType = "interval"
ModelVariableModelTypeQuery ModelVariableModelType = "query" VariableModelTypeQuery VariableModelType = "query"
ModelVariableModelTypeSystem ModelVariableModelType = "system" VariableModelTypeSystem VariableModelType = "system"
ModelVariableModelTypeTextbox ModelVariableModelType = "textbox" VariableModelTypeTextbox VariableModelType = "textbox"
) )
// Defines values for DashboardVariableType. // Defines values for DashboardVariableType.
const ( const (
ModelVariableTypeAdhoc ModelVariableType = "adhoc" VariableTypeAdhoc VariableType = "adhoc"
ModelVariableTypeConstant ModelVariableType = "constant" VariableTypeConstant VariableType = "constant"
ModelVariableTypeCustom ModelVariableType = "custom" VariableTypeCustom VariableType = "custom"
ModelVariableTypeDatasource ModelVariableType = "datasource" VariableTypeDatasource VariableType = "datasource"
ModelVariableTypeInterval ModelVariableType = "interval" VariableTypeInterval VariableType = "interval"
ModelVariableTypeQuery ModelVariableType = "query" VariableTypeQuery VariableType = "query"
ModelVariableTypeSystem ModelVariableType = "system" VariableTypeSystem VariableType = "system"
ModelVariableTypeTextbox ModelVariableType = "textbox" VariableTypeTextbox VariableType = "textbox"
) )
// Dashboard defines model for dashboard. // Dashboard defines model for dashboard.
@ -159,7 +159,7 @@ const (
type Model struct { type Model struct {
Annotations *struct { Annotations *struct {
// TODO docs // TODO docs
List []ModelAnnotationQuery `json:"list"` List []AnnotationQuery `json:"list"`
} `json:"annotations,omitempty"` } `json:"annotations,omitempty"`
// Description of dashboard. // Description of dashboard.
@ -169,16 +169,16 @@ type Model struct {
Editable bool `json:"editable"` Editable bool `json:"editable"`
// TODO docs // TODO docs
FiscalYearStartMonth *int `json:"fiscalYearStartMonth,omitempty"` FiscalYearStartMonth *int `json:"fiscalYearStartMonth,omitempty"`
GnetId *string `json:"gnetId,omitempty"` GnetId *string `json:"gnetId,omitempty"`
GraphTooltip ModelGraphTooltip `json:"graphTooltip"` GraphTooltip GraphTooltip `json:"graphTooltip"`
// Unique numeric identifier for the dashboard. // Unique numeric identifier for the dashboard.
// TODO must isolate or remove identifiers local to a Grafana instance...? // TODO must isolate or remove identifiers local to a Grafana instance...?
Id *int64 `json:"id,omitempty"` Id *int64 `json:"id,omitempty"`
// TODO docs // TODO docs
Links *[]ModelDashboardLink `json:"links,omitempty"` Links *[]DashboardLink `json:"links,omitempty"`
// TODO docs // TODO docs
LiveNow *bool `json:"liveNow,omitempty"` LiveNow *bool `json:"liveNow,omitempty"`
@ -193,13 +193,13 @@ type Model struct {
SchemaVersion int `json:"schemaVersion"` SchemaVersion int `json:"schemaVersion"`
// Theme of dashboard. // Theme of dashboard.
Style ModelStyle `json:"style"` Style Style `json:"style"`
// Tags associated with dashboard. // Tags associated with dashboard.
Tags *[]string `json:"tags,omitempty"` Tags *[]string `json:"tags,omitempty"`
Templating *struct { Templating *struct {
// TODO docs // TODO docs
List []ModelVariableModel `json:"list"` List []VariableModel `json:"list"`
} `json:"templating,omitempty"` } `json:"templating,omitempty"`
// Time range for dashboard, e.g. last 6 hours, last 7 days, etc // Time range for dashboard, e.g. last 6 hours, last 7 days, etc
@ -228,7 +228,7 @@ type Model struct {
} `json:"timepicker,omitempty"` } `json:"timepicker,omitempty"`
// Timezone of dashboard, // Timezone of dashboard,
Timezone *ModelTimezone `json:"timezone,omitempty"` Timezone *Timezone `json:"timezone,omitempty"`
// Title of dashboard. // Title of dashboard.
Title *string `json:"title,omitempty"` Title *string `json:"title,omitempty"`
@ -247,26 +247,26 @@ type Model struct {
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelGraphTooltip int type GraphTooltip int
// Theme of dashboard. // Theme of dashboard.
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelStyle string type Style string
// Timezone of dashboard, // Timezone of dashboard,
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelTimezone string type Timezone string
// TODO docs // TODO docs
// FROM: AnnotationQuery in grafana-data/src/types/annotations.ts // FROM: AnnotationQuery in grafana-data/src/types/annotations.ts
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelAnnotationQuery struct { type AnnotationQuery struct {
BuiltIn int `json:"builtIn"` BuiltIn int `json:"builtIn"`
// Datasource to use for annotation. // Datasource to use for annotation.
@ -298,8 +298,8 @@ type ModelAnnotationQuery struct {
// with types derived from plugins in the Instance variant. // with types derived from plugins in the Instance variant.
// When working directly from CUE, importers can extend this // When working directly from CUE, importers can extend this
// type directly to achieve the same effect. // type directly to achieve the same effect.
Target *ModelTarget `json:"target,omitempty"` Target *Target `json:"target,omitempty"`
Type string `json:"type"` Type string `json:"type"`
} }
// 0 for no shared crosshair or tooltip (default). // 0 for no shared crosshair or tooltip (default).
@ -308,37 +308,37 @@ type ModelAnnotationQuery struct {
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelDashboardCursorSync int type DashboardCursorSync int
// FROM public/app/features/dashboard/state/DashboardModels.ts - ish // FROM public/app/features/dashboard/state/DashboardModels.ts - ish
// TODO docs // TODO docs
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelDashboardLink struct { type DashboardLink struct {
AsDropdown bool `json:"asDropdown"` AsDropdown bool `json:"asDropdown"`
Icon *string `json:"icon,omitempty"` Icon *string `json:"icon,omitempty"`
IncludeVars bool `json:"includeVars"` IncludeVars bool `json:"includeVars"`
KeepTime bool `json:"keepTime"` KeepTime bool `json:"keepTime"`
Tags []string `json:"tags"` Tags []string `json:"tags"`
TargetBlank bool `json:"targetBlank"` TargetBlank bool `json:"targetBlank"`
Title string `json:"title"` Title string `json:"title"`
Tooltip *string `json:"tooltip,omitempty"` Tooltip *string `json:"tooltip,omitempty"`
Type ModelDashboardLinkType `json:"type"` Type DashboardLinkType `json:"type"`
Url *string `json:"url,omitempty"` Url *string `json:"url,omitempty"`
} }
// DashboardDashboardLinkType defines model for DashboardDashboardLink.Type. // DashboardDashboardLinkType defines model for DashboardDashboardLink.Type.
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelDashboardLinkType string type DashboardLinkType string
// TODO docs // TODO docs
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelFieldColor struct { type FieldColor struct {
// Stores the fixed color value if mode is fixed // Stores the fixed color value if mode is fixed
FixedColor *string `json:"fixedColor,omitempty"` FixedColor *string `json:"fixedColor,omitempty"`
@ -346,41 +346,41 @@ type ModelFieldColor struct {
Mode interface{} `json:"mode"` Mode interface{} `json:"mode"`
// TODO docs // TODO docs
SeriesBy *ModelFieldColorSeriesByMode `json:"seriesBy,omitempty"` SeriesBy *FieldColorSeriesByMode `json:"seriesBy,omitempty"`
} }
// TODO docs // TODO docs
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelFieldColorModeId string type FieldColorModeId string
// TODO docs // TODO docs
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelFieldColorSeriesByMode string type FieldColorSeriesByMode string
// DashboardGraphPanel defines model for dashboard.GraphPanel. // DashboardGraphPanel defines model for dashboard.GraphPanel.
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelGraphPanel struct { type GraphPanel struct {
// Support for legacy graph and heatmap panels. // Support for legacy graph and heatmap panels.
Type ModelGraphPanelType `json:"type"` Type GraphPanelType `json:"type"`
} }
// Support for legacy graph and heatmap panels. // Support for legacy graph and heatmap panels.
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelGraphPanelType string type GraphPanelType string
// DashboardGridPos defines model for dashboard.GridPos. // DashboardGridPos defines model for dashboard.GridPos.
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelGridPos struct { type GridPos struct {
// Panel // Panel
H int `json:"h"` H int `json:"h"`
@ -401,15 +401,15 @@ type ModelGridPos struct {
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelHeatmapPanel struct { type HeatmapPanel struct {
Type ModelHeatmapPanelType `json:"type"` Type HeatmapPanelType `json:"type"`
} }
// DashboardHeatmapPanelType defines model for DashboardHeatmapPanel.Type. // DashboardHeatmapPanelType defines model for DashboardHeatmapPanel.Type.
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelHeatmapPanelType string type HeatmapPanelType string
// Dashboard panels. Panels are canonically defined inline // Dashboard panels. Panels are canonically defined inline
// because they share a version timeline with the dashboard // because they share a version timeline with the dashboard
@ -417,7 +417,7 @@ type ModelHeatmapPanelType string
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelPanel struct { type Panel struct {
// The datasource used in all targets. // The datasource used in all targets.
Datasource *struct { Datasource *struct {
Type *string `json:"type,omitempty"` Type *string `json:"type,omitempty"`
@ -429,7 +429,7 @@ type ModelPanel struct {
FieldConfig struct { FieldConfig struct {
Defaults struct { Defaults struct {
// TODO docs // TODO docs
Color *ModelFieldColor `json:"color,omitempty"` Color *FieldColor `json:"color,omitempty"`
// custom is specified by the PanelFieldConfig field // custom is specified by the PanelFieldConfig field
// in panel plugin schemas. // in panel plugin schemas.
@ -475,8 +475,8 @@ type ModelPanel struct {
// //
// When defined, this value can be used as an identifier within the datasource scope, and // When defined, this value can be used as an identifier within the datasource scope, and
// may be used to update the results // may be used to update the results
Path *string `json:"path,omitempty"` Path *string `json:"path,omitempty"`
Thresholds *ModelThresholdsConfig `json:"thresholds,omitempty"` Thresholds *ThresholdsConfig `json:"thresholds,omitempty"`
// Numeric Options // Numeric Options
Unit *string `json:"unit,omitempty"` Unit *string `json:"unit,omitempty"`
@ -495,7 +495,7 @@ type ModelPanel struct {
} `json:"properties"` } `json:"properties"`
} `json:"overrides"` } `json:"overrides"`
} `json:"fieldConfig"` } `json:"fieldConfig"`
GridPos *ModelGridPos `json:"gridPos,omitempty"` GridPos *GridPos `json:"gridPos,omitempty"`
// TODO docs // TODO docs
Id *int `json:"id,omitempty"` Id *int `json:"id,omitempty"`
@ -506,7 +506,7 @@ type ModelPanel struct {
// Panel links. // Panel links.
// TODO fill this out - seems there are a couple variants? // TODO fill this out - seems there are a couple variants?
Links *[]ModelDashboardLink `json:"links,omitempty"` Links *[]DashboardLink `json:"links,omitempty"`
// TODO docs // TODO docs
MaxDataPoints *float32 `json:"maxDataPoints,omitempty"` MaxDataPoints *float32 `json:"maxDataPoints,omitempty"`
@ -523,13 +523,13 @@ type ModelPanel struct {
// Direction to repeat in if 'repeat' is set. // Direction to repeat in if 'repeat' is set.
// "h" for horizontal, "v" for vertical. // "h" for horizontal, "v" for vertical.
RepeatDirection ModelPanelRepeatDirection `json:"repeatDirection"` RepeatDirection PanelRepeatDirection `json:"repeatDirection"`
// TODO docs // TODO docs
Tags *[]string `json:"tags,omitempty"` Tags *[]string `json:"tags,omitempty"`
// TODO docs // TODO docs
Targets *[]ModelTarget `json:"targets,omitempty"` Targets *[]Target `json:"targets,omitempty"`
// TODO docs - seems to be an old field from old dashboard alerts? // TODO docs - seems to be an old field from old dashboard alerts?
Thresholds *[]interface{} `json:"thresholds,omitempty"` Thresholds *[]interface{} `json:"thresholds,omitempty"`
@ -564,13 +564,13 @@ type ModelPanel struct {
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelPanelRepeatDirection string type PanelRepeatDirection string
// Row panel // Row panel
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelRowPanel struct { type RowPanel struct {
Collapsed bool `json:"collapsed"` Collapsed bool `json:"collapsed"`
// Name of default datasource. // Name of default datasource.
@ -578,21 +578,21 @@ type ModelRowPanel struct {
Type *string `json:"type,omitempty"` Type *string `json:"type,omitempty"`
Uid *string `json:"uid,omitempty"` Uid *string `json:"uid,omitempty"`
} `json:"datasource,omitempty"` } `json:"datasource,omitempty"`
GridPos *ModelGridPos `json:"gridPos,omitempty"` GridPos *GridPos `json:"gridPos,omitempty"`
Id int `json:"id"` Id int `json:"id"`
Panels []interface{} `json:"panels"` Panels []interface{} `json:"panels"`
// Name of template variable to repeat for. // Name of template variable to repeat for.
Repeat *string `json:"repeat,omitempty"` Repeat *string `json:"repeat,omitempty"`
Title *string `json:"title,omitempty"` Title *string `json:"title,omitempty"`
Type ModelRowPanelType `json:"type"` Type RowPanelType `json:"type"`
} }
// DashboardRowPanelType defines model for DashboardRowPanel.Type. // DashboardRowPanelType defines model for DashboardRowPanel.Type.
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelRowPanelType string type RowPanelType string
// Schema for panel targets is specified by datasource // Schema for panel targets is specified by datasource
// plugins. We use a placeholder definition, which the Go // plugins. We use a placeholder definition, which the Go
@ -604,13 +604,13 @@ type ModelRowPanelType string
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelTarget map[string]interface{} type Target map[string]interface{}
// TODO docs // TODO docs
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelThreshold struct { type Threshold struct {
// TODO docs // TODO docs
Color string `json:"color"` Color string `json:"color"`
@ -628,8 +628,8 @@ type ModelThreshold struct {
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelThresholdsConfig struct { type ThresholdsConfig struct {
Mode ModelThresholdsConfigMode `json:"mode"` Mode ThresholdsConfigMode `json:"mode"`
// Must be sorted by 'value', first value is always -Infinity // Must be sorted by 'value', first value is always -Infinity
Steps []struct { Steps []struct {
@ -651,20 +651,20 @@ type ModelThresholdsConfig struct {
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelThresholdsConfigMode string type ThresholdsConfigMode string
// DashboardThresholdsMode defines model for dashboard.ThresholdsMode. // DashboardThresholdsMode defines model for dashboard.ThresholdsMode.
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelThresholdsMode string type ThresholdsMode string
// TODO docs // TODO docs
// FIXME this is extremely underspecfied; wasn't obvious which typescript types corresponded to it // FIXME this is extremely underspecfied; wasn't obvious which typescript types corresponded to it
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelTransformation struct { type Transformation struct {
Id string `json:"id"` Id string `json:"id"`
Options map[string]interface{} `json:"options"` Options map[string]interface{} `json:"options"`
} }
@ -676,17 +676,17 @@ type ModelTransformation struct {
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelVariableModel struct { type VariableModel struct {
Label *string `json:"label,omitempty"` Label *string `json:"label,omitempty"`
Name string `json:"name"` Name string `json:"name"`
Type ModelVariableModelType `json:"type"` Type VariableModelType `json:"type"`
} }
// DashboardVariableModelType defines model for DashboardVariableModel.Type. // DashboardVariableModelType defines model for DashboardVariableModel.Type.
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelVariableModelType string type VariableModelType string
// FROM: packages/grafana-data/src/types/templateVars.ts // FROM: packages/grafana-data/src/types/templateVars.ts
// TODO docs // TODO docs
@ -694,7 +694,7 @@ type ModelVariableModelType string
// //
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES. // THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok. // Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type ModelVariableType string type VariableType string
//go:embed coremodel.cue //go:embed coremodel.cue
var cueFS embed.FS var cueFS embed.FS

Loading…
Cancel
Save