merge main

This commit is contained in:
Ryan McKinley
2025-06-27 12:49:54 -07:00
864 changed files with 67821 additions and 25886 deletions
@@ -126,7 +126,9 @@ func TestIntegrationConvertPrometheusAlertmanagerEndpoints(t *testing.T) {
})
t.Run("error cases", func(t *testing.T) {
t.Run("POST without config identifier header should fail", func(t *testing.T) {
t.Run("POST without config identifier header should use default identifier", func(t *testing.T) {
defer cleanup("")
headers := map[string]string{
"Content-Type": "application/yaml",
"X-Grafana-Alerting-Merge-Matchers": "environment=test",
@@ -137,7 +139,14 @@ func TestIntegrationConvertPrometheusAlertmanagerEndpoints(t *testing.T) {
}
_, status, _ := apiClient.RawConvertPrometheusPostAlertmanagerConfig(t, amConfig, headers)
requireStatusCode(t, http.StatusBadRequest, status, "")
requireStatusCode(t, http.StatusAccepted, status, "")
getHeaders := map[string]string{
"X-Grafana-Alerting-Config-Identifier": "default",
}
responseConfig, status, _ := apiClient.RawConvertPrometheusGetAlertmanagerConfig(t, getHeaders)
requireStatusCode(t, http.StatusOK, status, "")
require.NotEmpty(t, responseConfig.AlertmanagerConfig)
})
t.Run("POST without merge matchers header should fail", func(t *testing.T) {
@@ -184,11 +193,27 @@ func TestIntegrationConvertPrometheusAlertmanagerEndpoints(t *testing.T) {
requireStatusCode(t, http.StatusBadRequest, status, "")
})
t.Run("DELETE without config identifier header should fail", func(t *testing.T) {
headers := map[string]string{}
t.Run("DELETE without config identifier header should use default identifier", func(t *testing.T) {
createHeaders := map[string]string{
"Content-Type": "application/yaml",
"X-Grafana-Alerting-Merge-Matchers": "environment=test",
}
_, status, _ := apiClient.RawConvertPrometheusDeleteAlertmanagerConfig(t, headers)
requireStatusCode(t, http.StatusBadRequest, status, "")
amConfig := apimodels.AlertmanagerUserConfig{
AlertmanagerConfig: testAlertmanagerConfigYAML,
}
_, status, _ := apiClient.RawConvertPrometheusPostAlertmanagerConfig(t, amConfig, createHeaders)
requireStatusCode(t, http.StatusAccepted, status, "")
_, status, _ = apiClient.RawConvertPrometheusGetAlertmanagerConfig(t, nil)
requireStatusCode(t, http.StatusOK, status, "")
_, status, _ = apiClient.RawConvertPrometheusDeleteAlertmanagerConfig(t, nil)
requireStatusCode(t, http.StatusAccepted, status, "")
_, status, _ = apiClient.RawConvertPrometheusGetAlertmanagerConfig(t, nil)
requireStatusCode(t, http.StatusNotFound, status, "")
})
})
@@ -551,3 +551,214 @@ func testPreserveSchemaVersion(t *testing.T, featureToggles []string) {
})
}
}
func TestIntegrationImportDashboardWithLibraryPanels(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
testImportDashboardWithLibraryPanels(t, []string{})
}
func TestIntegrationImportDashboardWithLibraryPanelsK8s(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}
testImportDashboardWithLibraryPanels(t, []string{featuremgmt.FlagKubernetesClientDashboardsFolders})
}
func testImportDashboardWithLibraryPanels(t *testing.T, featureToggles []string) {
dir, path := testinfra.CreateGrafDir(t, testinfra.GrafanaOpts{
DisableAnonymous: true,
EnableFeatureToggles: featureToggles,
})
grafanaListedAddr, _ := testinfra.StartGrafanaEnv(t, dir, path)
t.Run("import dashboard with library panels should create library panels and connections", func(t *testing.T) {
dashboardJSON := `{
"title": "Test Dashboard with Library Panels",
"panels": [
{
"id": 1,
"title": "Library Panel 1",
"type": "text",
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 0},
"libraryPanel": {
"uid": "test-lib-panel-1",
"name": "Test Library Panel 1"
}
},
{
"id": 2,
"title": "Library Panel 2",
"type": "stat",
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 0},
"libraryPanel": {
"uid": "test-lib-panel-2",
"name": "Test Library Panel 2"
}
}
],
"__elements": {
"test-lib-panel-1": {
"uid": "test-lib-panel-1",
"name": "Test Library Panel 1",
"kind": 1,
"type": "text",
"model": {
"title": "Test Library Panel 1",
"type": "text",
"options": {
"content": "This is a test library panel"
}
}
},
"test-lib-panel-2": {
"uid": "test-lib-panel-2",
"name": "Test Library Panel 2",
"kind": 1,
"type": "stat",
"model": {
"title": "Test Library Panel 2",
"type": "stat",
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"textMode": "auto"
},
"targets": [
{
"refId": "A",
"scenarioId": "csv_metric_values",
"stringInput": "1,20,90,30,5,0"
}
]
}
}
}
}`
data, err := simplejson.NewJson([]byte(dashboardJSON))
require.NoError(t, err)
buf := &bytes.Buffer{}
err = json.NewEncoder(buf).Encode(dashboardimport.ImportDashboardRequest{
Dashboard: data,
})
require.NoError(t, err)
u := fmt.Sprintf("http://admin:admin@%s/api/dashboards/import", grafanaListedAddr)
// nolint:gosec
resp, err := http.Post(u, "application/json", buf)
require.NoError(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode)
t.Cleanup(func() {
err := resp.Body.Close()
require.NoError(t, err)
})
b, err := io.ReadAll(resp.Body)
require.NoError(t, err)
var importResp struct {
UID string `json:"uid"`
}
err = json.Unmarshal(b, &importResp)
require.NoError(t, err)
require.NotEmpty(t, importResp.UID)
t.Run("library panels should be created", func(t *testing.T) {
url := fmt.Sprintf("http://admin:admin@%s/api/library-elements/test-lib-panel-1", grafanaListedAddr)
// nolint:gosec
resp, err := http.Get(url)
require.NoError(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode)
t.Cleanup(func() {
err := resp.Body.Close()
require.NoError(t, err)
})
panel, err := io.ReadAll(resp.Body)
require.NoError(t, err)
var panelRes struct {
Result struct {
UID string `json:"uid"`
Name string `json:"name"`
Type string `json:"type"`
} `json:"result"`
}
err = json.Unmarshal(panel, &panelRes)
require.NoError(t, err)
assert.Equal(t, "test-lib-panel-1", panelRes.Result.UID)
assert.Equal(t, "Test Library Panel 1", panelRes.Result.Name)
assert.Equal(t, "text", panelRes.Result.Type)
url = fmt.Sprintf("http://admin:admin@%s/api/library-elements/test-lib-panel-2", grafanaListedAddr)
// nolint:gosec
resp, err = http.Get(url)
require.NoError(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode)
t.Cleanup(func() {
err := resp.Body.Close()
require.NoError(t, err)
})
panel, err = io.ReadAll(resp.Body)
require.NoError(t, err)
err = json.Unmarshal(panel, &panelRes)
require.NoError(t, err)
assert.Equal(t, "test-lib-panel-2", panelRes.Result.UID)
assert.Equal(t, "Test Library Panel 2", panelRes.Result.Name)
assert.Equal(t, "stat", panelRes.Result.Type)
})
t.Run("library panels should be connected to dashboard", func(t *testing.T) {
url := fmt.Sprintf("http://admin:admin@%s/api/library-elements/test-lib-panel-1/connections", grafanaListedAddr)
// nolint:gosec
connectionsResp, err := http.Get(url)
require.NoError(t, err)
assert.Equal(t, http.StatusOK, connectionsResp.StatusCode)
t.Cleanup(func() {
err := connectionsResp.Body.Close()
require.NoError(t, err)
})
connections, err := io.ReadAll(connectionsResp.Body)
require.NoError(t, err)
var connectionsRes struct {
Result []struct {
ConnectionUID string `json:"connectionUid"`
} `json:"result"`
}
err = json.Unmarshal(connections, &connectionsRes)
require.NoError(t, err)
assert.Len(t, connectionsRes.Result, 1)
assert.Equal(t, importResp.UID, connectionsRes.Result[0].ConnectionUID)
url = fmt.Sprintf("http://admin:admin@%s/api/library-elements/test-lib-panel-2/connections", grafanaListedAddr)
// nolint:gosec
connectionsResp, err = http.Get(url)
require.NoError(t, err)
assert.Equal(t, http.StatusOK, connectionsResp.StatusCode)
t.Cleanup(func() {
err := connectionsResp.Body.Close()
require.NoError(t, err)
})
connections, err = io.ReadAll(connectionsResp.Body)
require.NoError(t, err)
err = json.Unmarshal(connections, &connectionsRes)
require.NoError(t, err)
assert.Len(t, connectionsRes.Result, 1)
assert.Equal(t, importResp.UID, connectionsRes.Result[0].ConnectionUID)
})
})
}
+1 -3
View File
@@ -15,7 +15,6 @@ import (
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/services/datasources"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/tests/testinfra"
"github.com/grafana/grafana/pkg/tests/testsuite"
)
@@ -29,8 +28,7 @@ func TestIntegrationLoki(t *testing.T) {
t.Skip("skipping integration test")
}
dir, path := testinfra.CreateGrafDir(t, testinfra.GrafanaOpts{
DisableAnonymous: true,
EnableFeatureToggles: []string{featuremgmt.FlagLokiSendDashboardPanelNames},
DisableAnonymous: true,
})
grafanaListeningAddr, testEnv := testinfra.StartGrafanaEnv(t, dir, path)
@@ -209,7 +209,7 @@
"path": "public/app/plugins/datasource/azuremonitor/img/azure_monitor_cpu.png"
}
],
"version": "11.6.0-pre",
"version": "12.1.0-pre",
"updated": "",
"keywords": [
"azure",
@@ -880,7 +880,7 @@
},
"build": {},
"screenshots": null,
"version": "11.6.0-pre",
"version": "12.1.0-pre",
"updated": "",
"keywords": null
},
@@ -934,7 +934,7 @@
},
"build": {},
"screenshots": null,
"version": "11.6.0-pre",
"version": "12.1.0-pre",
"updated": "",
"keywords": [
"grafana",
@@ -1190,34 +1190,34 @@
},
"description": "Open source, end-to-end distributed tracing",
"links": [
{
"name": "Learn more",
"url": "https://www.jaegertracing.io"
},
{
"name": "Jaeger GitHub Project",
"url": "https://github.com/jaegertracing/jaeger"
},
{
"name": "Repository",
"url": "https://github.com/grafana/grafana"
},
{
"name": "Raise issue",
"url": "https://github.com/grafana/grafana/issues/new"
},
{
"name": "Documentation",
"url": "https://grafana.com/docs/grafana/latest/datasources/jaeger/"
}
],
{
"name": "Learn more",
"url": "https://www.jaegertracing.io"
},
{
"name": "Jaeger GitHub Project",
"url": "https://github.com/jaegertracing/jaeger"
},
{
"name": "Repository",
"url": "https://github.com/grafana/grafana"
},
{
"name": "Raise issue",
"url": "https://github.com/grafana/grafana/issues/new"
},
{
"name": "Documentation",
"url": "https://grafana.com/docs/grafana/latest/datasources/jaeger/"
}
],
"logos": {
"small": "public/app/plugins/datasource/jaeger/img/jaeger_logo.svg",
"large": "public/app/plugins/datasource/jaeger/img/jaeger_logo.svg"
},
"build": {},
"screenshots": null,
"version": "11.6.0-pre",
"version": "12.1.0-pre",
"updated": "",
"keywords": null
},
@@ -1325,12 +1325,12 @@
},
"build": {},
"screenshots": null,
"version": "",
"version": "12.1.0-pre",
"updated": "",
"keywords": null
},
"dependencies": {
"grafanaDependency": "",
"grafanaDependency": "\u003e=10.4.0",
"grafanaVersion": "*",
"plugins": [],
"extensions": {
@@ -1375,7 +1375,7 @@
},
"build": {},
"screenshots": null,
"version": "11.6.0-pre",
"version": "12.1.0-pre",
"updated": "",
"keywords": null
},
@@ -1425,7 +1425,7 @@
},
"build": {},
"screenshots": null,
"version": "11.6.0-pre",
"version": "12.1.0-pre",
"updated": "",
"keywords": null
},
@@ -1629,7 +1629,7 @@
},
"build": {},
"screenshots": null,
"version": "11.6.0-pre",
"version": "12.1.0-pre",
"updated": "",
"keywords": [
"grafana",
@@ -1734,7 +1734,7 @@
},
"build": {},
"screenshots": null,
"version": "11.6.0-pre",
"version": "12.1.0-pre",
"updated": "",
"keywords": null
},
@@ -2042,7 +2042,7 @@
},
"build": {},
"screenshots": null,
"version": "11.6.0-pre",
"version": "12.1.0-pre",
"updated": "",
"keywords": null
},
@@ -2092,7 +2092,7 @@
},
"build": {},
"screenshots": null,
"version": "11.6.0-pre",
"version": "12.1.0-pre",
"updated": "",
"keywords": null
},
@@ -2445,7 +2445,7 @@
},
"build": {},
"screenshots": null,
"version": "11.6.0-pre",
"version": "12.1.0-pre",
"updated": "",
"keywords": null
},
@@ -62,7 +62,7 @@ func TestIntegrationValidation(t *testing.T) {
}
// TODO: Skip mode3 - borken due to race conditions while setting default permissions across storage backends
dualWriterModes := []rest.DualWriterMode{rest.Mode0}
dualWriterModes := []rest.DualWriterMode{rest.Mode0, rest.Mode1, rest.Mode2}
for _, dualWriterMode := range dualWriterModes {
t.Run(fmt.Sprintf("DualWriterMode %d", dualWriterMode), func(t *testing.T) {
// Create a K8sTestHelper which will set up a real API server
@@ -396,17 +396,10 @@ func runDashboardValidationTests(t *testing.T, ctx TestContext) {
require.NoError(t, err)
require.NotNil(t, updatedDash1)
// Try to update with the second copy (should fail with version conflict for mode 0, 4 and 5, but not for mode 1, 2 and 3)
updatedDash2, err := updateDashboard(t, editorClient, dash2, "Updated by second user", nil)
if ctx.DualWriterMode == rest.Mode1 || ctx.DualWriterMode == rest.Mode2 || ctx.DualWriterMode == rest.Mode3 {
require.NoError(t, err)
require.NotNil(t, updatedDash2)
meta, _ := utils.MetaAccessor(updatedDash2)
require.Equal(t, "Updated by second user", meta.FindTitle(""), "Dashboard title should be updated")
} else {
require.Error(t, err)
require.Contains(t, err.Error(), "the object has been modified", "Should fail with version conflict error")
}
// Try to update with the second copy. Should fail with version conflict.
_, err = updateDashboard(t, editorClient, dash2, "Updated by second user", nil)
require.Error(t, err)
require.Contains(t, err.Error(), "the object has been modified", "Should fail with version conflict error")
// Clean up
err = adminClient.Resource.Delete(context.Background(), dashUID, v1.DeleteOptions{})
@@ -438,6 +431,31 @@ func runDashboardValidationTests(t *testing.T, ctx TestContext) {
err = adminClient.Resource.Delete(context.Background(), dashUID, v1.DeleteOptions{})
require.NoError(t, err)
})
t.Run("dashboard version history available, even for UIDs ending in hyphen", func(t *testing.T) {
dashboardUID := "test-dashboard-"
dash, err := createDashboard(t, adminClient, "Dashboard with uid ending in hyphen", nil, &dashboardUID)
require.NoError(t, err)
updatedDash, err := updateDashboard(t, adminClient, dash, "Updated dashboard with uid ending in hyphen", nil)
require.NoError(t, err)
require.NotNil(t, updatedDash)
labelSelector := utils.LabelKeyGetHistory + "=true"
fieldSelector := "metadata.name=" + dashboardUID
versions, err := adminClient.Resource.List(context.Background(), v1.ListOptions{
LabelSelector: labelSelector,
FieldSelector: fieldSelector,
Limit: 10,
})
require.NoError(t, err)
require.NotNil(t, versions)
// one from initial save, one from update
require.Equal(t, len(versions.Items), 2)
err = adminClient.Resource.Delete(context.Background(), dashboardUID, v1.DeleteOptions{})
require.NoError(t, err)
})
})
t.Run("Dashboard provisioning validations", func(t *testing.T) {
@@ -915,232 +915,6 @@
}
]
},
"/apis/dashboard.grafana.app/v0alpha1/namespaces/{namespace}/librarypanels": {
"get": {
"tags": [
"LibraryPanel"
],
"description": "list objects of kind LibraryPanel",
"operationId": "listLibraryPanel",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v0alpha1.LibraryPanelList"
}
},
"application/json;stream=watch": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v0alpha1.LibraryPanelList"
}
},
"application/vnd.kubernetes.protobuf": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v0alpha1.LibraryPanelList"
}
},
"application/vnd.kubernetes.protobuf;stream=watch": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v0alpha1.LibraryPanelList"
}
},
"application/yaml": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v0alpha1.LibraryPanelList"
}
}
}
}
},
"x-kubernetes-action": "list",
"x-kubernetes-group-version-kind": {
"group": "dashboard.grafana.app",
"version": "v0alpha1",
"kind": "LibraryPanel"
}
},
"parameters": [
{
"name": "allowWatchBookmarks",
"in": "query",
"description": "allowWatchBookmarks requests watch events with type \"BOOKMARK\". Servers that do not implement bookmarks may ignore this flag and bookmarks are sent at the server's discretion. Clients should not assume bookmarks are returned at any specific interval, nor may they assume the server will send any BOOKMARK event during a session. If this is not a watch, this field is ignored.",
"schema": {
"type": "boolean",
"uniqueItems": true
}
},
{
"name": "continue",
"in": "query",
"description": "The continue option should be set when retrieving more results from the server. Since this value is server defined, clients may only use the continue value from a previous query result with identical query parameters (except for the value of continue) and the server may reject a continue value it does not recognize. If the specified continue value is no longer valid whether due to expiration (generally five to fifteen minutes) or a configuration change on the server, the server will respond with a 410 ResourceExpired error together with a continue token. If the client needs a consistent list, it must restart their list without the continue field. Otherwise, the client may send another list request with the token received with the 410 error, the server will respond with a list starting from the next key, but from the latest snapshot, which is inconsistent from the previous list results - objects that are created, modified, or deleted after the first list request will be included in the response, as long as their keys are after the \"next key\".\n\nThis field is not supported when watch is true. Clients may start a watch from the last resourceVersion value returned by the server and not miss any modifications.",
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "fieldSelector",
"in": "query",
"description": "A selector to restrict the list of returned objects by their fields. Defaults to everything.",
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "labelSelector",
"in": "query",
"description": "A selector to restrict the list of returned objects by their labels. Defaults to everything.",
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "limit",
"in": "query",
"description": "limit is a maximum number of responses to return for a list call. If more items exist, the server will set the `continue` field on the list metadata to a value that can be used with the same initial query to retrieve the next set of results. Setting a limit may return fewer than the requested amount of items (up to zero items) in the event all requested objects are filtered out and clients should only use the presence of the continue field to determine whether more results are available. Servers may choose not to support the limit argument and will return all of the available results. If limit is specified and the continue field is empty, clients may assume that no more results are available. This field is not supported if watch is true.\n\nThe server guarantees that the objects returned when using continue will be identical to issuing a single list call without a limit - that is, no objects created, modified, or deleted after the first request is issued will be included in any subsequent continued requests. This is sometimes referred to as a consistent snapshot, and ensures that a client that is using limit to receive smaller chunks of a very large result can ensure they see all possible objects. If objects are updated during a chunked list the version of the object that was present at the time the first list result was calculated is returned.",
"schema": {
"type": "integer",
"uniqueItems": true
}
},
{
"name": "namespace",
"in": "path",
"description": "object name and auth scope, such as for teams and projects",
"required": true,
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "pretty",
"in": "query",
"description": "If 'true', then the output is pretty printed. Defaults to 'false' unless the user-agent indicates a browser or command-line HTTP tool (curl and wget).",
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "resourceVersion",
"in": "query",
"description": "resourceVersion sets a constraint on what resource versions a request may be served from. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset",
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "resourceVersionMatch",
"in": "query",
"description": "resourceVersionMatch determines how resourceVersion is applied to list calls. It is highly recommended that resourceVersionMatch be set for list calls where resourceVersion is set See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions for details.\n\nDefaults to unset",
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "sendInitialEvents",
"in": "query",
"description": "`sendInitialEvents=true` may be set together with `watch=true`. In that case, the watch stream will begin with synthetic events to produce the current state of objects in the collection. Once all such events have been sent, a synthetic \"Bookmark\" event will be sent. The bookmark will report the ResourceVersion (RV) corresponding to the set of objects, and be marked with `\"k8s.io/initial-events-end\": \"true\"` annotation. Afterwards, the watch stream will proceed as usual, sending watch events corresponding to changes (subsequent to the RV) to objects watched.\n\nWhen `sendInitialEvents` option is set, we require `resourceVersionMatch` option to also be set. The semantic of the watch request is as following: - `resourceVersionMatch` = NotOlderThan\n is interpreted as \"data at least as new as the provided `resourceVersion`\"\n and the bookmark event is send when the state is synced\n to a `resourceVersion` at least as fresh as the one provided by the ListOptions.\n If `resourceVersion` is unset, this is interpreted as \"consistent read\" and the\n bookmark event is send when the state is synced at least to the moment\n when request started being processed.\n- `resourceVersionMatch` set to any other value or unset\n Invalid error is returned.\n\nDefaults to true if `resourceVersion=\"\"` or `resourceVersion=\"0\"` (for backward compatibility reasons) and to false otherwise.",
"schema": {
"type": "boolean",
"uniqueItems": true
}
},
{
"name": "timeoutSeconds",
"in": "query",
"description": "Timeout for the list/watch call. This limits the duration of the call, regardless of any activity or inactivity.",
"schema": {
"type": "integer",
"uniqueItems": true
}
},
{
"name": "watch",
"in": "query",
"description": "Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.",
"schema": {
"type": "boolean",
"uniqueItems": true
}
}
]
},
"/apis/dashboard.grafana.app/v0alpha1/namespaces/{namespace}/librarypanels/{name}": {
"get": {
"tags": [
"LibraryPanel"
],
"description": "read the specified LibraryPanel",
"operationId": "getLibraryPanel",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v0alpha1.LibraryPanel"
}
},
"application/vnd.kubernetes.protobuf": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v0alpha1.LibraryPanel"
}
},
"application/yaml": {
"schema": {
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v0alpha1.LibraryPanel"
}
}
}
}
},
"x-kubernetes-action": "get",
"x-kubernetes-group-version-kind": {
"group": "dashboard.grafana.app",
"version": "v0alpha1",
"kind": "LibraryPanel"
}
},
"parameters": [
{
"name": "name",
"in": "path",
"description": "name of the LibraryPanel",
"required": true,
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "namespace",
"in": "path",
"description": "object name and auth scope, such as for teams and projects",
"required": true,
"schema": {
"type": "string",
"uniqueItems": true
}
},
{
"name": "pretty",
"in": "query",
"description": "If 'true', then the output is pretty printed. Defaults to 'false' unless the user-agent indicates a browser or command-line HTTP tool (curl and wget).",
"schema": {
"type": "string",
"uniqueItems": true
}
}
]
},
"/apis/dashboard.grafana.app/v0alpha1/namespaces/{namespace}/search": {
"get": {
"tags": [
@@ -1315,139 +1089,6 @@
},
"components": {
"schemas": {
"com.github.grafana.grafana-plugin-sdk-go.experimental.apis.data.v0alpha1.DataQuery": {
"description": "Generic query properties",
"type": "object",
"properties": {
"datasource": {
"description": "The datasource",
"type": "object",
"required": [
"type"
],
"properties": {
"apiVersion": {
"description": "The apiserver version",
"type": "string"
},
"type": {
"description": "The datasource plugin type",
"type": "string"
},
"uid": {
"description": "Datasource UID (NOTE: name in k8s)",
"type": "string"
}
},
"additionalProperties": false
},
"hide": {
"description": "true if query is disabled (ie should not be returned to the dashboard)\nNOTE: this does not always imply that the query should not be executed since\nthe results from a hidden query may be used as the input to other queries (SSE etc)",
"type": "boolean"
},
"intervalMs": {
"description": "Interval is the suggested duration between time points in a time series query.\nNOTE: the values for intervalMs is not saved in the query model. It is typically calculated\nfrom the interval required to fill a pixels in the visualization",
"type": "number"
},
"maxDataPoints": {
"description": "MaxDataPoints is the maximum number of data points that should be returned from a time series query.\nNOTE: the values for maxDataPoints is not saved in the query model. It is typically calculated\nfrom the number of pixels visible in a visualization",
"type": "integer"
},
"queryType": {
"description": "QueryType is an optional identifier for the type of query.\nIt can be used to distinguish different types of queries.",
"type": "string"
},
"refId": {
"description": "RefID is the unique identifier of the query, set by the frontend call.",
"type": "string"
},
"resultAssertions": {
"description": "Optionally define expected query result behavior",
"type": "object",
"required": [
"typeVersion"
],
"properties": {
"maxFrames": {
"description": "Maximum frame count",
"type": "integer"
},
"type": {
"description": "Type asserts that the frame matches a known type structure.\n\n\nPossible enum values:\n - `\"\"` \n - `\"timeseries-wide\"` \n - `\"timeseries-long\"` \n - `\"timeseries-many\"` \n - `\"timeseries-multi\"` \n - `\"directory-listing\"` \n - `\"table\"` \n - `\"numeric-wide\"` \n - `\"numeric-multi\"` \n - `\"numeric-long\"` \n - `\"log-lines\"` ",
"type": "string",
"enum": [
"",
"timeseries-wide",
"timeseries-long",
"timeseries-many",
"timeseries-multi",
"directory-listing",
"table",
"numeric-wide",
"numeric-multi",
"numeric-long",
"log-lines"
],
"x-enum-description": {}
},
"typeVersion": {
"description": "TypeVersion is the version of the Type property. Versions greater than 0.0 correspond to the dataplane\ncontract documentation https://grafana.github.io/dataplane/contract/.",
"type": "array",
"maxItems": 2,
"minItems": 2,
"items": {
"type": "integer"
}
}
},
"additionalProperties": false
},
"timeRange": {
"description": "TimeRange represents the query range\nNOTE: unlike generic /ds/query, we can now send explicit time values in each query\nNOTE: the values for timeRange are not saved in a dashboard, they are constructed on the fly",
"type": "object",
"required": [
"from",
"to"
],
"properties": {
"from": {
"description": "From is the start time of the query.",
"type": "string",
"default": "now-6h"
},
"to": {
"description": "To is the end time of the query.",
"type": "string",
"default": "now"
}
},
"additionalProperties": false
}
},
"additionalProperties": true
},
"com.github.grafana.grafana-plugin-sdk-go.experimental.apis.data.v0alpha1.DataSourceRef": {
"description": "The datasource",
"type": "object",
"required": [
"type"
],
"properties": {
"apiVersion": {
"description": "The apiserver version",
"type": "string"
},
"type": {
"description": "The datasource plugin type",
"type": "string"
},
"uid": {
"description": "Datasource UID (NOTE: name in k8s)",
"type": "string"
}
},
"additionalProperties": false
},
"com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v0alpha1.AnnotationActions": {
"type": "object",
"required": [
@@ -1729,177 +1370,6 @@
}
]
},
"com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v0alpha1.LibraryPanel": {
"type": "object",
"required": [
"spec"
],
"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": {
"description": "Standard object's metadata More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata",
"default": {},
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta"
}
]
},
"spec": {
"description": "Panel properties",
"default": {},
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v0alpha1.LibraryPanelSpec"
}
]
},
"status": {
"description": "Status will show errors",
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v0alpha1.LibraryPanelStatus"
}
]
}
},
"x-kubernetes-group-version-kind": [
{
"group": "dashboard.grafana.app",
"kind": "LibraryPanel",
"version": "v0alpha1"
}
]
},
"com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v0alpha1.LibraryPanelList": {
"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": {},
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v0alpha1.LibraryPanel"
}
]
}
},
"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": {},
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.ListMeta"
}
]
}
},
"x-kubernetes-group-version-kind": [
{
"group": "dashboard.grafana.app",
"kind": "LibraryPanelList",
"version": "v0alpha1"
}
]
},
"com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v0alpha1.LibraryPanelSpec": {
"type": "object",
"required": [
"type",
"options",
"fieldConfig"
],
"properties": {
"datasource": {
"description": "The default datasource type",
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana-plugin-sdk-go.experimental.apis.data.v0alpha1.DataSourceRef"
}
]
},
"description": {
"description": "Library panel description",
"type": "string"
},
"fieldConfig": {
"description": "The fieldConfig schema depends on the panel type",
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apimachinery.apis.common.v0alpha1.Unstructured"
}
]
},
"options": {
"description": "The options schema depends on the panel type",
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apimachinery.apis.common.v0alpha1.Unstructured"
}
]
},
"pluginVersion": {
"description": "The panel type",
"type": "string"
},
"targets": {
"description": "The datasource queries",
"type": "array",
"items": {
"$ref": "#/components/schemas/com.github.grafana.grafana-plugin-sdk-go.experimental.apis.data.v0alpha1.DataQuery"
},
"x-kubernetes-list-type": "set"
},
"title": {
"description": "The panel title",
"type": "string"
},
"type": {
"description": "The panel type",
"type": "string",
"default": ""
}
}
},
"com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v0alpha1.LibraryPanelStatus": {
"type": "object",
"properties": {
"missing": {
"description": "The properties previously stored in SQL that are not included in this model",
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana.pkg.apimachinery.apis.common.v0alpha1.Unstructured"
}
]
},
"warnings": {
"description": "Translation warnings (mostly things that were in SQL columns but not found in the saved body)",
"type": "array",
"items": {
"type": "string",
"default": ""
}
}
}
},
"com.github.grafana.grafana.pkg.apimachinery.apis.common.v0alpha1.Unstructured": {
"type": "object",
"additionalProperties": true,
@@ -289,7 +289,7 @@ func TestIntegrationProvisioning_CreatingGitHubRepository(t *testing.T) {
found, err := helper.DashboardsV1.Resource.List(ctx, metav1.ListOptions{})
assert.NoError(t, err, "can list values")
assert.Equal(collect, 0, len(found.Items), "expected dashboards to be deleted")
}, time.Second*10, time.Millisecond*10, "Expected dashboards to be deleted")
}, time.Second*20, time.Millisecond*10, "Expected dashboards to be deleted")
t.Run("github url cleanup", func(t *testing.T) {
tests := []struct {