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
@@ -28,6 +28,7 @@ import (
|
||||
"k8s.io/client-go/rest"
|
||||
|
||||
"github.com/grafana/grafana/pkg/apimachinery/identity"
|
||||
"github.com/grafana/grafana/pkg/apimachinery/utils"
|
||||
"github.com/grafana/grafana/pkg/infra/localcache"
|
||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||
"github.com/grafana/grafana/pkg/server"
|
||||
@@ -894,3 +895,22 @@ func (c *K8sTestHelper) DeleteServiceAccount(user User, orgID int64, saID int64)
|
||||
|
||||
require.Equal(c.t, http.StatusOK, resp.Response.StatusCode, "failed to delete service account, body: %s", string(resp.Body))
|
||||
}
|
||||
|
||||
// Ensures that the passed error is an APIStatus error and fails the test if it is not.
|
||||
func (c *K8sTestHelper) RequireApiErrorStatus(err error, reason metav1.StatusReason, httpCode int) metav1.Status {
|
||||
require.Error(c.t, err)
|
||||
status, ok := utils.ExtractApiErrorStatus(err)
|
||||
if !ok {
|
||||
c.t.Fatalf("Expected error to be an APIStatus, but got %T", err)
|
||||
}
|
||||
|
||||
if reason != metav1.StatusReasonUnknown {
|
||||
require.Equal(c.t, status.Reason, reason)
|
||||
}
|
||||
|
||||
if httpCode != 0 {
|
||||
require.Equal(c.t, status.Code, int32(httpCode))
|
||||
}
|
||||
|
||||
return status
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user