mirror of https://github.com/grafana/grafana.git
Add `v2beta1` api version: Consolidate schema breaking changes (#108172)
* Revert "Revert: Future-proofing query and data source model in Dashboard Sche… (#107985)" This reverts commit13a89d4ae3
. * Revert "Revert "Schema V2: Simplify annotations v1<->v2 conversions" (#107984)" This reverts commit2b8c5bea1a
. * make gen apps * e2e update * Use v2alpha2 by default (#108177) * Use v2alpha2 by default * Apply only DS changes to alpha2 * Use v2alpha2 by default except to query * Create a v2 index in @grafana/schema * Update path and apply lint * Update tests * Update imports to v2 status * Fix failing openapi test * Schemav2 breaking changes: conversion implementation (#108224) * provision v2alpha1 dashboard * Run conversions for DS refactor * Run snapshot testing on conversions * Normalize output name * Update snapshots to include all panel and variable cases * fix lint * fix lint * fix test and go lint * more go lint --------- Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com> Co-authored-by: Haris Rozajac <haris.rozajac12@gmail.com> * Schema v2: Introduce group/datasource convention to GroupBy and AdHoc variable (#108237) * Schema v2: Introduce group/datasource convention to GroupBy and AdHoc variables * add conversion * App Installer: Authorizer support (#108419) * Chore: use `satisfies` and remove a load of `any`s (#108397) use satisfies and remove a load of anys * improve logging and fail unified-storage migration with more than 0 errors (#108471) improve logging and fail unified-storage migration with more than 0 errors * fix conversion test * Secrets: Create more granular fixed roles for SecureValues (#108382) * Provisioning: Fix bug in job progress recording (#108440) Fix bug in job progress recording * Provisioning: Fix ImportAllPanelsFromLocalRepository test (#108441) * Provisioning: Skip flaky test * Fix flaky provisioning test * Fix lint --------- Co-authored-by: Roberto Jimenez Sanchez <roberto.jimenez@grafana.com> * BulkDeleteProvisionedResource: Move progress bar into a second step (#108417) * Move progress bar into a second step --------- Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com> * [Dashboard Schema Codegen] Move dashboard CUE codegen block back up into kind body (#108476) [Dashboard Schema Codegen] Move dashboard CUE codegen block back up into kind body to make sure new versions have the same settings. --------- Co-authored-by: Haris Rozajac <haris.rozajac12@gmail.com> Co-authored-by: Todd Treece <360020+toddtreece@users.noreply.github.com> Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com> Co-authored-by: Will Assis <35489495+gassiss@users.noreply.github.com> Co-authored-by: Matheus Macabu <macabu@users.noreply.github.com> Co-authored-by: Roberto Jiménez Sánchez <jszroberto@gmail.com> Co-authored-by: Roberto Jimenez Sanchez <roberto.jimenez@grafana.com> Co-authored-by: Yunwen Zheng <yunwen.zheng@grafana.com> Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com> Co-authored-by: Austin Pond <IfSentient@users.noreply.github.com> Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com> * Dashboard Schema V2: Refactor VizConfigKind to follow DataQueryKind convention (#108148) * Dashboards API: Register v2alpha2 API * Prepare conversion functions * Fix test * Refactor VizConfigKind to follow DataQueryKind convention * fix tests * use new dataquerykind convention alpha 2 * add conversion * fix tests * fix tests * fix another test * Fix merge --------- Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com> * fix k8s codegen * Update e2e-playwright/dashboards/TestV2Dashboard.json * Update e2e/dashboards/TestV2Dashboard.json * revert app generation for non-related apps * try again * another try * also revert folder and secret app generation * v2alpha1 provisioned dashboard * Fix kind * Fix conversion snapshots * Update API discovery registry * Rename to v2beta1 * Rename migrations * Update apps/dashboard/pkg/apis/dashboard/v2beta1/doc.go Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com> * Ensure conditional rendering and other non changed properties --------- Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com> Co-authored-by: Haris Rozajac <haris.rozajac12@gmail.com> Co-authored-by: Todd Treece <360020+toddtreece@users.noreply.github.com> Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com> Co-authored-by: Will Assis <35489495+gassiss@users.noreply.github.com> Co-authored-by: Matheus Macabu <macabu@users.noreply.github.com> Co-authored-by: Roberto Jiménez Sánchez <jszroberto@gmail.com> Co-authored-by: Roberto Jimenez Sanchez <roberto.jimenez@grafana.com> Co-authored-by: Yunwen Zheng <yunwen.zheng@grafana.com> Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com> Co-authored-by: Austin Pond <IfSentient@users.noreply.github.com> Co-authored-by: Haris Rozajac <58232930+harisrozajac@users.noreply.github.com> Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
This commit is contained in:
parent
f92752c2f0
commit
20b08ccaab
|
@ -44,9 +44,9 @@ post-generate-cleanup: ## Clean up the generated code
|
|||
@echo "" >> ./pkg/apis/dashboard/v2alpha1/dashboard_spec.cue
|
||||
@cat ./kinds/v2alpha1/dashboard_spec.cue >> ./pkg/apis/dashboard/v2alpha1/dashboard_spec.cue
|
||||
|
||||
# Copy dashboard/v2alpha2 spec so we can use it for schema validation
|
||||
@echo "// This file is managed by grafana-app-sdk - DO NOT EDIT MANUALLY" > ./pkg/apis/dashboard/v2alpha2/dashboard_spec.cue
|
||||
@echo "// Source: apps/dashboard/kinds/v2alpha2/dashboard_spec.cue" >> ./pkg/apis/dashboard/v2alpha2/dashboard_spec.cue
|
||||
@echo "// To sync changes, run: make generate in apps/dashboard" >> ./pkg/apis/dashboard/v2alpha2/dashboard_spec.cue
|
||||
@echo "" >> ./pkg/apis/dashboard/v2alpha2/dashboard_spec.cue
|
||||
@cat ./kinds/v2alpha2/dashboard_spec.cue >> ./pkg/apis/dashboard/v2alpha2/dashboard_spec.cue
|
||||
# Copy dashboard/v2beta1 spec so we can use it for schema validation
|
||||
@echo "// This file is managed by grafana-app-sdk - DO NOT EDIT MANUALLY" > ./pkg/apis/dashboard/v2beta1/dashboard_spec.cue
|
||||
@echo "// Source: apps/dashboard/kinds/v2beta1/dashboard_spec.cue" >> ./pkg/apis/dashboard/v2beta1/dashboard_spec.cue
|
||||
@echo "// To sync changes, run: make generate in apps/dashboard" >> ./pkg/apis/dashboard/v2beta1/dashboard_spec.cue
|
||||
@echo "" >> ./pkg/apis/dashboard/v2beta1/dashboard_spec.cue
|
||||
@cat ./kinds/v2beta1/dashboard_spec.cue >> ./pkg/apis/dashboard/v2beta1/dashboard_spec.cue
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
v0 "github.com/grafana/grafana/sdkkinds/dashboard/v0alpha1"
|
||||
v1 "github.com/grafana/grafana/sdkkinds/dashboard/v1beta1"
|
||||
v2alpha1 "github.com/grafana/grafana/sdkkinds/dashboard/v2alpha1"
|
||||
v2alpha2 "github.com/grafana/grafana/sdkkinds/dashboard/v2alpha2"
|
||||
v2beta1 "github.com/grafana/grafana/sdkkinds/dashboard/v2beta1"
|
||||
)
|
||||
|
||||
// Status is the shared status of all dashboard versions.
|
||||
|
@ -67,9 +67,9 @@ dashboard: {
|
|||
status: DashboardStatus
|
||||
}
|
||||
}
|
||||
"v2alpha2": {
|
||||
"v2beta1": {
|
||||
schema: {
|
||||
spec: v2alpha2.DashboardSpec
|
||||
spec: v2beta1.DashboardSpec
|
||||
status: DashboardStatus
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package v2alpha2
|
||||
package v2beta1
|
||||
|
||||
DashboardSpec: {
|
||||
annotations: [...AnnotationQueryKind] | *[]
|
||||
|
@ -111,14 +111,6 @@ DashboardLink: {
|
|||
keepTime: bool | *false
|
||||
}
|
||||
|
||||
DataSourceRef: {
|
||||
// The plugin type-id
|
||||
type?: string
|
||||
|
||||
// Specific datasource instance
|
||||
uid?: string
|
||||
}
|
||||
|
||||
// A topic is attached to DataFrame metadata in query results.
|
||||
// This specifies where the data should be used.
|
||||
DataTopic: "series" | "annotations" | "alertStates" @cog(kind="enum",memberNames="Series|Annotations|AlertStates")
|
||||
|
@ -373,27 +365,27 @@ Kind: {
|
|||
|
||||
// --- Kinds ---
|
||||
VizConfigSpec: {
|
||||
pluginVersion: string
|
||||
options: [string]: _
|
||||
fieldConfig: FieldConfigSource
|
||||
}
|
||||
|
||||
VizConfigKind: {
|
||||
// The kind of a VizConfigKind is the plugin ID
|
||||
kind: string
|
||||
kind: "VizConfig"
|
||||
// The group is the plugin ID
|
||||
group: string
|
||||
version: string
|
||||
spec: VizConfigSpec
|
||||
}
|
||||
|
||||
AnnotationQuerySpec: {
|
||||
datasource?: DataSourceRef
|
||||
query?: DataQueryKind
|
||||
query: DataQueryKind
|
||||
enable: bool
|
||||
hide: bool
|
||||
iconColor: string
|
||||
name: string
|
||||
builtIn?: bool | *false
|
||||
filter?: AnnotationPanelFilter
|
||||
legacyOptions?: [string]: _ //Catch-all field for datasource-specific properties
|
||||
legacyOptions?: [string]: _ // Catch-all field for datasource-specific properties. Should not be available in as code tooling.
|
||||
}
|
||||
|
||||
AnnotationQueryKind: {
|
||||
|
@ -412,15 +404,19 @@ QueryOptionsSpec: {
|
|||
}
|
||||
|
||||
DataQueryKind: {
|
||||
// The kind of a DataQueryKind is the datasource type
|
||||
kind: string
|
||||
kind: "DataQuery"
|
||||
group: string
|
||||
version: string | *"v0"
|
||||
// New type for datasource reference
|
||||
// Not creating a new type until we figure out how to handle DS refs for group by, adhoc, and every place that uses DataSourceRef in TS.
|
||||
datasource?: {
|
||||
name?: string
|
||||
}
|
||||
spec: [string]: _
|
||||
}
|
||||
|
||||
PanelQuerySpec: {
|
||||
query: DataQueryKind
|
||||
datasource?: DataSourceRef
|
||||
|
||||
refId: string
|
||||
hidden: bool
|
||||
}
|
||||
|
@ -723,7 +719,6 @@ QueryVariableSpec: {
|
|||
refresh: VariableRefresh
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
datasource?: DataSourceRef
|
||||
query: DataQueryKind
|
||||
regex: string | *""
|
||||
sort: VariableSort
|
||||
|
@ -861,7 +856,6 @@ CustomVariableKind: {
|
|||
// GroupBy variable specification
|
||||
GroupByVariableSpec: {
|
||||
name: string | *""
|
||||
datasource?: DataSourceRef
|
||||
defaultValue?: VariableOption
|
||||
current: VariableOption | *{
|
||||
text: ""
|
||||
|
@ -878,13 +872,16 @@ GroupByVariableSpec: {
|
|||
// Group variable kind
|
||||
GroupByVariableKind: {
|
||||
kind: "GroupByVariable"
|
||||
group: string
|
||||
datasource?: {
|
||||
name?: string
|
||||
}
|
||||
spec: GroupByVariableSpec
|
||||
}
|
||||
|
||||
// Adhoc variable specification
|
||||
AdhocVariableSpec: {
|
||||
name: string | *""
|
||||
datasource?: DataSourceRef
|
||||
baseFilters: [...AdHocFilterWithLabels] | *[]
|
||||
filters: [...AdHocFilterWithLabels] | *[]
|
||||
defaultKeys: [...MetricFindValue] | *[]
|
||||
|
@ -920,6 +917,10 @@ AdHocFilterWithLabels: {
|
|||
// Adhoc variable kind
|
||||
AdhocVariableKind: {
|
||||
kind: "AdhocVariable"
|
||||
group: string
|
||||
datasource?: {
|
||||
name?: string
|
||||
}
|
||||
spec: AdhocVariableSpec
|
||||
}
|
||||
|
|
@ -1,175 +0,0 @@
|
|||
//go:build !ignore_autogenerated
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
// Code generated by conversion-gen. DO NOT EDIT.
|
||||
|
||||
package v2alpha2
|
||||
|
||||
import (
|
||||
url "net/url"
|
||||
unsafe "unsafe"
|
||||
|
||||
dashboard "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard"
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
func init() {
|
||||
localSchemeBuilder.Register(RegisterConversions)
|
||||
}
|
||||
|
||||
// RegisterConversions adds conversion functions to the given scheme.
|
||||
// Public to allow building arbitrary schemes.
|
||||
func RegisterConversions(s *runtime.Scheme) error {
|
||||
if err := s.AddGeneratedConversionFunc((*AnnotationActions)(nil), (*dashboard.AnnotationActions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(a.(*AnnotationActions), b.(*dashboard.AnnotationActions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*dashboard.AnnotationActions)(nil), (*AnnotationActions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(a.(*dashboard.AnnotationActions), b.(*AnnotationActions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*AnnotationPermission)(nil), (*dashboard.AnnotationPermission)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v2alpha2_AnnotationPermission_To_dashboard_AnnotationPermission(a.(*AnnotationPermission), b.(*dashboard.AnnotationPermission), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*dashboard.AnnotationPermission)(nil), (*AnnotationPermission)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_dashboard_AnnotationPermission_To_v2alpha2_AnnotationPermission(a.(*dashboard.AnnotationPermission), b.(*AnnotationPermission), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*DashboardAccess)(nil), (*dashboard.DashboardAccess)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v2alpha2_DashboardAccess_To_dashboard_DashboardAccess(a.(*DashboardAccess), b.(*dashboard.DashboardAccess), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*dashboard.DashboardAccess)(nil), (*DashboardAccess)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_dashboard_DashboardAccess_To_v2alpha2_DashboardAccess(a.(*dashboard.DashboardAccess), b.(*DashboardAccess), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*url.Values)(nil), (*VersionsQueryOptions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_url_Values_To_v2alpha2_VersionsQueryOptions(a.(*url.Values), b.(*VersionsQueryOptions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func autoConvert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(in *AnnotationActions, out *dashboard.AnnotationActions, s conversion.Scope) error {
|
||||
out.CanAdd = in.CanAdd
|
||||
out.CanEdit = in.CanEdit
|
||||
out.CanDelete = in.CanDelete
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions is an autogenerated conversion function.
|
||||
func Convert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(in *AnnotationActions, out *dashboard.AnnotationActions, s conversion.Scope) error {
|
||||
return autoConvert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(in *dashboard.AnnotationActions, out *AnnotationActions, s conversion.Scope) error {
|
||||
out.CanAdd = in.CanAdd
|
||||
out.CanEdit = in.CanEdit
|
||||
out.CanDelete = in.CanDelete
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions is an autogenerated conversion function.
|
||||
func Convert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(in *dashboard.AnnotationActions, out *AnnotationActions, s conversion.Scope) error {
|
||||
return autoConvert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v2alpha2_AnnotationPermission_To_dashboard_AnnotationPermission(in *AnnotationPermission, out *dashboard.AnnotationPermission, s conversion.Scope) error {
|
||||
if err := Convert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(&in.Dashboard, &out.Dashboard, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := Convert_v2alpha2_AnnotationActions_To_dashboard_AnnotationActions(&in.Organization, &out.Organization, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2alpha2_AnnotationPermission_To_dashboard_AnnotationPermission is an autogenerated conversion function.
|
||||
func Convert_v2alpha2_AnnotationPermission_To_dashboard_AnnotationPermission(in *AnnotationPermission, out *dashboard.AnnotationPermission, s conversion.Scope) error {
|
||||
return autoConvert_v2alpha2_AnnotationPermission_To_dashboard_AnnotationPermission(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_dashboard_AnnotationPermission_To_v2alpha2_AnnotationPermission(in *dashboard.AnnotationPermission, out *AnnotationPermission, s conversion.Scope) error {
|
||||
if err := Convert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(&in.Dashboard, &out.Dashboard, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := Convert_dashboard_AnnotationActions_To_v2alpha2_AnnotationActions(&in.Organization, &out.Organization, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_dashboard_AnnotationPermission_To_v2alpha2_AnnotationPermission is an autogenerated conversion function.
|
||||
func Convert_dashboard_AnnotationPermission_To_v2alpha2_AnnotationPermission(in *dashboard.AnnotationPermission, out *AnnotationPermission, s conversion.Scope) error {
|
||||
return autoConvert_dashboard_AnnotationPermission_To_v2alpha2_AnnotationPermission(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v2alpha2_DashboardAccess_To_dashboard_DashboardAccess(in *DashboardAccess, out *dashboard.DashboardAccess, s conversion.Scope) error {
|
||||
out.Slug = in.Slug
|
||||
out.Url = in.Url
|
||||
out.CanSave = in.CanSave
|
||||
out.CanEdit = in.CanEdit
|
||||
out.CanAdmin = in.CanAdmin
|
||||
out.CanStar = in.CanStar
|
||||
out.CanDelete = in.CanDelete
|
||||
out.AnnotationsPermissions = (*dashboard.AnnotationPermission)(unsafe.Pointer(in.AnnotationsPermissions))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2alpha2_DashboardAccess_To_dashboard_DashboardAccess is an autogenerated conversion function.
|
||||
func Convert_v2alpha2_DashboardAccess_To_dashboard_DashboardAccess(in *DashboardAccess, out *dashboard.DashboardAccess, s conversion.Scope) error {
|
||||
return autoConvert_v2alpha2_DashboardAccess_To_dashboard_DashboardAccess(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_dashboard_DashboardAccess_To_v2alpha2_DashboardAccess(in *dashboard.DashboardAccess, out *DashboardAccess, s conversion.Scope) error {
|
||||
out.Slug = in.Slug
|
||||
out.Url = in.Url
|
||||
out.CanSave = in.CanSave
|
||||
out.CanEdit = in.CanEdit
|
||||
out.CanAdmin = in.CanAdmin
|
||||
out.CanStar = in.CanStar
|
||||
out.CanDelete = in.CanDelete
|
||||
out.AnnotationsPermissions = (*AnnotationPermission)(unsafe.Pointer(in.AnnotationsPermissions))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_dashboard_DashboardAccess_To_v2alpha2_DashboardAccess is an autogenerated conversion function.
|
||||
func Convert_dashboard_DashboardAccess_To_v2alpha2_DashboardAccess(in *dashboard.DashboardAccess, out *DashboardAccess, s conversion.Scope) error {
|
||||
return autoConvert_dashboard_DashboardAccess_To_v2alpha2_DashboardAccess(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_url_Values_To_v2alpha2_VersionsQueryOptions(in *url.Values, out *VersionsQueryOptions, s conversion.Scope) error {
|
||||
// WARNING: Field TypeMeta does not have json tag, skipping.
|
||||
|
||||
if values, ok := map[string][]string(*in)["path"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_string(&values, &out.Path, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Path = ""
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["version"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_int64(&values, &out.Version, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Version = 0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_url_Values_To_v2alpha2_VersionsQueryOptions is an autogenerated conversion function.
|
||||
func Convert_url_Values_To_v2alpha2_VersionsQueryOptions(in *url.Values, out *VersionsQueryOptions, s conversion.Scope) error {
|
||||
return autoConvert_url_Values_To_v2alpha2_VersionsQueryOptions(in, out, s)
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAdHocFilterWithLabels,ValueLabels
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAdHocFilterWithLabels,Values
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAdhocVariableSpec,BaseFilters
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAdhocVariableSpec,DefaultKeys
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAdhocVariableSpec,Filters
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAnnotationPanelFilter,Ids
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardAutoGridLayoutSpec,Items
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardConditionalRenderingGroupSpec,Items
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardCustomVariableSpec,Options
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardDashboardLink,Tags
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardDatasourceVariableSpec,Options
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardFieldConfig,Links
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardFieldConfig,Mappings
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardFieldConfigSource,Overrides
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutSpec,Items
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGroupByVariableSpec,Options
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardIntervalVariableSpec,Options
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardMetadata,Finalizers
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardPanelSpec,Links
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryGroupSpec,Queries
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryGroupSpec,Transformations
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableSpec,Options
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableSpec,StaticOptions
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardRowsLayoutSpec,Rows
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardSpec,Annotations
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardSpec,Links
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardSpec,Tags
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardSpec,Variables
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardStringOrArrayOfString,ArrayOfString
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardTabsLayoutSpec,Tabs
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardThresholdsConfig,Steps
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardTimeSettingsSpec,AutoRefreshIntervals
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardTimeSettingsSpec,QuickRanges
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardV2alpha2FieldConfigSourceOverrides,Properties
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,LibraryPanelStatus,Warnings
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind,ConditionalRenderingDataKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind,ConditionalRenderingTimeRangeSizeKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind,ConditionalRenderingVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind,AutoGridLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind,GridLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind,RowsLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind,TabsLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind,AutoGridLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind,GridLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind,RowsLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind,TabsLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardIntervalVariableSpec,AutoCount
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardIntervalVariableSpec,AutoMin
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardPanelKindOrLibraryPanelKind,LibraryPanelKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardPanelKindOrLibraryPanelKind,PanelKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,AdhocVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,ConstantVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,CustomVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,DatasourceVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,GroupByVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,IntervalVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,QueryVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,TextVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardStringOrArrayOfString,ArrayOfString
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardStringOrArrayOfString,String
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardStringOrFloat64,Float64
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardStringOrFloat64,String
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,RangeMap
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,RegexMap
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,SpecialValueMap
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,ValueMap
|
||||
API rule violation: streaming_list_type_json_tags,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2,DashboardList,ListMeta
|
|
@ -1,4 +1,4 @@
|
|||
package v2alpha2
|
||||
package v2beta1
|
||||
|
||||
import "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
|
@ -6,7 +6,7 @@ const (
|
|||
// APIGroup is the API group used by all kinds in this package
|
||||
APIGroup = "dashboard.grafana.app"
|
||||
// APIVersion is the API version used by all kinds in this package
|
||||
APIVersion = "v2alpha2"
|
||||
APIVersion = "v2beta1"
|
||||
)
|
||||
|
||||
var (
|
|
@ -2,7 +2,7 @@
|
|||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v2alpha2
|
||||
package v2beta1
|
||||
|
||||
import (
|
||||
"encoding/json"
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v2alpha2
|
||||
package v2beta1
|
||||
|
||||
import (
|
||||
time "time"
|
|
@ -2,7 +2,7 @@
|
|||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v2alpha2
|
||||
package v2beta1
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -2,7 +2,7 @@
|
|||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v2alpha2
|
||||
package v2beta1
|
||||
|
||||
import (
|
||||
"github.com/grafana/grafana-app-sdk/resource"
|
||||
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
// schema is unexported to prevent accidental overwrites
|
||||
var (
|
||||
schemaDashboard = resource.NewSimpleSchema("dashboard.grafana.app", "v2alpha2", &Dashboard{}, &DashboardList{}, resource.WithKind("Dashboard"),
|
||||
schemaDashboard = resource.NewSimpleSchema("dashboard.grafana.app", "v2beta1", &Dashboard{}, &DashboardList{}, resource.WithKind("Dashboard"),
|
||||
resource.WithPlural("dashboards"), resource.WithScope(resource.NamespacedScope))
|
||||
kindDashboard = resource.Kind{
|
||||
Schema: schemaDashboard,
|
|
@ -1,8 +1,8 @@
|
|||
// This file is managed by grafana-app-sdk - DO NOT EDIT MANUALLY
|
||||
// Source: apps/dashboard/kinds/v2alpha2/dashboard_spec.cue
|
||||
// Source: apps/dashboard/kinds/v2beta1/dashboard_spec.cue
|
||||
// To sync changes, run: make generate in apps/dashboard
|
||||
|
||||
package v2alpha2
|
||||
package v2beta1
|
||||
|
||||
DashboardSpec: {
|
||||
annotations: [...AnnotationQueryKind] | *[]
|
||||
|
@ -115,14 +115,6 @@ DashboardLink: {
|
|||
keepTime: bool | *false
|
||||
}
|
||||
|
||||
DataSourceRef: {
|
||||
// The plugin type-id
|
||||
type?: string
|
||||
|
||||
// Specific datasource instance
|
||||
uid?: string
|
||||
}
|
||||
|
||||
// A topic is attached to DataFrame metadata in query results.
|
||||
// This specifies where the data should be used.
|
||||
DataTopic: "series" | "annotations" | "alertStates" @cog(kind="enum",memberNames="Series|Annotations|AlertStates")
|
||||
|
@ -377,27 +369,27 @@ Kind: {
|
|||
|
||||
// --- Kinds ---
|
||||
VizConfigSpec: {
|
||||
pluginVersion: string
|
||||
options: [string]: _
|
||||
fieldConfig: FieldConfigSource
|
||||
}
|
||||
|
||||
VizConfigKind: {
|
||||
// The kind of a VizConfigKind is the plugin ID
|
||||
kind: string
|
||||
kind: "VizConfig"
|
||||
// The group is the plugin ID
|
||||
group: string
|
||||
version: string
|
||||
spec: VizConfigSpec
|
||||
}
|
||||
|
||||
AnnotationQuerySpec: {
|
||||
datasource?: DataSourceRef
|
||||
query?: DataQueryKind
|
||||
query: DataQueryKind
|
||||
enable: bool
|
||||
hide: bool
|
||||
iconColor: string
|
||||
name: string
|
||||
builtIn?: bool | *false
|
||||
filter?: AnnotationPanelFilter
|
||||
legacyOptions?: [string]: _ //Catch-all field for datasource-specific properties
|
||||
legacyOptions?: [string]: _ // Catch-all field for datasource-specific properties. Should not be available in as code tooling.
|
||||
}
|
||||
|
||||
AnnotationQueryKind: {
|
||||
|
@ -416,15 +408,19 @@ QueryOptionsSpec: {
|
|||
}
|
||||
|
||||
DataQueryKind: {
|
||||
// The kind of a DataQueryKind is the datasource type
|
||||
kind: string
|
||||
kind: "DataQuery"
|
||||
group: string
|
||||
version: string | *"v0"
|
||||
// New type for datasource reference
|
||||
// Not creating a new type until we figure out how to handle DS refs for group by, adhoc, and every place that uses DataSourceRef in TS.
|
||||
datasource?: {
|
||||
name?: string
|
||||
}
|
||||
spec: [string]: _
|
||||
}
|
||||
|
||||
PanelQuerySpec: {
|
||||
query: DataQueryKind
|
||||
datasource?: DataSourceRef
|
||||
|
||||
refId: string
|
||||
hidden: bool
|
||||
}
|
||||
|
@ -727,7 +723,6 @@ QueryVariableSpec: {
|
|||
refresh: VariableRefresh
|
||||
skipUrlSync: bool | *false
|
||||
description?: string
|
||||
datasource?: DataSourceRef
|
||||
query: DataQueryKind
|
||||
regex: string | *""
|
||||
sort: VariableSort
|
||||
|
@ -865,7 +860,6 @@ CustomVariableKind: {
|
|||
// GroupBy variable specification
|
||||
GroupByVariableSpec: {
|
||||
name: string | *""
|
||||
datasource?: DataSourceRef
|
||||
defaultValue?: VariableOption
|
||||
current: VariableOption | *{
|
||||
text: ""
|
||||
|
@ -882,13 +876,16 @@ GroupByVariableSpec: {
|
|||
// Group variable kind
|
||||
GroupByVariableKind: {
|
||||
kind: "GroupByVariable"
|
||||
group: string
|
||||
datasource?: {
|
||||
name?: string
|
||||
}
|
||||
spec: GroupByVariableSpec
|
||||
}
|
||||
|
||||
// Adhoc variable specification
|
||||
AdhocVariableSpec: {
|
||||
name: string | *""
|
||||
datasource?: DataSourceRef
|
||||
baseFilters: [...AdHocFilterWithLabels] | *[]
|
||||
filters: [...AdHocFilterWithLabels] | *[]
|
||||
defaultKeys: [...MetricFindValue] | *[]
|
||||
|
@ -924,6 +921,10 @@ AdHocFilterWithLabels: {
|
|||
// Adhoc variable kind
|
||||
AdhocVariableKind: {
|
||||
kind: "AdhocVariable"
|
||||
group: string
|
||||
datasource?: {
|
||||
name?: string
|
||||
}
|
||||
spec: AdhocVariableSpec
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v2alpha2
|
||||
package v2beta1
|
||||
|
||||
import (
|
||||
json "encoding/json"
|
||||
|
@ -23,49 +23,42 @@ func NewDashboardAnnotationQueryKind() *DashboardAnnotationQueryKind {
|
|||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardAnnotationQuerySpec struct {
|
||||
Datasource *DashboardDataSourceRef `json:"datasource,omitempty"`
|
||||
Query *DashboardDataQueryKind `json:"query,omitempty"`
|
||||
Enable bool `json:"enable"`
|
||||
Hide bool `json:"hide"`
|
||||
IconColor string `json:"iconColor"`
|
||||
Name string `json:"name"`
|
||||
BuiltIn *bool `json:"builtIn,omitempty"`
|
||||
Filter *DashboardAnnotationPanelFilter `json:"filter,omitempty"`
|
||||
// Catch-all field for datasource-specific properties
|
||||
Query DashboardDataQueryKind `json:"query"`
|
||||
Enable bool `json:"enable"`
|
||||
Hide bool `json:"hide"`
|
||||
IconColor string `json:"iconColor"`
|
||||
Name string `json:"name"`
|
||||
BuiltIn *bool `json:"builtIn,omitempty"`
|
||||
Filter *DashboardAnnotationPanelFilter `json:"filter,omitempty"`
|
||||
// Catch-all field for datasource-specific properties. Should not be available in as code tooling.
|
||||
LegacyOptions map[string]interface{} `json:"legacyOptions,omitempty"`
|
||||
}
|
||||
|
||||
// NewDashboardAnnotationQuerySpec creates a new DashboardAnnotationQuerySpec object.
|
||||
func NewDashboardAnnotationQuerySpec() *DashboardAnnotationQuerySpec {
|
||||
return &DashboardAnnotationQuerySpec{
|
||||
Query: *NewDashboardDataQueryKind(),
|
||||
BuiltIn: (func(input bool) *bool { return &input })(false),
|
||||
}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardDataSourceRef struct {
|
||||
// The plugin type-id
|
||||
Type *string `json:"type,omitempty"`
|
||||
// Specific datasource instance
|
||||
Uid *string `json:"uid,omitempty"`
|
||||
}
|
||||
|
||||
// NewDashboardDataSourceRef creates a new DashboardDataSourceRef object.
|
||||
func NewDashboardDataSourceRef() *DashboardDataSourceRef {
|
||||
return &DashboardDataSourceRef{}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardDataQueryKind struct {
|
||||
// The kind of a DataQueryKind is the datasource type
|
||||
Kind string `json:"kind"`
|
||||
Spec map[string]interface{} `json:"spec"`
|
||||
Kind string `json:"kind"`
|
||||
Group string `json:"group"`
|
||||
Version string `json:"version"`
|
||||
// New type for datasource reference
|
||||
// Not creating a new type until we figure out how to handle DS refs for group by, adhoc, and every place that uses DataSourceRef in TS.
|
||||
Datasource *DashboardV2beta1DataQueryKindDatasource `json:"datasource,omitempty"`
|
||||
Spec map[string]interface{} `json:"spec"`
|
||||
}
|
||||
|
||||
// NewDashboardDataQueryKind creates a new DashboardDataQueryKind object.
|
||||
func NewDashboardDataQueryKind() *DashboardDataQueryKind {
|
||||
return &DashboardDataQueryKind{
|
||||
Spec: map[string]interface{}{},
|
||||
Kind: "DataQuery",
|
||||
Version: "v0",
|
||||
Spec: map[string]interface{}{},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,10 +192,9 @@ func NewDashboardPanelQueryKind() *DashboardPanelQueryKind {
|
|||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardPanelQuerySpec struct {
|
||||
Query DashboardDataQueryKind `json:"query"`
|
||||
Datasource *DashboardDataSourceRef `json:"datasource,omitempty"`
|
||||
RefId string `json:"refId"`
|
||||
Hidden bool `json:"hidden"`
|
||||
Query DashboardDataQueryKind `json:"query"`
|
||||
RefId string `json:"refId"`
|
||||
Hidden bool `json:"hidden"`
|
||||
}
|
||||
|
||||
// NewDashboardPanelQuerySpec creates a new DashboardPanelQuerySpec object.
|
||||
|
@ -295,14 +287,17 @@ func NewDashboardQueryOptionsSpec() *DashboardQueryOptionsSpec {
|
|||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardVizConfigKind struct {
|
||||
// The kind of a VizConfigKind is the plugin ID
|
||||
Kind string `json:"kind"`
|
||||
Spec DashboardVizConfigSpec `json:"spec"`
|
||||
Kind string `json:"kind"`
|
||||
// The group is the plugin ID
|
||||
Group string `json:"group"`
|
||||
Version string `json:"version"`
|
||||
Spec DashboardVizConfigSpec `json:"spec"`
|
||||
}
|
||||
|
||||
// NewDashboardVizConfigKind creates a new DashboardVizConfigKind object.
|
||||
func NewDashboardVizConfigKind() *DashboardVizConfigKind {
|
||||
return &DashboardVizConfigKind{
|
||||
Kind: "VizConfig",
|
||||
Spec: *NewDashboardVizConfigSpec(),
|
||||
}
|
||||
}
|
||||
|
@ -310,9 +305,8 @@ func NewDashboardVizConfigKind() *DashboardVizConfigKind {
|
|||
// --- Kinds ---
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardVizConfigSpec struct {
|
||||
PluginVersion string `json:"pluginVersion"`
|
||||
Options map[string]interface{} `json:"options"`
|
||||
FieldConfig DashboardFieldConfigSource `json:"fieldConfig"`
|
||||
Options map[string]interface{} `json:"options"`
|
||||
FieldConfig DashboardFieldConfigSource `json:"fieldConfig"`
|
||||
}
|
||||
|
||||
// NewDashboardVizConfigSpec creates a new DashboardVizConfigSpec object.
|
||||
|
@ -331,14 +325,14 @@ type DashboardFieldConfigSource struct {
|
|||
// Defaults are the options applied to all fields.
|
||||
Defaults DashboardFieldConfig `json:"defaults"`
|
||||
// Overrides are the options applied to specific fields overriding the defaults.
|
||||
Overrides []DashboardV2alpha2FieldConfigSourceOverrides `json:"overrides"`
|
||||
Overrides []DashboardV2beta1FieldConfigSourceOverrides `json:"overrides"`
|
||||
}
|
||||
|
||||
// NewDashboardFieldConfigSource creates a new DashboardFieldConfigSource object.
|
||||
func NewDashboardFieldConfigSource() *DashboardFieldConfigSource {
|
||||
return &DashboardFieldConfigSource{
|
||||
Defaults: *NewDashboardFieldConfig(),
|
||||
Overrides: []DashboardV2alpha2FieldConfigSourceOverrides{},
|
||||
Overrides: []DashboardV2beta1FieldConfigSourceOverrides{},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -468,14 +462,14 @@ func NewDashboardValueMappingResult() *DashboardValueMappingResult {
|
|||
type DashboardRangeMap struct {
|
||||
Type DashboardMappingType `json:"type"`
|
||||
// Range to match against and the result to apply when the value is within the range
|
||||
Options DashboardV2alpha2RangeMapOptions `json:"options"`
|
||||
Options DashboardV2beta1RangeMapOptions `json:"options"`
|
||||
}
|
||||
|
||||
// NewDashboardRangeMap creates a new DashboardRangeMap object.
|
||||
func NewDashboardRangeMap() *DashboardRangeMap {
|
||||
return &DashboardRangeMap{
|
||||
Type: DashboardMappingTypeRange,
|
||||
Options: *NewDashboardV2alpha2RangeMapOptions(),
|
||||
Options: *NewDashboardV2beta1RangeMapOptions(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,14 +479,14 @@ func NewDashboardRangeMap() *DashboardRangeMap {
|
|||
type DashboardRegexMap struct {
|
||||
Type DashboardMappingType `json:"type"`
|
||||
// Regular expression to match against and the result to apply when the value matches the regex
|
||||
Options DashboardV2alpha2RegexMapOptions `json:"options"`
|
||||
Options DashboardV2beta1RegexMapOptions `json:"options"`
|
||||
}
|
||||
|
||||
// NewDashboardRegexMap creates a new DashboardRegexMap object.
|
||||
func NewDashboardRegexMap() *DashboardRegexMap {
|
||||
return &DashboardRegexMap{
|
||||
Type: DashboardMappingTypeRegex,
|
||||
Options: *NewDashboardV2alpha2RegexMapOptions(),
|
||||
Options: *NewDashboardV2beta1RegexMapOptions(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -501,15 +495,15 @@ func NewDashboardRegexMap() *DashboardRegexMap {
|
|||
// For example, you can configure a special value mapping so that null values appear as N/A.
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardSpecialValueMap struct {
|
||||
Type DashboardMappingType `json:"type"`
|
||||
Options DashboardV2alpha2SpecialValueMapOptions `json:"options"`
|
||||
Type DashboardMappingType `json:"type"`
|
||||
Options DashboardV2beta1SpecialValueMapOptions `json:"options"`
|
||||
}
|
||||
|
||||
// NewDashboardSpecialValueMap creates a new DashboardSpecialValueMap object.
|
||||
func NewDashboardSpecialValueMap() *DashboardSpecialValueMap {
|
||||
return &DashboardSpecialValueMap{
|
||||
Type: DashboardMappingTypeSpecial,
|
||||
Options: *NewDashboardV2alpha2SpecialValueMapOptions(),
|
||||
Options: *NewDashboardV2beta1SpecialValueMapOptions(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1229,7 +1223,6 @@ type DashboardQueryVariableSpec struct {
|
|||
Refresh DashboardVariableRefresh `json:"refresh"`
|
||||
SkipUrlSync bool `json:"skipUrlSync"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
Datasource *DashboardDataSourceRef `json:"datasource,omitempty"`
|
||||
Query DashboardDataQueryKind `json:"query"`
|
||||
Regex string `json:"regex"`
|
||||
Sort DashboardVariableSort `json:"sort"`
|
||||
|
@ -1591,8 +1584,10 @@ func NewDashboardCustomVariableSpec() *DashboardCustomVariableSpec {
|
|||
// Group variable kind
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardGroupByVariableKind struct {
|
||||
Kind string `json:"kind"`
|
||||
Spec DashboardGroupByVariableSpec `json:"spec"`
|
||||
Kind string `json:"kind"`
|
||||
Group string `json:"group"`
|
||||
Datasource *DashboardV2beta1GroupByVariableKindDatasource `json:"datasource,omitempty"`
|
||||
Spec DashboardGroupByVariableSpec `json:"spec"`
|
||||
}
|
||||
|
||||
// NewDashboardGroupByVariableKind creates a new DashboardGroupByVariableKind object.
|
||||
|
@ -1607,7 +1602,6 @@ func NewDashboardGroupByVariableKind() *DashboardGroupByVariableKind {
|
|||
// +k8s:openapi-gen=true
|
||||
type DashboardGroupByVariableSpec struct {
|
||||
Name string `json:"name"`
|
||||
Datasource *DashboardDataSourceRef `json:"datasource,omitempty"`
|
||||
DefaultValue *DashboardVariableOption `json:"defaultValue,omitempty"`
|
||||
Current DashboardVariableOption `json:"current"`
|
||||
Options []DashboardVariableOption `json:"options"`
|
||||
|
@ -1640,8 +1634,10 @@ func NewDashboardGroupByVariableSpec() *DashboardGroupByVariableSpec {
|
|||
// Adhoc variable kind
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardAdhocVariableKind struct {
|
||||
Kind string `json:"kind"`
|
||||
Spec DashboardAdhocVariableSpec `json:"spec"`
|
||||
Kind string `json:"kind"`
|
||||
Group string `json:"group"`
|
||||
Datasource *DashboardV2beta1AdhocVariableKindDatasource `json:"datasource,omitempty"`
|
||||
Spec DashboardAdhocVariableSpec `json:"spec"`
|
||||
}
|
||||
|
||||
// NewDashboardAdhocVariableKind creates a new DashboardAdhocVariableKind object.
|
||||
|
@ -1656,7 +1652,6 @@ func NewDashboardAdhocVariableKind() *DashboardAdhocVariableKind {
|
|||
// +k8s:openapi-gen=true
|
||||
type DashboardAdhocVariableSpec struct {
|
||||
Name string `json:"name"`
|
||||
Datasource *DashboardDataSourceRef `json:"datasource,omitempty"`
|
||||
BaseFilters []DashboardAdHocFilterWithLabels `json:"baseFilters"`
|
||||
Filters []DashboardAdHocFilterWithLabels `json:"filters"`
|
||||
DefaultKeys []DashboardMetricFindValue `json:"defaultKeys"`
|
||||
|
@ -1771,21 +1766,31 @@ func NewDashboardSpec() *DashboardSpec {
|
|||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardV2alpha2FieldConfigSourceOverrides struct {
|
||||
type DashboardV2beta1DataQueryKindDatasource struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// NewDashboardV2beta1DataQueryKindDatasource creates a new DashboardV2beta1DataQueryKindDatasource object.
|
||||
func NewDashboardV2beta1DataQueryKindDatasource() *DashboardV2beta1DataQueryKindDatasource {
|
||||
return &DashboardV2beta1DataQueryKindDatasource{}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardV2beta1FieldConfigSourceOverrides struct {
|
||||
Matcher DashboardMatcherConfig `json:"matcher"`
|
||||
Properties []DashboardDynamicConfigValue `json:"properties"`
|
||||
}
|
||||
|
||||
// NewDashboardV2alpha2FieldConfigSourceOverrides creates a new DashboardV2alpha2FieldConfigSourceOverrides object.
|
||||
func NewDashboardV2alpha2FieldConfigSourceOverrides() *DashboardV2alpha2FieldConfigSourceOverrides {
|
||||
return &DashboardV2alpha2FieldConfigSourceOverrides{
|
||||
// NewDashboardV2beta1FieldConfigSourceOverrides creates a new DashboardV2beta1FieldConfigSourceOverrides object.
|
||||
func NewDashboardV2beta1FieldConfigSourceOverrides() *DashboardV2beta1FieldConfigSourceOverrides {
|
||||
return &DashboardV2beta1FieldConfigSourceOverrides{
|
||||
Matcher: *NewDashboardMatcherConfig(),
|
||||
Properties: []DashboardDynamicConfigValue{},
|
||||
}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardV2alpha2RangeMapOptions struct {
|
||||
type DashboardV2beta1RangeMapOptions struct {
|
||||
// Min value of the range. It can be null which means -Infinity
|
||||
From *float64 `json:"from"`
|
||||
// Max value of the range. It can be null which means +Infinity
|
||||
|
@ -1794,43 +1799,63 @@ type DashboardV2alpha2RangeMapOptions struct {
|
|||
Result DashboardValueMappingResult `json:"result"`
|
||||
}
|
||||
|
||||
// NewDashboardV2alpha2RangeMapOptions creates a new DashboardV2alpha2RangeMapOptions object.
|
||||
func NewDashboardV2alpha2RangeMapOptions() *DashboardV2alpha2RangeMapOptions {
|
||||
return &DashboardV2alpha2RangeMapOptions{
|
||||
// NewDashboardV2beta1RangeMapOptions creates a new DashboardV2beta1RangeMapOptions object.
|
||||
func NewDashboardV2beta1RangeMapOptions() *DashboardV2beta1RangeMapOptions {
|
||||
return &DashboardV2beta1RangeMapOptions{
|
||||
Result: *NewDashboardValueMappingResult(),
|
||||
}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardV2alpha2RegexMapOptions struct {
|
||||
type DashboardV2beta1RegexMapOptions struct {
|
||||
// Regular expression to match against
|
||||
Pattern string `json:"pattern"`
|
||||
// Config to apply when the value matches the regex
|
||||
Result DashboardValueMappingResult `json:"result"`
|
||||
}
|
||||
|
||||
// NewDashboardV2alpha2RegexMapOptions creates a new DashboardV2alpha2RegexMapOptions object.
|
||||
func NewDashboardV2alpha2RegexMapOptions() *DashboardV2alpha2RegexMapOptions {
|
||||
return &DashboardV2alpha2RegexMapOptions{
|
||||
// NewDashboardV2beta1RegexMapOptions creates a new DashboardV2beta1RegexMapOptions object.
|
||||
func NewDashboardV2beta1RegexMapOptions() *DashboardV2beta1RegexMapOptions {
|
||||
return &DashboardV2beta1RegexMapOptions{
|
||||
Result: *NewDashboardValueMappingResult(),
|
||||
}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardV2alpha2SpecialValueMapOptions struct {
|
||||
type DashboardV2beta1SpecialValueMapOptions struct {
|
||||
// Special value to match against
|
||||
Match DashboardSpecialValueMatch `json:"match"`
|
||||
// Config to apply when the value matches the special value
|
||||
Result DashboardValueMappingResult `json:"result"`
|
||||
}
|
||||
|
||||
// NewDashboardV2alpha2SpecialValueMapOptions creates a new DashboardV2alpha2SpecialValueMapOptions object.
|
||||
func NewDashboardV2alpha2SpecialValueMapOptions() *DashboardV2alpha2SpecialValueMapOptions {
|
||||
return &DashboardV2alpha2SpecialValueMapOptions{
|
||||
// NewDashboardV2beta1SpecialValueMapOptions creates a new DashboardV2beta1SpecialValueMapOptions object.
|
||||
func NewDashboardV2beta1SpecialValueMapOptions() *DashboardV2beta1SpecialValueMapOptions {
|
||||
return &DashboardV2beta1SpecialValueMapOptions{
|
||||
Result: *NewDashboardValueMappingResult(),
|
||||
}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardV2beta1GroupByVariableKindDatasource struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// NewDashboardV2beta1GroupByVariableKindDatasource creates a new DashboardV2beta1GroupByVariableKindDatasource object.
|
||||
func NewDashboardV2beta1GroupByVariableKindDatasource() *DashboardV2beta1GroupByVariableKindDatasource {
|
||||
return &DashboardV2beta1GroupByVariableKindDatasource{}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardV2beta1AdhocVariableKindDatasource struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// NewDashboardV2beta1AdhocVariableKindDatasource creates a new DashboardV2beta1AdhocVariableKindDatasource object.
|
||||
func NewDashboardV2beta1AdhocVariableKindDatasource() *DashboardV2beta1AdhocVariableKindDatasource {
|
||||
return &DashboardV2beta1AdhocVariableKindDatasource{}
|
||||
}
|
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type DashboardRepeatOptionsDirection string
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v2alpha2
|
||||
package v2beta1
|
||||
|
||||
// ConversionStatus is the status of the conversion of the dashboard.
|
||||
// +k8s:openapi-gen=true
|
|
@ -7,4 +7,4 @@
|
|||
// because grafana-app-sdk already provides deepcopy functions.
|
||||
// Kinds which are not generated by the SDK are explicitly opted in to deepcopy generation.
|
||||
|
||||
package v2alpha2 // import "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
package v2beta1 // import "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
|
@ -1,4 +1,4 @@
|
|||
package v2alpha2
|
||||
package v2beta1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
const (
|
||||
GROUP = "dashboard.grafana.app"
|
||||
VERSION = "v2alpha2"
|
||||
VERSION = "v2beta1"
|
||||
APIVERSION = GROUP + "/" + VERSION
|
||||
)
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package v2alpha2
|
||||
package v2beta1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
@ -1,4 +1,4 @@
|
|||
package v2alpha2
|
||||
package v2beta1
|
||||
|
||||
import (
|
||||
_ "embed"
|
|
@ -0,0 +1,175 @@
|
|||
//go:build !ignore_autogenerated
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
// Code generated by conversion-gen. DO NOT EDIT.
|
||||
|
||||
package v2beta1
|
||||
|
||||
import (
|
||||
url "net/url"
|
||||
unsafe "unsafe"
|
||||
|
||||
dashboard "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard"
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
func init() {
|
||||
localSchemeBuilder.Register(RegisterConversions)
|
||||
}
|
||||
|
||||
// RegisterConversions adds conversion functions to the given scheme.
|
||||
// Public to allow building arbitrary schemes.
|
||||
func RegisterConversions(s *runtime.Scheme) error {
|
||||
if err := s.AddGeneratedConversionFunc((*AnnotationActions)(nil), (*dashboard.AnnotationActions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v2beta1_AnnotationActions_To_dashboard_AnnotationActions(a.(*AnnotationActions), b.(*dashboard.AnnotationActions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*dashboard.AnnotationActions)(nil), (*AnnotationActions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_dashboard_AnnotationActions_To_v2beta1_AnnotationActions(a.(*dashboard.AnnotationActions), b.(*AnnotationActions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*AnnotationPermission)(nil), (*dashboard.AnnotationPermission)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v2beta1_AnnotationPermission_To_dashboard_AnnotationPermission(a.(*AnnotationPermission), b.(*dashboard.AnnotationPermission), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*dashboard.AnnotationPermission)(nil), (*AnnotationPermission)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_dashboard_AnnotationPermission_To_v2beta1_AnnotationPermission(a.(*dashboard.AnnotationPermission), b.(*AnnotationPermission), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*DashboardAccess)(nil), (*dashboard.DashboardAccess)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_v2beta1_DashboardAccess_To_dashboard_DashboardAccess(a.(*DashboardAccess), b.(*dashboard.DashboardAccess), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*dashboard.DashboardAccess)(nil), (*DashboardAccess)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_dashboard_DashboardAccess_To_v2beta1_DashboardAccess(a.(*dashboard.DashboardAccess), b.(*DashboardAccess), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddGeneratedConversionFunc((*url.Values)(nil), (*VersionsQueryOptions)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_url_Values_To_v2beta1_VersionsQueryOptions(a.(*url.Values), b.(*VersionsQueryOptions), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func autoConvert_v2beta1_AnnotationActions_To_dashboard_AnnotationActions(in *AnnotationActions, out *dashboard.AnnotationActions, s conversion.Scope) error {
|
||||
out.CanAdd = in.CanAdd
|
||||
out.CanEdit = in.CanEdit
|
||||
out.CanDelete = in.CanDelete
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2beta1_AnnotationActions_To_dashboard_AnnotationActions is an autogenerated conversion function.
|
||||
func Convert_v2beta1_AnnotationActions_To_dashboard_AnnotationActions(in *AnnotationActions, out *dashboard.AnnotationActions, s conversion.Scope) error {
|
||||
return autoConvert_v2beta1_AnnotationActions_To_dashboard_AnnotationActions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_dashboard_AnnotationActions_To_v2beta1_AnnotationActions(in *dashboard.AnnotationActions, out *AnnotationActions, s conversion.Scope) error {
|
||||
out.CanAdd = in.CanAdd
|
||||
out.CanEdit = in.CanEdit
|
||||
out.CanDelete = in.CanDelete
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_dashboard_AnnotationActions_To_v2beta1_AnnotationActions is an autogenerated conversion function.
|
||||
func Convert_dashboard_AnnotationActions_To_v2beta1_AnnotationActions(in *dashboard.AnnotationActions, out *AnnotationActions, s conversion.Scope) error {
|
||||
return autoConvert_dashboard_AnnotationActions_To_v2beta1_AnnotationActions(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v2beta1_AnnotationPermission_To_dashboard_AnnotationPermission(in *AnnotationPermission, out *dashboard.AnnotationPermission, s conversion.Scope) error {
|
||||
if err := Convert_v2beta1_AnnotationActions_To_dashboard_AnnotationActions(&in.Dashboard, &out.Dashboard, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := Convert_v2beta1_AnnotationActions_To_dashboard_AnnotationActions(&in.Organization, &out.Organization, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2beta1_AnnotationPermission_To_dashboard_AnnotationPermission is an autogenerated conversion function.
|
||||
func Convert_v2beta1_AnnotationPermission_To_dashboard_AnnotationPermission(in *AnnotationPermission, out *dashboard.AnnotationPermission, s conversion.Scope) error {
|
||||
return autoConvert_v2beta1_AnnotationPermission_To_dashboard_AnnotationPermission(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_dashboard_AnnotationPermission_To_v2beta1_AnnotationPermission(in *dashboard.AnnotationPermission, out *AnnotationPermission, s conversion.Scope) error {
|
||||
if err := Convert_dashboard_AnnotationActions_To_v2beta1_AnnotationActions(&in.Dashboard, &out.Dashboard, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := Convert_dashboard_AnnotationActions_To_v2beta1_AnnotationActions(&in.Organization, &out.Organization, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_dashboard_AnnotationPermission_To_v2beta1_AnnotationPermission is an autogenerated conversion function.
|
||||
func Convert_dashboard_AnnotationPermission_To_v2beta1_AnnotationPermission(in *dashboard.AnnotationPermission, out *AnnotationPermission, s conversion.Scope) error {
|
||||
return autoConvert_dashboard_AnnotationPermission_To_v2beta1_AnnotationPermission(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_v2beta1_DashboardAccess_To_dashboard_DashboardAccess(in *DashboardAccess, out *dashboard.DashboardAccess, s conversion.Scope) error {
|
||||
out.Slug = in.Slug
|
||||
out.Url = in.Url
|
||||
out.CanSave = in.CanSave
|
||||
out.CanEdit = in.CanEdit
|
||||
out.CanAdmin = in.CanAdmin
|
||||
out.CanStar = in.CanStar
|
||||
out.CanDelete = in.CanDelete
|
||||
out.AnnotationsPermissions = (*dashboard.AnnotationPermission)(unsafe.Pointer(in.AnnotationsPermissions))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_v2beta1_DashboardAccess_To_dashboard_DashboardAccess is an autogenerated conversion function.
|
||||
func Convert_v2beta1_DashboardAccess_To_dashboard_DashboardAccess(in *DashboardAccess, out *dashboard.DashboardAccess, s conversion.Scope) error {
|
||||
return autoConvert_v2beta1_DashboardAccess_To_dashboard_DashboardAccess(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_dashboard_DashboardAccess_To_v2beta1_DashboardAccess(in *dashboard.DashboardAccess, out *DashboardAccess, s conversion.Scope) error {
|
||||
out.Slug = in.Slug
|
||||
out.Url = in.Url
|
||||
out.CanSave = in.CanSave
|
||||
out.CanEdit = in.CanEdit
|
||||
out.CanAdmin = in.CanAdmin
|
||||
out.CanStar = in.CanStar
|
||||
out.CanDelete = in.CanDelete
|
||||
out.AnnotationsPermissions = (*AnnotationPermission)(unsafe.Pointer(in.AnnotationsPermissions))
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_dashboard_DashboardAccess_To_v2beta1_DashboardAccess is an autogenerated conversion function.
|
||||
func Convert_dashboard_DashboardAccess_To_v2beta1_DashboardAccess(in *dashboard.DashboardAccess, out *DashboardAccess, s conversion.Scope) error {
|
||||
return autoConvert_dashboard_DashboardAccess_To_v2beta1_DashboardAccess(in, out, s)
|
||||
}
|
||||
|
||||
func autoConvert_url_Values_To_v2beta1_VersionsQueryOptions(in *url.Values, out *VersionsQueryOptions, s conversion.Scope) error {
|
||||
// WARNING: Field TypeMeta does not have json tag, skipping.
|
||||
|
||||
if values, ok := map[string][]string(*in)["path"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_string(&values, &out.Path, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Path = ""
|
||||
}
|
||||
if values, ok := map[string][]string(*in)["version"]; ok && len(values) > 0 {
|
||||
if err := runtime.Convert_Slice_string_To_int64(&values, &out.Version, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
out.Version = 0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert_url_Values_To_v2beta1_VersionsQueryOptions is an autogenerated conversion function.
|
||||
func Convert_url_Values_To_v2beta1_VersionsQueryOptions(in *url.Values, out *VersionsQueryOptions, s conversion.Scope) error {
|
||||
return autoConvert_url_Values_To_v2beta1_VersionsQueryOptions(in, out, s)
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
// Code generated by deepcopy-gen. DO NOT EDIT.
|
||||
|
||||
package v2alpha2
|
||||
package v2beta1
|
||||
|
||||
import (
|
||||
v0alpha1 "github.com/grafana/grafana-plugin-sdk-go/experimental/apis/data/v0alpha1"
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
// Code generated by defaulter-gen. DO NOT EDIT.
|
||||
|
||||
package v2alpha2
|
||||
package v2beta1
|
||||
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,67 @@
|
|||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardAdHocFilterWithLabels,ValueLabels
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardAdHocFilterWithLabels,Values
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardAdhocVariableSpec,BaseFilters
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardAdhocVariableSpec,DefaultKeys
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardAdhocVariableSpec,Filters
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardAnnotationPanelFilter,Ids
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardAutoGridLayoutSpec,Items
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardConditionalRenderingGroupSpec,Items
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardCustomVariableSpec,Options
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardDashboardLink,Tags
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardDatasourceVariableSpec,Options
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardFieldConfig,Links
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardFieldConfig,Mappings
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardFieldConfigSource,Overrides
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardGridLayoutSpec,Items
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardGroupByVariableSpec,Options
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardIntervalVariableSpec,Options
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardMetadata,Finalizers
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardPanelSpec,Links
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardQueryGroupSpec,Queries
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardQueryGroupSpec,Transformations
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardQueryVariableSpec,Options
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardQueryVariableSpec,StaticOptions
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardRowsLayoutSpec,Rows
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardSpec,Annotations
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardSpec,Links
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardSpec,Tags
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardSpec,Variables
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardStringOrArrayOfString,ArrayOfString
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardTabsLayoutSpec,Tabs
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardThresholdsConfig,Steps
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardTimeSettingsSpec,AutoRefreshIntervals
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardTimeSettingsSpec,QuickRanges
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardV2beta1FieldConfigSourceOverrides,Properties
|
||||
API rule violation: list_type_missing,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,LibraryPanelStatus,Warnings
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind,ConditionalRenderingDataKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind,ConditionalRenderingTimeRangeSizeKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind,ConditionalRenderingVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind,AutoGridLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind,GridLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind,RowsLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind,TabsLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind,AutoGridLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind,GridLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind,RowsLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind,TabsLayoutKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardIntervalVariableSpec,AutoCount
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardIntervalVariableSpec,AutoMin
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardPanelKindOrLibraryPanelKind,LibraryPanelKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardPanelKindOrLibraryPanelKind,PanelKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,AdhocVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,ConstantVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,CustomVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,DatasourceVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,GroupByVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,IntervalVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,QueryVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind,TextVariableKind
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardStringOrArrayOfString,ArrayOfString
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardStringOrArrayOfString,String
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardStringOrFloat64,Float64
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardStringOrFloat64,String
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,RangeMap
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,RegexMap
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,SpecialValueMap
|
||||
API rule violation: names_match,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardValueMapOrRangeMapOrRegexMapOrSpecialValueMap,ValueMap
|
||||
API rule violation: streaming_list_type_json_tags,github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1,DashboardList,ListMeta
|
|
@ -15,7 +15,7 @@ import (
|
|||
v0alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
v1beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
v2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
v2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
v2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
)
|
||||
|
||||
var appManifestData = app.ManifestData{
|
||||
|
@ -62,7 +62,7 @@ var appManifestData = app.ManifestData{
|
|||
},
|
||||
|
||||
{
|
||||
Name: "v2alpha2",
|
||||
Name: "v2beta1",
|
||||
Served: true,
|
||||
Kinds: []app.ManifestVersionKind{
|
||||
{
|
||||
|
@ -88,7 +88,7 @@ var kindVersionToGoType = map[string]resource.Kind{
|
|||
"Dashboard/v0alpha1": v0alpha1.DashboardKind(),
|
||||
"Dashboard/v1beta1": v1beta1.DashboardKind(),
|
||||
"Dashboard/v2alpha1": v2alpha1.DashboardKind(),
|
||||
"Dashboard/v2alpha2": v2alpha2.DashboardKind(),
|
||||
"Dashboard/v2beta1": v2beta1.DashboardKind(),
|
||||
}
|
||||
|
||||
// ManifestGoTypeAssociator returns the associated resource.Kind instance for a given Kind and Version, if one exists.
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
dashv2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
)
|
||||
|
||||
func RegisterConversions(s *runtime.Scheme) error {
|
||||
|
@ -22,8 +22,8 @@ func RegisterConversions(s *runtime.Scheme) error {
|
|||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*dashv0.Dashboard)(nil), (*dashv2alpha2.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V0_to_V2alpha2(a.(*dashv0.Dashboard), b.(*dashv2alpha2.Dashboard), scope)
|
||||
if err := s.AddConversionFunc((*dashv0.Dashboard)(nil), (*dashv2beta1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V0_to_V2beta1(a.(*dashv0.Dashboard), b.(*dashv2beta1.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ func RegisterConversions(s *runtime.Scheme) error {
|
|||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*dashv1.Dashboard)(nil), (*dashv2alpha2.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V1_to_V2alpha2(a.(*dashv1.Dashboard), b.(*dashv2alpha2.Dashboard), scope)
|
||||
if err := s.AddConversionFunc((*dashv1.Dashboard)(nil), (*dashv2beta1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V1_to_V2beta1(a.(*dashv1.Dashboard), b.(*dashv2beta1.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -56,25 +56,25 @@ func RegisterConversions(s *runtime.Scheme) error {
|
|||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*dashv2alpha1.Dashboard)(nil), (*dashv2alpha2.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V2alpha1_to_V2alpha2(a.(*dashv2alpha1.Dashboard), b.(*dashv2alpha2.Dashboard), scope)
|
||||
if err := s.AddConversionFunc((*dashv2alpha1.Dashboard)(nil), (*dashv2beta1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V2alpha1_to_V2beta1(a.(*dashv2alpha1.Dashboard), b.(*dashv2beta1.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// v2alpha2 conversions
|
||||
if err := s.AddConversionFunc((*dashv2alpha2.Dashboard)(nil), (*dashv0.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V2alpha2_to_V0(a.(*dashv2alpha2.Dashboard), b.(*dashv0.Dashboard), scope)
|
||||
// v2beta1 conversions
|
||||
if err := s.AddConversionFunc((*dashv2beta1.Dashboard)(nil), (*dashv0.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V2beta1_to_V0(a.(*dashv2beta1.Dashboard), b.(*dashv0.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*dashv2alpha2.Dashboard)(nil), (*dashv1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V2alpha2_to_V1(a.(*dashv2alpha2.Dashboard), b.(*dashv1.Dashboard), scope)
|
||||
if err := s.AddConversionFunc((*dashv2beta1.Dashboard)(nil), (*dashv1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V2beta1_to_V1(a.(*dashv2beta1.Dashboard), b.(*dashv1.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.AddConversionFunc((*dashv2alpha2.Dashboard)(nil), (*dashv2alpha1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V2alpha2_to_V2alpha1(a.(*dashv2alpha2.Dashboard), b.(*dashv2alpha1.Dashboard), scope)
|
||||
if err := s.AddConversionFunc((*dashv2beta1.Dashboard)(nil), (*dashv2alpha1.Dashboard)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||
return Convert_V2beta1_to_V2alpha1(a.(*dashv2beta1.Dashboard), b.(*dashv2alpha1.Dashboard), scope)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package conversion
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
@ -9,10 +12,11 @@ import (
|
|||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/apis"
|
||||
dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
dashv2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration/testutil"
|
||||
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
|
||||
|
@ -27,7 +31,7 @@ func TestConversionMatrixExist(t *testing.T) {
|
|||
&dashv0.Dashboard{Spec: common.Unstructured{Object: map[string]any{"title": "dashboardV0"}}},
|
||||
&dashv1.Dashboard{Spec: common.Unstructured{Object: map[string]any{"title": "dashboardV1"}}},
|
||||
&dashv2alpha1.Dashboard{Spec: dashv2alpha1.DashboardSpec{Title: "dashboardV2alpha1"}},
|
||||
&dashv2alpha2.Dashboard{Spec: dashv2alpha2.DashboardSpec{Title: "dashboardV2alpha2"}},
|
||||
&dashv2beta1.Dashboard{Spec: dashv2beta1.DashboardSpec{Title: "dashboardV2beta1"}},
|
||||
}
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
|
@ -69,3 +73,150 @@ func TestDeepCopyValid(t *testing.T) {
|
|||
metaCopy.SetFolder("XYZ")
|
||||
require.Equal(t, "f1", meta1.GetFolder()) // 💣💣💣
|
||||
}
|
||||
|
||||
func TestDashboardConversionToAllVersions(t *testing.T) {
|
||||
// Initialize the migrator with a test data source provider
|
||||
migration.Initialize(testutil.GetTestProvider())
|
||||
|
||||
// Set up conversion scheme
|
||||
scheme := runtime.NewScheme()
|
||||
err := RegisterConversions(scheme)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Read all files from input directory
|
||||
files, err := os.ReadDir(filepath.Join("testdata", "input"))
|
||||
require.NoError(t, err, "Failed to read input directory")
|
||||
|
||||
for _, file := range files {
|
||||
if file.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
t.Run(fmt.Sprintf("Convert_%s", file.Name()), func(t *testing.T) {
|
||||
// Read input dashboard file
|
||||
inputFile := filepath.Join("testdata", "input", file.Name())
|
||||
// ignore gosec G304 as this function is only used in the test process
|
||||
//nolint:gosec
|
||||
inputData, err := os.ReadFile(inputFile)
|
||||
require.NoError(t, err, "Failed to read input file")
|
||||
|
||||
// Parse the input dashboard to get its version
|
||||
var rawDash map[string]interface{}
|
||||
err = json.Unmarshal(inputData, &rawDash)
|
||||
require.NoError(t, err, "Failed to unmarshal dashboard JSON")
|
||||
|
||||
// Extract apiVersion
|
||||
apiVersion, ok := rawDash["apiVersion"].(string)
|
||||
require.True(t, ok, "apiVersion not found or not a string")
|
||||
|
||||
// Parse group and version from apiVersion (format: "group/version")
|
||||
parts := strings.Split(apiVersion, "/")
|
||||
require.Equal(t, 2, len(parts), "apiVersion should be in format 'group/version'")
|
||||
sourceVersion := parts[1]
|
||||
|
||||
// Create source object based on version
|
||||
var sourceDash v1.Object
|
||||
switch sourceVersion {
|
||||
case "v0alpha1":
|
||||
var dash dashv0.Dashboard
|
||||
err = json.Unmarshal(inputData, &dash)
|
||||
sourceDash = &dash
|
||||
case "v1beta1":
|
||||
var dash dashv1.Dashboard
|
||||
err = json.Unmarshal(inputData, &dash)
|
||||
sourceDash = &dash
|
||||
case "v2alpha1":
|
||||
var dash dashv2alpha1.Dashboard
|
||||
err = json.Unmarshal(inputData, &dash)
|
||||
sourceDash = &dash
|
||||
case "v2beta1":
|
||||
var dash dashv2beta1.Dashboard
|
||||
err = json.Unmarshal(inputData, &dash)
|
||||
sourceDash = &dash
|
||||
default:
|
||||
t.Fatalf("Unsupported source version: %s", sourceVersion)
|
||||
}
|
||||
require.NoError(t, err, "Failed to unmarshal dashboard into typed object")
|
||||
|
||||
// Ensure output directory exists
|
||||
outDir := filepath.Join("testdata", "output")
|
||||
// ignore gosec G301 as this function is only used in the test process
|
||||
//nolint:gosec
|
||||
err = os.MkdirAll(outDir, 0755)
|
||||
require.NoError(t, err, "Failed to create output directory")
|
||||
|
||||
// Get target versions from the dashboard manifest
|
||||
manifest := apis.LocalManifest()
|
||||
targetVersions := make(map[string]runtime.Object)
|
||||
|
||||
// Get original filename without extension
|
||||
originalName := strings.TrimSuffix(file.Name(), ".json")
|
||||
|
||||
// Get all Dashboard versions from the manifest
|
||||
for _, kind := range manifest.ManifestData.Kinds() {
|
||||
if kind.Kind == "Dashboard" {
|
||||
for _, version := range kind.Versions {
|
||||
// Skip converting to the same version
|
||||
if version.VersionName == sourceVersion {
|
||||
continue
|
||||
}
|
||||
|
||||
filename := fmt.Sprintf("%s.%s.json", originalName, version.VersionName)
|
||||
|
||||
// Create target object based on version
|
||||
switch version.VersionName {
|
||||
case "v0alpha1":
|
||||
targetVersions[filename] = &dashv0.Dashboard{}
|
||||
case "v1beta1":
|
||||
targetVersions[filename] = &dashv1.Dashboard{}
|
||||
case "v2alpha1":
|
||||
targetVersions[filename] = &dashv2alpha1.Dashboard{}
|
||||
case "v2beta1":
|
||||
targetVersions[filename] = &dashv2beta1.Dashboard{}
|
||||
default:
|
||||
t.Logf("Unknown version %s, skipping", version.VersionName)
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Convert to each target version
|
||||
for filename, target := range targetVersions {
|
||||
t.Run(fmt.Sprintf("Convert_to_%s", filename), func(t *testing.T) {
|
||||
// Create a copy of the input dashboard for conversion
|
||||
inputCopy := sourceDash.(runtime.Object).DeepCopyObject()
|
||||
|
||||
// Convert to target version
|
||||
err = scheme.Convert(inputCopy, target, nil)
|
||||
require.NoError(t, err, "Conversion failed for %s", filename)
|
||||
|
||||
// Test the changes in the conversion result
|
||||
testConversion(t, target.(v1.Object), filename, outDir)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func testConversion(t *testing.T, convertedDash v1.Object, filename, outputDir string) {
|
||||
t.Helper()
|
||||
|
||||
outPath := filepath.Join(outputDir, filename)
|
||||
outBytes, err := json.MarshalIndent(convertedDash, "", " ")
|
||||
require.NoError(t, err, "failed to marshal converted dashboard")
|
||||
|
||||
if _, err := os.Stat(outPath); os.IsNotExist(err) {
|
||||
err = os.WriteFile(outPath, outBytes, 0644)
|
||||
require.NoError(t, err, "failed to write new output file %s", outPath)
|
||||
t.Logf("✓ Created new output file: %s", filename)
|
||||
return
|
||||
}
|
||||
|
||||
// ignore gosec G304 as this function is only used in the test process
|
||||
//nolint:gosec
|
||||
existingBytes, err := os.ReadFile(outPath)
|
||||
require.NoError(t, err, "failed to read existing output file")
|
||||
require.JSONEq(t, string(existingBytes), string(outBytes), "%s did not match", outPath)
|
||||
t.Logf("✓ Conversion to %s matches existing file", filename)
|
||||
}
|
||||
|
|
462
apps/dashboard/pkg/migration/conversion/testdata/input/v2alpha1.complete.json
vendored
Normal file
462
apps/dashboard/pkg/migration/conversion/testdata/input/v2alpha1.complete.json
vendored
Normal file
|
@ -0,0 +1,462 @@
|
|||
{
|
||||
"apiVersion": "dashboard.grafana.app/v2alpha1",
|
||||
"kind": "Dashboard",
|
||||
"metadata": {
|
||||
"name": "test-v2alpha1-complete",
|
||||
"labels": {
|
||||
"category": "test"
|
||||
},
|
||||
"annotations": {
|
||||
"description": "Complete example of v2alpha1 dashboard features"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"title": "Test: Complete V2alpha1 Dashboard Example",
|
||||
"description": "This dashboard demonstrates all features that need to be converted from v2alpha1 to v2beta1",
|
||||
"editable": true,
|
||||
"liveNow": true,
|
||||
"preload": true,
|
||||
"cursorSync": "Tooltip",
|
||||
"tags": ["test", "example", "migration"],
|
||||
"annotations": [
|
||||
{
|
||||
"kind": "AnnotationQuery",
|
||||
"spec": {
|
||||
"builtIn": true,
|
||||
"datasource": {
|
||||
"type": "grafana",
|
||||
"uid": "-- Grafana --"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations & Alerts",
|
||||
"query": {
|
||||
"kind": "grafana",
|
||||
"spec": {
|
||||
"limit": 100,
|
||||
"matchAny": false,
|
||||
"tags": [],
|
||||
"type": "dashboard"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "AnnotationQuery",
|
||||
"spec": {
|
||||
"builtIn": false,
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "gdev-prometheus"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "yellow",
|
||||
"name": "Prometheus Annotations",
|
||||
"query": {
|
||||
"kind": "prometheus",
|
||||
"spec": {
|
||||
"expr": "changes(process_start_time_seconds[1m])",
|
||||
"refId": "Anno"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"variables": [
|
||||
{
|
||||
"kind": "QueryVariable",
|
||||
"spec": {
|
||||
"name": "prometheus_query",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "gdev-prometheus"
|
||||
},
|
||||
"query": {
|
||||
"kind": "prometheus",
|
||||
"spec": {
|
||||
"expr": "up"
|
||||
}
|
||||
},
|
||||
"refresh": "time",
|
||||
"regex": "",
|
||||
"sort": "alphabetical",
|
||||
"multi": true,
|
||||
"includeAll": true,
|
||||
"current": {
|
||||
"text": "All",
|
||||
"value": ["$__all"]
|
||||
},
|
||||
"hide": "dontHide",
|
||||
"label": "Prometheus Query",
|
||||
"description": "Shows all up metrics",
|
||||
"skipUrlSync": false,
|
||||
"definition": "up"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "TextVariable",
|
||||
"spec": {
|
||||
"name": "text_var",
|
||||
"label": "Text Variable",
|
||||
"description": "A simple text variable",
|
||||
"query": "server1,server2,server3",
|
||||
"current": {
|
||||
"selected": true,
|
||||
"text": "server1",
|
||||
"value": "server1"
|
||||
},
|
||||
"hide": "dontHide",
|
||||
"skipUrlSync": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "ConstantVariable",
|
||||
"spec": {
|
||||
"name": "constant_var",
|
||||
"label": "Constant",
|
||||
"description": "A constant value",
|
||||
"query": "production",
|
||||
"current": {
|
||||
"selected": true,
|
||||
"text": "production",
|
||||
"value": "production"
|
||||
},
|
||||
"hide": "dontHide",
|
||||
"skipUrlSync": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "DatasourceVariable",
|
||||
"spec": {
|
||||
"name": "ds_var",
|
||||
"label": "Datasource",
|
||||
"description": "Select a datasource",
|
||||
"pluginId": "prometheus",
|
||||
"refresh": "load",
|
||||
"regex": "/^gdev-/",
|
||||
"current": {
|
||||
"text": "gdev-prometheus",
|
||||
"value": "gdev-prometheus"
|
||||
},
|
||||
"options": [
|
||||
{
|
||||
"text": "gdev-prometheus",
|
||||
"value": "gdev-prometheus"
|
||||
}
|
||||
],
|
||||
"multi": false,
|
||||
"includeAll": false,
|
||||
"hide": "dontHide",
|
||||
"skipUrlSync": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "IntervalVariable",
|
||||
"spec": {
|
||||
"name": "interval",
|
||||
"label": "Interval",
|
||||
"description": "Time interval selection",
|
||||
"query": "1m,5m,10m,30m,1h,6h,12h,1d",
|
||||
"current": {
|
||||
"selected": true,
|
||||
"text": "5m",
|
||||
"value": "5m"
|
||||
},
|
||||
"options": [
|
||||
{
|
||||
"text": "1m",
|
||||
"value": "1m"
|
||||
},
|
||||
{
|
||||
"text": "5m",
|
||||
"value": "5m"
|
||||
},
|
||||
{
|
||||
"text": "10m",
|
||||
"value": "10m"
|
||||
},
|
||||
{
|
||||
"text": "30m",
|
||||
"value": "30m"
|
||||
},
|
||||
{
|
||||
"text": "1h",
|
||||
"value": "1h"
|
||||
},
|
||||
{
|
||||
"text": "6h",
|
||||
"value": "6h"
|
||||
},
|
||||
{
|
||||
"text": "12h",
|
||||
"value": "12h"
|
||||
},
|
||||
{
|
||||
"text": "1d",
|
||||
"value": "1d"
|
||||
}
|
||||
],
|
||||
"auto": true,
|
||||
"auto_min": "10s",
|
||||
"auto_count": 30,
|
||||
"refresh": "load",
|
||||
"hide": "dontHide",
|
||||
"skipUrlSync": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "CustomVariable",
|
||||
"spec": {
|
||||
"name": "custom_var",
|
||||
"label": "Custom Options",
|
||||
"description": "Custom multi-value variable",
|
||||
"query": "prod : Production, staging : Staging, dev : Development",
|
||||
"current": {
|
||||
"text": ["Production"],
|
||||
"value": ["prod"]
|
||||
},
|
||||
"options": [
|
||||
{
|
||||
"text": "Production",
|
||||
"value": "prod"
|
||||
},
|
||||
{
|
||||
"text": "Staging",
|
||||
"value": "staging"
|
||||
},
|
||||
{
|
||||
"text": "Development",
|
||||
"value": "dev"
|
||||
}
|
||||
],
|
||||
"multi": true,
|
||||
"includeAll": true,
|
||||
"allValue": "*",
|
||||
"hide": "dontHide",
|
||||
"skipUrlSync": false,
|
||||
"allowCustomValue": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "GroupByVariable",
|
||||
"spec": {
|
||||
"name": "group_by",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "gdev-prometheus"
|
||||
},
|
||||
"current": {
|
||||
"text": "instance",
|
||||
"value": "instance"
|
||||
},
|
||||
"description": "Group metrics by label",
|
||||
"hide": "dontHide",
|
||||
"label": "Group By"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "AdhocVariable",
|
||||
"spec": {
|
||||
"name": "filters",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "gdev-prometheus"
|
||||
},
|
||||
"baseFilters": [
|
||||
{
|
||||
"key": "job",
|
||||
"operator": "=",
|
||||
"value": "grafana",
|
||||
"condition": "AND"
|
||||
}
|
||||
],
|
||||
"filters": [],
|
||||
"hide": "dontHide",
|
||||
"label": "Filters",
|
||||
"defaultKeys": [
|
||||
{
|
||||
"text": "job",
|
||||
"value": "job",
|
||||
"expandable": true
|
||||
},
|
||||
{
|
||||
"text": "instance",
|
||||
"value": "instance",
|
||||
"expandable": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"elements": {
|
||||
"panel-1": {
|
||||
"kind": "Panel",
|
||||
"spec": {
|
||||
"id": 1,
|
||||
"title": "Panel with Conditional Rendering",
|
||||
"description": "This panel demonstrates conditional rendering features",
|
||||
"data": {
|
||||
"kind": "QueryGroup",
|
||||
"spec": {
|
||||
"queries": [
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"refId": "A",
|
||||
"datasource": {
|
||||
"uid": "gdev-prometheus"
|
||||
},
|
||||
"query": {
|
||||
"kind": "prometheus",
|
||||
"spec": {
|
||||
"expr": "up{job=\"grafana\"}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"transformations": [
|
||||
{
|
||||
"kind": "reduce",
|
||||
"spec": {
|
||||
"id": "reduce",
|
||||
"options": {
|
||||
"mode": "reduceFields",
|
||||
"includeTimeField": false,
|
||||
"reducers": ["mean"]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"vizConfig": {
|
||||
"kind": "stat",
|
||||
"spec": {
|
||||
"pluginVersion": "12.1.0-pre",
|
||||
"options": {
|
||||
"colorMode": "value",
|
||||
"graphMode": "area",
|
||||
"justifyMode": "auto",
|
||||
"textMode": "auto"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "thresholds"
|
||||
},
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "red",
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"color": "green",
|
||||
"value": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"mappings": [
|
||||
{
|
||||
"type": "value",
|
||||
"options": {
|
||||
"0": {
|
||||
"text": "Down",
|
||||
"color": "red"
|
||||
},
|
||||
"1": {
|
||||
"text": "Up",
|
||||
"color": "green"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"layout": {
|
||||
"kind": "RowsLayout",
|
||||
"spec": {
|
||||
"rows": [
|
||||
{
|
||||
"kind": "Row",
|
||||
"spec": {
|
||||
"title": "Conditional Row",
|
||||
"collapse": false,
|
||||
"hideHeader": false,
|
||||
"fillScreen": false,
|
||||
"conditionalRendering": {
|
||||
"kind": "ConditionalRenderingGroup",
|
||||
"spec": {
|
||||
"visibility": "show",
|
||||
"condition": "and",
|
||||
"items": [
|
||||
{
|
||||
"kind": "ConditionalRenderingVariable",
|
||||
"spec": {
|
||||
"variable": "group_by",
|
||||
"operator": "includes",
|
||||
"value": "instance"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "ConditionalRenderingData",
|
||||
"spec": {
|
||||
"value": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "ConditionalRenderingTimeRangeSize",
|
||||
"spec": {
|
||||
"value": "1h"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"layout": {
|
||||
"kind": "GridLayout",
|
||||
"spec": {
|
||||
"items": [
|
||||
{
|
||||
"kind": "GridLayoutItem",
|
||||
"spec": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": 24,
|
||||
"height": 8,
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-1"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"timeSettings": {
|
||||
"timezone": "browser",
|
||||
"weekStart": "monday",
|
||||
"fiscalYearStartMonth": 0,
|
||||
"autoRefresh": "10s",
|
||||
"autoRefreshIntervals": ["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"],
|
||||
"from": "now-6h",
|
||||
"to": "now",
|
||||
"hideTimepicker": false
|
||||
}
|
||||
}
|
||||
}
|
1001
apps/dashboard/pkg/migration/conversion/testdata/input/v2alpha1.ds-data-query.json
vendored
Normal file
1001
apps/dashboard/pkg/migration/conversion/testdata/input/v2alpha1.ds-data-query.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
73
apps/dashboard/pkg/migration/conversion/testdata/input/v2alpha1.groupby-adhoc-vars.json
vendored
Normal file
73
apps/dashboard/pkg/migration/conversion/testdata/input/v2alpha1.groupby-adhoc-vars.json
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
"apiVersion": "dashboard.grafana.app/v2alpha1",
|
||||
"kind": "Dashboard",
|
||||
"metadata": {
|
||||
"name": "test-v2alpha1-groupby-adhoc-vars"
|
||||
},
|
||||
"spec": {
|
||||
"title": "Test: V2alpha1 dashboard with group by and adhoc variables",
|
||||
"variables": [
|
||||
{
|
||||
"kind": "GroupByVariable",
|
||||
"spec": {
|
||||
"current": {
|
||||
"text": "text7",
|
||||
"value": "value7"
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "gdev-prometheus"
|
||||
},
|
||||
"description": "A group by variable",
|
||||
"hide": "dontHide",
|
||||
"label": "Group By Variable"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "AdhocVariable",
|
||||
"spec": {
|
||||
"baseFilters": [
|
||||
{
|
||||
"condition": "AND",
|
||||
"key": "key1",
|
||||
"operator": "=",
|
||||
"value": "value1"
|
||||
},
|
||||
{
|
||||
"condition": "OR",
|
||||
"key": "key2",
|
||||
"operator": "=",
|
||||
"value": "value2"
|
||||
}
|
||||
],
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "datasource-3"
|
||||
},
|
||||
"defaultKeys": [
|
||||
{
|
||||
"expandable": true,
|
||||
"group": "defaultGroup1",
|
||||
"text": "defaultKey1",
|
||||
"value": "defaultKey1"
|
||||
}
|
||||
],
|
||||
"description": "An adhoc variable",
|
||||
"filters": [
|
||||
{
|
||||
"condition": "AND",
|
||||
"key": "key3",
|
||||
"operator": "=",
|
||||
"value": "value3"
|
||||
}
|
||||
],
|
||||
"hide": "dontHide",
|
||||
"label": "Adhoc Variable",
|
||||
"name": "adhocVar",
|
||||
"skipUrlSync": false,
|
||||
"allowCustomValue": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
202
apps/dashboard/pkg/migration/conversion/testdata/input/v2alpha1.viz-config.json
vendored
Normal file
202
apps/dashboard/pkg/migration/conversion/testdata/input/v2alpha1.viz-config.json
vendored
Normal file
|
@ -0,0 +1,202 @@
|
|||
{
|
||||
"apiVersion": "dashboard.grafana.app/v2alpha1",
|
||||
"kind": "Dashboard",
|
||||
"metadata": {
|
||||
"name": "test-v2alpha1-viz-config",
|
||||
"labels": {},
|
||||
"annotations": {}
|
||||
},
|
||||
"spec": {
|
||||
"elements": {
|
||||
"panel-1": {
|
||||
"kind": "Panel",
|
||||
"spec": {
|
||||
"data": {
|
||||
"kind": "QueryGroup",
|
||||
"spec": {
|
||||
"queries": [
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"hidden": false,
|
||||
"datasource": {
|
||||
"uid": "gdev-testdata"
|
||||
},
|
||||
"query": {
|
||||
"kind": "grafana-testdata-datasource",
|
||||
"spec": {
|
||||
"scenarioId": "random_walk",
|
||||
"seriesCount": 3
|
||||
},
|
||||
"version": "v0"
|
||||
},
|
||||
"refId": "A"
|
||||
}
|
||||
}
|
||||
],
|
||||
"queryOptions": {},
|
||||
"transformations": []
|
||||
}
|
||||
},
|
||||
"description": "",
|
||||
"id": 1,
|
||||
"links": [],
|
||||
"title": "Simple timeseries (WITH DS REF)",
|
||||
"vizConfig": {
|
||||
"kind": "timeseries",
|
||||
"spec": {
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisBorderShow": false,
|
||||
"axisCenteredZero": false,
|
||||
"axisColorMode": "text",
|
||||
"axisLabel": "",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
"barWidthFactor": 0.6,
|
||||
"drawStyle": "line",
|
||||
"fillOpacity": 0,
|
||||
"gradientMode": "none",
|
||||
"hideFrom": {
|
||||
"legend": false,
|
||||
"tooltip": false,
|
||||
"viz": false
|
||||
},
|
||||
"insertNulls": false,
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
"scaleDistribution": {
|
||||
"type": "linear"
|
||||
},
|
||||
"showPoints": "auto",
|
||||
"spanNulls": false,
|
||||
"stacking": {
|
||||
"group": "A",
|
||||
"mode": "none"
|
||||
},
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"hideZeros": false,
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"pluginVersion": "12.1.0-pre"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"layout": {
|
||||
"kind": "AutoGridLayout",
|
||||
"spec": {
|
||||
"columnWidthMode": "standard",
|
||||
"items": [
|
||||
{
|
||||
"kind": "AutoGridLayoutItem",
|
||||
"spec": {
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-3"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "AutoGridLayoutItem",
|
||||
"spec": {
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-4"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "AutoGridLayoutItem",
|
||||
"spec": {
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-2"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "AutoGridLayoutItem",
|
||||
"spec": {
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-1"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "AutoGridLayoutItem",
|
||||
"spec": {
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-5"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "AutoGridLayoutItem",
|
||||
"spec": {
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-6"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"maxColumnCount": 3,
|
||||
"rowHeightMode": "standard"
|
||||
}
|
||||
},
|
||||
"links": [],
|
||||
"liveNow": false,
|
||||
"preload": false,
|
||||
"tags": [],
|
||||
"timeSettings": {
|
||||
"autoRefresh": "",
|
||||
"autoRefreshIntervals": ["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"],
|
||||
"fiscalYearStartMonth": 0,
|
||||
"from": "now-6h",
|
||||
"hideTimepicker": false,
|
||||
"timezone": "browser",
|
||||
"to": "now"
|
||||
},
|
||||
"title": "Test: V2alpha1 dashboard with viz config"
|
||||
},
|
||||
"status": {}
|
||||
}
|
||||
|
20
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.complete.v0alpha1.json
vendored
Normal file
20
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.complete.v0alpha1.json
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"metadata": {
|
||||
"name": "test-v2alpha1-complete",
|
||||
"creationTimestamp": null,
|
||||
"labels": {
|
||||
"category": "test"
|
||||
},
|
||||
"annotations": {
|
||||
"description": "Complete example of v2alpha1 dashboard features"
|
||||
}
|
||||
},
|
||||
"spec": null,
|
||||
"status": {
|
||||
"conversion": {
|
||||
"failed": true,
|
||||
"storedVersion": "v2alpha1",
|
||||
"error": "backend conversion not yet implemented"
|
||||
}
|
||||
}
|
||||
}
|
20
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.complete.v1beta1.json
vendored
Normal file
20
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.complete.v1beta1.json
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"metadata": {
|
||||
"name": "test-v2alpha1-complete",
|
||||
"creationTimestamp": null,
|
||||
"labels": {
|
||||
"category": "test"
|
||||
},
|
||||
"annotations": {
|
||||
"description": "Complete example of v2alpha1 dashboard features"
|
||||
}
|
||||
},
|
||||
"spec": null,
|
||||
"status": {
|
||||
"conversion": {
|
||||
"failed": true,
|
||||
"storedVersion": "v2alpha1",
|
||||
"error": "backend conversion not yet implemented"
|
||||
}
|
||||
}
|
||||
}
|
511
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.complete.v2beta1.json
vendored
Normal file
511
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.complete.v2beta1.json
vendored
Normal file
|
@ -0,0 +1,511 @@
|
|||
{
|
||||
"kind": "Dashboard",
|
||||
"apiVersion": "v2beta1",
|
||||
"metadata": {
|
||||
"name": "test-v2alpha1-complete",
|
||||
"creationTimestamp": null,
|
||||
"labels": {
|
||||
"category": "test"
|
||||
},
|
||||
"annotations": {
|
||||
"description": "Complete example of v2alpha1 dashboard features"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"annotations": [
|
||||
{
|
||||
"kind": "AnnotationQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "grafana",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "-- Grafana --"
|
||||
},
|
||||
"spec": {
|
||||
"limit": 100,
|
||||
"matchAny": false,
|
||||
"tags": [],
|
||||
"type": "dashboard"
|
||||
}
|
||||
},
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations \u0026 Alerts",
|
||||
"builtIn": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "AnnotationQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "prometheus",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "gdev-prometheus"
|
||||
},
|
||||
"spec": {
|
||||
"expr": "changes(process_start_time_seconds[1m])",
|
||||
"refId": "Anno"
|
||||
}
|
||||
},
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "yellow",
|
||||
"name": "Prometheus Annotations",
|
||||
"builtIn": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"cursorSync": "Tooltip",
|
||||
"description": "This dashboard demonstrates all features that need to be converted from v2alpha1 to v2beta1",
|
||||
"editable": true,
|
||||
"elements": {
|
||||
"panel-1": {
|
||||
"kind": "Panel",
|
||||
"spec": {
|
||||
"id": 1,
|
||||
"title": "Panel with Conditional Rendering",
|
||||
"description": "This panel demonstrates conditional rendering features",
|
||||
"links": [],
|
||||
"data": {
|
||||
"kind": "QueryGroup",
|
||||
"spec": {
|
||||
"queries": [
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "prometheus",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "gdev-prometheus"
|
||||
},
|
||||
"spec": {
|
||||
"expr": "up{job=\"grafana\"}"
|
||||
}
|
||||
},
|
||||
"refId": "A",
|
||||
"hidden": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"transformations": [
|
||||
{
|
||||
"kind": "reduce",
|
||||
"spec": {
|
||||
"id": "reduce",
|
||||
"options": {
|
||||
"includeTimeField": false,
|
||||
"mode": "reduceFields",
|
||||
"reducers": [
|
||||
"mean"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"queryOptions": {}
|
||||
}
|
||||
},
|
||||
"vizConfig": {
|
||||
"kind": "VizConfig",
|
||||
"group": "stat",
|
||||
"version": "12.1.0-pre",
|
||||
"spec": {
|
||||
"options": {
|
||||
"colorMode": "value",
|
||||
"graphMode": "area",
|
||||
"justifyMode": "auto",
|
||||
"textMode": "auto"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"mappings": [
|
||||
{
|
||||
"type": "value",
|
||||
"options": {
|
||||
"0": {
|
||||
"text": "Down",
|
||||
"color": "red"
|
||||
},
|
||||
"1": {
|
||||
"text": "Up",
|
||||
"color": "green"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"value": 0,
|
||||
"color": "red"
|
||||
},
|
||||
{
|
||||
"value": 1,
|
||||
"color": "green"
|
||||
}
|
||||
]
|
||||
},
|
||||
"color": {
|
||||
"mode": "thresholds"
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"layout": {
|
||||
"kind": "RowsLayout",
|
||||
"spec": {
|
||||
"rows": [
|
||||
{
|
||||
"kind": "Row",
|
||||
"spec": {
|
||||
"title": "Conditional Row",
|
||||
"collapse": false,
|
||||
"hideHeader": false,
|
||||
"fillScreen": false,
|
||||
"conditionalRendering": {
|
||||
"kind": "ConditionalRenderingGroup",
|
||||
"spec": {
|
||||
"visibility": "show",
|
||||
"condition": "and",
|
||||
"items": [
|
||||
{
|
||||
"kind": "ConditionalRenderingVariable",
|
||||
"spec": {
|
||||
"variable": "group_by",
|
||||
"operator": "includes",
|
||||
"value": "instance"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "ConditionalRenderingData",
|
||||
"spec": {
|
||||
"value": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "ConditionalRenderingTimeRangeSize",
|
||||
"spec": {
|
||||
"value": "1h"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"layout": {
|
||||
"kind": "GridLayout",
|
||||
"spec": {
|
||||
"items": [
|
||||
{
|
||||
"kind": "GridLayoutItem",
|
||||
"spec": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": 24,
|
||||
"height": 8,
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-1"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"links": [],
|
||||
"liveNow": true,
|
||||
"preload": true,
|
||||
"tags": [
|
||||
"test",
|
||||
"example",
|
||||
"migration"
|
||||
],
|
||||
"timeSettings": {
|
||||
"timezone": "browser",
|
||||
"from": "now-6h",
|
||||
"to": "now",
|
||||
"autoRefresh": "10s",
|
||||
"autoRefreshIntervals": [
|
||||
"5s",
|
||||
"10s",
|
||||
"30s",
|
||||
"1m",
|
||||
"5m",
|
||||
"15m",
|
||||
"30m",
|
||||
"1h",
|
||||
"2h",
|
||||
"1d"
|
||||
],
|
||||
"hideTimepicker": false,
|
||||
"weekStart": "monday",
|
||||
"fiscalYearStartMonth": 0
|
||||
},
|
||||
"title": "Test: Complete V2alpha1 Dashboard Example",
|
||||
"variables": [
|
||||
{
|
||||
"kind": "QueryVariable",
|
||||
"spec": {
|
||||
"name": "prometheus_query",
|
||||
"current": {
|
||||
"text": "All",
|
||||
"value": [
|
||||
"$__all"
|
||||
]
|
||||
},
|
||||
"label": "Prometheus Query",
|
||||
"hide": "dontHide",
|
||||
"refresh": "time",
|
||||
"skipUrlSync": false,
|
||||
"description": "Shows all up metrics",
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "prometheus",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "gdev-prometheus"
|
||||
},
|
||||
"spec": {
|
||||
"expr": "up"
|
||||
}
|
||||
},
|
||||
"regex": "",
|
||||
"sort": "alphabetical",
|
||||
"definition": "up",
|
||||
"options": null,
|
||||
"multi": true,
|
||||
"includeAll": true,
|
||||
"allowCustomValue": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "TextVariable",
|
||||
"spec": {
|
||||
"name": "text_var",
|
||||
"current": {
|
||||
"selected": true,
|
||||
"text": "server1",
|
||||
"value": "server1"
|
||||
},
|
||||
"query": "server1,server2,server3",
|
||||
"label": "Text Variable",
|
||||
"hide": "dontHide",
|
||||
"skipUrlSync": false,
|
||||
"description": "A simple text variable"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "ConstantVariable",
|
||||
"spec": {
|
||||
"name": "constant_var",
|
||||
"query": "production",
|
||||
"current": {
|
||||
"selected": true,
|
||||
"text": "production",
|
||||
"value": "production"
|
||||
},
|
||||
"label": "Constant",
|
||||
"hide": "dontHide",
|
||||
"skipUrlSync": true,
|
||||
"description": "A constant value"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "DatasourceVariable",
|
||||
"spec": {
|
||||
"name": "ds_var",
|
||||
"pluginId": "prometheus",
|
||||
"refresh": "load",
|
||||
"regex": "/^gdev-/",
|
||||
"current": {
|
||||
"text": "gdev-prometheus",
|
||||
"value": "gdev-prometheus"
|
||||
},
|
||||
"options": [
|
||||
{
|
||||
"text": "gdev-prometheus",
|
||||
"value": "gdev-prometheus"
|
||||
}
|
||||
],
|
||||
"multi": false,
|
||||
"includeAll": false,
|
||||
"label": "Datasource",
|
||||
"hide": "dontHide",
|
||||
"skipUrlSync": false,
|
||||
"description": "Select a datasource",
|
||||
"allowCustomValue": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "IntervalVariable",
|
||||
"spec": {
|
||||
"name": "interval",
|
||||
"query": "1m,5m,10m,30m,1h,6h,12h,1d",
|
||||
"current": {
|
||||
"selected": true,
|
||||
"text": "5m",
|
||||
"value": "5m"
|
||||
},
|
||||
"options": [
|
||||
{
|
||||
"text": "1m",
|
||||
"value": "1m"
|
||||
},
|
||||
{
|
||||
"text": "5m",
|
||||
"value": "5m"
|
||||
},
|
||||
{
|
||||
"text": "10m",
|
||||
"value": "10m"
|
||||
},
|
||||
{
|
||||
"text": "30m",
|
||||
"value": "30m"
|
||||
},
|
||||
{
|
||||
"text": "1h",
|
||||
"value": "1h"
|
||||
},
|
||||
{
|
||||
"text": "6h",
|
||||
"value": "6h"
|
||||
},
|
||||
{
|
||||
"text": "12h",
|
||||
"value": "12h"
|
||||
},
|
||||
{
|
||||
"text": "1d",
|
||||
"value": "1d"
|
||||
}
|
||||
],
|
||||
"auto": true,
|
||||
"auto_min": "10s",
|
||||
"auto_count": 30,
|
||||
"refresh": "load",
|
||||
"label": "Interval",
|
||||
"hide": "dontHide",
|
||||
"skipUrlSync": false,
|
||||
"description": "Time interval selection"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "CustomVariable",
|
||||
"spec": {
|
||||
"name": "custom_var",
|
||||
"query": "prod : Production, staging : Staging, dev : Development",
|
||||
"current": {
|
||||
"text": [
|
||||
"Production"
|
||||
],
|
||||
"value": [
|
||||
"prod"
|
||||
]
|
||||
},
|
||||
"options": [
|
||||
{
|
||||
"text": "Production",
|
||||
"value": "prod"
|
||||
},
|
||||
{
|
||||
"text": "Staging",
|
||||
"value": "staging"
|
||||
},
|
||||
{
|
||||
"text": "Development",
|
||||
"value": "dev"
|
||||
}
|
||||
],
|
||||
"multi": true,
|
||||
"includeAll": true,
|
||||
"allValue": "*",
|
||||
"label": "Custom Options",
|
||||
"hide": "dontHide",
|
||||
"skipUrlSync": false,
|
||||
"description": "Custom multi-value variable",
|
||||
"allowCustomValue": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "GroupByVariable",
|
||||
"group": "prometheus",
|
||||
"datasource": {
|
||||
"name": "gdev-prometheus"
|
||||
},
|
||||
"spec": {
|
||||
"name": "group_by",
|
||||
"current": {
|
||||
"text": "instance",
|
||||
"value": "instance"
|
||||
},
|
||||
"options": null,
|
||||
"multi": false,
|
||||
"label": "Group By",
|
||||
"hide": "dontHide",
|
||||
"skipUrlSync": false,
|
||||
"description": "Group metrics by label"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "AdhocVariable",
|
||||
"group": "prometheus",
|
||||
"datasource": {
|
||||
"name": "gdev-prometheus"
|
||||
},
|
||||
"spec": {
|
||||
"name": "filters",
|
||||
"baseFilters": [
|
||||
{
|
||||
"key": "job",
|
||||
"operator": "=",
|
||||
"value": "grafana",
|
||||
"condition": "AND"
|
||||
}
|
||||
],
|
||||
"filters": [],
|
||||
"defaultKeys": [
|
||||
{
|
||||
"text": "job",
|
||||
"value": "job",
|
||||
"expandable": true
|
||||
},
|
||||
{
|
||||
"text": "instance",
|
||||
"value": "instance",
|
||||
"expandable": true
|
||||
}
|
||||
],
|
||||
"label": "Filters",
|
||||
"hide": "dontHide",
|
||||
"skipUrlSync": false,
|
||||
"allowCustomValue": false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"status": {
|
||||
"conversion": {
|
||||
"failed": false,
|
||||
"storedVersion": "v2alpha1",
|
||||
"error": ""
|
||||
}
|
||||
}
|
||||
}
|
14
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.ds-data-query.v0alpha1.json
vendored
Normal file
14
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.ds-data-query.v0alpha1.json
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"metadata": {
|
||||
"name": "test-v2alpha1-annotations",
|
||||
"creationTimestamp": null
|
||||
},
|
||||
"spec": null,
|
||||
"status": {
|
||||
"conversion": {
|
||||
"failed": true,
|
||||
"storedVersion": "v2alpha1",
|
||||
"error": "backend conversion not yet implemented"
|
||||
}
|
||||
}
|
||||
}
|
14
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.ds-data-query.v1beta1.json
vendored
Normal file
14
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.ds-data-query.v1beta1.json
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"metadata": {
|
||||
"name": "test-v2alpha1-annotations",
|
||||
"creationTimestamp": null
|
||||
},
|
||||
"spec": null,
|
||||
"status": {
|
||||
"conversion": {
|
||||
"failed": true,
|
||||
"storedVersion": "v2alpha1",
|
||||
"error": "backend conversion not yet implemented"
|
||||
}
|
||||
}
|
||||
}
|
1094
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.ds-data-query.v2beta1.json
vendored
Normal file
1094
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.ds-data-query.v2beta1.json
vendored
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"metadata": {
|
||||
"name": "test-v2alpha1-groupby-adhoc-vars",
|
||||
"creationTimestamp": null
|
||||
},
|
||||
"spec": null,
|
||||
"status": {
|
||||
"conversion": {
|
||||
"failed": true,
|
||||
"storedVersion": "v2alpha1",
|
||||
"error": "backend conversion not yet implemented"
|
||||
}
|
||||
}
|
||||
}
|
14
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.groupby-adhoc-vars.v1beta1.json
vendored
Normal file
14
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.groupby-adhoc-vars.v1beta1.json
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"metadata": {
|
||||
"name": "test-v2alpha1-groupby-adhoc-vars",
|
||||
"creationTimestamp": null
|
||||
},
|
||||
"spec": null,
|
||||
"status": {
|
||||
"conversion": {
|
||||
"failed": true,
|
||||
"storedVersion": "v2alpha1",
|
||||
"error": "backend conversion not yet implemented"
|
||||
}
|
||||
}
|
||||
}
|
100
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.groupby-adhoc-vars.v2beta1.json
vendored
Normal file
100
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.groupby-adhoc-vars.v2beta1.json
vendored
Normal file
|
@ -0,0 +1,100 @@
|
|||
{
|
||||
"kind": "Dashboard",
|
||||
"apiVersion": "v2beta1",
|
||||
"metadata": {
|
||||
"name": "test-v2alpha1-groupby-adhoc-vars",
|
||||
"creationTimestamp": null
|
||||
},
|
||||
"spec": {
|
||||
"annotations": [],
|
||||
"cursorSync": "",
|
||||
"elements": {},
|
||||
"layout": null,
|
||||
"links": [],
|
||||
"preload": false,
|
||||
"tags": null,
|
||||
"timeSettings": {
|
||||
"from": "",
|
||||
"to": "",
|
||||
"autoRefresh": "",
|
||||
"autoRefreshIntervals": null,
|
||||
"hideTimepicker": false,
|
||||
"fiscalYearStartMonth": 0
|
||||
},
|
||||
"title": "Test: V2alpha1 dashboard with group by and adhoc variables",
|
||||
"variables": [
|
||||
{
|
||||
"kind": "GroupByVariable",
|
||||
"group": "prometheus",
|
||||
"datasource": {
|
||||
"name": "gdev-prometheus"
|
||||
},
|
||||
"spec": {
|
||||
"name": "",
|
||||
"current": {
|
||||
"text": "text7",
|
||||
"value": "value7"
|
||||
},
|
||||
"options": null,
|
||||
"multi": false,
|
||||
"label": "Group By Variable",
|
||||
"hide": "dontHide",
|
||||
"skipUrlSync": false,
|
||||
"description": "A group by variable"
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "AdhocVariable",
|
||||
"group": "prometheus",
|
||||
"datasource": {
|
||||
"name": "datasource-3"
|
||||
},
|
||||
"spec": {
|
||||
"name": "adhocVar",
|
||||
"baseFilters": [
|
||||
{
|
||||
"key": "key1",
|
||||
"operator": "=",
|
||||
"value": "value1",
|
||||
"condition": "AND"
|
||||
},
|
||||
{
|
||||
"key": "key2",
|
||||
"operator": "=",
|
||||
"value": "value2",
|
||||
"condition": "OR"
|
||||
}
|
||||
],
|
||||
"filters": [
|
||||
{
|
||||
"key": "key3",
|
||||
"operator": "=",
|
||||
"value": "value3",
|
||||
"condition": "AND"
|
||||
}
|
||||
],
|
||||
"defaultKeys": [
|
||||
{
|
||||
"text": "defaultKey1",
|
||||
"value": "defaultKey1",
|
||||
"group": "defaultGroup1",
|
||||
"expandable": true
|
||||
}
|
||||
],
|
||||
"label": "Adhoc Variable",
|
||||
"hide": "dontHide",
|
||||
"skipUrlSync": false,
|
||||
"description": "An adhoc variable",
|
||||
"allowCustomValue": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"status": {
|
||||
"conversion": {
|
||||
"failed": false,
|
||||
"storedVersion": "v2alpha1",
|
||||
"error": ""
|
||||
}
|
||||
}
|
||||
}
|
14
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.viz-config.v0alpha1.json
vendored
Normal file
14
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.viz-config.v0alpha1.json
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"metadata": {
|
||||
"name": "test-v2alpha1-viz-config",
|
||||
"creationTimestamp": null
|
||||
},
|
||||
"spec": null,
|
||||
"status": {
|
||||
"conversion": {
|
||||
"failed": true,
|
||||
"storedVersion": "v2alpha1",
|
||||
"error": "backend conversion not yet implemented"
|
||||
}
|
||||
}
|
||||
}
|
14
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.viz-config.v1beta1.json
vendored
Normal file
14
apps/dashboard/pkg/migration/conversion/testdata/output/v2alpha1.viz-config.v1beta1.json
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"metadata": {
|
||||
"name": "test-v2alpha1-viz-config",
|
||||
"creationTimestamp": null
|
||||
},
|
||||
"spec": null,
|
||||
"status": {
|
||||
"conversion": {
|
||||
"failed": true,
|
||||
"storedVersion": "v2alpha1",
|
||||
"error": "backend conversion not yet implemented"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,33 +1,21 @@
|
|||
{
|
||||
"apiVersion": "dashboard.grafana.app/v2alpha1",
|
||||
"kind": "Dashboard",
|
||||
"apiVersion": "v2beta1",
|
||||
"metadata": {
|
||||
"name": "sample-dash-v2"
|
||||
"name": "test-v2alpha1-viz-config",
|
||||
"creationTimestamp": null
|
||||
},
|
||||
"spec": {
|
||||
"annotations": [
|
||||
{
|
||||
"kind": "AnnotationQuery",
|
||||
"spec": {
|
||||
"builtIn": true,
|
||||
"datasource": {
|
||||
"type": "grafana",
|
||||
"uid": "-- Grafana --"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations \u0026 Alerts"
|
||||
}
|
||||
}
|
||||
],
|
||||
"cursorSync": "Off",
|
||||
"description": "",
|
||||
"editable": true,
|
||||
"annotations": [],
|
||||
"cursorSync": "",
|
||||
"elements": {
|
||||
"panel-1": {
|
||||
"kind": "Panel",
|
||||
"spec": {
|
||||
"id": 1,
|
||||
"title": "Simple timeseries (WITH DS REF)",
|
||||
"description": "",
|
||||
"links": [],
|
||||
"data": {
|
||||
"kind": "QueryGroup",
|
||||
"spec": {
|
||||
|
@ -35,28 +23,60 @@
|
|||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"hidden": false,
|
||||
"query": {
|
||||
"kind": "grafana-testdata-datasource",
|
||||
"spec": {}
|
||||
"kind": "DataQuery",
|
||||
"group": "grafana-testdata-datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "gdev-testdata"
|
||||
},
|
||||
"spec": {
|
||||
"scenarioId": "random_walk",
|
||||
"seriesCount": 3
|
||||
}
|
||||
},
|
||||
"refId": "A"
|
||||
"refId": "A",
|
||||
"hidden": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"queryOptions": {},
|
||||
"transformations": []
|
||||
"transformations": [],
|
||||
"queryOptions": {}
|
||||
}
|
||||
},
|
||||
"description": "",
|
||||
"id": 1,
|
||||
"links": [],
|
||||
"title": "Simle timeseries",
|
||||
"vizConfig": {
|
||||
"kind": "timeseries",
|
||||
"kind": "VizConfig",
|
||||
"group": "timeseries",
|
||||
"version": "12.1.0-pre",
|
||||
"spec": {
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"hideZeros": false,
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"value": 0,
|
||||
"color": "green"
|
||||
},
|
||||
{
|
||||
"value": 80,
|
||||
"color": "red"
|
||||
}
|
||||
]
|
||||
},
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
|
@ -92,108 +112,10 @@
|
|||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green"
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"hideZeros": false,
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"pluginVersion": "12.0.0-pre"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"panel-2": {
|
||||
"kind": "Panel",
|
||||
"spec": {
|
||||
"data": {
|
||||
"kind": "QueryGroup",
|
||||
"spec": {
|
||||
"queries": [
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"hidden": false,
|
||||
"query": {
|
||||
"kind": "grafana-testdata-datasource",
|
||||
"spec": {}
|
||||
},
|
||||
"refId": "A"
|
||||
}
|
||||
}
|
||||
],
|
||||
"queryOptions": {},
|
||||
"transformations": []
|
||||
}
|
||||
},
|
||||
"description": "",
|
||||
"id": 2,
|
||||
"links": [],
|
||||
"title": "Simple stat",
|
||||
"vizConfig": {
|
||||
"kind": "stat",
|
||||
"spec": {
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "thresholds"
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green"
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {
|
||||
"colorMode": "value",
|
||||
"graphMode": "area",
|
||||
"justifyMode": "auto",
|
||||
"orientation": "auto",
|
||||
"percentChangeColorMode": "standard",
|
||||
"reduceOptions": {
|
||||
"calcs": ["lastNotNull"],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"showPercentChange": false,
|
||||
"textMode": "auto",
|
||||
"wideLayout": true
|
||||
},
|
||||
"pluginVersion": "12.0.0-pre"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -202,8 +124,28 @@
|
|||
"layout": {
|
||||
"kind": "AutoGridLayout",
|
||||
"spec": {
|
||||
"maxColumnCount": 3,
|
||||
"columnWidthMode": "standard",
|
||||
"rowHeightMode": "standard",
|
||||
"items": [
|
||||
{
|
||||
"kind": "AutoGridLayoutItem",
|
||||
"spec": {
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-3"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "AutoGridLayoutItem",
|
||||
"spec": {
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-4"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "AutoGridLayoutItem",
|
||||
"spec": {
|
||||
|
@ -221,10 +163,26 @@
|
|||
"name": "panel-1"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "AutoGridLayoutItem",
|
||||
"spec": {
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-5"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "AutoGridLayoutItem",
|
||||
"spec": {
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-6"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"maxColumnCount": 3,
|
||||
"rowHeightMode": "standard"
|
||||
]
|
||||
}
|
||||
},
|
||||
"links": [],
|
||||
|
@ -232,15 +190,33 @@
|
|||
"preload": false,
|
||||
"tags": [],
|
||||
"timeSettings": {
|
||||
"autoRefresh": "",
|
||||
"autoRefreshIntervals": ["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"],
|
||||
"fiscalYearStartMonth": 0,
|
||||
"from": "now-6h",
|
||||
"hideTimepicker": false,
|
||||
"timezone": "browser",
|
||||
"to": "now"
|
||||
"from": "now-6h",
|
||||
"to": "now",
|
||||
"autoRefresh": "",
|
||||
"autoRefreshIntervals": [
|
||||
"5s",
|
||||
"10s",
|
||||
"30s",
|
||||
"1m",
|
||||
"5m",
|
||||
"15m",
|
||||
"30m",
|
||||
"1h",
|
||||
"2h",
|
||||
"1d"
|
||||
],
|
||||
"hideTimepicker": false,
|
||||
"fiscalYearStartMonth": 0
|
||||
},
|
||||
"title": "v2alpha1 dashboard",
|
||||
"title": "Test: V2alpha1 dashboard with viz config",
|
||||
"variables": []
|
||||
},
|
||||
"status": {
|
||||
"conversion": {
|
||||
"failed": false,
|
||||
"storedVersion": "v2alpha1",
|
||||
"error": ""
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import (
|
|||
dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
dashv2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion"
|
||||
)
|
||||
|
@ -61,13 +61,13 @@ func Convert_V0_to_V2alpha1(in *dashv0.Dashboard, out *dashv2alpha1.Dashboard, s
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_V0_to_V2alpha2(in *dashv0.Dashboard, out *dashv2alpha2.Dashboard, scope conversion.Scope) error {
|
||||
func Convert_V0_to_V2beta1(in *dashv0.Dashboard, out *dashv2beta1.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO: implement V0 to V2alpha2 conversion
|
||||
// TODO: implement V0 to v2beta1 conversion
|
||||
|
||||
out.Status = dashv2alpha2.DashboardStatus{
|
||||
Conversion: &dashv2alpha2.DashboardConversionStatus{
|
||||
out.Status = dashv2beta1.DashboardStatus{
|
||||
Conversion: &dashv2beta1.DashboardConversionStatus{
|
||||
StoredVersion: dashv0.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
dashv2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
)
|
||||
|
||||
func Convert_V1_to_V0(in *dashv1.Dashboard, out *dashv0.Dashboard, scope conversion.Scope) error {
|
||||
|
@ -54,13 +54,13 @@ func Convert_V1_to_V2alpha1(in *dashv1.Dashboard, out *dashv2alpha1.Dashboard, s
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_V1_to_V2alpha2(in *dashv1.Dashboard, out *dashv2alpha2.Dashboard, scope conversion.Scope) error {
|
||||
func Convert_V1_to_V2beta1(in *dashv1.Dashboard, out *dashv2beta1.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO: implement V1 to V2alpha2 conversion
|
||||
// TODO: implement V1 to v2beta1 conversion
|
||||
|
||||
out.Status = dashv2alpha2.DashboardStatus{
|
||||
Conversion: &dashv2alpha2.DashboardConversionStatus{
|
||||
out.Status = dashv2beta1.DashboardStatus{
|
||||
Conversion: &dashv2beta1.DashboardConversionStatus{
|
||||
StoredVersion: dashv1.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
dashv2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
)
|
||||
|
||||
func Convert_V2alpha1_to_V0(in *dashv2alpha1.Dashboard, out *dashv0.Dashboard, scope conversion.Scope) error {
|
||||
|
@ -41,29 +41,40 @@ func Convert_V2alpha1_to_V1(in *dashv2alpha1.Dashboard, out *dashv1.Dashboard, s
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_V2alpha1_to_V2alpha2(in *dashv2alpha1.Dashboard, out *dashv2alpha2.Dashboard, scope conversion.Scope) error {
|
||||
func Convert_V2alpha1_to_V2beta1(in *dashv2alpha1.Dashboard, out *dashv2beta1.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO: implement V2alpha1 to V2alpha2 conversion
|
||||
// Convert the spec
|
||||
if err := ConvertDashboard_V2alpha1_to_V2beta1(in, out, scope); err != nil {
|
||||
out.Status = dashv2beta1.DashboardStatus{
|
||||
Conversion: &dashv2beta1.DashboardConversionStatus{
|
||||
StoredVersion: dashv2alpha1.VERSION,
|
||||
Failed: true,
|
||||
Error: err.Error(),
|
||||
},
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
out.Status = dashv2alpha2.DashboardStatus{
|
||||
Conversion: &dashv2alpha2.DashboardConversionStatus{
|
||||
// Set successful conversion status
|
||||
out.Status = dashv2beta1.DashboardStatus{
|
||||
Conversion: &dashv2beta1.DashboardConversionStatus{
|
||||
StoredVersion: dashv2alpha1.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
Failed: false,
|
||||
},
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
func Convert_V2alpha2_to_V0(in *dashv2alpha2.Dashboard, out *dashv0.Dashboard, scope conversion.Scope) error {
|
||||
|
||||
func Convert_V2beta1_to_V0(in *dashv2beta1.Dashboard, out *dashv0.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO: implement V2alpha2 to V0 conversion
|
||||
// TODO: implement v2beta1 to V0 conversion
|
||||
|
||||
out.Status = dashv0.DashboardStatus{
|
||||
Conversion: &dashv0.DashboardConversionStatus{
|
||||
StoredVersion: dashv2alpha2.VERSION,
|
||||
StoredVersion: dashv2beta1.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
},
|
||||
|
@ -72,14 +83,14 @@ func Convert_V2alpha2_to_V0(in *dashv2alpha2.Dashboard, out *dashv0.Dashboard, s
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_V2alpha2_to_V1(in *dashv2alpha2.Dashboard, out *dashv1.Dashboard, scope conversion.Scope) error {
|
||||
func Convert_V2beta1_to_V1(in *dashv2beta1.Dashboard, out *dashv1.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO: implement V2alpha2 to V1 conversion
|
||||
// TODO: implement v2beta1 to V1 conversion
|
||||
|
||||
out.Status = dashv1.DashboardStatus{
|
||||
Conversion: &dashv1.DashboardConversionStatus{
|
||||
StoredVersion: dashv2alpha2.VERSION,
|
||||
StoredVersion: dashv2beta1.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
},
|
||||
|
@ -88,14 +99,14 @@ func Convert_V2alpha2_to_V1(in *dashv2alpha2.Dashboard, out *dashv1.Dashboard, s
|
|||
return nil
|
||||
}
|
||||
|
||||
func Convert_V2alpha2_to_V2alpha1(in *dashv2alpha2.Dashboard, out *dashv2alpha1.Dashboard, scope conversion.Scope) error {
|
||||
func Convert_V2beta1_to_V2alpha1(in *dashv2beta1.Dashboard, out *dashv2alpha1.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
|
||||
// TODO: implement V2alpha2 to V2alpha1 conversion
|
||||
// TODO: implement v2beta1 to V2alpha1 conversion
|
||||
|
||||
out.Status = dashv2alpha1.DashboardStatus{
|
||||
Conversion: &dashv2alpha1.DashboardConversionStatus{
|
||||
StoredVersion: dashv2alpha2.VERSION,
|
||||
StoredVersion: dashv2beta1.VERSION,
|
||||
Failed: true,
|
||||
Error: "backend conversion not yet implemented",
|
||||
},
|
||||
|
|
|
@ -0,0 +1,981 @@
|
|||
package conversion
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
|
||||
dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashv2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
)
|
||||
|
||||
// Schema Migration: v2alpha1 → v2beta1
|
||||
//
|
||||
// This file handles the conversion from Dashboard v2alpha1 to v2beta1 schema.
|
||||
// The main changes between these versions are:
|
||||
//
|
||||
// 1. DataQueryKind Structure Changes:
|
||||
// - v2alpha1: kind = datasource type (e.g., "prometheus", "elasticsearch")
|
||||
// - v2beta1: kind = "DataQuery" (hardcoded), group = datasource type, version = "v0"
|
||||
//
|
||||
// 2. Datasource Reference Migration:
|
||||
// - v2alpha1: Datasource references stored at spec level (PanelQuerySpec.datasource, AnnotationQuerySpec.datasource, etc.)
|
||||
// - v2beta1: Datasource references moved inside DataQueryKind.datasource
|
||||
// - v2alpha1: {type?: string, uid?: string} → v2beta1: {name?: string}
|
||||
//
|
||||
// 3. Query Requirements:
|
||||
// - v2alpha1: AnnotationQuerySpec.query? is optional (can be nil)
|
||||
// - v2beta1: AnnotationQuerySpec.query is required
|
||||
// - Conversion creates default query structure when v2alpha1 query is nil
|
||||
//
|
||||
// 4. DataSourceRef Usage:
|
||||
// - v2alpha1: Used widely across different specs
|
||||
// - v2beta1: Kept only for backward compatibility in GroupBy and Adhoc variables
|
||||
//
|
||||
// 5. Datasource Mapping Strategy:
|
||||
// - Type → Name (if type is available)
|
||||
// - Uid → Name (if type is not available but uid is)
|
||||
//
|
||||
// The conversion preserves all dashboard functionality while restructuring
|
||||
// the data model to consolidate datasource references into the DataQueryKind.
|
||||
|
||||
func ConvertDashboard_V2alpha1_to_V2beta1(in *dashv2alpha1.Dashboard, out *dashv2beta1.Dashboard, scope conversion.Scope) error {
|
||||
out.ObjectMeta = in.ObjectMeta
|
||||
out.APIVersion = dashv2beta1.VERSION
|
||||
out.Kind = in.Kind
|
||||
|
||||
return convertDashboardSpec_V2alpha1_to_V2beta1(&in.Spec, &out.Spec, scope)
|
||||
}
|
||||
|
||||
func convertDashboardSpec_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardSpec, out *dashv2beta1.DashboardSpec, scope conversion.Scope) error {
|
||||
// Convert annotations
|
||||
out.Annotations = make([]dashv2beta1.DashboardAnnotationQueryKind, len(in.Annotations))
|
||||
for i, annotation := range in.Annotations {
|
||||
if err := convertAnnotationQuery_V2alpha1_to_V2beta1(&annotation, &out.Annotations[i], scope); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Copy simple fields
|
||||
out.CursorSync = dashv2beta1.DashboardDashboardCursorSync(in.CursorSync)
|
||||
out.Description = in.Description
|
||||
out.Editable = in.Editable
|
||||
out.LiveNow = in.LiveNow
|
||||
out.Preload = in.Preload
|
||||
out.Revision = in.Revision
|
||||
out.Tags = in.Tags
|
||||
out.Title = in.Title
|
||||
|
||||
// Convert elements
|
||||
out.Elements = make(map[string]dashv2beta1.DashboardElement, len(in.Elements))
|
||||
for key, element := range in.Elements {
|
||||
var convertedElement dashv2beta1.DashboardElement
|
||||
if err := convertElement_V2alpha1_to_V2beta1(&element, &convertedElement, scope); err != nil {
|
||||
return err
|
||||
}
|
||||
out.Elements[key] = convertedElement
|
||||
}
|
||||
|
||||
// Convert layout
|
||||
if err := convertLayout_V2alpha1_to_V2beta1(&in.Layout, &out.Layout, scope); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Convert links
|
||||
out.Links = make([]dashv2beta1.DashboardDashboardLink, len(in.Links))
|
||||
for i, link := range in.Links {
|
||||
convertDashboardLink_V2alpha1_to_V2beta1(&link, &out.Links[i])
|
||||
}
|
||||
|
||||
// Convert time settings
|
||||
if err := convertTimeSettings_V2alpha1_to_V2beta1(&in.TimeSettings, &out.TimeSettings, scope); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Convert variables
|
||||
out.Variables = make([]dashv2beta1.DashboardVariableKind, len(in.Variables))
|
||||
for i, variable := range in.Variables {
|
||||
if err := convertVariable_V2alpha1_to_V2beta1(&variable, &out.Variables[i], scope); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertAnnotationQuery_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardAnnotationQueryKind, out *dashv2beta1.DashboardAnnotationQueryKind, scope conversion.Scope) error {
|
||||
out.Kind = in.Kind
|
||||
|
||||
// Convert spec
|
||||
out.Spec.Enable = in.Spec.Enable
|
||||
out.Spec.Hide = in.Spec.Hide
|
||||
out.Spec.IconColor = in.Spec.IconColor
|
||||
out.Spec.Name = in.Spec.Name
|
||||
out.Spec.BuiltIn = in.Spec.BuiltIn
|
||||
out.Spec.Filter = (*dashv2beta1.DashboardAnnotationPanelFilter)(in.Spec.Filter)
|
||||
out.Spec.LegacyOptions = in.Spec.LegacyOptions
|
||||
|
||||
// Convert query - move datasource from annotation spec to query
|
||||
if err := convertDataQuery_V2alpha1_to_V2beta1(in.Spec.Query, &out.Spec.Query, in.Spec.Datasource, scope); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertDataQuery_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardDataQueryKind, out *dashv2beta1.DashboardDataQueryKind, datasource *dashv2alpha1.DashboardDataSourceRef, scope conversion.Scope) error {
|
||||
if in == nil {
|
||||
// v2beta1 requires a query even if v2alpha1 had none, so create a default
|
||||
out.Kind = "DataQuery"
|
||||
out.Group = ""
|
||||
out.Version = "v0"
|
||||
out.Spec = make(map[string]interface{})
|
||||
} else {
|
||||
out.Kind = "DataQuery"
|
||||
out.Group = in.Kind
|
||||
out.Version = "v0"
|
||||
out.Spec = in.Spec
|
||||
}
|
||||
|
||||
// Convert datasource reference
|
||||
if datasource != nil {
|
||||
out.Datasource = &dashv2beta1.DashboardV2beta1DataQueryKindDatasource{}
|
||||
if datasource.Uid != nil {
|
||||
out.Datasource.Name = datasource.Uid
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertElement_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardElement, out *dashv2beta1.DashboardElement, scope conversion.Scope) error {
|
||||
if in.PanelKind != nil {
|
||||
out.PanelKind = &dashv2beta1.DashboardPanelKind{}
|
||||
return convertPanelKind_V2alpha1_to_V2beta1(in.PanelKind, out.PanelKind, scope)
|
||||
}
|
||||
|
||||
if in.LibraryPanelKind != nil {
|
||||
out.LibraryPanelKind = &dashv2beta1.DashboardLibraryPanelKind{}
|
||||
return convertLibraryPanelKind_V2alpha1_to_V2beta1(in.LibraryPanelKind, out.LibraryPanelKind, scope)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertPanelKind_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardPanelKind, out *dashv2beta1.DashboardPanelKind, scope conversion.Scope) error {
|
||||
out.Kind = in.Kind
|
||||
|
||||
// Convert spec
|
||||
out.Spec.Id = in.Spec.Id
|
||||
out.Spec.Title = in.Spec.Title
|
||||
out.Spec.Description = in.Spec.Description
|
||||
out.Spec.Transparent = in.Spec.Transparent
|
||||
|
||||
// Convert links
|
||||
out.Spec.Links = make([]dashv2beta1.DashboardDataLink, len(in.Spec.Links))
|
||||
for i, link := range in.Spec.Links {
|
||||
convertDataLink_V2alpha1_to_V2beta1(&link, &out.Spec.Links[i])
|
||||
}
|
||||
|
||||
// Convert data (QueryGroup)
|
||||
if err := convertQueryGroup_V2alpha1_to_V2beta1(&in.Spec.Data, &out.Spec.Data, scope); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Convert vizConfig
|
||||
if err := convertVizConfig_V2alpha1_to_V2beta1(&in.Spec.VizConfig, &out.Spec.VizConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertLibraryPanelKind_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardLibraryPanelKind, out *dashv2beta1.DashboardLibraryPanelKind, scope conversion.Scope) error {
|
||||
out.Kind = in.Kind
|
||||
out.Spec.Id = in.Spec.Id
|
||||
out.Spec.Title = in.Spec.Title
|
||||
out.Spec.LibraryPanel = dashv2beta1.DashboardLibraryPanelRef{
|
||||
Name: in.Spec.LibraryPanel.Name,
|
||||
Uid: in.Spec.LibraryPanel.Uid,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertQueryGroup_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardQueryGroupKind, out *dashv2beta1.DashboardQueryGroupKind, scope conversion.Scope) error {
|
||||
out.Kind = in.Kind
|
||||
|
||||
// Convert queries
|
||||
out.Spec.Queries = make([]dashv2beta1.DashboardPanelQueryKind, len(in.Spec.Queries))
|
||||
for i, query := range in.Spec.Queries {
|
||||
if err := convertPanelQuery_V2alpha1_to_V2beta1(&query, &out.Spec.Queries[i], scope); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Convert transformations
|
||||
out.Spec.Transformations = make([]dashv2beta1.DashboardTransformationKind, len(in.Spec.Transformations))
|
||||
for i, transformation := range in.Spec.Transformations {
|
||||
convertTransformation_V2alpha1_to_V2beta1(&transformation, &out.Spec.Transformations[i])
|
||||
}
|
||||
|
||||
// Convert query options
|
||||
convertQueryOptions_V2alpha1_to_V2beta1(&in.Spec.QueryOptions, &out.Spec.QueryOptions)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertPanelQuery_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardPanelQueryKind, out *dashv2beta1.DashboardPanelQueryKind, scope conversion.Scope) error {
|
||||
out.Kind = in.Kind // PanelQueryKind keeps "PanelQuery" as its kind
|
||||
out.Spec.RefId = in.Spec.RefId
|
||||
out.Spec.Hidden = in.Spec.Hidden
|
||||
|
||||
// Convert query - move datasource from panel query spec to query
|
||||
if err := convertDataQuery_V2alpha1_to_V2beta1(&in.Spec.Query, &out.Spec.Query, in.Spec.Datasource, scope); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertTransformation_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardTransformationKind, out *dashv2beta1.DashboardTransformationKind) {
|
||||
out.Kind = in.Kind
|
||||
out.Spec.Id = in.Spec.Id
|
||||
out.Spec.Disabled = in.Spec.Disabled
|
||||
out.Spec.Filter = (*dashv2beta1.DashboardMatcherConfig)(in.Spec.Filter)
|
||||
out.Spec.Topic = (*dashv2beta1.DashboardDataTopic)(in.Spec.Topic)
|
||||
out.Spec.Options = in.Spec.Options
|
||||
}
|
||||
|
||||
func convertQueryOptions_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardQueryOptionsSpec, out *dashv2beta1.DashboardQueryOptionsSpec) {
|
||||
out.TimeFrom = in.TimeFrom
|
||||
out.MaxDataPoints = in.MaxDataPoints
|
||||
out.TimeShift = in.TimeShift
|
||||
out.QueryCachingTTL = in.QueryCachingTTL
|
||||
out.Interval = in.Interval
|
||||
out.CacheTimeout = in.CacheTimeout
|
||||
out.HideTimeOverride = in.HideTimeOverride
|
||||
}
|
||||
|
||||
func convertVizConfig_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardVizConfigKind, out *dashv2beta1.DashboardVizConfigKind) error {
|
||||
out.Kind = "VizConfig"
|
||||
out.Group = in.Kind
|
||||
out.Version = in.Spec.PluginVersion
|
||||
out.Spec = dashv2beta1.DashboardVizConfigSpec{
|
||||
Options: in.Spec.Options,
|
||||
}
|
||||
|
||||
// Convert field config
|
||||
convertFieldConfigSource_V2alpha1_to_V2beta1(&in.Spec.FieldConfig, &out.Spec.FieldConfig)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertFieldConfigSource_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardFieldConfigSource, out *dashv2beta1.DashboardFieldConfigSource) {
|
||||
// Convert defaults
|
||||
convertFieldConfig_V2alpha1_to_V2beta1(&in.Defaults, &out.Defaults)
|
||||
|
||||
// Convert overrides
|
||||
out.Overrides = make([]dashv2beta1.DashboardV2beta1FieldConfigSourceOverrides, len(in.Overrides))
|
||||
for i, override := range in.Overrides {
|
||||
convertFieldConfigOverride_V2alpha1_to_V2beta1(&override, &out.Overrides[i])
|
||||
}
|
||||
}
|
||||
|
||||
func convertFieldConfig_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardFieldConfig, out *dashv2beta1.DashboardFieldConfig) {
|
||||
*out = dashv2beta1.DashboardFieldConfig{
|
||||
DisplayName: in.DisplayName,
|
||||
DisplayNameFromDS: in.DisplayNameFromDS,
|
||||
Description: in.Description,
|
||||
Path: in.Path,
|
||||
Writeable: in.Writeable,
|
||||
Filterable: in.Filterable,
|
||||
Unit: in.Unit,
|
||||
Decimals: in.Decimals,
|
||||
Min: in.Min,
|
||||
Max: in.Max,
|
||||
Links: in.Links,
|
||||
NoValue: in.NoValue,
|
||||
Custom: in.Custom,
|
||||
}
|
||||
|
||||
// Convert thresholds
|
||||
if in.Thresholds != nil {
|
||||
out.Thresholds = &dashv2beta1.DashboardThresholdsConfig{
|
||||
Mode: dashv2beta1.DashboardThresholdsMode(in.Thresholds.Mode),
|
||||
Steps: make([]dashv2beta1.DashboardThreshold, len(in.Thresholds.Steps)),
|
||||
}
|
||||
for i, step := range in.Thresholds.Steps {
|
||||
out.Thresholds.Steps[i] = dashv2beta1.DashboardThreshold{
|
||||
Value: step.Value,
|
||||
Color: step.Color,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Convert color
|
||||
if in.Color != nil {
|
||||
out.Color = &dashv2beta1.DashboardFieldColor{
|
||||
Mode: dashv2beta1.DashboardFieldColorModeId(in.Color.Mode),
|
||||
FixedColor: in.Color.FixedColor,
|
||||
SeriesBy: (*dashv2beta1.DashboardFieldColorSeriesByMode)(in.Color.SeriesBy),
|
||||
}
|
||||
}
|
||||
|
||||
// Convert mappings
|
||||
if in.Mappings != nil {
|
||||
out.Mappings = make([]dashv2beta1.DashboardValueMapping, len(in.Mappings))
|
||||
for i, mapping := range in.Mappings {
|
||||
convertValueMapping_V2alpha1_to_V2beta1(&mapping, &out.Mappings[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func convertFieldConfigOverride_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardV2alpha1FieldConfigSourceOverrides, out *dashv2beta1.DashboardV2beta1FieldConfigSourceOverrides) {
|
||||
out.Matcher = dashv2beta1.DashboardMatcherConfig{
|
||||
Id: in.Matcher.Id,
|
||||
Options: in.Matcher.Options,
|
||||
}
|
||||
|
||||
out.Properties = make([]dashv2beta1.DashboardDynamicConfigValue, len(in.Properties))
|
||||
for i, prop := range in.Properties {
|
||||
out.Properties[i] = dashv2beta1.DashboardDynamicConfigValue{
|
||||
Id: prop.Id,
|
||||
Value: prop.Value,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func convertValueMapping_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardValueMapping, out *dashv2beta1.DashboardValueMapping) {
|
||||
if in.ValueMap != nil {
|
||||
out.ValueMap = &dashv2beta1.DashboardValueMap{
|
||||
Type: dashv2beta1.DashboardMappingType(in.ValueMap.Type),
|
||||
Options: make(map[string]dashv2beta1.DashboardValueMappingResult, len(in.ValueMap.Options)),
|
||||
}
|
||||
for k, v := range in.ValueMap.Options {
|
||||
out.ValueMap.Options[k] = dashv2beta1.DashboardValueMappingResult{
|
||||
Text: v.Text,
|
||||
Color: v.Color,
|
||||
Icon: v.Icon,
|
||||
Index: v.Index,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if in.RangeMap != nil {
|
||||
out.RangeMap = &dashv2beta1.DashboardRangeMap{
|
||||
Type: dashv2beta1.DashboardMappingType(in.RangeMap.Type),
|
||||
Options: dashv2beta1.DashboardV2beta1RangeMapOptions{
|
||||
From: in.RangeMap.Options.From,
|
||||
To: in.RangeMap.Options.To,
|
||||
Result: dashv2beta1.DashboardValueMappingResult{
|
||||
Text: in.RangeMap.Options.Result.Text,
|
||||
Color: in.RangeMap.Options.Result.Color,
|
||||
Icon: in.RangeMap.Options.Result.Icon,
|
||||
Index: in.RangeMap.Options.Result.Index,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if in.RegexMap != nil {
|
||||
out.RegexMap = &dashv2beta1.DashboardRegexMap{
|
||||
Type: dashv2beta1.DashboardMappingType(in.RegexMap.Type),
|
||||
Options: dashv2beta1.DashboardV2beta1RegexMapOptions{
|
||||
Pattern: in.RegexMap.Options.Pattern,
|
||||
Result: dashv2beta1.DashboardValueMappingResult{
|
||||
Text: in.RegexMap.Options.Result.Text,
|
||||
Color: in.RegexMap.Options.Result.Color,
|
||||
Icon: in.RegexMap.Options.Result.Icon,
|
||||
Index: in.RegexMap.Options.Result.Index,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if in.SpecialValueMap != nil {
|
||||
out.SpecialValueMap = &dashv2beta1.DashboardSpecialValueMap{
|
||||
Type: dashv2beta1.DashboardMappingType(in.SpecialValueMap.Type),
|
||||
Options: dashv2beta1.DashboardV2beta1SpecialValueMapOptions{
|
||||
Match: dashv2beta1.DashboardSpecialValueMatch(in.SpecialValueMap.Options.Match),
|
||||
Result: dashv2beta1.DashboardValueMappingResult{
|
||||
Text: in.SpecialValueMap.Options.Result.Text,
|
||||
Color: in.SpecialValueMap.Options.Result.Color,
|
||||
Icon: in.SpecialValueMap.Options.Result.Icon,
|
||||
Index: in.SpecialValueMap.Options.Result.Index,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func convertLayout_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind, out *dashv2beta1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind, scope conversion.Scope) error {
|
||||
if in.GridLayoutKind != nil {
|
||||
out.GridLayoutKind = &dashv2beta1.DashboardGridLayoutKind{
|
||||
Kind: in.GridLayoutKind.Kind,
|
||||
}
|
||||
return convertGridLayoutSpec_V2alpha1_to_V2beta1(&in.GridLayoutKind.Spec, &out.GridLayoutKind.Spec, scope)
|
||||
}
|
||||
|
||||
if in.RowsLayoutKind != nil {
|
||||
out.RowsLayoutKind = &dashv2beta1.DashboardRowsLayoutKind{
|
||||
Kind: in.RowsLayoutKind.Kind,
|
||||
}
|
||||
return convertRowsLayoutSpec_V2alpha1_to_V2beta1(&in.RowsLayoutKind.Spec, &out.RowsLayoutKind.Spec, scope)
|
||||
}
|
||||
|
||||
if in.AutoGridLayoutKind != nil {
|
||||
out.AutoGridLayoutKind = &dashv2beta1.DashboardAutoGridLayoutKind{
|
||||
Kind: in.AutoGridLayoutKind.Kind,
|
||||
}
|
||||
return convertAutoGridLayoutSpec_V2alpha1_to_V2beta1(&in.AutoGridLayoutKind.Spec, &out.AutoGridLayoutKind.Spec, scope)
|
||||
}
|
||||
|
||||
if in.TabsLayoutKind != nil {
|
||||
out.TabsLayoutKind = &dashv2beta1.DashboardTabsLayoutKind{
|
||||
Kind: in.TabsLayoutKind.Kind,
|
||||
}
|
||||
return convertTabsLayoutSpec_V2alpha1_to_V2beta1(&in.TabsLayoutKind.Spec, &out.TabsLayoutKind.Spec, scope)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertGridLayoutSpec_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardGridLayoutSpec, out *dashv2beta1.DashboardGridLayoutSpec, scope conversion.Scope) error {
|
||||
out.Items = make([]dashv2beta1.DashboardGridLayoutItemKind, len(in.Items))
|
||||
for i, item := range in.Items {
|
||||
out.Items[i] = dashv2beta1.DashboardGridLayoutItemKind{
|
||||
Kind: item.Kind,
|
||||
Spec: dashv2beta1.DashboardGridLayoutItemSpec{
|
||||
X: item.Spec.X,
|
||||
Y: item.Spec.Y,
|
||||
Width: item.Spec.Width,
|
||||
Height: item.Spec.Height,
|
||||
Element: dashv2beta1.DashboardElementReference{
|
||||
Kind: item.Spec.Element.Kind,
|
||||
Name: item.Spec.Element.Name,
|
||||
},
|
||||
Repeat: convertRepeatOptions_V2alpha1_to_V2beta1(item.Spec.Repeat),
|
||||
},
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertRowsLayoutSpec_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardRowsLayoutSpec, out *dashv2beta1.DashboardRowsLayoutSpec, scope conversion.Scope) error {
|
||||
out.Rows = make([]dashv2beta1.DashboardRowsLayoutRowKind, len(in.Rows))
|
||||
for i, row := range in.Rows {
|
||||
out.Rows[i] = dashv2beta1.DashboardRowsLayoutRowKind{
|
||||
Kind: row.Kind,
|
||||
Spec: dashv2beta1.DashboardRowsLayoutRowSpec{
|
||||
Title: row.Spec.Title,
|
||||
Collapse: row.Spec.Collapse,
|
||||
HideHeader: row.Spec.HideHeader,
|
||||
FillScreen: row.Spec.FillScreen,
|
||||
ConditionalRendering: convertConditionalRenderingGroupKind_V2alpha1_to_V2beta1(row.Spec.ConditionalRendering),
|
||||
Repeat: convertRowRepeatOptions_V2alpha1_to_V2beta1(row.Spec.Repeat),
|
||||
},
|
||||
}
|
||||
if err := convertRowLayout_V2alpha1_to_V2beta1(&row.Spec.Layout, &out.Rows[i].Spec.Layout, scope); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertAutoGridLayoutSpec_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardAutoGridLayoutSpec, out *dashv2beta1.DashboardAutoGridLayoutSpec, scope conversion.Scope) error {
|
||||
out.MaxColumnCount = in.MaxColumnCount
|
||||
out.ColumnWidthMode = dashv2beta1.DashboardAutoGridLayoutSpecColumnWidthMode(in.ColumnWidthMode)
|
||||
out.ColumnWidth = in.ColumnWidth
|
||||
out.RowHeightMode = dashv2beta1.DashboardAutoGridLayoutSpecRowHeightMode(in.RowHeightMode)
|
||||
out.RowHeight = in.RowHeight
|
||||
out.FillScreen = in.FillScreen
|
||||
|
||||
out.Items = make([]dashv2beta1.DashboardAutoGridLayoutItemKind, len(in.Items))
|
||||
for i, item := range in.Items {
|
||||
out.Items[i] = dashv2beta1.DashboardAutoGridLayoutItemKind{
|
||||
Kind: item.Kind,
|
||||
Spec: dashv2beta1.DashboardAutoGridLayoutItemSpec{
|
||||
Element: dashv2beta1.DashboardElementReference{
|
||||
Kind: item.Spec.Element.Kind,
|
||||
Name: item.Spec.Element.Name,
|
||||
},
|
||||
Repeat: convertAutoGridRepeatOptions_V2alpha1_to_V2beta1(item.Spec.Repeat),
|
||||
ConditionalRendering: convertConditionalRenderingGroupKind_V2alpha1_to_V2beta1(item.Spec.ConditionalRendering),
|
||||
},
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertTabsLayoutSpec_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardTabsLayoutSpec, out *dashv2beta1.DashboardTabsLayoutSpec, scope conversion.Scope) error {
|
||||
out.Tabs = make([]dashv2beta1.DashboardTabsLayoutTabKind, len(in.Tabs))
|
||||
for i, tab := range in.Tabs {
|
||||
out.Tabs[i] = dashv2beta1.DashboardTabsLayoutTabKind{
|
||||
Kind: tab.Kind,
|
||||
Spec: dashv2beta1.DashboardTabsLayoutTabSpec{
|
||||
Title: tab.Spec.Title,
|
||||
ConditionalRendering: convertConditionalRenderingGroupKind_V2alpha1_to_V2beta1(tab.Spec.ConditionalRendering),
|
||||
Repeat: convertTabRepeatOptions_V2alpha1_to_V2beta1(tab.Spec.Repeat),
|
||||
},
|
||||
}
|
||||
if err := convertTabLayout_V2alpha1_to_V2beta1(&tab.Spec.Layout, &out.Tabs[i].Spec.Layout, scope); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertDashboardLink_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardDashboardLink, out *dashv2beta1.DashboardDashboardLink) {
|
||||
out.Title = in.Title
|
||||
out.Type = dashv2beta1.DashboardDashboardLinkType(in.Type)
|
||||
out.Icon = in.Icon
|
||||
out.Tooltip = in.Tooltip
|
||||
out.Url = in.Url
|
||||
out.Tags = in.Tags
|
||||
out.AsDropdown = in.AsDropdown
|
||||
out.TargetBlank = in.TargetBlank
|
||||
out.IncludeVars = in.IncludeVars
|
||||
out.KeepTime = in.KeepTime
|
||||
}
|
||||
|
||||
func convertDataLink_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardDataLink, out *dashv2beta1.DashboardDataLink) {
|
||||
out.Title = in.Title
|
||||
out.Url = in.Url
|
||||
out.TargetBlank = in.TargetBlank
|
||||
}
|
||||
|
||||
func convertTimeSettings_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardTimeSettingsSpec, out *dashv2beta1.DashboardTimeSettingsSpec, scope conversion.Scope) error {
|
||||
out.Timezone = in.Timezone
|
||||
out.From = in.From
|
||||
out.To = in.To
|
||||
out.AutoRefresh = in.AutoRefresh
|
||||
out.AutoRefreshIntervals = in.AutoRefreshIntervals
|
||||
out.HideTimepicker = in.HideTimepicker
|
||||
out.WeekStart = (*dashv2beta1.DashboardTimeSettingsSpecWeekStart)(in.WeekStart)
|
||||
out.FiscalYearStartMonth = in.FiscalYearStartMonth
|
||||
out.NowDelay = in.NowDelay
|
||||
|
||||
// Convert quick ranges
|
||||
if in.QuickRanges != nil {
|
||||
out.QuickRanges = make([]dashv2beta1.DashboardTimeRangeOption, len(in.QuickRanges))
|
||||
for i, qr := range in.QuickRanges {
|
||||
out.QuickRanges[i] = dashv2beta1.DashboardTimeRangeOption{
|
||||
Display: qr.Display,
|
||||
From: qr.From,
|
||||
To: qr.To,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertVariable_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardVariableKind, out *dashv2beta1.DashboardVariableKind, scope conversion.Scope) error {
|
||||
if in.QueryVariableKind != nil {
|
||||
out.QueryVariableKind = &dashv2beta1.DashboardQueryVariableKind{
|
||||
Kind: in.QueryVariableKind.Kind,
|
||||
}
|
||||
return convertQueryVariableSpec_V2alpha1_to_V2beta1(&in.QueryVariableKind.Spec, &out.QueryVariableKind.Spec, scope)
|
||||
}
|
||||
|
||||
if in.TextVariableKind != nil {
|
||||
out.TextVariableKind = &dashv2beta1.DashboardTextVariableKind{
|
||||
Kind: in.TextVariableKind.Kind,
|
||||
Spec: dashv2beta1.DashboardTextVariableSpec{
|
||||
Name: in.TextVariableKind.Spec.Name,
|
||||
Current: convertVariableOption_V2alpha1_to_V2beta1(in.TextVariableKind.Spec.Current),
|
||||
Query: in.TextVariableKind.Spec.Query,
|
||||
Label: in.TextVariableKind.Spec.Label,
|
||||
Hide: dashv2beta1.DashboardVariableHide(in.TextVariableKind.Spec.Hide),
|
||||
SkipUrlSync: in.TextVariableKind.Spec.SkipUrlSync,
|
||||
Description: in.TextVariableKind.Spec.Description,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if in.ConstantVariableKind != nil {
|
||||
out.ConstantVariableKind = &dashv2beta1.DashboardConstantVariableKind{
|
||||
Kind: in.ConstantVariableKind.Kind,
|
||||
Spec: dashv2beta1.DashboardConstantVariableSpec{
|
||||
Name: in.ConstantVariableKind.Spec.Name,
|
||||
Query: in.ConstantVariableKind.Spec.Query,
|
||||
Current: convertVariableOption_V2alpha1_to_V2beta1(in.ConstantVariableKind.Spec.Current),
|
||||
Label: in.ConstantVariableKind.Spec.Label,
|
||||
Hide: dashv2beta1.DashboardVariableHide(in.ConstantVariableKind.Spec.Hide),
|
||||
SkipUrlSync: in.ConstantVariableKind.Spec.SkipUrlSync,
|
||||
Description: in.ConstantVariableKind.Spec.Description,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if in.DatasourceVariableKind != nil {
|
||||
out.DatasourceVariableKind = &dashv2beta1.DashboardDatasourceVariableKind{
|
||||
Kind: in.DatasourceVariableKind.Kind,
|
||||
Spec: dashv2beta1.DashboardDatasourceVariableSpec{
|
||||
Name: in.DatasourceVariableKind.Spec.Name,
|
||||
PluginId: in.DatasourceVariableKind.Spec.PluginId,
|
||||
Refresh: dashv2beta1.DashboardVariableRefresh(in.DatasourceVariableKind.Spec.Refresh),
|
||||
Regex: in.DatasourceVariableKind.Spec.Regex,
|
||||
Current: convertVariableOption_V2alpha1_to_V2beta1(in.DatasourceVariableKind.Spec.Current),
|
||||
Options: convertVariableOptions_V2alpha1_to_V2beta1(in.DatasourceVariableKind.Spec.Options),
|
||||
Multi: in.DatasourceVariableKind.Spec.Multi,
|
||||
IncludeAll: in.DatasourceVariableKind.Spec.IncludeAll,
|
||||
AllValue: in.DatasourceVariableKind.Spec.AllValue,
|
||||
Label: in.DatasourceVariableKind.Spec.Label,
|
||||
Hide: dashv2beta1.DashboardVariableHide(in.DatasourceVariableKind.Spec.Hide),
|
||||
SkipUrlSync: in.DatasourceVariableKind.Spec.SkipUrlSync,
|
||||
Description: in.DatasourceVariableKind.Spec.Description,
|
||||
AllowCustomValue: in.DatasourceVariableKind.Spec.AllowCustomValue,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if in.IntervalVariableKind != nil {
|
||||
out.IntervalVariableKind = &dashv2beta1.DashboardIntervalVariableKind{
|
||||
Kind: in.IntervalVariableKind.Kind,
|
||||
Spec: dashv2beta1.DashboardIntervalVariableSpec{
|
||||
Name: in.IntervalVariableKind.Spec.Name,
|
||||
Query: in.IntervalVariableKind.Spec.Query,
|
||||
Current: convertVariableOption_V2alpha1_to_V2beta1(in.IntervalVariableKind.Spec.Current),
|
||||
Options: convertVariableOptions_V2alpha1_to_V2beta1(in.IntervalVariableKind.Spec.Options),
|
||||
Auto: in.IntervalVariableKind.Spec.Auto,
|
||||
AutoMin: in.IntervalVariableKind.Spec.AutoMin,
|
||||
AutoCount: in.IntervalVariableKind.Spec.AutoCount,
|
||||
Refresh: dashv2beta1.DashboardVariableRefresh(in.IntervalVariableKind.Spec.Refresh),
|
||||
Label: in.IntervalVariableKind.Spec.Label,
|
||||
Hide: dashv2beta1.DashboardVariableHide(in.IntervalVariableKind.Spec.Hide),
|
||||
SkipUrlSync: in.IntervalVariableKind.Spec.SkipUrlSync,
|
||||
Description: in.IntervalVariableKind.Spec.Description,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if in.CustomVariableKind != nil {
|
||||
out.CustomVariableKind = &dashv2beta1.DashboardCustomVariableKind{
|
||||
Kind: in.CustomVariableKind.Kind,
|
||||
Spec: dashv2beta1.DashboardCustomVariableSpec{
|
||||
Name: in.CustomVariableKind.Spec.Name,
|
||||
Query: in.CustomVariableKind.Spec.Query,
|
||||
Current: convertVariableOption_V2alpha1_to_V2beta1(in.CustomVariableKind.Spec.Current),
|
||||
Options: convertVariableOptions_V2alpha1_to_V2beta1(in.CustomVariableKind.Spec.Options),
|
||||
Multi: in.CustomVariableKind.Spec.Multi,
|
||||
IncludeAll: in.CustomVariableKind.Spec.IncludeAll,
|
||||
AllValue: in.CustomVariableKind.Spec.AllValue,
|
||||
Label: in.CustomVariableKind.Spec.Label,
|
||||
Hide: dashv2beta1.DashboardVariableHide(in.CustomVariableKind.Spec.Hide),
|
||||
SkipUrlSync: in.CustomVariableKind.Spec.SkipUrlSync,
|
||||
Description: in.CustomVariableKind.Spec.Description,
|
||||
AllowCustomValue: in.CustomVariableKind.Spec.AllowCustomValue,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if in.GroupByVariableKind != nil {
|
||||
out.GroupByVariableKind = &dashv2beta1.DashboardGroupByVariableKind{
|
||||
Kind: in.GroupByVariableKind.Kind,
|
||||
Group: *in.GroupByVariableKind.Spec.Datasource.Type,
|
||||
Datasource: &dashv2beta1.DashboardV2beta1GroupByVariableKindDatasource{
|
||||
Name: in.GroupByVariableKind.Spec.Datasource.Uid,
|
||||
},
|
||||
Spec: dashv2beta1.DashboardGroupByVariableSpec{
|
||||
Name: in.GroupByVariableKind.Spec.Name,
|
||||
DefaultValue: convertVariableOptionPtr_V2alpha1_to_V2beta1(in.GroupByVariableKind.Spec.DefaultValue),
|
||||
Current: convertVariableOption_V2alpha1_to_V2beta1(in.GroupByVariableKind.Spec.Current),
|
||||
Options: convertVariableOptions_V2alpha1_to_V2beta1(in.GroupByVariableKind.Spec.Options),
|
||||
Multi: in.GroupByVariableKind.Spec.Multi,
|
||||
Label: in.GroupByVariableKind.Spec.Label,
|
||||
Hide: dashv2beta1.DashboardVariableHide(in.GroupByVariableKind.Spec.Hide),
|
||||
SkipUrlSync: in.GroupByVariableKind.Spec.SkipUrlSync,
|
||||
Description: in.GroupByVariableKind.Spec.Description,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if in.AdhocVariableKind != nil {
|
||||
out.AdhocVariableKind = &dashv2beta1.DashboardAdhocVariableKind{
|
||||
Kind: in.AdhocVariableKind.Kind,
|
||||
Group: *in.AdhocVariableKind.Spec.Datasource.Type,
|
||||
Datasource: &dashv2beta1.DashboardV2beta1AdhocVariableKindDatasource{
|
||||
Name: in.AdhocVariableKind.Spec.Datasource.Uid,
|
||||
},
|
||||
Spec: dashv2beta1.DashboardAdhocVariableSpec{
|
||||
Name: in.AdhocVariableKind.Spec.Name,
|
||||
BaseFilters: convertAdHocFilters_V2alpha1_to_V2beta1(in.AdhocVariableKind.Spec.BaseFilters),
|
||||
Filters: convertAdHocFilters_V2alpha1_to_V2beta1(in.AdhocVariableKind.Spec.Filters),
|
||||
DefaultKeys: convertMetricFindValues_V2alpha1_to_V2beta1(in.AdhocVariableKind.Spec.DefaultKeys),
|
||||
Label: in.AdhocVariableKind.Spec.Label,
|
||||
Hide: dashv2beta1.DashboardVariableHide(in.AdhocVariableKind.Spec.Hide),
|
||||
SkipUrlSync: in.AdhocVariableKind.Spec.SkipUrlSync,
|
||||
Description: in.AdhocVariableKind.Spec.Description,
|
||||
AllowCustomValue: in.AdhocVariableKind.Spec.AllowCustomValue,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertQueryVariableSpec_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardQueryVariableSpec, out *dashv2beta1.DashboardQueryVariableSpec, scope conversion.Scope) error {
|
||||
out.Name = in.Name
|
||||
out.Current = convertVariableOption_V2alpha1_to_V2beta1(in.Current)
|
||||
out.Label = in.Label
|
||||
out.Hide = dashv2beta1.DashboardVariableHide(in.Hide)
|
||||
out.Refresh = dashv2beta1.DashboardVariableRefresh(in.Refresh)
|
||||
out.SkipUrlSync = in.SkipUrlSync
|
||||
out.Description = in.Description
|
||||
out.Regex = in.Regex
|
||||
out.Sort = dashv2beta1.DashboardVariableSort(in.Sort)
|
||||
out.Definition = in.Definition
|
||||
out.Options = convertVariableOptions_V2alpha1_to_V2beta1(in.Options)
|
||||
out.Multi = in.Multi
|
||||
out.IncludeAll = in.IncludeAll
|
||||
out.AllValue = in.AllValue
|
||||
out.Placeholder = in.Placeholder
|
||||
out.AllowCustomValue = in.AllowCustomValue
|
||||
out.StaticOptions = convertVariableOptions_V2alpha1_to_V2beta1(in.StaticOptions)
|
||||
out.StaticOptionsOrder = (*dashv2beta1.DashboardQueryVariableSpecStaticOptionsOrder)(in.StaticOptionsOrder)
|
||||
|
||||
// Convert query - move datasource from variable spec to query
|
||||
if err := convertDataQuery_V2alpha1_to_V2beta1(&in.Query, &out.Query, in.Datasource, scope); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertVariableOption_V2alpha1_to_V2beta1(in dashv2alpha1.DashboardVariableOption) dashv2beta1.DashboardVariableOption {
|
||||
return dashv2beta1.DashboardVariableOption{
|
||||
Selected: in.Selected,
|
||||
Text: dashv2beta1.DashboardStringOrArrayOfString(in.Text),
|
||||
Value: dashv2beta1.DashboardStringOrArrayOfString(in.Value),
|
||||
}
|
||||
}
|
||||
|
||||
func convertVariableOptionPtr_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardVariableOption) *dashv2beta1.DashboardVariableOption {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := convertVariableOption_V2alpha1_to_V2beta1(*in)
|
||||
return &out
|
||||
}
|
||||
|
||||
func convertVariableOptions_V2alpha1_to_V2beta1(in []dashv2alpha1.DashboardVariableOption) []dashv2beta1.DashboardVariableOption {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := make([]dashv2beta1.DashboardVariableOption, len(in))
|
||||
for i, option := range in {
|
||||
out[i] = convertVariableOption_V2alpha1_to_V2beta1(option)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func convertAdHocFilters_V2alpha1_to_V2beta1(in []dashv2alpha1.DashboardAdHocFilterWithLabels) []dashv2beta1.DashboardAdHocFilterWithLabels {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := make([]dashv2beta1.DashboardAdHocFilterWithLabels, len(in))
|
||||
for i, filter := range in {
|
||||
out[i] = dashv2beta1.DashboardAdHocFilterWithLabels{
|
||||
Key: filter.Key,
|
||||
Operator: filter.Operator,
|
||||
Value: filter.Value,
|
||||
Values: filter.Values,
|
||||
KeyLabel: filter.KeyLabel,
|
||||
ValueLabels: filter.ValueLabels,
|
||||
ForceEdit: filter.ForceEdit,
|
||||
Origin: filter.Origin,
|
||||
Condition: filter.Condition,
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func convertMetricFindValues_V2alpha1_to_V2beta1(in []dashv2alpha1.DashboardMetricFindValue) []dashv2beta1.DashboardMetricFindValue {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := make([]dashv2beta1.DashboardMetricFindValue, len(in))
|
||||
for i, value := range in {
|
||||
out[i] = dashv2beta1.DashboardMetricFindValue{
|
||||
Text: value.Text,
|
||||
Value: (*dashv2beta1.DashboardStringOrFloat64)(value.Value),
|
||||
Group: value.Group,
|
||||
Expandable: value.Expandable,
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func convertRepeatOptions_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardRepeatOptions) *dashv2beta1.DashboardRepeatOptions {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
return &dashv2beta1.DashboardRepeatOptions{
|
||||
Mode: in.Mode,
|
||||
Value: in.Value,
|
||||
Direction: (*dashv2beta1.DashboardRepeatOptionsDirection)(in.Direction),
|
||||
MaxPerRow: in.MaxPerRow,
|
||||
}
|
||||
}
|
||||
|
||||
func convertRowRepeatOptions_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardRowRepeatOptions) *dashv2beta1.DashboardRowRepeatOptions {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
return &dashv2beta1.DashboardRowRepeatOptions{
|
||||
Mode: in.Mode,
|
||||
Value: in.Value,
|
||||
}
|
||||
}
|
||||
|
||||
func convertAutoGridRepeatOptions_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardAutoGridRepeatOptions) *dashv2beta1.DashboardAutoGridRepeatOptions {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
return &dashv2beta1.DashboardAutoGridRepeatOptions{
|
||||
Mode: in.Mode,
|
||||
Value: in.Value,
|
||||
}
|
||||
}
|
||||
|
||||
func convertTabRepeatOptions_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardTabRepeatOptions) *dashv2beta1.DashboardTabRepeatOptions {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
return &dashv2beta1.DashboardTabRepeatOptions{
|
||||
Mode: in.Mode,
|
||||
Value: in.Value,
|
||||
}
|
||||
}
|
||||
|
||||
func convertConditionalRenderingGroupKind_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardConditionalRenderingGroupKind) *dashv2beta1.DashboardConditionalRenderingGroupKind {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
out := &dashv2beta1.DashboardConditionalRenderingGroupKind{
|
||||
Kind: in.Kind,
|
||||
Spec: dashv2beta1.DashboardConditionalRenderingGroupSpec{
|
||||
Visibility: dashv2beta1.DashboardConditionalRenderingGroupSpecVisibility(in.Spec.Visibility),
|
||||
Condition: dashv2beta1.DashboardConditionalRenderingGroupSpecCondition(in.Spec.Condition),
|
||||
Items: make([]dashv2beta1.DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind, len(in.Spec.Items)),
|
||||
},
|
||||
}
|
||||
|
||||
// Convert each item in the Items slice
|
||||
for i, item := range in.Spec.Items {
|
||||
out.Spec.Items[i] = dashv2beta1.DashboardConditionalRenderingVariableKindOrConditionalRenderingDataKindOrConditionalRenderingTimeRangeSizeKind{}
|
||||
|
||||
if item.ConditionalRenderingVariableKind != nil {
|
||||
out.Spec.Items[i].ConditionalRenderingVariableKind = &dashv2beta1.DashboardConditionalRenderingVariableKind{
|
||||
Kind: item.ConditionalRenderingVariableKind.Kind,
|
||||
Spec: dashv2beta1.DashboardConditionalRenderingVariableSpec{
|
||||
Variable: item.ConditionalRenderingVariableKind.Spec.Variable,
|
||||
Operator: dashv2beta1.DashboardConditionalRenderingVariableSpecOperator(item.ConditionalRenderingVariableKind.Spec.Operator),
|
||||
Value: item.ConditionalRenderingVariableKind.Spec.Value,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if item.ConditionalRenderingDataKind != nil {
|
||||
out.Spec.Items[i].ConditionalRenderingDataKind = &dashv2beta1.DashboardConditionalRenderingDataKind{
|
||||
Kind: item.ConditionalRenderingDataKind.Kind,
|
||||
Spec: dashv2beta1.DashboardConditionalRenderingDataSpec{
|
||||
Value: item.ConditionalRenderingDataKind.Spec.Value,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if item.ConditionalRenderingTimeRangeSizeKind != nil {
|
||||
out.Spec.Items[i].ConditionalRenderingTimeRangeSizeKind = &dashv2beta1.DashboardConditionalRenderingTimeRangeSizeKind{
|
||||
Kind: item.ConditionalRenderingTimeRangeSizeKind.Kind,
|
||||
Spec: dashv2beta1.DashboardConditionalRenderingTimeRangeSizeSpec{
|
||||
Value: item.ConditionalRenderingTimeRangeSizeKind.Spec.Value,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
func convertRowLayout_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind, out *dashv2beta1.DashboardGridLayoutKindOrAutoGridLayoutKindOrTabsLayoutKindOrRowsLayoutKind, scope conversion.Scope) error {
|
||||
// Handle the different union type orderings by converting through the main layout function
|
||||
// Create a temporary variable with the correct type ordering
|
||||
var tempIn dashv2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind
|
||||
var tempOut dashv2beta1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind
|
||||
|
||||
// Copy the layout data with the correct ordering
|
||||
if in.GridLayoutKind != nil {
|
||||
tempIn.GridLayoutKind = in.GridLayoutKind
|
||||
}
|
||||
if in.RowsLayoutKind != nil {
|
||||
tempIn.RowsLayoutKind = in.RowsLayoutKind
|
||||
}
|
||||
if in.AutoGridLayoutKind != nil {
|
||||
tempIn.AutoGridLayoutKind = in.AutoGridLayoutKind
|
||||
}
|
||||
if in.TabsLayoutKind != nil {
|
||||
tempIn.TabsLayoutKind = in.TabsLayoutKind
|
||||
}
|
||||
|
||||
if err := convertLayout_V2alpha1_to_V2beta1(&tempIn, &tempOut, scope); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Copy back to the output with the correct ordering
|
||||
if tempOut.GridLayoutKind != nil {
|
||||
out.GridLayoutKind = tempOut.GridLayoutKind
|
||||
}
|
||||
if tempOut.RowsLayoutKind != nil {
|
||||
out.RowsLayoutKind = tempOut.RowsLayoutKind
|
||||
}
|
||||
if tempOut.AutoGridLayoutKind != nil {
|
||||
out.AutoGridLayoutKind = tempOut.AutoGridLayoutKind
|
||||
}
|
||||
if tempOut.TabsLayoutKind != nil {
|
||||
out.TabsLayoutKind = tempOut.TabsLayoutKind
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertTabLayout_V2alpha1_to_V2beta1(in *dashv2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind, out *dashv2beta1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind, scope conversion.Scope) error {
|
||||
// Handle the different union type orderings by converting through the main layout function
|
||||
// Create a temporary variable with the correct type ordering
|
||||
var tempIn dashv2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind
|
||||
var tempOut dashv2beta1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind
|
||||
|
||||
// Copy the layout data with the correct ordering
|
||||
if in.GridLayoutKind != nil {
|
||||
tempIn.GridLayoutKind = in.GridLayoutKind
|
||||
}
|
||||
if in.RowsLayoutKind != nil {
|
||||
tempIn.RowsLayoutKind = in.RowsLayoutKind
|
||||
}
|
||||
if in.AutoGridLayoutKind != nil {
|
||||
tempIn.AutoGridLayoutKind = in.AutoGridLayoutKind
|
||||
}
|
||||
if in.TabsLayoutKind != nil {
|
||||
tempIn.TabsLayoutKind = in.TabsLayoutKind
|
||||
}
|
||||
|
||||
if err := convertLayout_V2alpha1_to_V2beta1(&tempIn, &tempOut, scope); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Copy back to the output with the correct ordering
|
||||
if tempOut.GridLayoutKind != nil {
|
||||
out.GridLayoutKind = tempOut.GridLayoutKind
|
||||
}
|
||||
if tempOut.RowsLayoutKind != nil {
|
||||
out.RowsLayoutKind = tempOut.RowsLayoutKind
|
||||
}
|
||||
if tempOut.AutoGridLayoutKind != nil {
|
||||
out.AutoGridLayoutKind = tempOut.AutoGridLayoutKind
|
||||
}
|
||||
if tempOut.TabsLayoutKind != nil {
|
||||
out.TabsLayoutKind = tempOut.TabsLayoutKind
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,257 @@
|
|||
{
|
||||
"kind": "Dashboard",
|
||||
"apiVersion": "dashboard.grafana.app/v1beta1",
|
||||
"metadata": {
|
||||
"name": "test-v1-annotations",
|
||||
"annotations": {
|
||||
"hello": "world"
|
||||
},
|
||||
"labels": {
|
||||
"region": "west"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"annotations": {
|
||||
"list": [
|
||||
{
|
||||
"builtIn": 1,
|
||||
"datasource": {
|
||||
"type": "grafana",
|
||||
"uid": "-- Grafana --"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations & Alerts",
|
||||
"target": {
|
||||
"limit": 100,
|
||||
"matchAny": false,
|
||||
"tags": [],
|
||||
"type": "dashboard"
|
||||
},
|
||||
"type": "dashboard"
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "grafana-testdata-datasource",
|
||||
"uid": "PD8C576611E62080A"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "blue",
|
||||
"name": "testdata-annos",
|
||||
"target": {
|
||||
"lines": 10,
|
||||
"refId": "Anno",
|
||||
"scenarioId": "annotations"
|
||||
}
|
||||
},
|
||||
{
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "blue",
|
||||
"name": "no-ds-testdata-annos",
|
||||
"target": {
|
||||
"lines": 10,
|
||||
"refId": "Anno",
|
||||
"scenarioId": "annotations"
|
||||
}
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "gdev-prometheus"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "yellow",
|
||||
"name": "prom-annos",
|
||||
"target": {
|
||||
"expr": "{action=\"add_client\"}",
|
||||
"interval": "",
|
||||
"lines": 10,
|
||||
"refId": "Anno",
|
||||
"scenarioId": "annotations"
|
||||
}
|
||||
},
|
||||
{
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "yellow",
|
||||
"name": "no-ds-prom-annos",
|
||||
"target": {
|
||||
"expr": "{action=\"add_client\"}",
|
||||
"interval": "",
|
||||
"lines": 10,
|
||||
"refId": "Anno",
|
||||
"scenarioId": "annotations"
|
||||
}
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "grafana-postgresql-datasource",
|
||||
"uid": "PBBCEC2D313BC06C3"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "red",
|
||||
"name": "postgress-annos",
|
||||
"target": {
|
||||
"editorMode": "builder",
|
||||
"format": "table",
|
||||
"lines": 10,
|
||||
"rawSql": "",
|
||||
"refId": "Anno",
|
||||
"scenarioId": "annotations",
|
||||
"sql": {
|
||||
"columns": [
|
||||
{
|
||||
"parameters": [],
|
||||
"type": "function"
|
||||
}
|
||||
],
|
||||
"groupBy": [
|
||||
{
|
||||
"property": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "groupBy"
|
||||
}
|
||||
],
|
||||
"limit": 50
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "elasticsearch",
|
||||
"uid": "gdev-elasticsearch"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "red",
|
||||
"name": "elastic - annos",
|
||||
"tagsField": "asd",
|
||||
"target": {
|
||||
"lines": 10,
|
||||
"query": "test query",
|
||||
"refId": "Anno",
|
||||
"scenarioId": "annotations"
|
||||
},
|
||||
"textField": "asd",
|
||||
"timeEndField": "asdas",
|
||||
"timeField": "asd"
|
||||
}
|
||||
]
|
||||
},
|
||||
"editable": true,
|
||||
"fiscalYearStartMonth": 0,
|
||||
"graphTooltip": 0,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "grafana-testdata-datasource",
|
||||
"uid": "PD8C576611E62080A"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisBorderShow": false,
|
||||
"axisCenteredZero": false,
|
||||
"axisColorMode": "text",
|
||||
"axisLabel": "",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
"barWidthFactor": 0.6,
|
||||
"drawStyle": "line",
|
||||
"fillOpacity": 0,
|
||||
"gradientMode": "none",
|
||||
"hideFrom": {
|
||||
"legend": false,
|
||||
"tooltip": false,
|
||||
"viz": false
|
||||
},
|
||||
"insertNulls": false,
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
"scaleDistribution": {
|
||||
"type": "linear"
|
||||
},
|
||||
"showPoints": "auto",
|
||||
"spanNulls": false,
|
||||
"stacking": {
|
||||
"group": "A",
|
||||
"mode": "none"
|
||||
},
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"id": 1,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"hideZeros": false,
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"pluginVersion": "12.1.0-pre",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "New panel",
|
||||
"type": "timeseries"
|
||||
}
|
||||
],
|
||||
"preload": false,
|
||||
"schemaVersion": 41,
|
||||
"tags": [],
|
||||
"templating": {
|
||||
"list": []
|
||||
},
|
||||
"time": {
|
||||
"from": "now-6h",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {},
|
||||
"timezone": "browser",
|
||||
"title": "Test: V1 dashboard with annotations",
|
||||
"version": 8
|
||||
}
|
||||
}
|
|
@ -0,0 +1,257 @@
|
|||
{
|
||||
"kind": "Dashboard",
|
||||
"apiVersion": "dashboard.grafana.app/v1beta1",
|
||||
"metadata": {
|
||||
"name": "test-v1beta1-annotations",
|
||||
"annotations": {
|
||||
"hello": "world"
|
||||
},
|
||||
"labels": {
|
||||
"region": "west"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"annotations": {
|
||||
"list": [
|
||||
{
|
||||
"builtIn": 1,
|
||||
"datasource": {
|
||||
"type": "grafana",
|
||||
"uid": "-- Grafana --"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations & Alerts",
|
||||
"target": {
|
||||
"limit": 100,
|
||||
"matchAny": false,
|
||||
"tags": [],
|
||||
"type": "dashboard"
|
||||
},
|
||||
"type": "dashboard"
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "grafana-testdata-datasource",
|
||||
"uid": "PD8C576611E62080A"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "blue",
|
||||
"name": "testdata-annos",
|
||||
"target": {
|
||||
"lines": 10,
|
||||
"refId": "Anno",
|
||||
"scenarioId": "annotations"
|
||||
}
|
||||
},
|
||||
{
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "blue",
|
||||
"name": "no-ds-testdata-annos",
|
||||
"target": {
|
||||
"lines": 10,
|
||||
"refId": "Anno",
|
||||
"scenarioId": "annotations"
|
||||
}
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "gdev-prometheus"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "yellow",
|
||||
"name": "prom-annos",
|
||||
"target": {
|
||||
"expr": "{action=\"add_client\"}",
|
||||
"interval": "",
|
||||
"lines": 10,
|
||||
"refId": "Anno",
|
||||
"scenarioId": "annotations"
|
||||
}
|
||||
},
|
||||
{
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "yellow",
|
||||
"name": "no-ds-prom-annos",
|
||||
"target": {
|
||||
"expr": "{action=\"add_client\"}",
|
||||
"interval": "",
|
||||
"lines": 10,
|
||||
"refId": "Anno",
|
||||
"scenarioId": "annotations"
|
||||
}
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "grafana-postgresql-datasource",
|
||||
"uid": "PBBCEC2D313BC06C3"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "red",
|
||||
"name": "postgress-annos",
|
||||
"target": {
|
||||
"editorMode": "builder",
|
||||
"format": "table",
|
||||
"lines": 10,
|
||||
"rawSql": "",
|
||||
"refId": "Anno",
|
||||
"scenarioId": "annotations",
|
||||
"sql": {
|
||||
"columns": [
|
||||
{
|
||||
"parameters": [],
|
||||
"type": "function"
|
||||
}
|
||||
],
|
||||
"groupBy": [
|
||||
{
|
||||
"property": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "groupBy"
|
||||
}
|
||||
],
|
||||
"limit": 50
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "elasticsearch",
|
||||
"uid": "gdev-elasticsearch"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": false,
|
||||
"iconColor": "red",
|
||||
"name": "elastic - annos",
|
||||
"tagsField": "asd",
|
||||
"target": {
|
||||
"lines": 10,
|
||||
"query": "test query",
|
||||
"refId": "Anno",
|
||||
"scenarioId": "annotations"
|
||||
},
|
||||
"textField": "asd",
|
||||
"timeEndField": "asdas",
|
||||
"timeField": "asd"
|
||||
}
|
||||
]
|
||||
},
|
||||
"editable": true,
|
||||
"fiscalYearStartMonth": 0,
|
||||
"graphTooltip": 0,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "grafana-testdata-datasource",
|
||||
"uid": "PD8C576611E62080A"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisBorderShow": false,
|
||||
"axisCenteredZero": false,
|
||||
"axisColorMode": "text",
|
||||
"axisLabel": "",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
"barWidthFactor": 0.6,
|
||||
"drawStyle": "line",
|
||||
"fillOpacity": 0,
|
||||
"gradientMode": "none",
|
||||
"hideFrom": {
|
||||
"legend": false,
|
||||
"tooltip": false,
|
||||
"viz": false
|
||||
},
|
||||
"insertNulls": false,
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
"scaleDistribution": {
|
||||
"type": "linear"
|
||||
},
|
||||
"showPoints": "auto",
|
||||
"spanNulls": false,
|
||||
"stacking": {
|
||||
"group": "A",
|
||||
"mode": "none"
|
||||
},
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"id": 1,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": true
|
||||
},
|
||||
"tooltip": {
|
||||
"hideZeros": false,
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"pluginVersion": "12.1.0-pre",
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "New panel",
|
||||
"type": "timeseries"
|
||||
}
|
||||
],
|
||||
"preload": false,
|
||||
"schemaVersion": 41,
|
||||
"tags": [],
|
||||
"templating": {
|
||||
"list": []
|
||||
},
|
||||
"time": {
|
||||
"from": "now-6h",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {},
|
||||
"timezone": "browser",
|
||||
"title": "Test: v1alpha1 dashboard with annotations",
|
||||
"version": 8
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -23,6 +23,8 @@ test.describe(
|
|||
await page.getByTestId(selectors.components.DashboardImportPage.textarea).fill(JSON.stringify(testV2Dashboard));
|
||||
await page.getByTestId(selectors.components.DashboardImportPage.submit).click();
|
||||
await page.getByTestId(selectors.components.ImportDashboardForm.name).fill('Paste tab');
|
||||
await page.getByTestId(selectors.components.DataSourcePicker.inputV2).click();
|
||||
await page.locator('div[data-testid="data-source-card"]').first().click();
|
||||
await page.getByTestId(selectors.components.ImportDashboardForm.submit).click();
|
||||
|
||||
await dashboardPage.getByGrafanaSelector(selectors.components.NavToolbar.editDashboard.editButton).click();
|
||||
|
|
|
@ -29,6 +29,8 @@ test.describe(
|
|||
await page.getByTestId(selectors.components.DashboardImportPage.textarea).fill(JSON.stringify(testV2Dashboard));
|
||||
await page.getByTestId(selectors.components.DashboardImportPage.submit).click();
|
||||
await page.getByTestId(selectors.components.ImportDashboardForm.name).fill(title);
|
||||
await page.getByTestId(selectors.components.DataSourcePicker.inputV2).click();
|
||||
await page.locator('div[data-testid="data-source-card"]').first().click();
|
||||
await page.getByTestId(selectors.components.ImportDashboardForm.submit).click();
|
||||
}
|
||||
|
||||
|
|
|
@ -381,6 +381,8 @@ async function importTestDashboard(page: Page, selectors: E2ESelectorGroups, tit
|
|||
await page.getByTestId(selectors.components.DashboardImportPage.textarea).fill(JSON.stringify(testV2Dashboard));
|
||||
await page.getByTestId(selectors.components.DashboardImportPage.submit).click();
|
||||
await page.getByTestId(selectors.components.ImportDashboardForm.name).fill(title);
|
||||
await page.getByTestId(selectors.components.DataSourcePicker.inputV2).click();
|
||||
await page.locator('div[data-testid="data-source-card"]').first().click();
|
||||
await page.getByTestId(selectors.components.ImportDashboardForm.submit).click();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,12 @@
|
|||
{
|
||||
"apiVersion": "dashboard.grafana.app/v2alpha1",
|
||||
"apiVersion": "dashboard.grafana.app/v2beta1",
|
||||
"kind": "Dashboard",
|
||||
"metadata": {
|
||||
"name": "admjzp8",
|
||||
"namespace": "default",
|
||||
"uid": "hrbekBWXeM7nC7GtouIbcngFyuqt8Xx7KlE4AnTwV7AX",
|
||||
"resourceVersion": "1",
|
||||
"name": "fa400625-2a44-4add-a369-e6c972eb4bd6",
|
||||
"generation": 1,
|
||||
"creationTimestamp": "2025-05-16T09:41:56Z",
|
||||
"labels": {
|
||||
"grafana.app/deprecatedInternalID": "182"
|
||||
},
|
||||
"annotations": {
|
||||
"grafana.app/createdBy": "user:cejvsh18uudxcf",
|
||||
"grafana.app/updatedBy": "user:cejvsh18uudxcf",
|
||||
"grafana.app/updatedTimestamp": "2025-05-16T09:41:56Z",
|
||||
"grafana.app/folder": ""
|
||||
}
|
||||
"creationTimestamp": "2025-05-27T11:40:22Z",
|
||||
"labels": {},
|
||||
"annotations": {}
|
||||
},
|
||||
"spec": {
|
||||
"annotations": [
|
||||
|
@ -24,19 +14,20 @@
|
|||
"kind": "AnnotationQuery",
|
||||
"spec": {
|
||||
"builtIn": true,
|
||||
"datasource": {
|
||||
"type": "grafana",
|
||||
"uid": "-- Grafana --"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations & Alerts"
|
||||
"name": "Annotations & Alerts",
|
||||
"query": {
|
||||
"group": "grafana",
|
||||
"kind": "DataQuery",
|
||||
"spec": {},
|
||||
"version": "v0"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"cursorSync": "Off",
|
||||
"description": "",
|
||||
"editable": true,
|
||||
"elements": {
|
||||
"panel-1": {
|
||||
|
@ -49,14 +40,12 @@
|
|||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"datasource": {
|
||||
"type": "grafana-testdata-datasource",
|
||||
"uid": "PD8C576611E62080A"
|
||||
},
|
||||
"hidden": false,
|
||||
"query": {
|
||||
"kind": "grafana-testdata-datasource",
|
||||
"spec": {}
|
||||
"group": "grafana-testdata-datasource",
|
||||
"kind": "DataQuery",
|
||||
"spec": {},
|
||||
"version": "v0"
|
||||
},
|
||||
"refId": "A"
|
||||
}
|
||||
|
@ -155,14 +144,12 @@
|
|||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"datasource": {
|
||||
"type": "grafana-testdata-datasource",
|
||||
"uid": "PD8C576611E62080A"
|
||||
},
|
||||
"hidden": false,
|
||||
"query": {
|
||||
"kind": "grafana-testdata-datasource",
|
||||
"spec": {}
|
||||
"group": "grafana-testdata-datasource",
|
||||
"kind": "DataQuery",
|
||||
"spec": {},
|
||||
"version": "v0"
|
||||
},
|
||||
"refId": "A"
|
||||
}
|
||||
|
@ -261,14 +248,12 @@
|
|||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"datasource": {
|
||||
"type": "grafana-testdata-datasource",
|
||||
"uid": "PD8C576611E62080A"
|
||||
},
|
||||
"hidden": false,
|
||||
"query": {
|
||||
"kind": "grafana-testdata-datasource",
|
||||
"spec": {}
|
||||
"group": "grafana-testdata-datasource",
|
||||
"kind": "DataQuery",
|
||||
"spec": {},
|
||||
"version": "v0"
|
||||
},
|
||||
"refId": "A"
|
||||
}
|
||||
|
@ -380,7 +365,7 @@
|
|||
"spec": {
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-2"
|
||||
"name": "panel-3"
|
||||
},
|
||||
"height": 8,
|
||||
"width": 12,
|
||||
|
@ -393,7 +378,7 @@
|
|||
"spec": {
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-3"
|
||||
"name": "panel-2"
|
||||
},
|
||||
"height": 8,
|
||||
"width": 12,
|
||||
|
@ -417,7 +402,7 @@
|
|||
"timezone": "browser",
|
||||
"to": "now"
|
||||
},
|
||||
"title": "New Test V2 Dashboard",
|
||||
"title": "Test V2 Dashboard",
|
||||
"variables": []
|
||||
},
|
||||
"status": {}
|
||||
|
|
|
@ -1,22 +1,12 @@
|
|||
{
|
||||
"apiVersion": "dashboard.grafana.app/v2alpha1",
|
||||
"apiVersion": "dashboard.grafana.app/v2beta1",
|
||||
"kind": "Dashboard",
|
||||
"metadata": {
|
||||
"name": "admjzp8",
|
||||
"namespace": "default",
|
||||
"uid": "hrbekBWXeM7nC7GtouIbcngFyuqt8Xx7KlE4AnTwV7AX",
|
||||
"resourceVersion": "1",
|
||||
"name": "fa400625-2a44-4add-a369-e6c972eb4bd6",
|
||||
"generation": 1,
|
||||
"creationTimestamp": "2025-05-16T09:41:56Z",
|
||||
"labels": {
|
||||
"grafana.app/deprecatedInternalID": "182"
|
||||
},
|
||||
"annotations": {
|
||||
"grafana.app/createdBy": "user:cejvsh18uudxcf",
|
||||
"grafana.app/updatedBy": "user:cejvsh18uudxcf",
|
||||
"grafana.app/updatedTimestamp": "2025-05-16T09:41:56Z",
|
||||
"grafana.app/folder": ""
|
||||
}
|
||||
"creationTimestamp": "2025-05-27T11:40:22Z",
|
||||
"labels": {},
|
||||
"annotations": {}
|
||||
},
|
||||
"spec": {
|
||||
"annotations": [
|
||||
|
@ -24,19 +14,20 @@
|
|||
"kind": "AnnotationQuery",
|
||||
"spec": {
|
||||
"builtIn": true,
|
||||
"datasource": {
|
||||
"type": "grafana",
|
||||
"uid": "-- Grafana --"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations & Alerts"
|
||||
"name": "Annotations & Alerts",
|
||||
"query": {
|
||||
"group": "grafana",
|
||||
"kind": "DataQuery",
|
||||
"spec": {},
|
||||
"version": "v0"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"cursorSync": "Off",
|
||||
"description": "",
|
||||
"editable": true,
|
||||
"elements": {
|
||||
"panel-1": {
|
||||
|
@ -49,14 +40,12 @@
|
|||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"datasource": {
|
||||
"type": "grafana-testdata-datasource",
|
||||
"uid": "PD8C576611E62080A"
|
||||
},
|
||||
"hidden": false,
|
||||
"query": {
|
||||
"kind": "grafana-testdata-datasource",
|
||||
"spec": {}
|
||||
"group": "grafana-testdata-datasource",
|
||||
"kind": "DataQuery",
|
||||
"spec": {},
|
||||
"version": "v0"
|
||||
},
|
||||
"refId": "A"
|
||||
}
|
||||
|
@ -155,14 +144,12 @@
|
|||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"datasource": {
|
||||
"type": "grafana-testdata-datasource",
|
||||
"uid": "PD8C576611E62080A"
|
||||
},
|
||||
"hidden": false,
|
||||
"query": {
|
||||
"kind": "grafana-testdata-datasource",
|
||||
"spec": {}
|
||||
"group": "grafana-testdata-datasource",
|
||||
"kind": "DataQuery",
|
||||
"spec": {},
|
||||
"version": "v0"
|
||||
},
|
||||
"refId": "A"
|
||||
}
|
||||
|
@ -261,14 +248,12 @@
|
|||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"datasource": {
|
||||
"type": "grafana-testdata-datasource",
|
||||
"uid": "PD8C576611E62080A"
|
||||
},
|
||||
"hidden": false,
|
||||
"query": {
|
||||
"kind": "grafana-testdata-datasource",
|
||||
"spec": {}
|
||||
"group": "grafana-testdata-datasource",
|
||||
"kind": "DataQuery",
|
||||
"spec": {},
|
||||
"version": "v0"
|
||||
},
|
||||
"refId": "A"
|
||||
}
|
||||
|
@ -380,7 +365,7 @@
|
|||
"spec": {
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-2"
|
||||
"name": "panel-3"
|
||||
},
|
||||
"height": 8,
|
||||
"width": 12,
|
||||
|
@ -393,7 +378,7 @@
|
|||
"spec": {
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-3"
|
||||
"name": "panel-2"
|
||||
},
|
||||
"height": 8,
|
||||
"width": 12,
|
||||
|
@ -417,7 +402,7 @@
|
|||
"timezone": "browser",
|
||||
"to": "now"
|
||||
},
|
||||
"title": "New Test V2 Dashboard",
|
||||
"title": "Test V2 Dashboard",
|
||||
"variables": []
|
||||
},
|
||||
"status": {}
|
||||
|
|
|
@ -17,5 +17,9 @@ export const importV2Dashboard = ({ title }: ImportDashboardConfig) => {
|
|||
if (title) {
|
||||
e2e.components.ImportDashboardForm.name().clear().type(title);
|
||||
}
|
||||
|
||||
e2e.components.DataSourcePicker.inputV2().click();
|
||||
cy.get('div[data-testid="data-source-card"]').first().click();
|
||||
|
||||
e2e.components.ImportDashboardForm.submit().click();
|
||||
};
|
||||
|
|
|
@ -579,7 +579,6 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV
|
|||
github.com/RaveNoX/go-jsoncommentstrip v1.0.0 h1:t527LHHE3HmiHrq74QMpNPZpGCIJzTx+apLkMKt4HC0=
|
||||
github.com/RoaringBitmap/gocroaring v0.4.0 h1:5nufXUgWpBEUNEJXw7926YAA58ZAQRpWPrQV1xCoSjc=
|
||||
github.com/RoaringBitmap/real-roaring-datasets v0.0.0-20190726190000-eb7c87156f76 h1:ZYlhPbqQFU+AHfgtCdHGDTtRW1a8geZyiE8c6Q+Sl1s=
|
||||
github.com/RoaringBitmap/real-roaring-datasets v0.0.0-20190726190000-eb7c87156f76/go.mod h1:oM0MHmQ3nDsq609SS36p+oYbRi16+oVvU2Bw4Ipv0SE=
|
||||
github.com/Sereal/Sereal/Go/sereal v0.0.0-20231009093132-b9187f1a92c6 h1:5kUcJJAKWWI82Xnp/CaU0eu5hLlHkmm9acjowSkwCd0=
|
||||
github.com/Sereal/Sereal/Go/sereal v0.0.0-20231009093132-b9187f1a92c6/go.mod h1:JwrycNnC8+sZPDyzM3MQ86LvaGzSpfxg885KOOwFRW4=
|
||||
github.com/Shopify/goreferrer v0.0.0-20220729165902-8cddb4f5de06 h1:KkH3I3sJuOLP3TjA/dfr4NAY8bghDwnXiU7cTKxQqo0=
|
||||
|
@ -971,8 +970,6 @@ github.com/grafana/grafana-app-sdk/logging v0.39.0/go.mod h1:WhDENSnaGHtyVVwZGVn
|
|||
github.com/grafana/grafana-app-sdk/logging v0.39.1/go.mod h1:WhDENSnaGHtyVVwZGVnAR7YLvh2xlLDYR3D7E6h7XVk=
|
||||
github.com/grafana/grafana-aws-sdk v0.38.2 h1:TzQD0OpWsNjtldi5G5TLDlBRk8OyDf+B5ujcoAu4Dp0=
|
||||
github.com/grafana/grafana-aws-sdk v0.38.2/go.mod h1:j3vi+cXYHEFqjhBGrI6/lw1TNM+dl0Y3f0cSnDOPy+s=
|
||||
github.com/grafana/grafana-aws-sdk v1.0.2 h1:98eBuHYFmgvH0xO9kKf4RBsEsgQRp8EOA/9yhDIpkss=
|
||||
github.com/grafana/grafana-aws-sdk v1.0.2/go.mod h1:hO7q7yWV+t6dmiyJjMa3IbuYnYkBua+G/IAlOPVIYKE=
|
||||
github.com/grafana/grafana-plugin-sdk-go v0.263.0/go.mod h1:U43Cnrj/9DNYyvFcNdeUWNjMXTKNB0jcTcQGpWKd2gw=
|
||||
github.com/grafana/grafana-plugin-sdk-go v0.267.0/go.mod h1:OuwS4c/JYgn0rr/w5zhJBpLo4gKm/vw15RsfpYAvK9Q=
|
||||
github.com/grafana/grafana-plugin-sdk-go v0.269.1/go.mod h1:yv2KbO4mlr9WuDK2f+2gHAMTwwLmLuqaEnrPXTRU+OI=
|
||||
|
@ -1668,7 +1665,6 @@ golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
|||
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||
golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
|
||||
golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
|
||||
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
export * from './v2beta1/types.spec.gen';
|
||||
export * from './v2beta1/types.status.gen';
|
||||
export * from './v2beta1/types.metadata.gen';
|
|
@ -1,4 +1,4 @@
|
|||
import { Spec } from './v2alpha1/types.spec.gen';
|
||||
import { defaultDataQueryKind, Spec } from './v2';
|
||||
|
||||
export const handyTestingSchema: Spec = {
|
||||
title: 'Default Dashboard',
|
||||
|
@ -37,15 +37,16 @@ export const handyTestingSchema: Spec = {
|
|||
spec: {
|
||||
builtIn: false,
|
||||
query: {
|
||||
kind: 'prometheus',
|
||||
kind: 'DataQuery',
|
||||
version: defaultDataQueryKind().version,
|
||||
group: 'prometheus',
|
||||
datasource: {
|
||||
name: 'uid',
|
||||
},
|
||||
spec: {
|
||||
expr: 'test-query',
|
||||
},
|
||||
},
|
||||
datasource: {
|
||||
type: 'prometheus',
|
||||
uid: 'uid',
|
||||
},
|
||||
filter: { ids: [1] },
|
||||
enable: true,
|
||||
hide: false,
|
||||
|
@ -57,15 +58,16 @@ export const handyTestingSchema: Spec = {
|
|||
kind: 'AnnotationQuery',
|
||||
spec: {
|
||||
builtIn: false,
|
||||
datasource: {
|
||||
type: 'grafana-testdata-datasource',
|
||||
uid: 'uid',
|
||||
},
|
||||
enable: true,
|
||||
iconColor: 'red',
|
||||
name: 'Enabled',
|
||||
query: {
|
||||
kind: 'grafana-testdata-datasource',
|
||||
kind: 'DataQuery',
|
||||
version: defaultDataQueryKind().version,
|
||||
group: 'grafana-testdata-datasource',
|
||||
datasource: {
|
||||
name: 'uid',
|
||||
},
|
||||
spec: {
|
||||
lines: 4,
|
||||
refId: 'Anno',
|
||||
|
@ -79,15 +81,16 @@ export const handyTestingSchema: Spec = {
|
|||
kind: 'AnnotationQuery',
|
||||
spec: {
|
||||
builtIn: false,
|
||||
datasource: {
|
||||
type: 'grafana-testdata-datasource',
|
||||
uid: 'uid',
|
||||
},
|
||||
enable: false,
|
||||
iconColor: 'yellow',
|
||||
name: 'Disabled',
|
||||
query: {
|
||||
kind: 'grafana-testdata-datasource',
|
||||
kind: 'DataQuery',
|
||||
version: defaultDataQueryKind().version,
|
||||
group: 'grafana-testdata-datasource',
|
||||
datasource: {
|
||||
name: 'uid',
|
||||
},
|
||||
spec: { lines: 5, refId: 'Anno', scenarioId: 'annotations' },
|
||||
},
|
||||
hide: false,
|
||||
|
@ -97,16 +100,17 @@ export const handyTestingSchema: Spec = {
|
|||
kind: 'AnnotationQuery',
|
||||
spec: {
|
||||
builtIn: false,
|
||||
datasource: {
|
||||
type: 'grafana-testdata-datasource',
|
||||
uid: 'uid',
|
||||
},
|
||||
enable: true,
|
||||
hide: true,
|
||||
iconColor: 'dark-purple',
|
||||
name: 'Hidden',
|
||||
query: {
|
||||
kind: 'grafana-testdata-datasource',
|
||||
kind: 'DataQuery',
|
||||
version: defaultDataQueryKind().version,
|
||||
group: 'grafana-testdata-datasource',
|
||||
datasource: {
|
||||
name: 'uid',
|
||||
},
|
||||
spec: {
|
||||
lines: 6,
|
||||
refId: 'Anno',
|
||||
|
@ -128,12 +132,13 @@ export const handyTestingSchema: Spec = {
|
|||
kind: 'PanelQuery',
|
||||
spec: {
|
||||
refId: 'A',
|
||||
datasource: {
|
||||
type: 'prometheus',
|
||||
uid: 'datasource1',
|
||||
},
|
||||
query: {
|
||||
kind: 'prometheus',
|
||||
kind: 'DataQuery',
|
||||
version: defaultDataQueryKind().version,
|
||||
group: 'prometheus',
|
||||
datasource: {
|
||||
name: 'datasource1',
|
||||
},
|
||||
spec: {
|
||||
expr: 'test-query',
|
||||
},
|
||||
|
@ -179,14 +184,15 @@ export const handyTestingSchema: Spec = {
|
|||
title: 'Test Panel',
|
||||
id: 1,
|
||||
vizConfig: {
|
||||
kind: 'timeseries',
|
||||
kind: 'VizConfig',
|
||||
group: 'timeseries',
|
||||
version: '7.0.0',
|
||||
spec: {
|
||||
fieldConfig: {
|
||||
defaults: {},
|
||||
overrides: [],
|
||||
},
|
||||
options: {},
|
||||
pluginVersion: '7.0.0',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -265,10 +271,6 @@ export const handyTestingSchema: Spec = {
|
|||
text: 'text1',
|
||||
value: 'value1',
|
||||
},
|
||||
datasource: {
|
||||
type: 'prometheus',
|
||||
uid: 'datasource1',
|
||||
},
|
||||
definition: 'definition1',
|
||||
description: 'A query variable',
|
||||
hide: 'dontHide',
|
||||
|
@ -278,7 +280,12 @@ export const handyTestingSchema: Spec = {
|
|||
name: 'queryVar',
|
||||
options: [],
|
||||
query: {
|
||||
kind: 'prometheus',
|
||||
kind: 'DataQuery',
|
||||
version: defaultDataQueryKind().version,
|
||||
group: 'prometheus',
|
||||
datasource: {
|
||||
name: 'datasource1',
|
||||
},
|
||||
spec: {
|
||||
expr: 'test-query',
|
||||
refId: 'A',
|
||||
|
@ -411,15 +418,15 @@ export const handyTestingSchema: Spec = {
|
|||
},
|
||||
{
|
||||
kind: 'GroupByVariable',
|
||||
group: 'prometheus',
|
||||
datasource: {
|
||||
name: 'datasource2',
|
||||
},
|
||||
spec: {
|
||||
current: {
|
||||
text: 'text7',
|
||||
value: 'value7',
|
||||
},
|
||||
datasource: {
|
||||
type: 'prometheus',
|
||||
uid: 'datasource2',
|
||||
},
|
||||
description: 'A group by variable',
|
||||
hide: 'dontHide',
|
||||
label: 'Group By Variable',
|
||||
|
@ -440,6 +447,10 @@ export const handyTestingSchema: Spec = {
|
|||
},
|
||||
{
|
||||
kind: 'AdhocVariable',
|
||||
group: 'prometheus',
|
||||
datasource: {
|
||||
name: 'datasource3',
|
||||
},
|
||||
spec: {
|
||||
baseFilters: [
|
||||
{
|
||||
|
@ -455,10 +466,6 @@ export const handyTestingSchema: Spec = {
|
|||
value: 'value2',
|
||||
},
|
||||
],
|
||||
datasource: {
|
||||
type: 'prometheus',
|
||||
uid: 'datasource3',
|
||||
},
|
||||
defaultKeys: [
|
||||
{
|
||||
expandable: true,
|
||||
|
|
|
@ -11,19 +11,19 @@ export const defaultAnnotationQueryKind = (): AnnotationQueryKind => ({
|
|||
});
|
||||
|
||||
export interface AnnotationQuerySpec {
|
||||
datasource?: DataSourceRef;
|
||||
query?: DataQueryKind;
|
||||
query: DataQueryKind;
|
||||
enable: boolean;
|
||||
hide: boolean;
|
||||
iconColor: string;
|
||||
name: string;
|
||||
builtIn?: boolean;
|
||||
filter?: AnnotationPanelFilter;
|
||||
// Catch-all field for datasource-specific properties
|
||||
// Catch-all field for datasource-specific properties. Should not be available in as code tooling.
|
||||
legacyOptions?: Record<string, any>;
|
||||
}
|
||||
|
||||
export const defaultAnnotationQuerySpec = (): AnnotationQuerySpec => ({
|
||||
query: defaultDataQueryKind(),
|
||||
enable: false,
|
||||
hide: false,
|
||||
iconColor: "",
|
||||
|
@ -31,24 +31,22 @@ export const defaultAnnotationQuerySpec = (): AnnotationQuerySpec => ({
|
|||
builtIn: false,
|
||||
});
|
||||
|
||||
export interface DataSourceRef {
|
||||
// The plugin type-id
|
||||
type?: string;
|
||||
// Specific datasource instance
|
||||
uid?: string;
|
||||
}
|
||||
|
||||
export const defaultDataSourceRef = (): DataSourceRef => ({
|
||||
});
|
||||
|
||||
export interface DataQueryKind {
|
||||
// The kind of a DataQueryKind is the datasource type
|
||||
kind: string;
|
||||
kind: "DataQuery";
|
||||
group: string;
|
||||
version: string;
|
||||
// New type for datasource reference
|
||||
// Not creating a new type until we figure out how to handle DS refs for group by, adhoc, and every place that uses DataSourceRef in TS.
|
||||
datasource?: {
|
||||
name?: string;
|
||||
};
|
||||
spec: Record<string, any>;
|
||||
}
|
||||
|
||||
export const defaultDataQueryKind = (): DataQueryKind => ({
|
||||
kind: "",
|
||||
kind: "DataQuery",
|
||||
group: "",
|
||||
version: "v0",
|
||||
spec: {},
|
||||
});
|
||||
|
||||
|
@ -151,7 +149,6 @@ export const defaultPanelQueryKind = (): PanelQueryKind => ({
|
|||
|
||||
export interface PanelQuerySpec {
|
||||
query: DataQueryKind;
|
||||
datasource?: DataSourceRef;
|
||||
refId: string;
|
||||
hidden: boolean;
|
||||
}
|
||||
|
@ -228,25 +225,27 @@ export const defaultQueryOptionsSpec = (): QueryOptionsSpec => ({
|
|||
});
|
||||
|
||||
export interface VizConfigKind {
|
||||
// The kind of a VizConfigKind is the plugin ID
|
||||
kind: string;
|
||||
kind: "VizConfig";
|
||||
// The group is the plugin ID
|
||||
group: string;
|
||||
version: string;
|
||||
spec: VizConfigSpec;
|
||||
}
|
||||
|
||||
export const defaultVizConfigKind = (): VizConfigKind => ({
|
||||
kind: "",
|
||||
kind: "VizConfig",
|
||||
group: "",
|
||||
version: "",
|
||||
spec: defaultVizConfigSpec(),
|
||||
});
|
||||
|
||||
// --- Kinds ---
|
||||
export interface VizConfigSpec {
|
||||
pluginVersion: string;
|
||||
options: Record<string, any>;
|
||||
fieldConfig: FieldConfigSource;
|
||||
}
|
||||
|
||||
export const defaultVizConfigSpec = (): VizConfigSpec => ({
|
||||
pluginVersion: "",
|
||||
options: {},
|
||||
fieldConfig: defaultFieldConfigSource(),
|
||||
});
|
||||
|
@ -994,7 +993,6 @@ export interface QueryVariableSpec {
|
|||
refresh: VariableRefresh;
|
||||
skipUrlSync: boolean;
|
||||
description?: string;
|
||||
datasource?: DataSourceRef;
|
||||
query: DataQueryKind;
|
||||
regex: string;
|
||||
sort: VariableSort;
|
||||
|
@ -1254,18 +1252,22 @@ export const defaultCustomVariableSpec = (): CustomVariableSpec => ({
|
|||
// Group variable kind
|
||||
export interface GroupByVariableKind {
|
||||
kind: "GroupByVariable";
|
||||
group: string;
|
||||
datasource?: {
|
||||
name?: string;
|
||||
};
|
||||
spec: GroupByVariableSpec;
|
||||
}
|
||||
|
||||
export const defaultGroupByVariableKind = (): GroupByVariableKind => ({
|
||||
kind: "GroupByVariable",
|
||||
group: "",
|
||||
spec: defaultGroupByVariableSpec(),
|
||||
});
|
||||
|
||||
// GroupBy variable specification
|
||||
export interface GroupByVariableSpec {
|
||||
name: string;
|
||||
datasource?: DataSourceRef;
|
||||
defaultValue?: VariableOption;
|
||||
current: VariableOption;
|
||||
options: VariableOption[];
|
||||
|
@ -1288,18 +1290,22 @@ export const defaultGroupByVariableSpec = (): GroupByVariableSpec => ({
|
|||
// Adhoc variable kind
|
||||
export interface AdhocVariableKind {
|
||||
kind: "AdhocVariable";
|
||||
group: string;
|
||||
datasource?: {
|
||||
name?: string;
|
||||
};
|
||||
spec: AdhocVariableSpec;
|
||||
}
|
||||
|
||||
export const defaultAdhocVariableKind = (): AdhocVariableKind => ({
|
||||
kind: "AdhocVariable",
|
||||
group: "",
|
||||
spec: defaultAdhocVariableSpec(),
|
||||
});
|
||||
|
||||
// Adhoc variable specification
|
||||
export interface AdhocVariableSpec {
|
||||
name: string;
|
||||
datasource?: DataSourceRef;
|
||||
baseFilters: AdHocFilterWithLabels[];
|
||||
filters: AdHocFilterWithLabels[];
|
||||
defaultKeys: MetricFindValue[];
|
|
@ -9,7 +9,7 @@ import (
|
|||
dashboardV0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashboardV1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashboardV2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashboardV2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
dashboardV2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
commonV0 "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
|
||||
"github.com/grafana/grafana/pkg/apimachinery/utils"
|
||||
"github.com/grafana/grafana/pkg/storage/unified/apistore"
|
||||
|
@ -42,8 +42,8 @@ func NewDashboardLargeObjectSupport(scheme *runtime.Scheme, threshold int) *apis
|
|||
Description: dash.Spec.Description,
|
||||
Tags: dash.Spec.Tags,
|
||||
}
|
||||
case *dashboardV2alpha2.Dashboard:
|
||||
dash.Spec = dashboardV2alpha2.DashboardSpec{
|
||||
case *dashboardV2beta1.Dashboard:
|
||||
dash.Spec = dashboardV2beta1.DashboardSpec{
|
||||
Title: dash.Spec.Title,
|
||||
Description: dash.Spec.Description,
|
||||
Tags: dash.Spec.Tags,
|
||||
|
@ -64,7 +64,7 @@ func NewDashboardLargeObjectSupport(scheme *runtime.Scheme, threshold int) *apis
|
|||
return dash.Spec.UnmarshalJSON(blob)
|
||||
case *dashboardV2alpha1.Dashboard:
|
||||
return json.Unmarshal(blob, &dash.Spec)
|
||||
case *dashboardV2alpha2.Dashboard:
|
||||
case *dashboardV2beta1.Dashboard:
|
||||
return json.Unmarshal(blob, &dash.Spec)
|
||||
default:
|
||||
return fmt.Errorf("unsupported dashboard type %T", obj)
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
dashv2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
)
|
||||
|
||||
func TestLargeDashboardSupportV1(t *testing.T) {
|
||||
|
@ -174,47 +174,47 @@ func TestLargeDashboardSupportV2alpha1(t *testing.T) {
|
|||
require.True(t, exists)
|
||||
}
|
||||
|
||||
func TestLargeDashboardSupportV2alpha2(t *testing.T) {
|
||||
func TestLargeDashboardSupportV2beta1(t *testing.T) {
|
||||
// Test RebuildSpec functionality specifically for v2 dashboards
|
||||
// This tests the json.Unmarshal(blob, &dash.Spec) path for structured specs
|
||||
// unlike v0/v1 which use the UnmarshalJSON path for unstructured specs
|
||||
|
||||
// Create a v2 dashboard with structured spec
|
||||
originalV2Dash := &dashv2alpha2.Dashboard{
|
||||
originalV2Dash := &dashv2beta1.Dashboard{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-v2",
|
||||
Namespace: "test",
|
||||
},
|
||||
Spec: dashv2alpha2.DashboardSpec{
|
||||
Spec: dashv2beta1.DashboardSpec{
|
||||
Title: "Test V2 Dashboard",
|
||||
Description: stringPtr("A test dashboard for v2 large object support"),
|
||||
Tags: []string{"test", "v2", "large-object"},
|
||||
Editable: boolPtr(true),
|
||||
LiveNow: boolPtr(false),
|
||||
Preload: false,
|
||||
Annotations: []dashv2alpha2.DashboardAnnotationQueryKind{
|
||||
Annotations: []dashv2beta1.DashboardAnnotationQueryKind{
|
||||
{
|
||||
Kind: "AnnotationQuery",
|
||||
Spec: dashv2alpha2.DashboardAnnotationQuerySpec{
|
||||
Spec: dashv2beta1.DashboardAnnotationQuerySpec{
|
||||
Name: "Test Annotation",
|
||||
},
|
||||
},
|
||||
},
|
||||
Elements: map[string]dashv2alpha2.DashboardElement{
|
||||
Elements: map[string]dashv2beta1.DashboardElement{
|
||||
"panel-1": {
|
||||
PanelKind: &dashv2alpha2.DashboardPanelKind{},
|
||||
PanelKind: &dashv2beta1.DashboardPanelKind{},
|
||||
},
|
||||
},
|
||||
Layout: dashv2alpha2.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind{},
|
||||
TimeSettings: dashv2alpha2.DashboardTimeSettingsSpec{},
|
||||
CursorSync: dashv2alpha2.DashboardDashboardCursorSyncOff,
|
||||
Variables: []dashv2alpha2.DashboardVariableKind{},
|
||||
Links: []dashv2alpha2.DashboardDashboardLink{},
|
||||
Layout: dashv2beta1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind{},
|
||||
TimeSettings: dashv2beta1.DashboardTimeSettingsSpec{},
|
||||
CursorSync: dashv2beta1.DashboardDashboardCursorSyncOff,
|
||||
Variables: []dashv2beta1.DashboardVariableKind{},
|
||||
Links: []dashv2beta1.DashboardDashboardLink{},
|
||||
},
|
||||
}
|
||||
|
||||
scheme := runtime.NewScheme()
|
||||
err := dashv2alpha2.AddToScheme(scheme)
|
||||
err := dashv2beta1.AddToScheme(scheme)
|
||||
require.NoError(t, err)
|
||||
|
||||
largeObject := NewDashboardLargeObjectSupport(scheme, 0)
|
||||
|
@ -243,7 +243,7 @@ func TestLargeDashboardSupportV2alpha2(t *testing.T) {
|
|||
require.Empty(t, dashToReduce.Spec.Links)
|
||||
|
||||
// Now test RebuildSpec - this is the key test for v2!
|
||||
rehydratedDash := &dashv2alpha2.Dashboard{
|
||||
rehydratedDash := &dashv2beta1.Dashboard{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-v2-rehydrated",
|
||||
Namespace: "test",
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
dashboardV0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashboardV1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashboardV2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashboardV2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
dashboardV2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion"
|
||||
"github.com/grafana/grafana/pkg/apimachinery/utils"
|
||||
|
@ -71,17 +71,17 @@ func (b *DashboardsAPIBuilder) Mutate(ctx context.Context, a admission.Attribute
|
|||
|
||||
resourceInfo = dashboardV2alpha1.DashboardResourceInfo
|
||||
|
||||
case *dashboardV2alpha2.Dashboard:
|
||||
case *dashboardV2beta1.Dashboard:
|
||||
// Temporary fix: The generator fails to properly initialize this property, so we'll do it here
|
||||
// until the generator is fixed.
|
||||
if v.Spec.Layout.GridLayoutKind == nil && v.Spec.Layout.RowsLayoutKind == nil && v.Spec.Layout.AutoGridLayoutKind == nil && v.Spec.Layout.TabsLayoutKind == nil {
|
||||
v.Spec.Layout.GridLayoutKind = &dashboardV2alpha2.DashboardGridLayoutKind{
|
||||
v.Spec.Layout.GridLayoutKind = &dashboardV2beta1.DashboardGridLayoutKind{
|
||||
Kind: "GridLayout",
|
||||
Spec: dashboardV2alpha2.DashboardGridLayoutSpec{},
|
||||
Spec: dashboardV2beta1.DashboardGridLayoutSpec{},
|
||||
}
|
||||
}
|
||||
|
||||
resourceInfo = dashboardV2alpha2.DashboardResourceInfo
|
||||
resourceInfo = dashboardV2beta1.DashboardResourceInfo
|
||||
|
||||
// Noop for V2
|
||||
default:
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
dashv2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration/testutil"
|
||||
|
@ -152,9 +152,9 @@ func TestDashboardAPIBuilder_Mutate(t *testing.T) {
|
|||
expectedTitle: "test123",
|
||||
},
|
||||
{
|
||||
name: "v2alpha2 should set layout if it is not set",
|
||||
inputObj: &dashv2alpha2.Dashboard{
|
||||
Spec: dashv2alpha2.DashboardSpec{
|
||||
name: "v2beta1 should set layout if it is not set",
|
||||
inputObj: &dashv2beta1.Dashboard{
|
||||
Spec: dashv2beta1.DashboardSpec{
|
||||
Title: "test123",
|
||||
},
|
||||
},
|
||||
|
@ -215,7 +215,7 @@ func TestDashboardAPIBuilder_Mutate(t *testing.T) {
|
|||
require.Equal(t, schemaversion.LATEST_VERSION, schemaVersion, "dashboard should be migrated to the latest version")
|
||||
}
|
||||
case *dashv2alpha1.Dashboard:
|
||||
case *dashv2alpha2.Dashboard:
|
||||
case *dashv2beta1.Dashboard:
|
||||
require.Equal(t, tt.expectedTitle, v.Spec.Title, "title should be set")
|
||||
require.NotNil(t, v.Spec.Layout, "layout should be set")
|
||||
require.NotNil(t, v.Spec.Layout.GridLayoutKind, "layout should be a GridLayout")
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
dashv2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration/conversion"
|
||||
"github.com/grafana/grafana/pkg/apimachinery/identity"
|
||||
|
@ -157,20 +157,20 @@ func RegisterAPIService(
|
|||
|
||||
func (b *DashboardsAPIBuilder) GetGroupVersions() []schema.GroupVersion {
|
||||
if featuremgmt.AnyEnabled(b.features, featuremgmt.FlagDashboardNewLayouts) {
|
||||
// If dashboards v2 is enabled, we want to use v2alpha1 as the default API version.
|
||||
// If dashboards v2 is enabled, we want to use v2beta1 as the default API version.
|
||||
return []schema.GroupVersion{
|
||||
dashv2beta1.DashboardResourceInfo.GroupVersion(),
|
||||
dashv2alpha1.DashboardResourceInfo.GroupVersion(),
|
||||
dashv0.DashboardResourceInfo.GroupVersion(),
|
||||
dashv1.DashboardResourceInfo.GroupVersion(),
|
||||
dashv2alpha2.DashboardResourceInfo.GroupVersion(),
|
||||
}
|
||||
}
|
||||
|
||||
return []schema.GroupVersion{
|
||||
dashv1.DashboardResourceInfo.GroupVersion(),
|
||||
dashv0.DashboardResourceInfo.GroupVersion(),
|
||||
dashv2beta1.DashboardResourceInfo.GroupVersion(),
|
||||
dashv2alpha1.DashboardResourceInfo.GroupVersion(),
|
||||
dashv2alpha2.DashboardResourceInfo.GroupVersion(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ func (b *DashboardsAPIBuilder) InstallSchema(scheme *runtime.Scheme) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := dashv2alpha2.AddToScheme(scheme); err != nil {
|
||||
if err := dashv2beta1.AddToScheme(scheme); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -401,7 +401,7 @@ func getDashboardProperties(obj runtime.Object) (string, string, error) {
|
|||
case *dashv2alpha1.Dashboard:
|
||||
title = d.Spec.Title
|
||||
refresh = d.Spec.TimeSettings.AutoRefresh
|
||||
case *dashv2alpha2.Dashboard:
|
||||
case *dashv2beta1.Dashboard:
|
||||
title = d.Spec.Title
|
||||
refresh = d.Spec.TimeSettings.AutoRefresh
|
||||
default:
|
||||
|
@ -483,11 +483,11 @@ func (b *DashboardsAPIBuilder) UpdateAPIGroupInfo(apiGroupInfo *genericapiserver
|
|||
}
|
||||
|
||||
if err := b.storageForVersion(apiGroupInfo, opts, largeObjects,
|
||||
dashv2alpha2.DashboardResourceInfo,
|
||||
dashv2beta1.DashboardResourceInfo,
|
||||
nil, // do not register library panel
|
||||
func(obj runtime.Object, access *internal.DashboardAccess) (v runtime.Object, err error) {
|
||||
dto := &dashv2alpha2.DashboardWithAccessInfo{}
|
||||
dash, ok := obj.(*dashv2alpha2.Dashboard)
|
||||
dto := &dashv2beta1.DashboardWithAccessInfo{}
|
||||
dash, ok := obj.(*dashv2beta1.Dashboard)
|
||||
if ok {
|
||||
dto.Dashboard = *dash
|
||||
}
|
||||
|
@ -572,7 +572,7 @@ func (b *DashboardsAPIBuilder) GetOpenAPIDefinitions() common.GetOpenAPIDefiniti
|
|||
defs := dashv0.GetOpenAPIDefinitions(ref)
|
||||
maps.Copy(defs, dashv1.GetOpenAPIDefinitions(ref))
|
||||
maps.Copy(defs, dashv2alpha1.GetOpenAPIDefinitions(ref))
|
||||
maps.Copy(defs, dashv2alpha2.GetOpenAPIDefinitions(ref))
|
||||
maps.Copy(defs, dashv2beta1.GetOpenAPIDefinitions(ref))
|
||||
return defs
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
dashv0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashv2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
dashv2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
|
||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
|
@ -177,8 +177,8 @@ func TestDashboardAPIBuilder_GetGroupVersions(t *testing.T) {
|
|||
expected: []schema.GroupVersion{
|
||||
dashv1.DashboardResourceInfo.GroupVersion(),
|
||||
dashv0.DashboardResourceInfo.GroupVersion(),
|
||||
dashv2beta1.DashboardResourceInfo.GroupVersion(),
|
||||
dashv2alpha1.DashboardResourceInfo.GroupVersion(),
|
||||
dashv2alpha2.DashboardResourceInfo.GroupVersion(),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -189,8 +189,8 @@ func TestDashboardAPIBuilder_GetGroupVersions(t *testing.T) {
|
|||
expected: []schema.GroupVersion{
|
||||
dashv1.DashboardResourceInfo.GroupVersion(),
|
||||
dashv0.DashboardResourceInfo.GroupVersion(),
|
||||
dashv2beta1.DashboardResourceInfo.GroupVersion(),
|
||||
dashv2alpha1.DashboardResourceInfo.GroupVersion(),
|
||||
dashv2alpha2.DashboardResourceInfo.GroupVersion(),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -199,10 +199,10 @@ func TestDashboardAPIBuilder_GetGroupVersions(t *testing.T) {
|
|||
featuremgmt.FlagDashboardNewLayouts,
|
||||
},
|
||||
expected: []schema.GroupVersion{
|
||||
dashv2beta1.DashboardResourceInfo.GroupVersion(),
|
||||
dashv2alpha1.DashboardResourceInfo.GroupVersion(),
|
||||
dashv0.DashboardResourceInfo.GroupVersion(),
|
||||
dashv1.DashboardResourceInfo.GroupVersion(),
|
||||
dashv2alpha2.DashboardResourceInfo.GroupVersion(),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
v0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
v1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
v2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
v2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
v2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
"github.com/grafana/grafana/pkg/apimachinery/utils"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
)
|
||||
|
@ -34,7 +34,7 @@ func (b *DashboardsAPIBuilder) ValidateDashboardSpec(ctx context.Context, obj ru
|
|||
case *v1.Dashboard:
|
||||
errorOnSchemaMismatches = !b.features.IsEnabled(ctx, featuremgmt.FlagDashboardDisableSchemaValidationV1)
|
||||
case *v2alpha1.Dashboard:
|
||||
case *v2alpha2.Dashboard:
|
||||
case *v2beta1.Dashboard:
|
||||
errorOnSchemaMismatches = !b.features.IsEnabled(ctx, featuremgmt.FlagDashboardDisableSchemaValidationV2)
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid dashboard type: %T", obj)
|
||||
|
@ -56,8 +56,8 @@ func (b *DashboardsAPIBuilder) ValidateDashboardSpec(ctx context.Context, obj ru
|
|||
errors, schemaVersionError = v1.ValidateDashboardSpec(v, alwaysLogSchemaValidationErrors)
|
||||
case *v2alpha1.Dashboard:
|
||||
errors = v2alpha1.ValidateDashboardSpec(v)
|
||||
case *v2alpha2.Dashboard:
|
||||
errors = v2alpha2.ValidateDashboardSpec(v)
|
||||
case *v2beta1.Dashboard:
|
||||
errors = v2beta1.ValidateDashboardSpec(v)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,9 +54,9 @@ func ExportResources(ctx context.Context, options provisioning.ExportJobOptions,
|
|||
return v2clientAlphaV1.Get(ctx, item.GetName(), metav1.GetOptions{})
|
||||
}
|
||||
|
||||
if strings.HasPrefix(storedVersion, "v2alpha2") {
|
||||
if strings.HasPrefix(storedVersion, "v2beta1") {
|
||||
if v2clientAlphaV2 == nil {
|
||||
v2clientAlphaV2, _, err = clients.ForResource(resources.DashboardResourceV2alpha2)
|
||||
v2clientAlphaV2, _, err = clients.ForResource(resources.DashboardResourceV2beta1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -434,7 +434,7 @@ func TestExportResources_Dashboards_V2Alpha1_ClientError(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestExportResources_Dashboards_V2Alpha2(t *testing.T) {
|
||||
func TestExportResources_Dashboards_V2beta1(t *testing.T) {
|
||||
mockItems := []unstructured.Unstructured{
|
||||
{
|
||||
Object: map[string]interface{}{
|
||||
|
@ -446,7 +446,7 @@ func TestExportResources_Dashboards_V2Alpha2(t *testing.T) {
|
|||
"status": map[string]interface{}{
|
||||
"conversion": map[string]interface{}{
|
||||
"failed": true,
|
||||
"storedVersion": "v2alpha2",
|
||||
"storedVersion": "v2beta1",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -467,9 +467,9 @@ func TestExportResources_Dashboards_V2Alpha2(t *testing.T) {
|
|||
resourceClients.On("ForResource", resources.DashboardResource).Return(mockClient, gvk, nil)
|
||||
|
||||
// Setup v2 client
|
||||
v2Dashboard := createV2DashboardObject("v2-dashboard", "v2alpha2")
|
||||
v2Dashboard := createV2DashboardObject("v2-dashboard", "v2beta1")
|
||||
v2Client := &mockDynamicInterface{items: []unstructured.Unstructured{v2Dashboard}}
|
||||
resourceClients.On("ForResource", resources.DashboardResourceV2alpha2).Return(v2Client, gvk, nil)
|
||||
resourceClients.On("ForResource", resources.DashboardResourceV2beta1).Return(v2Client, gvk, nil)
|
||||
|
||||
options := resources.WriteOptions{
|
||||
Path: "grafana",
|
||||
|
@ -482,7 +482,7 @@ func TestExportResources_Dashboards_V2Alpha2(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestExportResources_Dashboards_V2Alpha2_ClientError(t *testing.T) {
|
||||
func TestExportResources_Dashboards_V2beta1_ClientError(t *testing.T) {
|
||||
mockItems := []unstructured.Unstructured{
|
||||
{
|
||||
Object: map[string]interface{}{
|
||||
|
@ -494,7 +494,7 @@ func TestExportResources_Dashboards_V2Alpha2_ClientError(t *testing.T) {
|
|||
"status": map[string]interface{}{
|
||||
"conversion": map[string]interface{}{
|
||||
"failed": true,
|
||||
"storedVersion": "v2alpha2",
|
||||
"storedVersion": "v2beta1",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -525,7 +525,7 @@ func TestExportResources_Dashboards_V2Alpha2_ClientError(t *testing.T) {
|
|||
}
|
||||
|
||||
setupResources := func(repoResources *resources.MockRepositoryResources, resourceClients *resources.MockResourceClients, mockClient *mockDynamicInterface, gvk schema.GroupVersionKind) {
|
||||
resourceClients.On("ForResource", resources.DashboardResourceV2alpha2).Return(nil, gvk, fmt.Errorf("v2 client error"))
|
||||
resourceClients.On("ForResource", resources.DashboardResourceV2beta1).Return(nil, gvk, fmt.Errorf("v2 client error"))
|
||||
resourceClients.On("ForResource", resources.DashboardResource).Return(mockClient, gvk, nil)
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
dashboardV1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashboardV2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashboardV2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
dashboardV2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
folders "github.com/grafana/grafana/apps/folder/pkg/apis/folder/v1beta1"
|
||||
iam "github.com/grafana/grafana/pkg/apis/iam/v0alpha1"
|
||||
"github.com/grafana/grafana/pkg/services/apiserver"
|
||||
|
@ -24,7 +24,7 @@ var (
|
|||
FolderResource = folders.FolderResourceInfo.GroupVersionResource()
|
||||
DashboardResource = dashboardV1.DashboardResourceInfo.GroupVersionResource()
|
||||
DashboardResourceV2alpha1 = dashboardV2alpha1.DashboardResourceInfo.GroupVersionResource()
|
||||
DashboardResourceV2alpha2 = dashboardV2alpha2.DashboardResourceInfo.GroupVersionResource()
|
||||
DashboardResourceV2beta1 = dashboardV2beta1.DashboardResourceInfo.GroupVersionResource()
|
||||
|
||||
// SupportedProvisioningResources is the list of resources that can fully managed from the UI
|
||||
SupportedProvisioningResources = []schema.GroupVersionResource{FolderResource, DashboardResource}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||
|
||||
dashboardV2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashboardV2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
dashboardV2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
"github.com/grafana/grafana/pkg/infra/localcache"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||
|
@ -101,8 +101,8 @@ func (s *Server) getContextuals(subject string) (*openfgav1.ContextualTupleKeys,
|
|||
User: subject,
|
||||
Relation: common.RelationSetView,
|
||||
Object: common.NewGroupResourceIdent(
|
||||
dashboardV2alpha2.DashboardResourceInfo.GroupResource().Group,
|
||||
dashboardV2alpha2.DashboardResourceInfo.GroupResource().Resource,
|
||||
dashboardV2beta1.DashboardResourceInfo.GroupResource().Group,
|
||||
dashboardV2beta1.DashboardResourceInfo.GroupResource().Resource,
|
||||
"",
|
||||
),
|
||||
},
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
dashboardV0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashboardV1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashboardV2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashboardV2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
dashboardV2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
@ -191,10 +191,10 @@ func TestIntegrationDashboardsAppV2alpha1(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestIntegrationDashboardsAppV2alpha2(t *testing.T) {
|
||||
func TestIntegrationDashboardsAppV2beta1(t *testing.T) {
|
||||
gvr := schema.GroupVersionResource{
|
||||
Group: dashboardV2alpha2.GROUP,
|
||||
Version: dashboardV2alpha2.VERSION,
|
||||
Group: dashboardV2beta1.GROUP,
|
||||
Version: dashboardV2beta1.VERSION,
|
||||
Resource: "dashboards",
|
||||
}
|
||||
if testing.Short() {
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
dashboardV0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashboardV1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashboardV2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashboardV2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
dashboardV2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
foldersV1 "github.com/grafana/grafana/apps/folder/pkg/apis/folder/v1beta1"
|
||||
"github.com/grafana/grafana/pkg/apiserver/rest"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
|
@ -440,12 +440,12 @@ func runDashboardValidationTests(t *testing.T, ctx TestContext) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "v2alpha2 dashboard with correct spec should not throw on v2",
|
||||
resourceInfo: dashboardV2alpha2.DashboardResourceInfo,
|
||||
name: "v2beta1 dashboard with correct spec should not throw on v2",
|
||||
resourceInfo: dashboardV2beta1.DashboardResourceInfo,
|
||||
expectSpecErr: false,
|
||||
testObject: &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
"apiVersion": dashboardV2alpha2.DashboardResourceInfo.TypeMeta().APIVersion,
|
||||
"apiVersion": dashboardV2beta1.DashboardResourceInfo.TypeMeta().APIVersion,
|
||||
"kind": "Dashboard",
|
||||
"metadata": map[string]interface{}{
|
||||
"generateName": "test-",
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
apiVersion: dashboard.grafana.app/v2alpha2
|
||||
kind: Dashboard
|
||||
metadata:
|
||||
name: test-v2alpha2
|
||||
spec:
|
||||
title: Test dashboard. Created at v2alpha2
|
||||
layout:
|
||||
kind: GridLayout
|
||||
spec:
|
||||
items: []
|
|
@ -0,0 +1,10 @@
|
|||
apiVersion: dashboard.grafana.app/v2beta1
|
||||
kind: Dashboard
|
||||
metadata:
|
||||
name: test-v2beta1
|
||||
spec:
|
||||
title: Test dashboard. Created at v2beta1
|
||||
layout:
|
||||
kind: GridLayout
|
||||
spec:
|
||||
items: []
|
|
@ -25,7 +25,7 @@ import (
|
|||
dashboardV0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
||||
dashboardV1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashboardsV2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
dashboardsV2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
|
||||
dashboardsV2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
||||
folder "github.com/grafana/grafana/apps/folder/pkg/apis/folder/v1beta1"
|
||||
provisioning "github.com/grafana/grafana/pkg/apis/provisioning/v0alpha1"
|
||||
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest"
|
||||
|
@ -51,7 +51,7 @@ type provisioningTestHelper struct {
|
|||
DashboardsV0 *apis.K8sResourceClient
|
||||
DashboardsV1 *apis.K8sResourceClient
|
||||
DashboardsV2alpha1 *apis.K8sResourceClient
|
||||
DashboardsV2alpha2 *apis.K8sResourceClient
|
||||
DashboardsV2beta1 *apis.K8sResourceClient
|
||||
AdminREST *rest.RESTClient
|
||||
EditorREST *rest.RESTClient
|
||||
ViewerREST *rest.RESTClient
|
||||
|
@ -270,10 +270,10 @@ func runGrafana(t *testing.T, options ...grafanaOption) *provisioningTestHelper
|
|||
Namespace: "default", // actually org1
|
||||
GVR: dashboardsV2alpha1.DashboardResourceInfo.GroupVersionResource(),
|
||||
})
|
||||
dashboardsV2alpha2 := helper.GetResourceClient(apis.ResourceClientArgs{
|
||||
dashboardsV2beta1 := helper.GetResourceClient(apis.ResourceClientArgs{
|
||||
User: helper.Org1.Admin,
|
||||
Namespace: "default", // actually org1
|
||||
GVR: dashboardsV2alpha2.DashboardResourceInfo.GroupVersionResource(),
|
||||
GVR: dashboardsV2beta1.DashboardResourceInfo.GroupVersionResource(),
|
||||
})
|
||||
|
||||
// Repo client, but less guard rails. Useful for subresources. We'll need this later...
|
||||
|
@ -313,7 +313,7 @@ func runGrafana(t *testing.T, options ...grafanaOption) *provisioningTestHelper
|
|||
DashboardsV0: dashboardsV0,
|
||||
DashboardsV1: dashboardsV1,
|
||||
DashboardsV2alpha1: dashboardsV2alpha1,
|
||||
DashboardsV2alpha2: dashboardsV2alpha2,
|
||||
DashboardsV2beta1: dashboardsV2beta1,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -658,9 +658,9 @@ func TestProvisioning_ExportUnifiedToRepository(t *testing.T) {
|
|||
_, err = helper.DashboardsV2alpha1.Resource.Create(ctx, dashboard, metav1.CreateOptions{})
|
||||
require.NoError(t, err, "should be able to create v2alpha1 dashboard")
|
||||
|
||||
dashboard = helper.LoadYAMLOrJSONFile("exportunifiedtorepository/dashboard-test-v2alpha2.yaml")
|
||||
_, err = helper.DashboardsV2alpha2.Resource.Create(ctx, dashboard, metav1.CreateOptions{})
|
||||
require.NoError(t, err, "should be able to create v2alpha2 dashboard")
|
||||
dashboard = helper.LoadYAMLOrJSONFile("exportunifiedtorepository/dashboard-test-v2beta1.yaml")
|
||||
_, err = helper.DashboardsV2beta1.Resource.Create(ctx, dashboard, metav1.CreateOptions{})
|
||||
require.NoError(t, err, "should be able to create v2beta1 dashboard")
|
||||
|
||||
// Now for the repository.
|
||||
const repo = "local-repository"
|
||||
|
@ -701,7 +701,7 @@ func TestProvisioning_ExportUnifiedToRepository(t *testing.T) {
|
|||
{title: "Test dashboard. Created at v0", apiVersion: "dashboard.grafana.app/v0alpha1", name: "test-v0", fileName: "test-dashboard-created-at-v0.json"},
|
||||
{title: "Test dashboard. Created at v1", apiVersion: "dashboard.grafana.app/v1beta1", name: "test-v1", fileName: "test-dashboard-created-at-v1.json"},
|
||||
{title: "Test dashboard. Created at v2alpha1", apiVersion: "dashboard.grafana.app/v2alpha1", name: "test-v2alpha1", fileName: "test-dashboard-created-at-v2alpha1.json"},
|
||||
{title: "Test dashboard. Created at v2alpha2", apiVersion: "dashboard.grafana.app/v2alpha2", name: "test-v2alpha2", fileName: "test-dashboard-created-at-v2alpha2.json"},
|
||||
{title: "Test dashboard. Created at v2beta1", apiVersion: "dashboard.grafana.app/v2beta1", name: "test-v2beta1", fileName: "test-dashboard-created-at-v2beta1.json"},
|
||||
} {
|
||||
fpath := filepath.Join(helper.ProvisioningPath, test.fileName)
|
||||
//nolint:gosec // we are ok with reading files in testdata
|
||||
|
|
|
@ -6,7 +6,7 @@ import { defaultDashboard as defaultDashboardData } from '@grafana/schema';
|
|||
import {
|
||||
Spec as DashboardV2Spec,
|
||||
defaultSpec as defaultDashboardV2Spec,
|
||||
} from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
} from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import { backendSrv } from 'app/core/services/backend_srv';
|
||||
import { DashboardWithAccessInfo } from 'app/features/dashboard/api/types';
|
||||
import { DashboardSearchItemType } from 'app/features/search/types';
|
||||
|
@ -80,7 +80,7 @@ const mockDashboard: DashboardDTO = {
|
|||
};
|
||||
|
||||
const mockDashboardV2: DashboardWithAccessInfo<DashboardV2Spec> = {
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
spec: {
|
||||
...defaultDashboardV2Spec(),
|
||||
|
|
|
@ -4,7 +4,7 @@ import { AppEvents, isTruthy, locationUtil } from '@grafana/data';
|
|||
import { t } from '@grafana/i18n';
|
||||
import { config, getBackendSrv, isFetchError, locationService } from '@grafana/runtime';
|
||||
import { Dashboard } from '@grafana/schema';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import { folderAPIv1beta1 as folderAPI } from 'app/api/clients/folder/v1beta1';
|
||||
import { createBaseQuery, handleRequestError } from 'app/api/createBaseQuery';
|
||||
import appEvents from 'app/core/app_events';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { t } from '@grafana/i18n';
|
||||
import { SceneComponentProps, sceneGraph, SceneObject, SceneObjectBase, SceneObjectState } from '@grafana/scenes';
|
||||
import { ConditionalRenderingGroupKind } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { ConditionalRenderingGroupKind } from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
|
||||
import { ConditionalRenderingChangedEvent } from '../edit-pane/shared';
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import { useMemo } from 'react';
|
|||
import { PanelData } from '@grafana/data';
|
||||
import { t } from '@grafana/i18n';
|
||||
import { SceneComponentProps, sceneGraph } from '@grafana/scenes';
|
||||
import { ConditionalRenderingDataKind } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { ConditionalRenderingDataKind } from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import { Combobox, ComboboxOption } from '@grafana/ui';
|
||||
|
||||
import { dashboardEditActions } from '../edit-pane/shared';
|
||||
|
|
|
@ -3,7 +3,7 @@ import { useMemo } from 'react';
|
|||
|
||||
import { t } from '@grafana/i18n';
|
||||
import { SceneComponentProps, sceneGraph } from '@grafana/scenes';
|
||||
import { ConditionalRenderingGroupKind } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { ConditionalRenderingGroupKind } from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import { Stack } from '@grafana/ui';
|
||||
|
||||
import { dashboardEditActions } from '../edit-pane/shared';
|
||||
|
|
|
@ -4,7 +4,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|||
import { rangeUtil, SelectableValue } from '@grafana/data';
|
||||
import { t } from '@grafana/i18n';
|
||||
import { SceneComponentProps, sceneGraph } from '@grafana/scenes';
|
||||
import { ConditionalRenderingTimeRangeSizeKind } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { ConditionalRenderingTimeRangeSizeKind } from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import { Field, Select, useStyles2 } from '@grafana/ui';
|
||||
|
||||
import { dashboardEditActions } from '../edit-pane/shared';
|
||||
|
|
|
@ -2,7 +2,7 @@ import { useMemo } from 'react';
|
|||
|
||||
import { t } from '@grafana/i18n';
|
||||
import { SceneComponentProps, sceneGraph, VariableDependencyConfig } from '@grafana/scenes';
|
||||
import { ConditionalRenderingVariableKind } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { ConditionalRenderingVariableKind } from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import { Box, Combobox, ComboboxOption, Input, Stack } from '@grafana/ui';
|
||||
|
||||
import { dashboardEditActions } from '../edit-pane/shared';
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
ConditionalRenderingGroupKind,
|
||||
ConditionalRenderingTimeRangeSizeKind,
|
||||
ConditionalRenderingVariableKind,
|
||||
} from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
} from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
|
||||
import { ConditionalRenderingData } from './ConditionalRenderingData';
|
||||
import { ConditionalRenderingGroup } from './ConditionalRenderingGroup';
|
||||
|
|
|
@ -4,7 +4,7 @@ import { BackendSrv, config, locationService, setBackendSrv } from '@grafana/run
|
|||
import {
|
||||
Spec as DashboardV2Spec,
|
||||
defaultSpec as defaultDashboardV2Spec,
|
||||
} from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
} from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import store from 'app/core/store';
|
||||
import { getDashboardAPI } from 'app/features/dashboard/api/dashboard_api';
|
||||
import { DashboardVersionError, DashboardWithAccessInfo } from 'app/features/dashboard/api/types';
|
||||
|
@ -37,6 +37,39 @@ jest.mock('@grafana/runtime', () => {
|
|||
...original.config.featureToggles,
|
||||
dashboardNewLayouts: false, // Default value
|
||||
},
|
||||
|
||||
bootData: {
|
||||
...original.config.bootData,
|
||||
settings: {
|
||||
...original.config.bootData.settings,
|
||||
datasources: {
|
||||
'gdev-testdata': {
|
||||
id: 7,
|
||||
uid: 'abc',
|
||||
type: 'grafana-testdata-datasource',
|
||||
name: 'gdev-testdata',
|
||||
meta: {
|
||||
id: 'grafana-testdata-datasource',
|
||||
type: 'datasource',
|
||||
name: 'TestData',
|
||||
aliasIDs: ['testdata'],
|
||||
},
|
||||
},
|
||||
'-- Grafana --': {
|
||||
id: -1,
|
||||
uid: 'grafana',
|
||||
type: 'datasource',
|
||||
name: '-- Grafana --',
|
||||
meta: {
|
||||
id: 'grafana',
|
||||
type: 'datasource',
|
||||
name: '-- Grafana --',
|
||||
},
|
||||
},
|
||||
},
|
||||
defaultDatasource: 'gdev-testdata',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@ -64,7 +97,7 @@ const setupDashboardAPI = (
|
|||
const setupV1FailureV2Success = (
|
||||
v2Response: DashboardWithAccessInfo<DashboardV2Spec> = {
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash',
|
||||
|
@ -75,7 +108,7 @@ const setupV1FailureV2Success = (
|
|||
}
|
||||
) => {
|
||||
const getDashSpy = jest.fn();
|
||||
setupLoadDashboardMockReject(new DashboardVersionError('v2alpha1'));
|
||||
setupLoadDashboardMockReject(new DashboardVersionError('v2beta1'));
|
||||
setupDashboardAPI(v2Response, getDashSpy);
|
||||
return getDashSpy;
|
||||
};
|
||||
|
@ -331,7 +364,7 @@ describe('DashboardScenePageStateManager v2', () => {
|
|||
setupDashboardAPI(
|
||||
{
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash',
|
||||
|
@ -378,7 +411,7 @@ describe('DashboardScenePageStateManager v2', () => {
|
|||
setupDashboardAPI(
|
||||
{
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash',
|
||||
|
@ -398,7 +431,7 @@ describe('DashboardScenePageStateManager v2', () => {
|
|||
setupDashboardAPI(
|
||||
{
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash2',
|
||||
|
@ -421,7 +454,7 @@ describe('DashboardScenePageStateManager v2', () => {
|
|||
setupDashboardAPI(
|
||||
{
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash',
|
||||
|
@ -446,7 +479,7 @@ describe('DashboardScenePageStateManager v2', () => {
|
|||
setupDashboardAPI(
|
||||
{
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash',
|
||||
|
@ -543,7 +576,7 @@ describe('DashboardScenePageStateManager v2', () => {
|
|||
setupDashboardAPI(
|
||||
{
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash',
|
||||
|
@ -577,7 +610,7 @@ describe('DashboardScenePageStateManager v2', () => {
|
|||
|
||||
loader.setDashboardCache('fake-dash', {
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash',
|
||||
|
@ -600,7 +633,7 @@ describe('DashboardScenePageStateManager v2', () => {
|
|||
setupDashboardAPI(
|
||||
{
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash',
|
||||
|
@ -626,7 +659,7 @@ describe('DashboardScenePageStateManager v2', () => {
|
|||
setupDashboardAPI(
|
||||
{
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash',
|
||||
|
@ -661,7 +694,7 @@ describe('DashboardScenePageStateManager v2', () => {
|
|||
setupDashboardAPI(
|
||||
{
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash',
|
||||
|
@ -684,7 +717,7 @@ describe('DashboardScenePageStateManager v2', () => {
|
|||
setupDashboardAPI(
|
||||
{
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash',
|
||||
|
@ -709,7 +742,7 @@ describe('DashboardScenePageStateManager v2', () => {
|
|||
setupDashboardAPI(
|
||||
{
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash',
|
||||
|
@ -740,7 +773,7 @@ describe('DashboardScenePageStateManager v2', () => {
|
|||
setupDashboardAPI(
|
||||
{
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash',
|
||||
|
@ -761,7 +794,7 @@ describe('DashboardScenePageStateManager v2', () => {
|
|||
setupDashboardAPI(
|
||||
{
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash',
|
||||
|
@ -791,7 +824,7 @@ describe('DashboardScenePageStateManager v2', () => {
|
|||
setupDashboardAPI(
|
||||
{
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash',
|
||||
|
@ -825,7 +858,7 @@ describe('DashboardScenePageStateManager v2', () => {
|
|||
setupDashboardAPI(
|
||||
{
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash',
|
||||
|
@ -842,7 +875,7 @@ describe('DashboardScenePageStateManager v2', () => {
|
|||
await loader.loadDashboard({ uid: 'fake-dash', route: DashboardRoutes.Normal });
|
||||
|
||||
const mockLoader = {
|
||||
loadDashboard: jest.fn().mockRejectedValue(new DashboardVersionError('v2alpha1')),
|
||||
loadDashboard: jest.fn().mockRejectedValue(new DashboardVersionError('v2beta1')),
|
||||
};
|
||||
|
||||
loader['dashboardLoader'] = mockLoader as unknown as DashboardLoaderSrvV2;
|
||||
|
@ -915,7 +948,7 @@ describe('UnifiedDashboardScenePageStateManager', () => {
|
|||
const originalFetchDashboard = v2Manager.fetchDashboard;
|
||||
v2Manager.fetchDashboard = jest.fn().mockResolvedValue({
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'fake-dash',
|
||||
|
@ -951,7 +984,7 @@ describe('UnifiedDashboardScenePageStateManager', () => {
|
|||
// V2 dashboard response
|
||||
const v2Response: DashboardWithAccessInfo<DashboardV2Spec> = {
|
||||
access: {},
|
||||
apiVersion: 'v2alpha1',
|
||||
apiVersion: 'v2beta1',
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
metadata: {
|
||||
name: 'v2-dash',
|
||||
|
@ -1215,7 +1248,7 @@ const customHomeDashboardV1Spec = {
|
|||
content: '# Welcome to the home dashboard!\n\n## Example of v2 schema home dashboard',
|
||||
mode: 'markdown',
|
||||
},
|
||||
pluginVersion: '',
|
||||
pluginVersion: '1.0.0',
|
||||
targets: [{ refId: 'A' }],
|
||||
title: 'Welcome',
|
||||
transformations: [],
|
||||
|
@ -1272,9 +1305,10 @@ const customHomeDashboardV2Spec = {
|
|||
},
|
||||
},
|
||||
vizConfig: {
|
||||
kind: 'text',
|
||||
kind: 'VizConfig',
|
||||
version: '1.0.0',
|
||||
group: 'text',
|
||||
spec: {
|
||||
pluginVersion: '',
|
||||
options: {
|
||||
mode: 'markdown',
|
||||
content: '# Welcome to the home dashboard!\n\n## Example of v2 schema home dashboard',
|
||||
|
@ -1557,7 +1591,7 @@ const v2ProvisionedDashboardResource = {
|
|||
resource: {
|
||||
type: {
|
||||
group: 'dashboard.grafana.app',
|
||||
version: 'v2alpha1',
|
||||
version: 'v2beta1',
|
||||
kind: 'Dashboard',
|
||||
resource: 'dashboards',
|
||||
},
|
||||
|
@ -1565,7 +1599,7 @@ const v2ProvisionedDashboardResource = {
|
|||
existing: {},
|
||||
action: 'update',
|
||||
dryRun: {
|
||||
apiVersion: 'dashboard.grafana.app/v2alpha1',
|
||||
apiVersion: 'dashboard.grafana.app/v2beta1',
|
||||
kind: 'Dashboard',
|
||||
metadata: {
|
||||
annotations: {
|
||||
|
@ -1588,9 +1622,11 @@ const v2ProvisionedDashboardResource = {
|
|||
kind: 'AnnotationQuery',
|
||||
spec: {
|
||||
builtIn: true,
|
||||
datasource: {
|
||||
type: 'grafana',
|
||||
uid: '-- Grafana --',
|
||||
query: {
|
||||
kind: 'DataQuery',
|
||||
group: 'grafana',
|
||||
spec: {},
|
||||
version: 'v0',
|
||||
},
|
||||
enable: true,
|
||||
hide: true,
|
||||
|
@ -1613,13 +1649,14 @@ const v2ProvisionedDashboardResource = {
|
|||
{
|
||||
kind: 'PanelQuery',
|
||||
spec: {
|
||||
datasource: {
|
||||
type: 'grafana-testdata-datasource',
|
||||
uid: 'PD8C576611E62080A',
|
||||
},
|
||||
hidden: false,
|
||||
query: {
|
||||
kind: 'grafana-testdata-datasource',
|
||||
kind: 'DataQuery',
|
||||
group: 'grafana-testdata-datasource',
|
||||
version: 'v0',
|
||||
datasource: {
|
||||
name: 'PD8C576611E62080A',
|
||||
},
|
||||
spec: {
|
||||
scenarioId: 'random_walk',
|
||||
seriesCount: 2,
|
||||
|
|
|
@ -2,7 +2,7 @@ import { locationUtil, UrlQueryMap } from '@grafana/data';
|
|||
import { t } from '@grafana/i18n';
|
||||
import { config, getBackendSrv, isFetchError, locationService } from '@grafana/runtime';
|
||||
import { sceneGraph } from '@grafana/scenes';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import { BASE_URL } from 'app/api/clients/provisioning/v0alpha1/baseAPI';
|
||||
import { StateManagerBase } from 'app/core/services/StateManagerBase';
|
||||
import { getMessageFromError, getMessageIdFromError, getStatusFromError } from 'app/core/utils/errors';
|
||||
|
@ -15,7 +15,7 @@ import {
|
|||
} from 'app/features/apiserver/types';
|
||||
import { transformDashboardV2SpecToV1 } from 'app/features/dashboard/api/ResponseTransformers';
|
||||
import { DashboardVersionError, DashboardWithAccessInfo } from 'app/features/dashboard/api/types';
|
||||
import { isDashboardV2Resource, isDashboardV2Spec } from 'app/features/dashboard/api/utils';
|
||||
import { isDashboardV2Resource, isDashboardV2Spec, isV2StoredVersion } from 'app/features/dashboard/api/utils';
|
||||
import { dashboardLoaderSrv, DashboardLoaderSrvV2 } from 'app/features/dashboard/services/DashboardLoaderSrv';
|
||||
import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv';
|
||||
import { emitDashboardViewEvent } from 'app/features/dashboard/state/analyticsProcessor';
|
||||
|
@ -204,7 +204,7 @@ abstract class DashboardScenePageStateManagerBase<T>
|
|||
dryRun: any,
|
||||
provisioningPreview: ProvisioningPreview
|
||||
) {
|
||||
if (dryRun.apiVersion.split('/')[1] === 'v2alpha1') {
|
||||
if (dryRun.apiVersion.split('/')[1] === 'v2beta1') {
|
||||
return {
|
||||
...dryRun,
|
||||
kind: 'DashboardWithAccessInfo',
|
||||
|
@ -751,7 +751,7 @@ export class UnifiedDashboardScenePageStateManager extends DashboardScenePageSta
|
|||
return await operation(this.activeManager);
|
||||
} catch (error) {
|
||||
if (error instanceof DashboardVersionError) {
|
||||
const manager = error.data.storedVersion === 'v2alpha1' ? this.v2Manager : this.v1Manager;
|
||||
const manager = isV2StoredVersion(error.data.storedVersion) ? this.v2Manager : this.v1Manager;
|
||||
this.activeManager = manager;
|
||||
return await operation(manager);
|
||||
} else {
|
||||
|
@ -797,7 +797,7 @@ export class UnifiedDashboardScenePageStateManager extends DashboardScenePageSta
|
|||
try {
|
||||
return await this.v1Manager.loadSnapshotScene(slug);
|
||||
} catch (error) {
|
||||
if (error instanceof DashboardVersionError && error.data.storedVersion === 'v2alpha1') {
|
||||
if (error instanceof DashboardVersionError && isV2StoredVersion(error.data.storedVersion)) {
|
||||
return await this.v2Manager.loadSnapshotScene(slug);
|
||||
}
|
||||
throw new Error('Snapshot not found');
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Dashboard } from '@grafana/schema';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
|
||||
import { jsonDiff } from '../settings/version-history/utils';
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import {
|
|||
AdhocVariableSpec,
|
||||
Spec as DashboardV2Spec,
|
||||
VariableKind,
|
||||
} from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
} from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import { ResponseTransformers } from 'app/features/dashboard/api/ResponseTransformers';
|
||||
import { isDashboardV2Spec } from 'app/features/dashboard/api/utils';
|
||||
import { DashboardDataDTO, DashboardDTO } from 'app/types/dashboard';
|
||||
|
|
|
@ -4,7 +4,7 @@ import { selectors } from '@grafana/e2e-selectors';
|
|||
import { Trans, t } from '@grafana/i18n';
|
||||
import { config, isFetchError } from '@grafana/runtime';
|
||||
import { Dashboard } from '@grafana/schema';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import { Alert, Box, Button, Stack } from '@grafana/ui';
|
||||
import { WorkflowOption } from 'app/features/provisioning/types';
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { locationUtil } from '@grafana/data';
|
|||
import { t } from '@grafana/i18n';
|
||||
import { locationService, reportInteraction } from '@grafana/runtime';
|
||||
import { Dashboard } from '@grafana/schema';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import appEvents from 'app/core/app_events';
|
||||
import { useAppNotification } from 'app/core/copy/appNotification';
|
||||
import { updateDashboardName } from 'app/core/reducers/navBarTree';
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
VizPanel,
|
||||
} from '@grafana/scenes';
|
||||
import { Dashboard, DashboardLink, LibraryPanel } from '@grafana/schema';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import appEvents from 'app/core/app_events';
|
||||
import { ScrollRefElement } from 'app/core/components/NativeScrollbar';
|
||||
import { LS_PANEL_COPY_KEY } from 'app/core/constants';
|
||||
|
@ -752,7 +752,7 @@ export class DashboardScene extends SceneObjectBase<DashboardSceneState> impleme
|
|||
const { meta } = this.state;
|
||||
const spec = this.getSaveAsModel(options);
|
||||
|
||||
const apiVersion = this.serializer instanceof V2DashboardSerializer ? 'v2alpha1' : 'v1beta1'; // get from the dashboard?
|
||||
const apiVersion = this.serializer instanceof V2DashboardSerializer ? 'v2beta1' : 'v1beta1'; // get from the dashboard?
|
||||
return {
|
||||
apiVersion: `dashboard.grafana.app/${apiVersion}`,
|
||||
kind: 'Dashboard',
|
||||
|
|
|
@ -2,13 +2,13 @@ import { find } from 'lodash';
|
|||
|
||||
import { DataSourceInstanceSettings, DataSourceRef, PanelPluginMeta, TypedVariableModel } from '@grafana/data';
|
||||
import { Dashboard, DashboardCursorSync, ThresholdsMode } from '@grafana/schema';
|
||||
import { handyTestingSchema } from '@grafana/schema/dist/esm/schema/dashboard/v2_examples';
|
||||
import {
|
||||
DatasourceVariableKind,
|
||||
LibraryPanelKind,
|
||||
PanelKind,
|
||||
QueryVariableKind,
|
||||
} from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
} from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import { handyTestingSchema } from '@grafana/schema/dist/esm/schema/dashboard/v2_examples';
|
||||
import config from 'app/core/config';
|
||||
import { DashboardModel } from 'app/features/dashboard/state/DashboardModel';
|
||||
import { createAdHocVariableAdapter } from 'app/features/variables/adhoc/adapter';
|
||||
|
@ -600,13 +600,12 @@ describe('dashboard exporter v2', () => {
|
|||
{
|
||||
kind: 'PanelQuery',
|
||||
spec: {
|
||||
datasource: {
|
||||
type: 'prometheus',
|
||||
uid: '${datasourceVar}',
|
||||
},
|
||||
hidden: false,
|
||||
query: {
|
||||
kind: 'prometheus',
|
||||
datasource: {
|
||||
name: '${datasourceVar}',
|
||||
},
|
||||
group: 'prometheus',
|
||||
spec: {
|
||||
editorMode: 'builder',
|
||||
expr: 'go_goroutines{job="prometheus"}',
|
||||
|
@ -634,7 +633,7 @@ describe('dashboard exporter v2', () => {
|
|||
it('should replace datasource in a query variable', async () => {
|
||||
const { dashboard } = await setup();
|
||||
const variable = dashboard.variables[0] as QueryVariableKind;
|
||||
expect(variable.spec.datasource?.uid).toBeUndefined();
|
||||
expect(variable.spec.query.datasource?.name).toBeUndefined();
|
||||
});
|
||||
|
||||
it('do not expose datasource name and id in datasource variable', async () => {
|
||||
|
@ -648,7 +647,7 @@ describe('dashboard exporter v2', () => {
|
|||
const { dashboard } = await setup();
|
||||
const annotationQuery = dashboard.annotations[0];
|
||||
|
||||
expect(annotationQuery.spec.datasource?.uid).toBeUndefined();
|
||||
expect(annotationQuery.spec.query?.datasource?.name).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should not remove datasource ref from panel that uses a datasource variable', async () => {
|
||||
|
@ -658,11 +657,8 @@ describe('dashboard exporter v2', () => {
|
|||
if (panel.kind !== 'Panel') {
|
||||
throw new Error('Panel should be a Panel');
|
||||
}
|
||||
|
||||
expect(panel.spec.data.spec.queries[0].spec.datasource).toEqual({
|
||||
type: 'prometheus',
|
||||
uid: '${datasourceVar}',
|
||||
});
|
||||
expect(panel.spec.data.spec.queries[0].spec.query.datasource?.name).toBe('${datasourceVar}');
|
||||
expect(panel.spec.data.spec.queries[0].spec.query.group).toBe('prometheus');
|
||||
});
|
||||
|
||||
it('should convert library panels to inline panels when sharing externally', async () => {
|
||||
|
@ -698,7 +694,7 @@ describe('dashboard exporter v2', () => {
|
|||
expect(convertedPanel.spec.id).toBe(123);
|
||||
|
||||
// Check that the panel was properly converted
|
||||
expect(convertedPanel.spec.data.spec.queries[0].spec.query.kind).toBe('testdb');
|
||||
expect(convertedPanel.spec.data.spec.queries[0].spec.query.kind).toBe('DataQuery');
|
||||
expect(convertedPanel.spec.data.spec.queries[0].spec.refId).toBe('A');
|
||||
});
|
||||
|
||||
|
@ -771,7 +767,8 @@ describe('dashboard exporter v2', () => {
|
|||
expect(placeholderPanel.kind).toBe('Panel');
|
||||
expect((placeholderPanel as PanelKind).spec.id).toBe(125);
|
||||
expect((placeholderPanel as PanelKind).spec.title).toBe('Invalid Library Panel');
|
||||
expect((placeholderPanel as PanelKind).spec.vizConfig.kind).toBe('text');
|
||||
expect((placeholderPanel as PanelKind).spec.vizConfig.kind).toBe('VizConfig');
|
||||
expect((placeholderPanel as PanelKind).spec.vizConfig.group).toBe('text');
|
||||
|
||||
// Verify console.error was called
|
||||
expect(consoleSpy).toHaveBeenCalledWith('Failed to load library panel invalid-uid:', expect.any(Error));
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
QueryVariableKind,
|
||||
LibraryPanelRef,
|
||||
LibraryPanelKind,
|
||||
} from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
} from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import { notifyApp } from 'app/core/actions';
|
||||
import config from 'app/core/config';
|
||||
import { createErrorNotification } from 'app/core/copy/appNotification';
|
||||
|
@ -378,9 +378,10 @@ async function convertLibraryPanelToInlinePanel(libraryPanelElement: LibraryPane
|
|||
},
|
||||
},
|
||||
vizConfig: {
|
||||
kind: 'text',
|
||||
kind: 'VizConfig',
|
||||
group: 'text',
|
||||
version: '',
|
||||
spec: {
|
||||
pluginVersion: '',
|
||||
options: {
|
||||
content: `**Library Panel Load Error**\n\nUnable to load library panel: ${libraryPanel.name} (${libraryPanel.uid})\n\nError: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
||||
mode: 'markdown',
|
||||
|
@ -406,7 +407,8 @@ export async function makeExportableV2(dashboard: DashboardV2Spec, isSharingExte
|
|||
const removeDataSourceRefs = (
|
||||
obj: AnnotationQueryKind['spec'] | QueryVariableKind['spec'] | PanelQueryKind['spec']
|
||||
) => {
|
||||
const datasourceUid = obj.datasource?.uid;
|
||||
const datasourceUid = obj.query?.datasource?.name;
|
||||
|
||||
if (datasourceUid?.startsWith('${') && datasourceUid?.endsWith('}')) {
|
||||
const varName = datasourceUid.slice(2, -1);
|
||||
// if there's a match we don't want to remove the datasource ref
|
||||
|
@ -416,7 +418,7 @@ export async function makeExportableV2(dashboard: DashboardV2Spec, isSharingExte
|
|||
}
|
||||
}
|
||||
|
||||
obj.datasource = undefined;
|
||||
obj.query && (obj.query.datasource = undefined);
|
||||
};
|
||||
|
||||
const processPanel = (panel: PanelKind) => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
|
||||
/**
|
||||
* Removes a panel reference from a layout.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { t } from '@grafana/i18n';
|
||||
import { config } from '@grafana/runtime';
|
||||
import { SceneComponentProps, SceneObject, SceneObjectBase, SceneObjectState, VizPanel } from '@grafana/scenes';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import { GRID_CELL_VMARGIN } from 'app/core/constants';
|
||||
import { OptionsPaneItemDescriptor } from 'app/features/dashboard/components/PanelEditor/OptionsPaneItemDescriptor';
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
SceneGridLayoutDragStartEvent,
|
||||
SceneObject,
|
||||
} from '@grafana/scenes';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import { useStyles2 } from '@grafana/ui';
|
||||
import { GRID_COLUMN_COUNT } from 'app/core/constants';
|
||||
import DashboardEmpty from 'app/features/dashboard/dashgrid/DashboardEmpty';
|
||||
|
|
|
@ -9,7 +9,7 @@ import {
|
|||
VariableDependencyConfig,
|
||||
VizPanel,
|
||||
} from '@grafana/scenes';
|
||||
import { RowsLayoutRowKind } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { RowsLayoutRowKind } from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
import appEvents from 'app/core/app_events';
|
||||
import { LS_ROW_COPY_KEY } from 'app/core/constants';
|
||||
import store from 'app/core/store';
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
SceneObjectState,
|
||||
VizPanel,
|
||||
} from '@grafana/scenes';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha1/types.spec.gen';
|
||||
import { Spec as DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2';
|
||||
|
||||
import { dashboardEditActions, ObjectsReorderedOnCanvasEvent } from '../../edit-pane/shared';
|
||||
import { serializeRowsLayout } from '../../serialization/layoutSerializers/RowsLayoutSerializer';
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue