Dashboards: Add apiVersion to dashboard table (#100845)

This commit is contained in:
Ryan McKinley
2025-03-04 07:47:45 +03:00
committed by GitHub
parent 8a341ebcce
commit c1b48cc488
84 changed files with 1074 additions and 2392 deletions

View File

@ -99,6 +99,16 @@ func (hs *HTTPServer) GetDashboard(c *contextmodel.ReqContext) response.Response
return rsp
}
// V2 values should be read from the k8s API
if strings.HasPrefix(dash.APIVersion, "v2") {
root := hs.Cfg.AppSubURL
if !strings.HasSuffix(root, "/") {
root += "/"
}
url := fmt.Sprintf("%sapis/dashboard.grafana.app/%s/namespaces/%s/dashboards/%s", root, dash.APIVersion, hs.namespacer(c.OrgID), dash.UID)
return response.Redirect(url)
}
var (
publicDashboardEnabled = false
err error
@ -182,6 +192,7 @@ func (hs *HTTPServer) GetDashboard(c *contextmodel.ReqContext) response.Response
UpdatedBy: updater,
CreatedBy: creator,
Version: dash.Version,
APIVersion: dash.APIVersion,
HasACL: dash.HasACL,
IsFolder: dash.IsFolder,
FolderId: dash.FolderID, // nolint:staticcheck

View File

@ -26,6 +26,7 @@ type DashboardMeta struct {
Version int `json:"version"`
HasACL bool `json:"hasAcl" xorm:"has_acl"`
IsFolder bool `json:"isFolder"`
APIVersion string `json:"apiVersion,omitempty"` // v0alpha1, v1, v2beta1 etc -- the version things were *saved* at
// Deprecated: use FolderUID instead
FolderId int64 `json:"folderId"`
FolderUid string `json:"folderUid"`