mirror of https://github.com/grafana/grafana.git
172 lines
5.4 KiB
Go
172 lines
5.4 KiB
Go
//
|
|
// This file is generated by grafana-app-sdk
|
|
// DO NOT EDIT
|
|
//
|
|
|
|
package apis
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/grafana/grafana-app-sdk/app"
|
|
"github.com/grafana/grafana-app-sdk/resource"
|
|
"k8s.io/apimachinery/pkg/runtime"
|
|
"k8s.io/kube-openapi/pkg/spec3"
|
|
|
|
v0alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
|
|
v1beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
|
v2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
|
v2beta1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2beta1"
|
|
)
|
|
|
|
var appManifestData = app.ManifestData{
|
|
AppName: "dashboard",
|
|
Group: "dashboard.grafana.app",
|
|
PreferredVersion: "v1beta1",
|
|
Versions: []app.ManifestVersion{
|
|
{
|
|
Name: "v0alpha1",
|
|
Served: true,
|
|
Kinds: []app.ManifestVersionKind{
|
|
{
|
|
Kind: "Dashboard",
|
|
Plural: "Dashboards",
|
|
Scope: "Namespaced",
|
|
Conversion: false,
|
|
},
|
|
},
|
|
Routes: app.ManifestVersionRoutes{
|
|
Namespaced: map[string]spec3.PathProps{},
|
|
Cluster: map[string]spec3.PathProps{},
|
|
},
|
|
},
|
|
|
|
{
|
|
Name: "v1beta1",
|
|
Served: true,
|
|
Kinds: []app.ManifestVersionKind{
|
|
{
|
|
Kind: "Dashboard",
|
|
Plural: "Dashboards",
|
|
Scope: "Namespaced",
|
|
Conversion: false,
|
|
},
|
|
},
|
|
Routes: app.ManifestVersionRoutes{
|
|
Namespaced: map[string]spec3.PathProps{},
|
|
Cluster: map[string]spec3.PathProps{},
|
|
},
|
|
},
|
|
|
|
{
|
|
Name: "v2alpha1",
|
|
Served: true,
|
|
Kinds: []app.ManifestVersionKind{
|
|
{
|
|
Kind: "Dashboard",
|
|
Plural: "Dashboards",
|
|
Scope: "Namespaced",
|
|
Conversion: false,
|
|
},
|
|
},
|
|
Routes: app.ManifestVersionRoutes{
|
|
Namespaced: map[string]spec3.PathProps{},
|
|
Cluster: map[string]spec3.PathProps{},
|
|
},
|
|
},
|
|
|
|
{
|
|
Name: "v2beta1",
|
|
Served: true,
|
|
Kinds: []app.ManifestVersionKind{
|
|
{
|
|
Kind: "Dashboard",
|
|
Plural: "Dashboards",
|
|
Scope: "Namespaced",
|
|
Conversion: false,
|
|
},
|
|
},
|
|
Routes: app.ManifestVersionRoutes{
|
|
Namespaced: map[string]spec3.PathProps{},
|
|
Cluster: map[string]spec3.PathProps{},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
func LocalManifest() app.Manifest {
|
|
return app.NewEmbeddedManifest(appManifestData)
|
|
}
|
|
|
|
func RemoteManifest() app.Manifest {
|
|
return app.NewAPIServerManifest("dashboard")
|
|
}
|
|
|
|
var kindVersionToGoType = map[string]resource.Kind{
|
|
"Dashboard/v0alpha1": v0alpha1.DashboardKind(),
|
|
"Dashboard/v1beta1": v1beta1.DashboardKind(),
|
|
"Dashboard/v2alpha1": v2alpha1.DashboardKind(),
|
|
"Dashboard/v2beta1": v2beta1.DashboardKind(),
|
|
}
|
|
|
|
// ManifestGoTypeAssociator returns the associated resource.Kind instance for a given Kind and Version, if one exists.
|
|
// If there is no association for the provided Kind and Version, exists will return false.
|
|
func ManifestGoTypeAssociator(kind, version string) (goType resource.Kind, exists bool) {
|
|
goType, exists = kindVersionToGoType[fmt.Sprintf("%s/%s", kind, version)]
|
|
return goType, exists
|
|
}
|
|
|
|
var customRouteToGoResponseType = map[string]any{}
|
|
|
|
// ManifestCustomRouteResponsesAssociator returns the associated response go type for a given kind, version, custom route path, and method, if one exists.
|
|
// kind may be empty for custom routes which are not kind subroutes. Leading slashes are removed from subroute paths.
|
|
// If there is no association for the provided kind, version, custom route path, and method, exists will return false.
|
|
// Resource routes (those without a kind) should prefix their route with "<namespace>/" if the route is namespaced (otherwise the route is assumed to be cluster-scope)
|
|
func ManifestCustomRouteResponsesAssociator(kind, version, path, verb string) (goType any, exists bool) {
|
|
if len(path) > 0 && path[0] == '/' {
|
|
path = path[1:]
|
|
}
|
|
goType, exists = customRouteToGoResponseType[fmt.Sprintf("%s|%s|%s|%s", version, kind, path, strings.ToUpper(verb))]
|
|
return goType, exists
|
|
}
|
|
|
|
var customRouteToGoParamsType = map[string]runtime.Object{}
|
|
|
|
func ManifestCustomRouteQueryAssociator(kind, version, path, verb string) (goType runtime.Object, exists bool) {
|
|
if len(path) > 0 && path[0] == '/' {
|
|
path = path[1:]
|
|
}
|
|
goType, exists = customRouteToGoParamsType[fmt.Sprintf("%s|%s|%s|%s", version, kind, path, strings.ToUpper(verb))]
|
|
return goType, exists
|
|
}
|
|
|
|
var customRouteToGoRequestBodyType = map[string]any{}
|
|
|
|
func ManifestCustomRouteRequestBodyAssociator(kind, version, path, verb string) (goType any, exists bool) {
|
|
if len(path) > 0 && path[0] == '/' {
|
|
path = path[1:]
|
|
}
|
|
goType, exists = customRouteToGoRequestBodyType[fmt.Sprintf("%s|%s|%s|%s", version, kind, path, strings.ToUpper(verb))]
|
|
return goType, exists
|
|
}
|
|
|
|
type GoTypeAssociator struct{}
|
|
|
|
func NewGoTypeAssociator() *GoTypeAssociator {
|
|
return &GoTypeAssociator{}
|
|
}
|
|
|
|
func (g *GoTypeAssociator) KindToGoType(kind, version string) (goType resource.Kind, exists bool) {
|
|
return ManifestGoTypeAssociator(kind, version)
|
|
}
|
|
func (g *GoTypeAssociator) CustomRouteReturnGoType(kind, version, path, verb string) (goType any, exists bool) {
|
|
return ManifestCustomRouteResponsesAssociator(kind, version, path, verb)
|
|
}
|
|
func (g *GoTypeAssociator) CustomRouteQueryGoType(kind, version, path, verb string) (goType runtime.Object, exists bool) {
|
|
return ManifestCustomRouteQueryAssociator(kind, version, path, verb)
|
|
}
|
|
func (g *GoTypeAssociator) CustomRouteRequestBodyGoType(kind, version, path, verb string) (goType any, exists bool) {
|
|
return ManifestCustomRouteRequestBodyAssociator(kind, version, path, verb)
|
|
}
|