DualWrite: Cleanup and centralize the dual write creation (#90013)

This commit is contained in:
Ryan McKinley
2024-07-11 23:23:31 +03:00
committed by GitHub
parent 4b5b599982
commit d2bc4f3255
22 changed files with 125 additions and 150 deletions
+3 -8
View File
@@ -15,11 +15,12 @@ import (
"k8s.io/kube-openapi/pkg/spec3"
"k8s.io/kube-openapi/pkg/validation/spec"
"github.com/prometheus/client_golang/prometheus"
scope "github.com/grafana/grafana/pkg/apis/scope/v0alpha1"
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest"
"github.com/grafana/grafana/pkg/services/apiserver/builder"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/prometheus/client_golang/prometheus"
)
var _ builder.APIGroupBuilder = (*ScopeAPIBuilder)(nil)
@@ -48,11 +49,6 @@ func (b *ScopeAPIBuilder) GetGroupVersion() schema.GroupVersion {
return scope.SchemeGroupVersion
}
func (b *ScopeAPIBuilder) GetDesiredDualWriterMode(dualWrite bool, modeMap map[string]grafanarest.DualWriterMode) grafanarest.DualWriterMode {
// Add required configuration support in order to enable other modes. For an example, see pkg/registry/apis/playlist/register.go
return grafanarest.Mode0
}
func (b *ScopeAPIBuilder) InstallSchema(scheme *runtime.Scheme) error {
err := scope.AddToScheme(scheme)
if err != nil {
@@ -121,8 +117,7 @@ func (b *ScopeAPIBuilder) GetAPIGroupInfo(
scheme *runtime.Scheme,
codecs serializer.CodecFactory,
optsGetter generic.RESTOptionsGetter,
_ grafanarest.DualWriterMode, // dual write desired mode (not relevant)
_ prometheus.Registerer, // prometheus registerer
_ grafanarest.DualWriteBuilder,
) (*genericapiserver.APIGroupInfo, error) {
apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(scope.GROUP, scheme, metav1.ParameterCodec, codecs)