Dashboards: Add Dashboard Schema validation (2) (#103844)
* Activate schema validation and align underlying systems * update to save as v0 if not the right schema version * Resolve merge conflicts * Move RequireApiErrorStatus to tests package * Add mutation tests * Fix lint * Only do min version check if dashboard is v1 * Fix lint and disable provisioning test * Revert provisioning changes * Revert more tests and add schema test * Reran gen * SQL Dashboard save * Adjust APIVERSION * Fixed mutation test * Add logging on downgrade --------- Co-authored-by: Marco de Abreu <18629099+marcoabreu@users.noreply.github.com> Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
This commit is contained in:
co-authored by
Marco de Abreu
Stephanie Hingtgen
parent
07a225649d
commit
c47ab101d1
@@ -58,7 +58,17 @@ func (b *DashboardsAPIBuilder) Mutate(ctx context.Context, a admission.Attribute
|
||||
}
|
||||
}
|
||||
case *dashboardV2.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 = &dashboardV2.DashboardGridLayoutKind{
|
||||
Kind: "GridLayout",
|
||||
Spec: dashboardV2.DashboardGridLayoutSpec{},
|
||||
}
|
||||
}
|
||||
|
||||
resourceInfo = dashboardV2.DashboardResourceInfo
|
||||
|
||||
// Noop for V2
|
||||
default:
|
||||
return fmt.Errorf("mutation error: expected to dashboard, got %T", obj)
|
||||
|
||||
Reference in New Issue
Block a user