Chore: Generate plugin version and remove lineage version (#69781)

* Generate plugin version and remove lineage version

* Generate version for each major

* Remove pluginVersion from core plugins

* Remove code version generation

* Generate cue files

* Move grafana version into jenny

* fix go import
This commit is contained in:
Selene 2023-06-27 11:47:14 +02:00 committed by GitHub
parent b0ac49926d
commit b0893c29a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
74 changed files with 101 additions and 79 deletions

View File

@ -9,6 +9,8 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const pluginVersion = "10.1.0-pre";
export interface Options {
/**
* Name of the alertmanager used as a source for alerts

View File

@ -9,6 +9,8 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const pluginVersion = "10.1.0-pre";
export interface Options {
limit: number;
navigateAfter: string;

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "1.0.0";
export interface AzureMonitorQuery extends common.DataQuery {
/**
* Azure Monitor Logs sub-query properties.

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export interface Options extends common.OptionsWithLegend, common.OptionsWithTooltip, common.OptionsWithTextFormatting {
/**
* Controls the radius of each bar.

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export interface Options extends common.SingleStatBaseOptions {
displayMode: common.BarGaugeDisplayMode;
minVizHeight: number;

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export enum VizDisplayMode {
Candles = 'candles',
CandlesVolume = 'candles+volume',

View File

@ -11,6 +11,8 @@
import * as ui from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export enum HorizontalConstraint {
Center = 'center',
Left = 'left',

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export interface MetricStat {
/**
* The ID of the AWS account to query for the metric, specifying `all` will query all accounts that the monitoring account is permitted to query.

View File

@ -9,6 +9,8 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const pluginVersion = "10.1.0-pre";
export interface Options {
folderId?: number;
includeVars: boolean;

View File

@ -9,6 +9,8 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const pluginVersion = "10.1.0-pre";
export interface Options {
selectedSeries: number;
}

View File

@ -9,6 +9,8 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const pluginVersion = "10.1.0-pre";
export type UpdateConfig = {
render: boolean,
dataChanged: boolean,

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export type BucketAggregation = (DateHistogram | Histogram | Terms | Filters | GeoHashGrid | Nested);
export type MetricAggregation = (Count | PipelineMetricAggregation | MetricAggregationWithSettings);

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export interface Options extends common.SingleStatBaseOptions {
showThresholdLabels: boolean;
showThresholdMarkers: boolean;

View File

@ -11,6 +11,8 @@
import * as ui from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export interface Options {
basemap: ui.MapLayerOptions;
controls: ControlsOptions;

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "1.0.0";
export interface CloudMonitoringQuery extends common.DataQuery {
/**
* Aliases can be set to modify the legend labels. e.g. {{metric.label.xxx}}. See docs for more detail.

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export type PhlareQueryType = ('metrics' | 'profile' | 'both');
export const defaultPhlareQueryType: PhlareQueryType = 'both';

View File

@ -11,6 +11,8 @@
import * as ui from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
/**
* Controls the color mode of the heatmap
*/

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export interface Options extends common.OptionsWithLegend, common.OptionsWithTooltip {
/**
* Offset buckets by this amount

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export interface Options {
dedupStrategy: common.LogsDedupStrategy;
enableLogDetails: boolean;

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export enum QueryEditorMode {
Builder = 'builder',
Code = 'code',

View File

@ -9,6 +9,8 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const pluginVersion = "10.1.0-pre";
export interface Options {
/**
* empty/missing will default to grafana blog

View File

@ -9,6 +9,8 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const pluginVersion = "10.1.0-pre";
export interface ArcOption {
/**
* The color of the arc.

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export type ParcaQueryType = ('metrics' | 'profile' | 'both');
export const defaultParcaQueryType: ParcaQueryType = 'both';

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
/**
* Select the pie chart display style.
*/

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export enum QueryEditorMode {
Builder = 'builder',
Code = 'code',

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export interface Options extends common.SingleStatBaseOptions {
colorMode: common.BigValueColorMode;
graphMode: common.BigValueGraphMode;

View File

@ -11,6 +11,8 @@
import * as ui from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export interface Options extends ui.OptionsWithLegend, ui.OptionsWithTooltip, ui.OptionsWithTimezones {
/**
* Controls value alignment on the timelines

View File

@ -11,6 +11,8 @@
import * as ui from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export interface Options extends ui.OptionsWithLegend, ui.OptionsWithTooltip, ui.OptionsWithTimezones {
/**
* Controls the column width

View File

@ -11,6 +11,8 @@
import * as ui from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export interface Options {
/**
* Controls the height of the rows

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export interface TempoQuery extends common.DataQuery {
filters: Array<TraceqlFilter>;
/**

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export enum TestDataQueryType {
Annotations = 'annotations',
Arrow = 'arrow',

View File

@ -9,6 +9,8 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const pluginVersion = "10.1.0-pre";
export enum TextMode {
Code = 'code',
HTML = 'html',

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export interface Options extends common.OptionsWithTimezones {
legend: common.VizLegendOptions;
tooltip: common.VizTooltipOptions;

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
/**
* Identical to timeseries... except it does not have timezone settings
*/

View File

@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.1.0-pre";
export enum SeriesMapping {
Auto = 'auto',
Manual = 'manual',

View File

@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"strings"
"time"
)
@ -14,7 +15,7 @@ type PackageJSON struct {
// Opens the package.json file in the provided directory and returns a struct that represents its contents
func OpenPackageJSON(dir string) (PackageJSON, error) {
reader, err := os.Open("package.json")
reader, err := os.Open(filepath.Clean(dir + "/package.json"))
if err != nil {
return PackageJSON{}, err
}

View File

@ -1,10 +1,14 @@
package codegen
import (
"fmt"
"os"
"path"
"path/filepath"
"github.com/grafana/codejen"
tsast "github.com/grafana/cuetsy/ts/ast"
"github.com/grafana/grafana/pkg/build"
corecodegen "github.com/grafana/grafana/pkg/codegen"
"github.com/grafana/grafana/pkg/cuectx"
"github.com/grafana/grafana/pkg/plugins/pfs"
@ -37,6 +41,13 @@ func (j *pleJenny) Generate(decl *pfs.PluginDecl) (codejen.Files, error) {
return nil, err
}
version := "export const pluginVersion = \"%s\";"
if decl.PluginMeta.Info.Version != nil {
version = fmt.Sprintf(version, *decl.PluginMeta.Info.Version)
} else {
version = fmt.Sprintf(version, getGrafanaVersion())
}
files := make(codejen.Files, len(jf))
for i, file := range jf {
tsf := &tsast.File{}
@ -48,6 +59,10 @@ func (j *pleJenny) Generate(decl *pfs.PluginDecl) (codejen.Files, error) {
}
}
tsf.Nodes = append(tsf.Nodes, tsast.Raw{
Data: version,
})
tsf.Nodes = append(tsf.Nodes, tsast.Raw{
Data: string(file.Data),
})
@ -70,3 +85,17 @@ func kinds2pd(rt *thema.Runtime, j codejen.OneToMany[kindsys.Kind]) codejen.OneT
return kd
})
}
func getGrafanaVersion() string {
dir, err := os.Getwd()
if err != nil {
return ""
}
pkg, err := build.OpenPackageJSON(path.Join(dir, "../../../"))
if err != nil {
return ""
}
return pkg.Version
}

View File

@ -42,12 +42,6 @@ func (j *ptsJenny) Generate(decl *pfs.PluginDecl) (*codejen.File, error) {
}
}
v := decl.Lineage.Latest().Version()
tsf.Nodes = append(tsf.Nodes, tsast.Raw{
Data: fmt.Sprintf("export const %sModelVersion = Object.freeze([%v, %v]);", decl.SchemaInterface.Name(), v[0], v[1]),
})
jf, err := j.inner.Generate(decl)
if err != nil {
return nil, err

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const DataQueryModelVersion = Object.freeze([0, 0]);
export interface AzureMonitorQuery extends common.DataQuery {
/**
* Azure Monitor Logs sub-query properties.

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const DataQueryModelVersion = Object.freeze([0, 0]);
export interface CloudMonitoringQuery extends common.DataQuery {
/**
* Aliases can be set to modify the legend labels. e.g. {{metric.label.xxx}}. See docs for more detail.

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const DataQueryModelVersion = Object.freeze([0, 0]);
export interface MetricStat {
/**
* The ID of the AWS account to query for the metric, specifying `all` will query all accounts that the monitoring account is permitted to query.

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const DataQueryModelVersion = Object.freeze([0, 0]);
export type BucketAggregation = (DateHistogram | Histogram | Terms | Filters | GeoHashGrid | Nested);
export type MetricAggregation = (Count | PipelineMetricAggregation | MetricAggregationWithSettings);

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const DataQueryModelVersion = Object.freeze([0, 0]);
export type PhlareQueryType = ('metrics' | 'profile' | 'both');
export const defaultPhlareQueryType: PhlareQueryType = 'both';

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const DataQueryModelVersion = Object.freeze([0, 0]);
export enum QueryEditorMode {
Builder = 'builder',
Code = 'code',

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const DataQueryModelVersion = Object.freeze([0, 0]);
export type ParcaQueryType = ('metrics' | 'profile' | 'both');
export const defaultParcaQueryType: ParcaQueryType = 'both';

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const DataQueryModelVersion = Object.freeze([0, 0]);
export enum QueryEditorMode {
Builder = 'builder',
Code = 'code',

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const DataQueryModelVersion = Object.freeze([0, 0]);
export interface TempoQuery extends common.DataQuery {
filters: Array<TraceqlFilter>;
/**

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const DataQueryModelVersion = Object.freeze([0, 0]);
export enum TestDataQueryType {
Annotations = 'annotations',
Arrow = 'arrow',

View File

@ -8,8 +8,6 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface Options {
/**
* Name of the alertmanager used as a source for alerts

View File

@ -8,8 +8,6 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface Options {
limit: number;
navigateAfter: string;

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface Options extends common.OptionsWithLegend, common.OptionsWithTooltip, common.OptionsWithTextFormatting {
/**
* Controls the radius of each bar.

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface Options extends common.SingleStatBaseOptions {
displayMode: common.BarGaugeDisplayMode;
minVizHeight: number;

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export enum VizDisplayMode {
Candles = 'candles',
CandlesVolume = 'candles+volume',

View File

@ -10,7 +10,6 @@ import {
VizDisplayMode,
CandlestickFieldMap,
FieldConfig,
PanelCfgModelVersion,
} from './panelcfg.gen';
export const defaultOptions: Partial<Options> = {
@ -33,5 +32,4 @@ export {
VizDisplayMode,
CandlestickFieldMap,
FieldConfig,
PanelCfgModelVersion,
};

View File

@ -10,8 +10,6 @@
import * as ui from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export enum HorizontalConstraint {
Center = 'center',
Left = 'left',

View File

@ -8,8 +8,6 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface Options {
folderId?: number;
includeVars: boolean;

View File

@ -8,8 +8,6 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface Options {
selectedSeries: number;
}

View File

@ -8,8 +8,6 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export type UpdateConfig = {
render: boolean,
dataChanged: boolean,

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface Options extends common.SingleStatBaseOptions {
showThresholdLabels: boolean;
showThresholdMarkers: boolean;

View File

@ -10,8 +10,6 @@
import * as ui from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface Options {
basemap: ui.MapLayerOptions;
controls: ControlsOptions;

View File

@ -10,8 +10,6 @@
import * as ui from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
/**
* Controls the color mode of the heatmap
*/

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface Options extends common.OptionsWithLegend, common.OptionsWithTooltip {
/**
* Offset buckets by this amount

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface Options {
dedupStrategy: common.LogsDedupStrategy;
enableLogDetails: boolean;

View File

@ -8,8 +8,6 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface Options {
/**
* empty/missing will default to grafana blog

View File

@ -8,8 +8,6 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface ArcOption {
/**
* The color of the arc.

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
/**
* Select the pie chart display style.
*/

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface Options extends common.SingleStatBaseOptions {
colorMode: common.BigValueColorMode;
graphMode: common.BigValueGraphMode;

View File

@ -10,8 +10,6 @@
import * as ui from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface Options extends ui.OptionsWithLegend, ui.OptionsWithTooltip, ui.OptionsWithTimezones {
/**
* Controls value alignment on the timelines

View File

@ -10,8 +10,6 @@
import * as ui from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface Options extends ui.OptionsWithLegend, ui.OptionsWithTooltip, ui.OptionsWithTimezones {
/**
* Controls the column width

View File

@ -10,8 +10,6 @@
import * as ui from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface Options {
/**
* Controls the height of the rows

View File

@ -8,8 +8,6 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export enum TextMode {
Code = 'code',
HTML = 'html',

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface Options extends common.OptionsWithTimezones {
legend: common.VizLegendOptions;
tooltip: common.VizTooltipOptions;

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
/**
* Identical to timeseries... except it does not have timezone settings
*/

View File

@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export enum SeriesMapping {
Auto = 'auto',
Manual = 'manual',