mirror of https://github.com/grafana/grafana
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>pull/103949/head
parent
07a225649d
commit
c47ab101d1
@ -0,0 +1,20 @@ |
||||
package utils |
||||
|
||||
import ( |
||||
"errors" |
||||
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors" |
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
||||
) |
||||
|
||||
// Extract the status from an APIStatus error
|
||||
func ExtractApiErrorStatus(err error) (metav1.Status, bool) { |
||||
if err == nil { |
||||
return metav1.Status{}, false |
||||
} |
||||
if statusErr, ok := err.(apierrors.APIStatus); ok && errors.As(err, &statusErr) { |
||||
return statusErr.Status(), true |
||||
} |
||||
|
||||
return metav1.Status{}, false |
||||
} |
||||
@ -0,0 +1,29 @@ |
||||
{ |
||||
"title": "Provisioning test - invalid schema", |
||||
"uid": "invalid-schema-uid", |
||||
"schemaVersion": 41, |
||||
"tags": [ |
||||
"tag" |
||||
], |
||||
"revision": "this-is-not-a-number", |
||||
"panels": [ |
||||
{ |
||||
"gridPos": { |
||||
"h": 3, |
||||
"w": 12, |
||||
"x": 0, |
||||
"y": 0 |
||||
}, |
||||
"id": 34, |
||||
"options": { |
||||
"content": "# All panels\n\nThis dashboard was created to quickly check accessiblity issues on a lot of panels at the same time ", |
||||
"mode": "markdown" |
||||
}, |
||||
"pluginVersion": "8.1.0-pre", |
||||
"transparent": true, |
||||
"type": "text", |
||||
"repeat": "something", |
||||
"repeatDirection": "this is not an allowed value" |
||||
} |
||||
] |
||||
} |
||||
Loading…
Reference in new issue