[v10.0.x] Chore: Generate plugin version and remove lineage version (#70735)

* 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

(cherry picked from commit b0893c29a7)

* Update versions
This commit is contained in:
Selene
2023-06-28 17:55:47 +02:00
committed by GitHub
parent c81813a9a2
commit e250d51857
70 changed files with 99 additions and 73 deletions
@@ -9,6 +9,8 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const pluginVersion = "10.0.2";
export interface Options {
/**
* Name of the alertmanager used as a source for alerts
@@ -9,6 +9,8 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const pluginVersion = "10.0.2";
export interface Options {
limit: number;
navigateAfter: string;
@@ -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.
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
export interface Options extends common.OptionsWithLegend, common.OptionsWithTooltip, common.OptionsWithTextFormatting {
/**
* Controls the radius of each bar.
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
export interface Options extends common.SingleStatBaseOptions {
displayMode: common.BarGaugeDisplayMode;
minVizHeight: number;
@@ -11,6 +11,8 @@
import * as ui from '@grafana/schema';
export const pluginVersion = "10.0.2";
export enum HorizontalConstraint {
Center = 'center',
Left = 'left',
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
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.
@@ -9,6 +9,8 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const pluginVersion = "10.0.2";
export interface Options {
folderId?: number;
includeVars: boolean;
@@ -9,6 +9,8 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const pluginVersion = "10.0.2";
export interface Options {
selectedSeries: number;
}
@@ -9,6 +9,8 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const pluginVersion = "10.0.2";
export type UpdateConfig = {
render: boolean,
dataChanged: boolean,
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
export type BucketAggregation = (DateHistogram | Histogram | Terms | Filters | GeoHashGrid | Nested);
export type MetricAggregation = (Count | PipelineMetricAggregation | MetricAggregationWithSettings);
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
export interface Options extends common.SingleStatBaseOptions {
showThresholdLabels: boolean;
showThresholdMarkers: boolean;
@@ -11,6 +11,8 @@
import * as ui from '@grafana/schema';
export const pluginVersion = "10.0.2";
export interface Options {
basemap: ui.MapLayerOptions;
controls: ControlsOptions;
@@ -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.
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
export type PhlareQueryType = ('metrics' | 'profile' | 'both');
export const defaultPhlareQueryType: PhlareQueryType = 'both';
@@ -11,6 +11,8 @@
import * as ui from '@grafana/schema';
export const pluginVersion = "10.0.2";
/**
* Controls the color mode of the heatmap
*/
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
export interface Options extends common.OptionsWithLegend, common.OptionsWithTooltip {
/**
* Offset buckets by this amount
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
export interface Options {
dedupStrategy: common.LogsDedupStrategy;
enableLogDetails: boolean;
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
export enum QueryEditorMode {
Builder = 'builder',
Code = 'code',
@@ -9,6 +9,8 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const pluginVersion = "10.0.2";
export interface Options {
/**
* empty/missing will default to grafana blog
@@ -9,6 +9,8 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const pluginVersion = "10.0.2";
export interface ArcOption {
/**
* The color of the arc.
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
export type ParcaQueryType = ('metrics' | 'profile' | 'both');
export const defaultParcaQueryType: ParcaQueryType = 'both';
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
/**
* Select the pie chart display style.
*/
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
export enum QueryEditorMode {
Builder = 'builder',
Code = 'code',
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
export interface Options extends common.SingleStatBaseOptions {
colorMode: common.BigValueColorMode;
graphMode: common.BigValueGraphMode;
@@ -11,6 +11,8 @@
import * as ui from '@grafana/schema';
export const pluginVersion = "10.0.2";
export interface Options extends ui.OptionsWithLegend, ui.OptionsWithTooltip, ui.OptionsWithTimezones {
/**
* Controls value alignment on the timelines
@@ -11,6 +11,8 @@
import * as ui from '@grafana/schema';
export const pluginVersion = "10.0.2";
export interface Options extends ui.OptionsWithLegend, ui.OptionsWithTooltip, ui.OptionsWithTimezones {
/**
* Controls the column width
@@ -11,6 +11,8 @@
import * as ui from '@grafana/schema';
export const pluginVersion = "10.0.2";
export interface Options {
/**
* Controls the height of the rows
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
export interface TempoQuery extends common.DataQuery {
filters: Array<TraceqlFilter>;
/**
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
export enum TestDataQueryType {
Annotations = 'annotations',
Arrow = 'arrow',
@@ -9,6 +9,8 @@
//
// Run 'make gen-cue' from repository root to regenerate.
export const pluginVersion = "10.0.2";
export enum TextMode {
Code = 'code',
HTML = 'html',
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
export interface Options extends common.OptionsWithTimezones {
legend: common.VizLegendOptions;
tooltip: common.VizTooltipOptions;
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
/**
* Identical to timeseries... except it does not have timezone settings
*/
@@ -11,6 +11,8 @@
import * as common from '@grafana/schema';
export const pluginVersion = "10.0.2";
export enum SeriesMapping {
Auto = 'auto',
Manual = 'manual',
+2 -1
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
}
@@ -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
}
@@ -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
@@ -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.
@@ -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.
@@ -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);
@@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const DataQueryModelVersion = Object.freeze([0, 0]);
export enum QueryEditorMode {
Builder = 'builder',
Code = 'code',
@@ -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';
@@ -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';
@@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const DataQueryModelVersion = Object.freeze([0, 0]);
export enum QueryEditorMode {
Builder = 'builder',
Code = 'code',
@@ -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>;
/**
@@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const DataQueryModelVersion = Object.freeze([0, 0]);
export enum TestDataQueryType {
Annotations = 'annotations',
Arrow = 'arrow',
@@ -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
@@ -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;
@@ -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.
@@ -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;
@@ -10,8 +10,6 @@
import * as ui from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export enum HorizontalConstraint {
Center = 'center',
Left = 'left',
@@ -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;
@@ -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;
}
@@ -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,
@@ -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;
@@ -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;
@@ -10,8 +10,6 @@
import * as ui from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
/**
* Controls the color mode of the heatmap
*/
@@ -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
@@ -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;
@@ -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
@@ -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.
@@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
/**
* Select the pie chart display style.
*/
@@ -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;
@@ -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
@@ -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
@@ -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
@@ -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',
@@ -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;
@@ -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
*/
@@ -10,8 +10,6 @@
import * as common from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export enum SeriesMapping {
Auto = 'auto',
Manual = 'manual',