mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
writing to SQL
This commit is contained in:
parent
bb7d6d44cd
commit
37c2dade15
@ -13,11 +13,12 @@ import (
|
||||
"k8s.io/kube-openapi/pkg/spec3"
|
||||
"k8s.io/kube-openapi/pkg/validation/spec"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
peakq "github.com/grafana/grafana/pkg/apis/peakq/v0alpha1"
|
||||
"github.com/grafana/grafana/pkg/apiserver/builder"
|
||||
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
var _ builder.APIGroupBuilder = (*PeakQAPIBuilder)(nil)
|
||||
|
@ -27,7 +27,7 @@ func ProvideResourceServer(db db.DB, cfg *setting.Cfg, features featuremgmt.Feat
|
||||
}
|
||||
|
||||
supportBlobs := true
|
||||
useEntitySQL := false
|
||||
useEntitySQL := true // save in SQL (but watch not working)
|
||||
|
||||
// Create a local blob filesystem blob store
|
||||
if supportBlobs {
|
||||
@ -156,7 +156,7 @@ func (b *entityBridge) WriteEvent(ctx context.Context, event resource.WriteEvent
|
||||
Namespace: event.Key.Namespace,
|
||||
Name: event.Key.Name,
|
||||
Guid: string(event.Object.GetUID()),
|
||||
GroupVersion: gvr.GroupVersion().String(),
|
||||
GroupVersion: gvr.Version,
|
||||
|
||||
Folder: obj.GetFolder(),
|
||||
Body: event.Value,
|
||||
|
72
pkg/tests/apis/peakq/peakq_test.go
Normal file
72
pkg/tests/apis/peakq/peakq_test.go
Normal file
@ -0,0 +1,72 @@
|
||||
package playlist
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/tests/apis"
|
||||
"github.com/grafana/grafana/pkg/tests/testinfra"
|
||||
"github.com/grafana/grafana/pkg/tests/testsuite"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
testsuite.Run(m)
|
||||
}
|
||||
|
||||
func TestIntegrationFoldersApp(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
}
|
||||
helper := apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{
|
||||
AppModeProduction: false, // required for experimental APIs
|
||||
EnableFeatureToggles: []string{
|
||||
featuremgmt.FlagGrafanaAPIServerWithExperimentalAPIs, // Required to start the example service
|
||||
},
|
||||
})
|
||||
|
||||
t.Run("Check discovery client", func(t *testing.T) {
|
||||
disco := helper.NewDiscoveryClient()
|
||||
resources, err := disco.ServerResourcesForGroupVersion("peakq.grafana.app/v0alpha1")
|
||||
require.NoError(t, err)
|
||||
|
||||
v1Disco, err := json.MarshalIndent(resources, "", " ")
|
||||
require.NoError(t, err)
|
||||
fmt.Printf("%s", string(v1Disco))
|
||||
require.JSONEq(t, `{
|
||||
"kind": "APIResourceList",
|
||||
"apiVersion": "v1",
|
||||
"groupVersion": "peakq.grafana.app/v0alpha1",
|
||||
"resources": [
|
||||
{
|
||||
"name": "querytemplates",
|
||||
"singularName": "querytemplate",
|
||||
"namespaced": true,
|
||||
"kind": "QueryTemplate",
|
||||
"verbs": [
|
||||
"create",
|
||||
"delete",
|
||||
"deletecollection",
|
||||
"get",
|
||||
"list",
|
||||
"patch",
|
||||
"update",
|
||||
"watch"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "querytemplates/render",
|
||||
"singularName": "",
|
||||
"namespaced": true,
|
||||
"kind": "RenderedQuery",
|
||||
"verbs": [
|
||||
"get"
|
||||
]
|
||||
}
|
||||
]
|
||||
}`, string(v1Disco))
|
||||
})
|
||||
}
|
7
pkg/tests/apis/peakq/testdata/query-generate.yaml
vendored
Normal file
7
pkg/tests/apis/peakq/testdata/query-generate.yaml
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
apiVersion: peakq.grafana.app/v0alpha1
|
||||
kind: QueryTemplate
|
||||
metadata:
|
||||
generateName: x # anything is ok here... except yes or true -- they become boolean!
|
||||
spec:
|
||||
title: Generated query template
|
||||
description: A description from here
|
Loading…
Reference in New Issue
Block a user