mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
api: Validate dashboards on save via coremodels, behind feature toggle (#48252)
* Add coremodelValidation feature flag * coremodels: use stubs when feature flag is off * api: validate dashboards on save * Need pointer receiver for FeatureManager * Update dashboard Go model * Align doc comments * Include CoremodelRegistry in test * Wedge coremodel in on all test cases, ugh * Ugh fix comment again * Update pkg/framework/coremodel/staticregistry/provide.go Co-authored-by: Artur Wierzbicki <wierzbicki.artur.94@gmail.com> * Update Thema (and its deps) for better errs * omg whitespace Co-authored-by: Artur Wierzbicki <wierzbicki.artur.94@gmail.com>
This commit is contained in:
@@ -76,3 +76,12 @@ func (r *Registry) addModels(models []Interface) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get retrieves a coremodel with the given string identifier. nil, false
|
||||
// is returned if no such coremodel exists.
|
||||
func (r *Registry) Get(name string) (cm Interface, has bool) {
|
||||
r.lock.RLock()
|
||||
cm, has = r.modelIdx[name]
|
||||
r.lock.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ import (
|
||||
func ProvideRegistry(
|
||||
dashboard *dashboard.Coremodel,
|
||||
) (*coremodel.Registry, error) {
|
||||
return coremodel.NewRegistry(
|
||||
cmlist := []coremodel.Interface{
|
||||
dashboard,
|
||||
)
|
||||
}
|
||||
|
||||
return coremodel.NewRegistry(cmlist...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user