Dashboards API: v2alpha2 missing pieces (#108293)

* Dashboards API: v2alpha2 missing pieces

* Fix issue with dashboard client scope for alpha versions

As we now have 2 different alpha versions for v2 we need to store the
clients separately.

* Improve debuggability of provisioning export test

- Add a helper function to print the tree structure.
- Be explicit about the expected file names expected in each case.

* Update pkg/registry/apis/dashboard/mutate.go

* Update pkg/services/authz/zanzana/server/server.go

Co-authored-by: Igor Suleymanov <radiohead@users.noreply.github.com>

* Review

* go lint

---------

Co-authored-by: Roberto Jimenez Sanchez <roberto.jimenez@grafana.com>
Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
Co-authored-by: Igor Suleymanov <radiohead@users.noreply.github.com>
This commit is contained in:
Dominik Prokop
2025-07-22 11:44:05 +02:00
committed by GitHub
co-authored by Igor Suleymanov Roberto Jimenez Sanchez Stephanie Hingtgen
parent eeb44c1d63
commit d72a70d246
15 changed files with 877 additions and 512 deletions
@@ -12,7 +12,8 @@ import (
v0 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
v1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
v2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
v2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
v2alpha2 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha2"
"github.com/grafana/grafana/pkg/apimachinery/utils"
"github.com/grafana/grafana/pkg/services/featuremgmt"
)
@@ -32,7 +33,8 @@ func (b *DashboardsAPIBuilder) ValidateDashboardSpec(ctx context.Context, obj ru
errorOnSchemaMismatches = false // Never error for v0
case *v1.Dashboard:
errorOnSchemaMismatches = !b.features.IsEnabled(ctx, featuremgmt.FlagDashboardDisableSchemaValidationV1)
case *v2.Dashboard:
case *v2alpha1.Dashboard:
case *v2alpha2.Dashboard:
errorOnSchemaMismatches = !b.features.IsEnabled(ctx, featuremgmt.FlagDashboardDisableSchemaValidationV2)
default:
return nil, fmt.Errorf("invalid dashboard type: %T", obj)
@@ -52,8 +54,10 @@ func (b *DashboardsAPIBuilder) ValidateDashboardSpec(ctx context.Context, obj ru
errors, schemaVersionError = v0.ValidateDashboardSpec(v, alwaysLogSchemaValidationErrors)
case *v1.Dashboard:
errors, schemaVersionError = v1.ValidateDashboardSpec(v, alwaysLogSchemaValidationErrors)
case *v2.Dashboard:
errors = v2.ValidateDashboardSpec(v)
case *v2alpha1.Dashboard:
errors = v2alpha1.ValidateDashboardSpec(v)
case *v2alpha2.Dashboard:
errors = v2alpha2.ValidateDashboardSpec(v)
}
}