Skip to content

Commit b0893c2

Browse files
authored
Chore: Generate plugin version and remove lineage version (grafana#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
1 parent b0ac499 commit b0893c2

File tree

74 files changed

+101
-79
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+101
-79
lines changed

packages/grafana-schema/src/raw/composable/alertgroups/panelcfg/x/AlertGroupsPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
//
1010
// Run 'make gen-cue' from repository root to regenerate.
1111

12+
export const pluginVersion = "10.1.0-pre";
13+
1214
export interface Options {
1315
/**
1416
* Name of the alertmanager used as a source for alerts

packages/grafana-schema/src/raw/composable/annotationslist/panelcfg/x/AnnotationsListPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
//
1010
// Run 'make gen-cue' from repository root to regenerate.
1111

12+
export const pluginVersion = "10.1.0-pre";
13+
1214
export interface Options {
1315
limit: number;
1416
navigateAfter: string;

packages/grafana-schema/src/raw/composable/azuremonitor/dataquery/x/AzureMonitorDataQuery_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "1.0.0";
15+
1416
export interface AzureMonitorQuery extends common.DataQuery {
1517
/**
1618
* Azure Monitor Logs sub-query properties.

packages/grafana-schema/src/raw/composable/barchart/panelcfg/x/BarChartPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export interface Options extends common.OptionsWithLegend, common.OptionsWithTooltip, common.OptionsWithTextFormatting {
1517
/**
1618
* Controls the radius of each bar.

packages/grafana-schema/src/raw/composable/bargauge/panelcfg/x/BarGaugePanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export interface Options extends common.SingleStatBaseOptions {
1517
displayMode: common.BarGaugeDisplayMode;
1618
minVizHeight: number;

packages/grafana-schema/src/raw/composable/candlestick/panelcfg/x/CandlestickPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export enum VizDisplayMode {
1517
Candles = 'candles',
1618
CandlesVolume = 'candles+volume',

packages/grafana-schema/src/raw/composable/canvas/panelcfg/x/CanvasPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as ui from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export enum HorizontalConstraint {
1517
Center = 'center',
1618
Left = 'left',

packages/grafana-schema/src/raw/composable/cloudwatch/dataquery/x/CloudWatchDataQuery_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export interface MetricStat {
1517
/**
1618
* 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.

packages/grafana-schema/src/raw/composable/dashboardlist/panelcfg/x/DashboardListPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
//
1010
// Run 'make gen-cue' from repository root to regenerate.
1111

12+
export const pluginVersion = "10.1.0-pre";
13+
1214
export interface Options {
1315
folderId?: number;
1416
includeVars: boolean;

packages/grafana-schema/src/raw/composable/datagrid/panelcfg/x/DatagridPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
//
1010
// Run 'make gen-cue' from repository root to regenerate.
1111

12+
export const pluginVersion = "10.1.0-pre";
13+
1214
export interface Options {
1315
selectedSeries: number;
1416
}

packages/grafana-schema/src/raw/composable/debug/panelcfg/x/DebugPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
//
1010
// Run 'make gen-cue' from repository root to regenerate.
1111

12+
export const pluginVersion = "10.1.0-pre";
13+
1214
export type UpdateConfig = {
1315
render: boolean,
1416
dataChanged: boolean,

packages/grafana-schema/src/raw/composable/elasticsearch/dataquery/x/ElasticsearchDataQuery_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export type BucketAggregation = (DateHistogram | Histogram | Terms | Filters | GeoHashGrid | Nested);
1517

1618
export type MetricAggregation = (Count | PipelineMetricAggregation | MetricAggregationWithSettings);

packages/grafana-schema/src/raw/composable/gauge/panelcfg/x/GaugePanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export interface Options extends common.SingleStatBaseOptions {
1517
showThresholdLabels: boolean;
1618
showThresholdMarkers: boolean;

packages/grafana-schema/src/raw/composable/geomap/panelcfg/x/GeomapPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as ui from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export interface Options {
1517
basemap: ui.MapLayerOptions;
1618
controls: ControlsOptions;

packages/grafana-schema/src/raw/composable/googlecloudmonitoring/dataquery/x/GoogleCloudMonitoringDataQuery_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "1.0.0";
15+
1416
export interface CloudMonitoringQuery extends common.DataQuery {
1517
/**
1618
* Aliases can be set to modify the legend labels. e.g. {{metric.label.xxx}}. See docs for more detail.

packages/grafana-schema/src/raw/composable/grafanapyroscope/dataquery/x/GrafanaPyroscopeDataQuery_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export type PhlareQueryType = ('metrics' | 'profile' | 'both');
1517

1618
export const defaultPhlareQueryType: PhlareQueryType = 'both';

packages/grafana-schema/src/raw/composable/heatmap/panelcfg/x/HeatmapPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as ui from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
/**
1517
* Controls the color mode of the heatmap
1618
*/

packages/grafana-schema/src/raw/composable/histogram/panelcfg/x/HistogramPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export interface Options extends common.OptionsWithLegend, common.OptionsWithTooltip {
1517
/**
1618
* Offset buckets by this amount

packages/grafana-schema/src/raw/composable/logs/panelcfg/x/LogsPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export interface Options {
1517
dedupStrategy: common.LogsDedupStrategy;
1618
enableLogDetails: boolean;

packages/grafana-schema/src/raw/composable/loki/dataquery/x/LokiDataQuery_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export enum QueryEditorMode {
1517
Builder = 'builder',
1618
Code = 'code',

packages/grafana-schema/src/raw/composable/news/panelcfg/x/NewsPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
//
1010
// Run 'make gen-cue' from repository root to regenerate.
1111

12+
export const pluginVersion = "10.1.0-pre";
13+
1214
export interface Options {
1315
/**
1416
* empty/missing will default to grafana blog

packages/grafana-schema/src/raw/composable/nodegraph/panelcfg/x/NodeGraphPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
//
1010
// Run 'make gen-cue' from repository root to regenerate.
1111

12+
export const pluginVersion = "10.1.0-pre";
13+
1214
export interface ArcOption {
1315
/**
1416
* The color of the arc.

packages/grafana-schema/src/raw/composable/parca/dataquery/x/ParcaDataQuery_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export type ParcaQueryType = ('metrics' | 'profile' | 'both');
1517

1618
export const defaultParcaQueryType: ParcaQueryType = 'both';

packages/grafana-schema/src/raw/composable/piechart/panelcfg/x/PieChartPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
/**
1517
* Select the pie chart display style.
1618
*/

packages/grafana-schema/src/raw/composable/prometheus/dataquery/x/PrometheusDataQuery_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export enum QueryEditorMode {
1517
Builder = 'builder',
1618
Code = 'code',

packages/grafana-schema/src/raw/composable/stat/panelcfg/x/StatPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export interface Options extends common.SingleStatBaseOptions {
1517
colorMode: common.BigValueColorMode;
1618
graphMode: common.BigValueGraphMode;

packages/grafana-schema/src/raw/composable/statetimeline/panelcfg/x/StateTimelinePanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as ui from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export interface Options extends ui.OptionsWithLegend, ui.OptionsWithTooltip, ui.OptionsWithTimezones {
1517
/**
1618
* Controls value alignment on the timelines

packages/grafana-schema/src/raw/composable/statushistory/panelcfg/x/StatusHistoryPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as ui from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export interface Options extends ui.OptionsWithLegend, ui.OptionsWithTooltip, ui.OptionsWithTimezones {
1517
/**
1618
* Controls the column width

packages/grafana-schema/src/raw/composable/table/panelcfg/x/TablePanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as ui from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export interface Options {
1517
/**
1618
* Controls the height of the rows

packages/grafana-schema/src/raw/composable/tempo/dataquery/x/TempoDataQuery_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export interface TempoQuery extends common.DataQuery {
1517
filters: Array<TraceqlFilter>;
1618
/**

packages/grafana-schema/src/raw/composable/testdata/dataquery/x/TestDataDataQuery_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export enum TestDataQueryType {
1517
Annotations = 'annotations',
1618
Arrow = 'arrow',

packages/grafana-schema/src/raw/composable/text/panelcfg/x/TextPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
//
1010
// Run 'make gen-cue' from repository root to regenerate.
1111

12+
export const pluginVersion = "10.1.0-pre";
13+
1214
export enum TextMode {
1315
Code = 'code',
1416
HTML = 'html',

packages/grafana-schema/src/raw/composable/timeseries/panelcfg/x/TimeSeriesPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export interface Options extends common.OptionsWithTimezones {
1517
legend: common.VizLegendOptions;
1618
tooltip: common.VizTooltipOptions;

packages/grafana-schema/src/raw/composable/trend/panelcfg/x/TrendPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
/**
1517
* Identical to timeseries... except it does not have timezone settings
1618
*/

packages/grafana-schema/src/raw/composable/xychart/panelcfg/x/XYChartPanelCfg_types.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
import * as common from '@grafana/schema';
1313

14+
export const pluginVersion = "10.1.0-pre";
15+
1416
export enum SeriesMapping {
1517
Auto = 'auto',
1618
Manual = 'manual',

pkg/build/version.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66
"os"
7+
"path/filepath"
78
"strings"
89
"time"
910
)
@@ -14,7 +15,7 @@ type PackageJSON struct {
1415

1516
// Opens the package.json file in the provided directory and returns a struct that represents its contents
1617
func OpenPackageJSON(dir string) (PackageJSON, error) {
17-
reader, err := os.Open("package.json")
18+
reader, err := os.Open(filepath.Clean(dir + "/package.json"))
1819
if err != nil {
1920
return PackageJSON{}, err
2021
}

pkg/plugins/codegen/jenny_pluginseachmajor.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package codegen
22

33
import (
4+
"fmt"
5+
"os"
6+
"path"
47
"path/filepath"
58

69
"github.com/grafana/codejen"
710
tsast "github.com/grafana/cuetsy/ts/ast"
11+
"github.com/grafana/grafana/pkg/build"
812
corecodegen "github.com/grafana/grafana/pkg/codegen"
913
"github.com/grafana/grafana/pkg/cuectx"
1014
"github.com/grafana/grafana/pkg/plugins/pfs"
@@ -37,6 +41,13 @@ func (j *pleJenny) Generate(decl *pfs.PluginDecl) (codejen.Files, error) {
3741
return nil, err
3842
}
3943

44+
version := "export const pluginVersion = \"%s\";"
45+
if decl.PluginMeta.Info.Version != nil {
46+
version = fmt.Sprintf(version, *decl.PluginMeta.Info.Version)
47+
} else {
48+
version = fmt.Sprintf(version, getGrafanaVersion())
49+
}
50+
4051
files := make(codejen.Files, len(jf))
4152
for i, file := range jf {
4253
tsf := &tsast.File{}
@@ -48,6 +59,10 @@ func (j *pleJenny) Generate(decl *pfs.PluginDecl) (codejen.Files, error) {
4859
}
4960
}
5061

62+
tsf.Nodes = append(tsf.Nodes, tsast.Raw{
63+
Data: version,
64+
})
65+
5166
tsf.Nodes = append(tsf.Nodes, tsast.Raw{
5267
Data: string(file.Data),
5368
})
@@ -70,3 +85,17 @@ func kinds2pd(rt *thema.Runtime, j codejen.OneToMany[kindsys.Kind]) codejen.OneT
7085
return kd
7186
})
7287
}
88+
89+
func getGrafanaVersion() string {
90+
dir, err := os.Getwd()
91+
if err != nil {
92+
return ""
93+
}
94+
95+
pkg, err := build.OpenPackageJSON(path.Join(dir, "../../../"))
96+
if err != nil {
97+
return ""
98+
}
99+
100+
return pkg.Version
101+
}

0 commit comments

Comments
 (0)