mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 02:42:22 +08:00
K8s/Dashboards: Fix dashboard list and add tests (#91523)
This commit is contained in:
38
pkg/registry/apis/dashboard/legacy/queries.go
Normal file
38
pkg/registry/apis/dashboard/legacy/queries.go
Normal file
@ -0,0 +1,38 @@
|
||||
package legacy
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"text/template"
|
||||
|
||||
"github.com/grafana/grafana/pkg/storage/unified/sql/sqltemplate"
|
||||
)
|
||||
|
||||
// Templates setup.
|
||||
var (
|
||||
//go:embed *.sql
|
||||
sqlTemplatesFS embed.FS
|
||||
|
||||
sqlTemplates = template.Must(template.New("sql").ParseFS(sqlTemplatesFS, `*.sql`))
|
||||
)
|
||||
|
||||
func mustTemplate(filename string) *template.Template {
|
||||
if t := sqlTemplates.Lookup(filename); t != nil {
|
||||
return t
|
||||
}
|
||||
panic(fmt.Sprintf("template file not found: %s", filename))
|
||||
}
|
||||
|
||||
// Templates.
|
||||
var (
|
||||
sqlQueryDashboards = mustTemplate("query_dashboards.sql")
|
||||
)
|
||||
|
||||
type sqlQuery struct {
|
||||
*sqltemplate.SQLTemplate
|
||||
Query *DashboardQuery
|
||||
}
|
||||
|
||||
func (r sqlQuery) Validate() error {
|
||||
return nil // TODO
|
||||
}
|
Reference in New Issue
Block a user