|
|
|
|
@ -1,6 +1,16 @@ |
|
|
|
|
package dashboard |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"github.com/prometheus/client_golang/prometheus" |
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
|
|
|
|
"k8s.io/apimachinery/pkg/runtime" |
|
|
|
|
"k8s.io/apimachinery/pkg/runtime/schema" |
|
|
|
|
"k8s.io/apiserver/pkg/registry/generic" |
|
|
|
|
"k8s.io/apiserver/pkg/registry/rest" |
|
|
|
|
genericapiserver "k8s.io/apiserver/pkg/server" |
|
|
|
|
"k8s.io/kube-openapi/pkg/common" |
|
|
|
|
"k8s.io/kube-openapi/pkg/spec3" |
|
|
|
|
|
|
|
|
|
dashboard "github.com/grafana/grafana/pkg/apis/dashboard/v0alpha1" |
|
|
|
|
grafanaregistry "github.com/grafana/grafana/pkg/apiserver/registry/generic" |
|
|
|
|
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest" |
|
|
|
|
@ -18,16 +28,6 @@ import ( |
|
|
|
|
"github.com/grafana/grafana/pkg/storage/legacysql" |
|
|
|
|
"github.com/grafana/grafana/pkg/storage/unified/apistore" |
|
|
|
|
"github.com/grafana/grafana/pkg/storage/unified/resource" |
|
|
|
|
"github.com/prometheus/client_golang/prometheus" |
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
|
|
|
|
"k8s.io/apimachinery/pkg/runtime" |
|
|
|
|
"k8s.io/apimachinery/pkg/runtime/schema" |
|
|
|
|
"k8s.io/apimachinery/pkg/runtime/serializer" |
|
|
|
|
"k8s.io/apiserver/pkg/registry/generic" |
|
|
|
|
"k8s.io/apiserver/pkg/registry/rest" |
|
|
|
|
genericapiserver "k8s.io/apiserver/pkg/server" |
|
|
|
|
common "k8s.io/kube-openapi/pkg/common" |
|
|
|
|
"k8s.io/kube-openapi/pkg/spec3" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
|
@ -124,18 +124,11 @@ func (b *DashboardsAPIBuilder) InstallSchema(scheme *runtime.Scheme) error { |
|
|
|
|
return scheme.SetVersionPriority(resourceInfo.GroupVersion()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (b *DashboardsAPIBuilder) GetAPIGroupInfo( |
|
|
|
|
scheme *runtime.Scheme, |
|
|
|
|
codecs serializer.CodecFactory, // pointer?
|
|
|
|
|
optsGetter generic.RESTOptionsGetter, |
|
|
|
|
dualWriteBuilder grafanarest.DualWriteBuilder, |
|
|
|
|
) (*genericapiserver.APIGroupInfo, error) { |
|
|
|
|
apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(dashboard.GROUP, scheme, metav1.ParameterCodec, codecs) |
|
|
|
|
|
|
|
|
|
func (b *DashboardsAPIBuilder) UpdateAPIGroupInfo(apiGroupInfo *genericapiserver.APIGroupInfo, scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter, dualWriteBuilder grafanarest.DualWriteBuilder) error { |
|
|
|
|
dash := b.legacy.resource |
|
|
|
|
legacyStore, err := b.legacy.newStore(scheme, optsGetter) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
storage := map[string]rest.Storage{} |
|
|
|
|
@ -149,23 +142,23 @@ func (b *DashboardsAPIBuilder) GetAPIGroupInfo( |
|
|
|
|
if optsGetter != nil && dualWriteBuilder != nil { |
|
|
|
|
store, err := newStorage(scheme) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: grafanaregistry.GetAttrs} |
|
|
|
|
if err := store.CompleteWithOptions(options); err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
storage[dash.StoragePath()], err = dualWriteBuilder(dash.GroupResource(), legacyStore, store) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Register the DTO endpoint that will consolidate all dashboard bits
|
|
|
|
|
storage[dash.StoragePath("dto")], err = newDTOConnector(storage[dash.StoragePath()], b) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Expose read only library panels
|
|
|
|
|
@ -174,7 +167,7 @@ func (b *DashboardsAPIBuilder) GetAPIGroupInfo( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
apiGroupInfo.VersionedResourcesStorageMap[dashboard.VERSION] = storage |
|
|
|
|
return &apiGroupInfo, nil |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (b *DashboardsAPIBuilder) GetOpenAPIDefinitions() common.GetOpenAPIDefinitions { |
|
|
|
|
|