mirror of https://github.com/grafana/grafana.git
84 lines
11 KiB
Go
84 lines
11 KiB
Go
|
//
|
||
|
// This file is generated by grafana-app-sdk
|
||
|
// DO NOT EDIT
|
||
|
//
|
||
|
|
||
|
package kinds
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
"strings"
|
||
|
|
||
|
"github.com/grafana/grafana-app-sdk/app"
|
||
|
"github.com/grafana/grafana-app-sdk/resource"
|
||
|
|
||
|
v0alpha1 "github.com/grafana/grafana/apps/provisioning/kinds/provisioning/v0alpha1"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
rawSchemaRepositoryv0alpha1 = []byte(`{"spec":{"properties":{"bitbucket":{"description":"The repository on Bitbucket.\nMutually exclusive with local | github | git.","properties":{"branch":{"description":"The branch to use in the repository.","type":"string"},"encryptedToken":{"description":"Token for accessing the repository, but encrypted. This is not possible to read back to a user decrypted.","items":{"type":"string"},"type":"array"},"path":{"description":"Path is the subdirectory for the Grafana data. If specified, Grafana will ignore anything that is outside this directory in the repository.","type":"string"},"token":{"description":"Token for accessing the repository. If set, it will be encrypted into encryptedToken, then set to an empty string again.","type":"string"},"tokenUser":{"description":"TokenUser is the user that will be used to access the repository if it's a personal access token.","type":"string"},"url":{"description":"The repository URL (e.g. ` + "`" + `https://bitbucket.org/example/test` + "`" + `).","type":"string"}},"required":["branch"],"type":"object"},"description":{"description":"Repository description","type":"string"},"git":{"description":"The repository on Git.\nMutually exclusive with local | github | git.","properties":{"branch":{"description":"The branch to use in the repository.","type":"string"},"encryptedToken":{"description":"Token for accessing the repository, but encrypted. This is not possible to read back to a user decrypted.","items":{"type":"string"},"type":"array"},"path":{"description":"Path is the subdirectory for the Grafana data. If specified, Grafana will ignore anything that is outside this directory in the repository.","type":"string"},"token":{"description":"Token for accessing the repository. If set, it will be encrypted into encryptedToken, then set to an empty string again.","type":"string"},"tokenUser":{"description":"TokenUser is the user that will be used to access the repository if it's a personal access token.","type":"string"},"url":{"description":"The repository URL (e.g. ` + "`" + `https://github.com/example/test.git` + "`" + `).","type":"string"}},"required":["branch"],"type":"object"},"github":{"description":"The repository on GitHub.\nMutually exclusive with local | github | git.","properties":{"branch":{"description":"The branch to use in the repository.","type":"string"},"encryptedToken":{"description":"Token for accessing the repository, but encrypted. This is not possible to read back to a user decrypted.","items":{"type":"string"},"type":"array"},"generateDashboardPreviews":{"description":"Whether we should show dashboard previews for pull requests.\nBy default, this is false (i.e. we will not create previews).","type":"boolean"},"path":{"description":"Path is the subdirectory for the Grafana data. If specified, Grafana will ignore anything that is outside this directory in the repository.","type":"string"},"token":{"description":"Token for accessing the repository. If set, it will be encrypted into encryptedToken, then set to an empty string again.","type":"string"},"url":{"description":"The repository URL (e.g. ` + "`" + `https://github.com/example/test` + "`" + `).","type":"string"}},"required":["branch"],"type":"object"},"gitlab":{"description":"The repository on GitLab.\nMutually exclusive with local | github | git.","properties":{"branch":{"description":"The branch to use in the repository.","type":"string"},"encryptedToken":{"description":"Token for accessing the repository, but encrypted. This is not possible to read back to a user decrypted.","items":{"type":"string"},"type":"array"},"path":{"description":"Path is the subdirectory for the Grafana data. If specified, Grafana will ignore anything that is outside this directory in the repository.","type":"string"},"token":{"description":"Token for accessing the repository. If set, it will be encrypted into encryptedToken, then set to an empty string again.","type":"string"},"url":{"description":"The repository URL (e.g. ` + "`" + `https://gitlab.com/example/test` + "`" + `).","type":"strin
|
||
|
versionSchemaRepositoryv0alpha1 app.VersionSchema
|
||
|
_ = json.Unmarshal(rawSchemaRepositoryv0alpha1, &versionSchemaRepositoryv0alpha1)
|
||
|
)
|
||
|
|
||
|
var appManifestData = app.ManifestData{
|
||
|
AppName: "provisioning",
|
||
|
Group: "provisioning.grafana.app",
|
||
|
Versions: []app.ManifestVersion{
|
||
|
{
|
||
|
Name: "v0alpha1",
|
||
|
Served: true,
|
||
|
Kinds: []app.ManifestVersionKind{
|
||
|
{
|
||
|
Kind: "Repository",
|
||
|
Plural: "Repositories",
|
||
|
Scope: "Namespaced",
|
||
|
Conversion: false,
|
||
|
Admission: &app.AdmissionCapabilities{
|
||
|
Validation: &app.ValidationCapability{
|
||
|
Operations: []app.AdmissionOperation{
|
||
|
app.AdmissionOperationCreate,
|
||
|
app.AdmissionOperationUpdate,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
Schema: &versionSchemaRepositoryv0alpha1,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
}
|
||
|
|
||
|
func LocalManifest() app.Manifest {
|
||
|
return app.NewEmbeddedManifest(appManifestData)
|
||
|
}
|
||
|
|
||
|
func RemoteManifest() app.Manifest {
|
||
|
return app.NewAPIServerManifest("provisioning")
|
||
|
}
|
||
|
|
||
|
var kindVersionToGoType = map[string]resource.Kind{
|
||
|
"Repository/v0alpha1": v0alpha1.RepositoryKind(),
|
||
|
}
|
||
|
|
||
|
// 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.
|
||
|
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
|
||
|
}
|