From edcb6e6895a742cb0b6993741a3ccfe94d3aebec Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Tue, 12 Aug 2025 20:25:19 +0300 Subject: [PATCH] Provisioning: Fix OpenAPI generation (#109513) * post-process spec * update client * fix the openapi * revert playlist change * Fix unmanaged resource counts --------- Co-authored-by: Roberto Jimenez Sanchez --- pkg/registry/apis/provisioning/register.go | 10 +- pkg/registry/apis/provisioning/routes.go | 4 +- .../provisioning.grafana.app-v0alpha1.json | 1836 +++-------------- .../provisioning/v0alpha1/endpoints.gen.ts | 26 +- scripts/process-specs.ts | 5 + 5 files changed, 352 insertions(+), 1529 deletions(-) diff --git a/pkg/registry/apis/provisioning/register.go b/pkg/registry/apis/provisioning/register.go index 3956498f944..d22e81d3cf9 100644 --- a/pkg/registry/apis/provisioning/register.go +++ b/pkg/registry/apis/provisioning/register.go @@ -793,7 +793,7 @@ func (b *APIBuilder) PostProcessOpenAPI(oas *spec3.OpenAPI) (*spec3.OpenAPI, err repoprefix := root + "namespaces/{namespace}/repositories/{name}" defs := b.GetOpenAPIDefinitions()(func(path string) spec.Ref { return spec.Ref{} }) defsBase := "github.com/grafana/grafana/apps/provisioning/pkg/apis/provisioning/v0alpha1." - refsBase := "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1." + refsBase := "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1." sub := oas.Paths.Paths[repoprefix+"/test"] if sub != nil { @@ -1076,12 +1076,12 @@ spec: // Add any missing definitions //----------------------------- for k, v := range defs { - clean := strings.Replace(k, defsBase, "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.", 1) + clean := strings.Replace(k, defsBase, "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.", 1) if oas.Components.Schemas[clean] == nil { oas.Components.Schemas[clean] = &v.Schema } } - compBase := "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1." + compBase := "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1." schema := oas.Components.Schemas[compBase+"RepositoryViewList"].Properties["items"] schema.Items = &spec.SchemaOrArray{ Schema: &spec.Schema{ @@ -1128,6 +1128,10 @@ spec: schema.Items = countSpec oas.Components.Schemas[compBase+"ResourceStats"].Properties["instance"] = schema + schema = oas.Components.Schemas[compBase+"ResourceStats"].Properties["unmanaged"] + schema.Items = countSpec + oas.Components.Schemas[compBase+"ResourceStats"].Properties["unmanaged"] = schema + schema = oas.Components.Schemas[compBase+"ResourceStats"].Properties["managed"] schema.Items = managerSpec oas.Components.Schemas[compBase+"ResourceStats"].Properties["managed"] = schema diff --git a/pkg/registry/apis/provisioning/routes.go b/pkg/registry/apis/provisioning/routes.go index 749c4a8d2ed..5136555bf41 100644 --- a/pkg/registry/apis/provisioning/routes.go +++ b/pkg/registry/apis/provisioning/routes.go @@ -53,7 +53,7 @@ func (b *APIBuilder) GetAPIRoutes(gv schema.GroupVersion) *builder.APIRoutes { MediaTypeProps: spec3.MediaTypeProps{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Ref: spec.MustCreateRef("#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ResourceStats"), + Ref: spec.MustCreateRef("#/components/schemas/com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.ResourceStats"), }, }, }, @@ -101,7 +101,7 @@ func (b *APIBuilder) GetAPIRoutes(gv schema.GroupVersion) *builder.APIRoutes { MediaTypeProps: spec3.MediaTypeProps{ Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ - Ref: spec.MustCreateRef("#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.RepositoryViewList"), + Ref: spec.MustCreateRef("#/components/schemas/com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.RepositoryViewList"), }, }, }, diff --git a/pkg/tests/apis/openapi_snapshots/provisioning.grafana.app-v0alpha1.json b/pkg/tests/apis/openapi_snapshots/provisioning.grafana.app-v0alpha1.json index dbe70573707..2352079084e 100644 --- a/pkg/tests/apis/openapi_snapshots/provisioning.grafana.app-v0alpha1.json +++ b/pkg/tests/apis/openapi_snapshots/provisioning.grafana.app-v0alpha1.json @@ -1734,7 +1734,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.JobList" + "$ref": "#/components/schemas/com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.JobList" } } } @@ -1757,7 +1757,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.JobSpec" + "$ref": "#/components/schemas/com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.JobSpec" }, "examples": { "incremental": { @@ -1788,7 +1788,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.Job" + "$ref": "#/components/schemas/com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.Job" } } } @@ -1837,7 +1837,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.Job" + "$ref": "#/components/schemas/com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.Job" } } } @@ -2527,7 +2527,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.RepositoryViewList" + "$ref": "#/components/schemas/com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.RepositoryViewList" } } } @@ -2560,7 +2560,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ResourceStats" + "$ref": "#/components/schemas/com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.ResourceStats" } } } @@ -2571,6 +2571,26 @@ }, "components": { "schemas": { + "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.Author": { + "type": "object", + "required": [ + "name", + "username" + ], + "properties": { + "avatarURL": { + "type": "string" + }, + "name": { + "type": "string", + "default": "" + }, + "username": { + "type": "string", + "default": "" + } + } + }, "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.BitbucketRepositoryConfig": { "type": "object", "required": [ @@ -2674,6 +2694,59 @@ } } }, + "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.FileItem": { + "type": "object", + "required": [ + "path" + ], + "properties": { + "author": { + "type": "string" + }, + "hash": { + "type": "string" + }, + "modified": { + "type": "integer", + "format": "int64" + }, + "path": { + "type": "string", + "default": "" + }, + "size": { + "type": "integer", + "format": "int64" + } + } + }, + "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.FileList": { + "description": "Information we can get just from the file listing", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "items": { + "type": "array", + "items": { + "default": {} + }, + "x-kubernetes-list-type": "atomic" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "default": {} + } + } + }, "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.GitHubRepositoryConfig": { "type": "object", "required": [ @@ -2886,6 +2959,64 @@ } ] }, + "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.HistoryItem": { + "type": "object", + "required": [ + "ref", + "message", + "authors", + "createdAt" + ], + "properties": { + "authors": { + "type": "array", + "items": { + "default": {} + }, + "x-kubernetes-list-type": "atomic" + }, + "createdAt": { + "type": "integer", + "format": "int64", + "default": 0 + }, + "message": { + "type": "string", + "default": "" + }, + "ref": { + "type": "string", + "default": "" + } + } + }, + "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.HistoryList": { + "description": "HistoryList is a list of versions of a resource", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "items": { + "type": "array", + "items": { + "default": {} + }, + "x-kubernetes-list-type": "atomic" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "default": {} + } + } + }, "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.Job": { "description": "The repository name and type are stored as labels", "type": "object", @@ -3154,6 +3285,33 @@ } } }, + "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.ManagerStats": { + "type": "object", + "required": [ + "stats" + ], + "properties": { + "id": { + "description": "Manager identity", + "type": "string" + }, + "kind": { + "description": "Manager kind", + "type": "string" + }, + "stats": { + "description": "stats", + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/components/schemas/com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.ResourceCount" + } + ] + } + } + } + }, "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.MigrateJobOptions": { "type": "object", "properties": { @@ -3545,6 +3703,112 @@ } } }, + "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.RepositoryView": { + "type": "object", + "required": [ + "name", + "title", + "type", + "target", + "workflows" + ], + "properties": { + "branch": { + "description": "For git, this is the target branch", + "type": "string" + }, + "name": { + "description": "The k8s name for this repository", + "type": "string", + "default": "" + }, + "target": { + "description": "When syncing, where values are saved\n\nPossible enum values:\n - `\"folder\"` Resources will be saved into a folder managed by this repository It will contain a copy of everything from the remote The folder k8s name will be the same as the repository k8s name\n - `\"instance\"` Resources are saved in the global context Only one repository may specify the `instance` target When this exists, the UI will promote writing to the instance repo rather than the grafana database (where possible)", + "type": "string", + "default": "", + "enum": [ + "folder", + "instance" + ] + }, + "title": { + "description": "Repository display", + "type": "string", + "default": "" + }, + "type": { + "description": "The repository type\n\nPossible enum values:\n - `\"bitbucket\"`\n - `\"git\"`\n - `\"github\"`\n - `\"gitlab\"`\n - `\"local\"`", + "type": "string", + "default": "", + "enum": [ + "bitbucket", + "git", + "github", + "gitlab", + "local" + ] + }, + "workflows": { + "description": "The supported workflows", + "type": "array", + "items": { + "type": "string", + "default": "", + "enum": [ + "branch", + "write" + ] + } + } + } + }, + "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.RepositoryViewList": { + "description": "Summary shows a view of the configuration that is sanitized and is OK for logged in users to see", + "type": "object", + "required": [ + "items" + ], + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "availableRepositoryTypes": { + "description": "AvailableRepositoryTypes is the list of repository types supported in this instance (e.g. git, bitbucket, github, etc)", + "type": "array", + "items": { + "type": "string", + "default": "", + "enum": [ + "bitbucket", + "git", + "github", + "gitlab", + "local" + ] + } + }, + "items": { + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/components/schemas/com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.RepositoryView" + } + ] + }, + "x-kubernetes-map-type": "atomic" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "legacyStorage": { + "description": "The backend is using legacy storage FIXME: Not sure where this should be exposed... but we need it somewhere The UI should force the onboarding workflow when this is true", + "type": "boolean" + } + } + }, "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.ResourceCount": { "type": "object", "required": [ @@ -3769,6 +4033,59 @@ } } }, + "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.ResourceStats": { + "description": "Information we can get just from the file listing", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + "type": "string" + }, + "instance": { + "description": "Stats across all unified storage When legacy storage is still used, this will offer a shim", + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/components/schemas/com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.ResourceCount" + } + ] + }, + "x-kubernetes-list-type": "atomic" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + "type": "string" + }, + "managed": { + "description": "Stats for each manager", + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/components/schemas/com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.ManagerStats" + } + ] + }, + "x-kubernetes-list-type": "atomic" + }, + "metadata": { + "default": {} + }, + "unmanaged": { + "description": "Stats across all unified storage When legacy storage is still used, this will offer a shim", + "type": "array", + "items": { + "allOf": [ + { + "$ref": "#/components/schemas/com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.ResourceCount" + } + ] + }, + "x-kubernetes-list-type": "atomic" + } + } + }, "com.github.grafana.grafana.apps.provisioning.pkg.apis.provisioning.v0alpha1.ResourceType": { "type": "object", "properties": { @@ -4094,1513 +4411,6 @@ "additionalProperties": true, "x-kubernetes-preserve-unknown-fields": true }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.Author": { - "type": "object", - "required": [ - "name", - "username" - ], - "properties": { - "avatarURL": { - "type": "string" - }, - "name": { - "type": "string", - "default": "" - }, - "username": { - "type": "string", - "default": "" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.BitbucketRepositoryConfig": { - "type": "object", - "required": [ - "branch" - ], - "properties": { - "branch": { - "description": "The branch to use in the repository.", - "type": "string", - "default": "" - }, - "encryptedToken": { - "description": "Token for accessing the repository, but encrypted. This is not possible to read back to a user decrypted.", - "type": "string", - "format": "byte", - "x-kubernetes-list-type": "atomic" - }, - "path": { - "description": "Path is the subdirectory for the Grafana data. If specified, Grafana will ignore anything that is outside this directory in the repository. This is usually something like `grafana/`. Trailing and leading slash are not required. They are always added when needed. The path is relative to the root of the repository, regardless of the leading slash.\n\nWhen specifying something like `grafana-`, we will not look for `grafana-*`; we will only look for files under the directory `/grafana-/`. That means `/grafana-example.json` would not be found.", - "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" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.DeleteJobOptions": { - "type": "object", - "properties": { - "paths": { - "description": "Paths to be deleted. Examples: - dashboard.json (for a file) - a/b/c/other-dashboard.json (for a file) - nested/deep/ (for a directory) FIXME: we should validate this in admission hooks", - "type": "array", - "items": { - "type": "string", - "default": "" - } - }, - "ref": { - "description": "Ref to the branch or commit hash to delete from", - "type": "string" - }, - "resources": { - "description": "Resources to delete This option has been created because currently the frontend does not use standarized app platform APIs. For performance and API consistency reasons, the preferred option is it to use the paths.", - "type": "array", - "items": { - "default": {} - } - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ErrorDetails": { - "type": "object", - "required": [ - "type" - ], - "properties": { - "detail": { - "type": "string" - }, - "field": { - "type": "string" - }, - "type": { - "type": "string", - "default": "" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ExportJobOptions": { - "type": "object", - "properties": { - "branch": { - "description": "FIXME: we should validate this in admission hooks Target branch for export (only git)", - "type": "string" - }, - "folder": { - "description": "The source folder (or empty) to export", - "type": "string" - }, - "message": { - "description": "Message to use when committing the changes in a single commit", - "type": "string" - }, - "path": { - "description": "FIXME: we should validate this in admission hooks Prefix in target file system", - "type": "string" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.FileItem": { - "type": "object", - "required": [ - "path" - ], - "properties": { - "author": { - "type": "string" - }, - "hash": { - "type": "string" - }, - "modified": { - "type": "integer", - "format": "int64" - }, - "path": { - "type": "string", - "default": "" - }, - "size": { - "type": "integer", - "format": "int64" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.FileList": { - "description": "Information we can get just from the file listing", - "type": "object", - "required": [ - "items" - ], - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "items": { - "type": "array", - "items": { - "default": {} - }, - "x-kubernetes-list-type": "atomic" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "metadata": { - "default": {} - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.GitHubRepositoryConfig": { - "type": "object", - "required": [ - "branch" - ], - "properties": { - "branch": { - "description": "The branch to use in the repository.", - "type": "string", - "default": "" - }, - "encryptedToken": { - "description": "Token for accessing the repository, but encrypted. This is not possible to read back to a user decrypted.", - "type": "string", - "format": "byte", - "x-kubernetes-list-type": "atomic" - }, - "generateDashboardPreviews": { - "description": "Whether we should show dashboard previews for pull requests. By 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. This is usually something like `grafana/`. Trailing and leading slash are not required. They are always added when needed. The path is relative to the root of the repository, regardless of the leading slash.\n\nWhen specifying something like `grafana-`, we will not look for `grafana-*`; we will only look for files under the directory `/grafana-/`. That means `/grafana-example.json` would not be found.", - "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" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.GitLabRepositoryConfig": { - "type": "object", - "required": [ - "branch" - ], - "properties": { - "branch": { - "description": "The branch to use in the repository.", - "type": "string", - "default": "" - }, - "encryptedToken": { - "description": "Token for accessing the repository, but encrypted. This is not possible to read back to a user decrypted.", - "type": "string", - "format": "byte", - "x-kubernetes-list-type": "atomic" - }, - "path": { - "description": "Path is the subdirectory for the Grafana data. If specified, Grafana will ignore anything that is outside this directory in the repository. This is usually something like `grafana/`. Trailing and leading slash are not required. They are always added when needed. The path is relative to the root of the repository, regardless of the leading slash.\n\nWhen specifying something like `grafana-`, we will not look for `grafana-*`; we will only look for files under the directory `/grafana-/`. That means `/grafana-example.json` would not be found.", - "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": "string" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.GitRepositoryConfig": { - "type": "object", - "required": [ - "branch" - ], - "properties": { - "branch": { - "description": "The branch to use in the repository.", - "type": "string", - "default": "" - }, - "encryptedToken": { - "description": "Token for accessing the repository, but encrypted. This is not possible to read back to a user decrypted.", - "type": "string", - "format": "byte", - "x-kubernetes-list-type": "atomic" - }, - "path": { - "description": "Path is the subdirectory for the Grafana data. If specified, Grafana will ignore anything that is outside this directory in the repository. This is usually something like `grafana/`. Trailing and leading slash are not required. They are always added when needed. The path is relative to the root of the repository, regardless of the leading slash.\n\nWhen specifying something like `grafana-`, we will not look for `grafana-*`; we will only look for files under the directory `/grafana-/`. That means `/grafana-example.json` would not be found.", - "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" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.HealthStatus": { - "type": "object", - "required": [ - "healthy" - ], - "properties": { - "checked": { - "description": "When the health was checked last time", - "type": "integer", - "format": "int64" - }, - "healthy": { - "description": "When not healthy, requests will not be executed", - "type": "boolean", - "default": false - }, - "message": { - "description": "Summary messages (can be shown to users) Will only be populated when not healthy", - "type": "array", - "items": { - "type": "string", - "default": "" - }, - "x-kubernetes-list-type": "atomic" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.HistoricJob": { - "description": "HistoricJob is an append only log, saving all jobs that have been processed.\n\nNOTE: This should not be used directly by any external consumer. When there is a more stable integration with loki (an appropriate append only store) this may be removed without notice.\n\nThe repository name and type are stored as labels.", - "type": "object", - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "metadata": { - "default": {} - }, - "spec": { - "default": {} - }, - "status": { - "default": {} - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.HistoricJobList": { - "type": "object", - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "items": { - "type": "array", - "items": { - "default": {} - } - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "metadata": { - "default": {} - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.HistoryItem": { - "type": "object", - "required": [ - "ref", - "message", - "authors", - "createdAt" - ], - "properties": { - "authors": { - "type": "array", - "items": { - "default": {} - }, - "x-kubernetes-list-type": "atomic" - }, - "createdAt": { - "type": "integer", - "format": "int64", - "default": 0 - }, - "message": { - "type": "string", - "default": "" - }, - "ref": { - "type": "string", - "default": "" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.HistoryList": { - "description": "HistoryList is a list of versions of a resource", - "type": "object", - "required": [ - "items" - ], - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "items": { - "type": "array", - "items": { - "default": {} - }, - "x-kubernetes-list-type": "atomic" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "metadata": { - "default": {} - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.Job": { - "description": "The repository name and type are stored as labels", - "type": "object", - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "metadata": { - "default": {} - }, - "spec": { - "default": {} - }, - "status": { - "default": {} - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.JobList": { - "type": "object", - "required": [ - "items" - ], - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "items": { - "type": "array", - "items": { - "default": {} - } - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "metadata": { - "default": {} - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.JobResourceSummary": { - "type": "object", - "properties": { - "create": { - "type": "integer", - "format": "int64" - }, - "delete": { - "type": "integer", - "format": "int64" - }, - "error": { - "description": "Create or update (export)", - "type": "integer", - "format": "int64" - }, - "errors": { - "description": "Report errors for this resource type This may not be an exhaustive list and recommend looking at the logs for more info", - "type": "array", - "items": { - "type": "string", - "default": "" - } - }, - "group": { - "type": "string" - }, - "noop": { - "description": "No action required (useful for sync)", - "type": "integer", - "format": "int64" - }, - "resource": { - "type": "string" - }, - "total": { - "type": "integer", - "format": "int64" - }, - "update": { - "type": "integer", - "format": "int64" - }, - "write": { - "type": "integer", - "format": "int64" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.JobSpec": { - "type": "object", - "properties": { - "action": { - "description": "Possible enum values:\n - `\"delete\"` deletes files in the remote repository\n - `\"migrate\"` acts like JobActionExport, then JobActionPull. It also tries to preserve the history.\n - `\"move\"` moves files in the remote repository\n - `\"pr\"` adds additional useful information to a PR, such as comments with preview links and rendered images.\n - `\"pull\"` replicates the remote branch in the local copy of the repository.\n - `\"push\"` replicates the local copy of the repository in the remote branch.", - "type": "string", - "enum": [ - "delete", - "migrate", - "move", - "pr", - "pull", - "push" - ] - }, - "delete": { - "description": "Delete when the action is `delete`" - }, - "migrate": { - "description": "Required when the action is `migrate`" - }, - "move": { - "description": "Move when the action is `move`" - }, - "pr": { - "description": "Pull request options" - }, - "pull": { - "description": "Required when the action is `pull`" - }, - "push": { - "description": "Required when the action is `push`" - }, - "repository": { - "description": "The the repository reference (for now also in labels) This value is required, but will be popuplated from the job making the request", - "type": "string" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.JobStatus": { - "description": "The job status", - "type": "object", - "properties": { - "errors": { - "type": "array", - "items": { - "type": "string", - "default": "" - } - }, - "finished": { - "type": "integer", - "format": "int64" - }, - "message": { - "type": "string" - }, - "progress": { - "description": "Optional value 0-100 that can be set while running", - "type": "number", - "format": "double" - }, - "started": { - "type": "integer", - "format": "int64" - }, - "state": { - "description": "Possible enum values:\n - `\"error\"` Finished with errors\n - `\"pending\"` Job has been submitted, but not processed yet\n - `\"success\"` Finished with success\n - `\"warning\"` Finished with some non-critical errors\n - `\"working\"` The job is running", - "type": "string", - "enum": [ - "error", - "pending", - "success", - "warning", - "working" - ] - }, - "summary": { - "description": "Summary of processed actions", - "type": "array", - "items": {} - }, - "url": { - "description": "URLs contains URLs for the reference branch or commit if applicable." - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.LocalRepositoryConfig": { - "type": "object", - "properties": { - "path": { - "type": "string" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ManagerStats": { - "type": "object", - "required": [ - "stats" - ], - "properties": { - "id": { - "description": "Manager identity", - "type": "string" - }, - "kind": { - "description": "Manager kind", - "type": "string" - }, - "stats": { - "description": "stats", - "type": "array", - "items": { - "allOf": [ - { - "$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ResourceCount" - } - ] - } - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.MigrateJobOptions": { - "type": "object", - "properties": { - "history": { - "description": "Preserve history (if possible)", - "type": "boolean" - }, - "message": { - "description": "Message to use when committing the changes in a single commit", - "type": "string" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.MoveJobOptions": { - "type": "object", - "properties": { - "paths": { - "description": "Paths to be deleted. Examples: - dashboard.json (for a file) - a/b/c/other-dashboard.json (for a file) - nested/deep/ (for a directory) FIXME: we should validate this in admission hooks", - "type": "array", - "items": { - "type": "string", - "default": "" - } - }, - "ref": { - "description": "Ref to the branch or commit hash that should move", - "type": "string" - }, - "resources": { - "description": "Resources to move This option has been created because currently the frontend does not use standarized app platform APIs. For performance and API consistency reasons, the preferred option is it to use the paths.", - "type": "array", - "items": { - "default": {} - } - }, - "targetPath": { - "description": "Destination path for the move (e.g. \"new-location/\")", - "type": "string" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.PullRequestJobOptions": { - "type": "object", - "properties": { - "hash": { - "description": "The specific commit hash that triggered this notice", - "type": "string" - }, - "pr": { - "description": "Pull request number (when appropriate)", - "type": "integer", - "format": "int32" - }, - "ref": { - "description": "The branch of commit hash", - "type": "string" - }, - "url": { - "description": "URL to the originator (eg, PR URL)", - "type": "string" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.RefItem": { - "type": "object", - "required": [ - "name" - ], - "properties": { - "hash": { - "description": "The SHA hash of the commit this ref points to", - "type": "string" - }, - "name": { - "description": "The name of the reference (branch or tag)", - "type": "string", - "default": "" - }, - "refURL": { - "description": "The URL to the reference (branch or tag)", - "type": "string" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.RefList": { - "type": "object", - "required": [ - "items" - ], - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "items": { - "type": "array", - "items": { - "default": {} - }, - "x-kubernetes-list-type": "atomic" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "metadata": { - "default": {} - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.Repository": { - "description": "When this code is changed, make sure to update the code generation. As of writing, this can be done via the hack dir in the root of the repo: ./hack/update-codegen.sh provisioning If you've opened the generated files in this dir at some point in VSCode, you may also have to re-open them to clear errors.", - "type": "object", - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "metadata": { - "default": {} - }, - "spec": { - "default": {} - }, - "status": { - "default": {} - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.RepositoryList": { - "type": "object", - "required": [ - "items" - ], - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "items": { - "type": "array", - "items": { - "default": {} - }, - "x-kubernetes-list-type": "atomic" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "metadata": { - "default": {} - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.RepositorySpec": { - "type": "object", - "required": [ - "title", - "workflows", - "sync", - "type" - ], - "properties": { - "bitbucket": { - "description": "The repository on Bitbucket. Mutually exclusive with local | github | git." - }, - "description": { - "description": "Repository description", - "type": "string" - }, - "git": { - "description": "The repository on Git. Mutually exclusive with local | github | git." - }, - "github": { - "description": "The repository on GitHub. Mutually exclusive with local | github | git." - }, - "gitlab": { - "description": "The repository on GitLab. Mutually exclusive with local | github | git." - }, - "local": { - "description": "The repository on the local file system. Mutually exclusive with local | github." - }, - "sync": { - "description": "Sync settings -- how values are pulled from the repository into grafana", - "default": {} - }, - "title": { - "description": "The repository display name (shown in the UI)", - "type": "string", - "default": "" - }, - "type": { - "description": "The repository type. When selected oneOf the values below should be non-nil\n\nPossible enum values:\n - `\"bitbucket\"`\n - `\"git\"`\n - `\"github\"`\n - `\"gitlab\"`\n - `\"local\"`", - "type": "string", - "default": "", - "enum": [ - "bitbucket", - "git", - "github", - "gitlab", - "local" - ] - }, - "workflows": { - "description": "UI driven Workflow that allow changes to the contends of the repository. The order is relevant for defining the precedence of the workflows. When empty, the repository does not support any edits (eg, readonly)", - "type": "array", - "items": { - "type": "string", - "default": "", - "enum": [ - "branch", - "write" - ] - } - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.RepositoryStatus": { - "description": "The status of a Repository. This is expected never to be created by a kubectl call or similar, and is expected to rarely (if ever) be edited manually. As such, it is also a little less well structured than the spec, such as conditional-but-ever-present fields.", - "type": "object", - "required": [ - "observedGeneration", - "health", - "sync", - "webhook" - ], - "properties": { - "health": { - "description": "This will get updated with the current health status (and updated periodically)", - "default": {} - }, - "observedGeneration": { - "description": "The generation of the spec last time reconciliation ran", - "type": "integer", - "format": "int64", - "default": 0 - }, - "stats": { - "description": "The object count when sync last ran", - "type": "array", - "items": { - "default": {} - }, - "x-kubernetes-list-type": "atomic" - }, - "sync": { - "description": "Sync information with the last sync information", - "default": {} - }, - "webhook": { - "description": "Webhook Information (if applicable)" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.RepositoryURLs": { - "type": "object", - "properties": { - "compareURL": { - "description": "Compare this version to the target branch", - "type": "string" - }, - "newPullRequestURL": { - "description": "A URL that will create a new pull request for this branch", - "type": "string" - }, - "repositoryURL": { - "description": "A URL pointing to the repository this lives in", - "type": "string" - }, - "sourceURL": { - "description": "A URL pointing to the file or ref in the repository", - "type": "string" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.RepositoryView": { - "type": "object", - "required": [ - "name", - "title", - "type", - "target", - "workflows" - ], - "properties": { - "branch": { - "description": "For git, this is the target branch", - "type": "string" - }, - "name": { - "description": "The k8s name for this repository", - "type": "string", - "default": "" - }, - "target": { - "description": "When syncing, where values are saved\n\nPossible enum values:\n - `\"folder\"` Resources will be saved into a folder managed by this repository It will contain a copy of everything from the remote The folder k8s name will be the same as the repository k8s name\n - `\"instance\"` Resources are saved in the global context Only one repository may specify the `instance` target When this exists, the UI will promote writing to the instance repo rather than the grafana database (where possible)", - "type": "string", - "default": "", - "enum": [ - "folder", - "instance" - ] - }, - "title": { - "description": "Repository display", - "type": "string", - "default": "" - }, - "type": { - "description": "The repository type\n\nPossible enum values:\n - `\"bitbucket\"`\n - `\"git\"`\n - `\"github\"`\n - `\"gitlab\"`\n - `\"local\"`", - "type": "string", - "default": "", - "enum": [ - "bitbucket", - "git", - "github", - "gitlab", - "local" - ] - }, - "workflows": { - "description": "The supported workflows", - "type": "array", - "items": { - "type": "string", - "default": "", - "enum": [ - "branch", - "write" - ] - } - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.RepositoryViewList": { - "description": "Summary shows a view of the configuration that is sanitized and is OK for logged in users to see", - "type": "object", - "required": [ - "items" - ], - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "availableRepositoryTypes": { - "description": "AvailableRepositoryTypes is the list of repository types supported in this instance (e.g. git, bitbucket, github, etc)", - "type": "array", - "items": { - "type": "string", - "default": "", - "enum": [ - "bitbucket", - "git", - "github", - "gitlab", - "local" - ] - } - }, - "items": { - "type": "array", - "items": { - "allOf": [ - { - "$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.RepositoryView" - } - ] - }, - "x-kubernetes-map-type": "atomic" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "legacyStorage": { - "description": "The backend is using legacy storage FIXME: Not sure where this should be exposed... but we need it somewhere The UI should force the onboarding workflow when this is true", - "type": "boolean" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ResourceCount": { - "type": "object", - "required": [ - "group", - "resource", - "count" - ], - "properties": { - "count": { - "type": "integer", - "format": "int64", - "default": 0 - }, - "group": { - "type": "string", - "default": "" - }, - "resource": { - "type": "string", - "default": "" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ResourceList": { - "description": "Information we can get just from the file listing", - "type": "object", - "required": [ - "items" - ], - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "items": { - "type": "array", - "items": { - "default": {} - }, - "x-kubernetes-list-type": "atomic" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "metadata": { - "default": {} - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ResourceListItem": { - "type": "object", - "required": [ - "path", - "group", - "resource", - "name", - "hash" - ], - "properties": { - "folder": { - "type": "string" - }, - "group": { - "type": "string", - "default": "" - }, - "hash": { - "description": "the k8s identifier", - "type": "string", - "default": "" - }, - "name": { - "type": "string", - "default": "" - }, - "path": { - "type": "string", - "default": "" - }, - "resource": { - "type": "string", - "default": "" - }, - "time": { - "type": "integer", - "format": "int64" - }, - "title": { - "type": "string" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ResourceObjects": { - "type": "object", - "required": [ - "type" - ], - "properties": { - "action": { - "description": "The action required/used for dryRun\n\nPossible enum values:\n - `\"create\"`\n - `\"delete\"`\n - `\"move\"`\n - `\"update\"`", - "type": "string", - "enum": [ - "create", - "delete", - "move", - "update" - ] - }, - "dryRun": { - "description": "The value returned from a dryRun request" - }, - "existing": { - "description": "The same value, currently saved in the grafana database" - }, - "file": { - "description": "The resource from the repository with all modifications applied eg, the name, folder etc will all be applied to this object" - }, - "type": { - "description": "The identified type for this object", - "default": {} - }, - "upsert": { - "description": "For write events, this will return the value that was added or updated" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ResourceRef": { - "type": "object", - "properties": { - "group": { - "description": "Group is the group of the resource, such as \"dashboard.grafana.app\".", - "type": "string" - }, - "kind": { - "description": "Kind is the type of resource, for example, \"Dashboard\".", - "type": "string" - }, - "name": { - "description": "Name is the name of the resource, such as a dashboard UID.", - "type": "string" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ResourceRepositoryInfo": { - "type": "object", - "required": [ - "type", - "title", - "namespace", - "name" - ], - "properties": { - "name": { - "description": "The name (identifier)", - "type": "string", - "default": "" - }, - "namespace": { - "description": "The namespace this belongs to", - "type": "string", - "default": "" - }, - "title": { - "description": "The display name for this repository", - "type": "string", - "default": "" - }, - "type": { - "description": "The repository type\n\nPossible enum values:\n - `\"bitbucket\"`\n - `\"git\"`\n - `\"github\"`\n - `\"gitlab\"`\n - `\"local\"`", - "type": "string", - "default": "", - "enum": [ - "bitbucket", - "git", - "github", - "gitlab", - "local" - ] - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ResourceStats": { - "description": "Information we can get just from the file listing", - "type": "object", - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "instance": { - "description": "Stats across all unified storage When legacy storage is still used, this will offer a shim", - "type": "array", - "items": { - "allOf": [ - { - "$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ResourceCount" - } - ] - }, - "x-kubernetes-list-type": "atomic" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "managed": { - "description": "Stats for each manager", - "type": "array", - "items": { - "allOf": [ - { - "$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ManagerStats" - } - ] - }, - "x-kubernetes-list-type": "atomic" - }, - "metadata": { - "default": {} - }, - "unmanaged": { - "description": "Stats across all unified storage When legacy storage is still used, this will offer a shim", - "type": "array", - "items": { - "default": {} - }, - "x-kubernetes-list-type": "atomic" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ResourceType": { - "type": "object", - "properties": { - "classic": { - "description": "For non-k8s native formats, what did this start as\n\nPossible enum values:\n - `\"access-control\"` Access control https://github.com/grafana/grafana/blob/v11.3.1/conf/provisioning/access-control/sample.yaml\n - `\"alerting\"` Alert configuration https://github.com/grafana/grafana/blob/v11.3.1/conf/provisioning/alerting/sample.yaml\n - `\"dashboard\"` Dashboard JSON\n - `\"datasources\"` Datasource definitions eg: https://github.com/grafana/grafana/blob/v11.3.1/conf/provisioning/datasources/sample.yaml", - "type": "string", - "enum": [ - "access-control", - "alerting", - "dashboard", - "datasources" - ] - }, - "group": { - "type": "string" - }, - "kind": { - "type": "string" - }, - "resource": { - "type": "string" - }, - "version": { - "type": "string" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.ResourceWrapper": { - "description": "This is a container type for any resource type", - "type": "object", - "required": [ - "repository", - "resource" - ], - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "errors": { - "description": "If errors exist, show them here", - "type": "array", - "items": { - "type": "string", - "default": "" - }, - "x-kubernetes-list-type": "atomic" - }, - "hash": { - "description": "The repo hash value", - "type": "string" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "path": { - "description": "Path to the remote file", - "type": "string" - }, - "ref": { - "description": "The request ref (or branch if exists)", - "type": "string" - }, - "repository": { - "description": "Basic repository info", - "default": {} - }, - "resource": { - "description": "Different flavors of the same object", - "default": {} - }, - "timestamp": { - "description": "The modified time in the remote file system" - }, - "urls": { - "description": "Typed links for this file (only supported by external systems, github etc)" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.SyncJobOptions": { - "type": "object", - "required": [ - "incremental" - ], - "properties": { - "incremental": { - "description": "Incremental synchronization for versioned repositories", - "type": "boolean", - "default": false - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.SyncOptions": { - "type": "object", - "required": [ - "enabled", - "target" - ], - "properties": { - "enabled": { - "description": "Enabled must be saved as true before any sync job will run", - "type": "boolean", - "default": false - }, - "intervalSeconds": { - "description": "When non-zero, the sync will run periodically", - "type": "integer", - "format": "int64" - }, - "target": { - "description": "Where values should be saved\n\nPossible enum values:\n - `\"folder\"` Resources will be saved into a folder managed by this repository It will contain a copy of everything from the remote The folder k8s name will be the same as the repository k8s name\n - `\"instance\"` Resources are saved in the global context Only one repository may specify the `instance` target When this exists, the UI will promote writing to the instance repo rather than the grafana database (where possible)", - "type": "string", - "default": "", - "enum": [ - "folder", - "instance" - ] - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.SyncStatus": { - "type": "object", - "required": [ - "state", - "message" - ], - "properties": { - "finished": { - "description": "When the sync job finished", - "type": "integer", - "format": "int64" - }, - "incremental": { - "description": "Incremental synchronization for versioned repositories", - "type": "boolean" - }, - "job": { - "description": "The ID for the job that ran this sync", - "type": "string" - }, - "lastRef": { - "description": "The repository ref when the last successful sync ran", - "type": "string" - }, - "message": { - "description": "Summary messages (will be shown to users)", - "type": "array", - "items": { - "type": "string", - "default": "" - }, - "x-kubernetes-list-type": "atomic" - }, - "scheduled": { - "description": "When the next sync check is scheduled", - "type": "integer", - "format": "int64" - }, - "started": { - "description": "When the sync job started", - "type": "integer", - "format": "int64" - }, - "state": { - "description": "pending, running, success, error\n\nPossible enum values:\n - `\"error\"` Finished with errors\n - `\"pending\"` Job has been submitted, but not processed yet\n - `\"success\"` Finished with success\n - `\"warning\"` Finished with some non-critical errors\n - `\"working\"` The job is running", - "type": "string", - "default": "", - "enum": [ - "error", - "pending", - "success", - "warning", - "working" - ] - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.TestResults": { - "description": "HistoryList is a list of versions of a resource", - "type": "object", - "required": [ - "code", - "success" - ], - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "code": { - "description": "HTTP status code", - "type": "integer", - "format": "int32", - "default": 0 - }, - "errors": { - "description": "Field related errors", - "type": "array", - "items": { - "default": {} - } - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "success": { - "description": "Is the connection healthy", - "type": "boolean", - "default": false - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.WebhookResponse": { - "type": "object", - "properties": { - "added": { - "description": "Optional message", - "type": "string" - }, - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "code": { - "description": "HTTP Status code 200 implies that the payload was understood but nothing is required 202 implies that an async job has been scheduled to handle the request", - "type": "integer", - "format": "int32" - }, - "job": { - "description": "Jobs to be processed When the response is 202 (Accepted) the queued jobs will be returned" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - } - } - }, - "com.github.grafana.grafana.pkg.apis.provisioning.v0alpha1.WebhookStatus": { - "type": "object", - "properties": { - "encryptedSecret": { - "type": "string", - "format": "byte" - }, - "id": { - "type": "integer", - "format": "int64" - }, - "lastEvent": { - "type": "integer", - "format": "int64" - }, - "secret": { - "type": "string" - }, - "subscribedEvents": { - "type": "array", - "items": { - "type": "string", - "default": "" - } - }, - "url": { - "type": "string" - } - } - }, "io.k8s.apimachinery.pkg.apis.meta.v1.APIResource": { "description": "APIResource specifies the name of a resource and whether it is namespaced.", "type": "object", diff --git a/public/app/api/clients/provisioning/v0alpha1/endpoints.gen.ts b/public/app/api/clients/provisioning/v0alpha1/endpoints.gen.ts index 63f4e3af895..33ee7549eb7 100644 --- a/public/app/api/clients/provisioning/v0alpha1/endpoints.gen.ts +++ b/public/app/api/clients/provisioning/v0alpha1/endpoints.gen.ts @@ -853,6 +853,16 @@ export type JobResourceSummary = { update?: number; write?: number; }; +export type RepositoryUrLs = { + /** Compare this version to the target branch */ + compareURL?: string; + /** A URL that will create a new pull request for this branch */ + newPullRequestURL?: string; + /** A URL pointing to the repository this lives in */ + repositoryURL?: string; + /** A URL pointing to the file or ref in the repository */ + sourceURL?: string; +}; export type JobStatus = { errors?: string[]; finished?: number; @@ -869,6 +879,8 @@ export type JobStatus = { state?: 'error' | 'pending' | 'success' | 'warning' | 'working'; /** Summary of processed actions */ summary?: JobResourceSummary[]; + /** URLs contains URLs for the reference branch or commit if applicable. */ + url?: RepositoryUrLs; }; export type Job = { /** APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources */ @@ -1176,16 +1188,6 @@ export type ResourceObjects = { /** For write events, this will return the value that was added or updated */ upsert?: Unstructured; }; -export type ResourceUrLs = { - /** Compare this version to the target branch */ - compareURL?: string; - /** A URL that will create a new pull requeset for this branch */ - newPullRequestURL?: string; - /** A URL pointing to the repository this lives in */ - repositoryURL?: string; - /** A URL pointing to the this file in the repository */ - sourceURL?: string; -}; export type ResourceWrapper = { /** APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources */ apiVersion?: string; @@ -1206,7 +1208,7 @@ export type ResourceWrapper = { /** The modified time in the remote file system */ timestamp?: Time; /** Typed links for this file (only supported by external systems, github etc) */ - urls?: ResourceUrLs; + urls?: RepositoryUrLs; }; export type ResourceListItem = { folder?: string; @@ -1310,6 +1312,8 @@ export type ResourceStats = { /** Stats for each manager */ managed?: ManagerStats[]; metadata?: any; + /** Stats across all unified storage When legacy storage is still used, this will offer a shim */ + unmanaged?: ResourceCount[]; }; export const { useListJobQuery, diff --git a/scripts/process-specs.ts b/scripts/process-specs.ts index f13fdf7cb74..8ebd24705de 100644 --- a/scripts/process-specs.ts +++ b/scripts/process-specs.ts @@ -69,6 +69,11 @@ function processOpenAPISpec(spec: OpenAPIV3.Document) { const newSchemas: Record = {}; for (const schemaKey of Object.keys(newSpec.components.schemas)) { const newKey = simplifySchemaName(schemaKey); + if (newSchemas[newKey]) { + // This can happen when invalid specs are used, although ignoring the error will work + // it is better to fix the spec to avoid confusion. + throw new Error(`Duplicate schema key found: ${newKey}. from: ${schemaKey}`); + } const schemaObject = newSpec.components.schemas[schemaKey]; updateRefs(schemaObject);