migrate

package
v0.55.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecutePanelScript added in v0.52.0

func ExecutePanelScript(cueScript *build.Instance, grafanaPanelData []byte) (*plugin.Plugin, bool, error)

func ExecuteQueryScript added in v0.52.0

func ExecuteQueryScript(cueScript *build.Instance, grafanaQueryData []byte) (*plugin.Plugin, bool, error)

func ExecuteVariableScript added in v0.52.0

func ExecuteVariableScript(cueScript *build.Instance, grafanaVariableData []byte) (*plugin.Plugin, bool, error)

func GetPluginKind added in v0.52.0

func GetPluginKind(migrateFile string) (plugin.Kind, error)

GetPluginKind guesses the plugin kind from a migration file based on expected patterns

func Load

func Load(pluginPath string, moduleSpec v1.ModuleSpec) ([]schema.LoadSchema, error)

func LoadMigrateSchema

func LoadMigrateSchema(schemaPath string) (*build.Instance, error)

func ReplaceInputValue

func ReplaceInputValue(input map[string]string, grafanaDashboard string) string

Types

type CurrentValue

type CurrentValue struct {
	Value *variable.DefaultValue `json:"value,omitempty"`
}
type GrafanaLink struct {
	Title       string `json:"title"`
	URL         string `json:"url"`
	TargetBlank bool   `json:"targetBlank"`
	IncludeVars bool   `json:"includeVars"`
	Tooltip     string `json:"tooltip"`
}

type GrafanaTimeRange added in v0.55.0

type GrafanaTimeRange struct {
	From string `json:"from"`
	To   string `json:"to"`
}

GrafanaTimeRange is the default time range of a Grafana dashboard, e.g. {"from": "now-6h", "to": "now"}.

func (*GrafanaTimeRange) UnmarshalJSON added in v0.55.0

func (t *GrafanaTimeRange) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes the time range best-effort: a value that is not an object of strings leaves the time range empty (the migration then uses the default duration of Perses), instead of making the whole migration fail.

type GridPosition

type GridPosition struct {
	Height int     `json:"h"`
	Width  int     `json:"w"`
	X      float64 `json:"x"`
	Y      float64 `json:"y"`
}

type LenientString added in v0.55.0

type LenientString string

LenientString is a string field of a Grafana dashboard that is decoded best-effort: a JSON value that is not a string (e.g. `"refresh": false`, written by older Grafana versions when auto-refresh is off) is decoded as an empty string, instead of making the whole migration fail.

func (*LenientString) UnmarshalJSON added in v0.55.0

func (s *LenientString) UnmarshalJSON(data []byte) error

type Migration

type Migration interface {
	Load(pluginPath string, module v1.PluginModule) error
	LoadDevPlugin(pluginPath string, module v1.PluginModule) error
	UnLoadDevPlugin(module v1.PluginModule)
	Migrate(grafanaDashboard *SimplifiedDashboard, useDefaultDatasource bool) (*v1.Dashboard, error)
}

func New

func New() Migration

type Panel

type Panel struct {
	Type            string            `json:"type"`
	Title           string            `json:"title"`
	Description     string            `json:"description"`
	Repeat          string            `json:"repeat"`
	RepeatDirection string            `json:"repeatDirection"`
	MaxPerRow       *int              `json:"maxPerRow"`
	Collapsed       bool              `json:"collapsed"`
	Panels          []Panel           `json:"panels"`
	GridPosition    GridPosition      `json:"gridPos"`
	Targets         []json.RawMessage `json:"targets"`
	Links           []GrafanaLink     `json:"links"`
	json.RawMessage
}

func (*Panel) UnmarshalJSON

func (p *Panel) UnmarshalJSON(data []byte) error

Custom unmarshal to both store fields and keep raw data (used by the CUE-based migration logic). Checks unmarshalling errors only when unmarshaling complex structs.

type SimplifiedDashboard

type SimplifiedDashboard struct {
	UID        string        `json:"uid,omitempty"`
	Title      string        `json:"title"`
	Tags       []string      `json:"tags"`
	Panels     []Panel       `json:"panels"`
	Links      []GrafanaLink `json:"links"`
	Templating struct {
		List []TemplateVar `json:"list"`
	} `json:"templating"`
	// Time is the default time range of the dashboard. It is nil when the dashboard has none.
	Time *GrafanaTimeRange `json:"time"`
	// Refresh is the default auto-refresh interval of the dashboard, e.g. "1m". It is empty when auto-refresh is off.
	Refresh LenientString `json:"refresh"`
	// Timezone is the timezone of the dashboard: "browser", "utc", an IANA timezone name, or empty.
	Timezone LenientString `json:"timezone"`
}

func (*SimplifiedDashboard) UnmarshalJSON

func (d *SimplifiedDashboard) UnmarshalJSON(data []byte) error

type TemplateVar

type TemplateVar struct {
	Name        string          `json:"name"`
	Type        string          `json:"type"`
	Description string          `json:"description"`
	Label       string          `json:"label"`
	Hide        int             `json:"hide"`
	Sort        *int            `json:"sort,omitempty"`
	IncludeAll  bool            `json:"includeAll"`
	AllValue    string          `json:"allValue"`
	Multi       bool            `json:"multi"`
	Current     *CurrentValue   `json:"current,omitempty"`
	Query       json.RawMessage `json:"query"`
	json.RawMessage
}

func (*TemplateVar) UnmarshalJSON

func (v *TemplateVar) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL