grafana/pkg/apiserver/rest/dualwriter_mode4.go
Arati R 2232fe033b
Storage: Add mode-specific dual writers (#85551)
* Set up skeleton dual writers for each mode
* Add Create functionality to each of the mode-specific DualWriters
* Add switch for selecting DualWriter
2024-04-04 14:02:51 +02:00

26 lines
857 B
Go

package rest
import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/rest"
)
type DualWriterMode4 struct {
DualWriter
}
// NewDualWriterMode4 returns a new DualWriter in mode 4.
// Mode 4 represents writing and reading from Storage.
func NewDualWriterMode4(legacy LegacyStorage, storage Storage) *DualWriterMode4 {
return &DualWriterMode4{*NewDualWriter(legacy, storage)}
}
// Create overrides the default behavior of the DualWriter and writes only to Storage.
// #TODO remove this once we remove the default DualWriter implementation
func (d *DualWriterMode4) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
return d.Storage.Create(ctx, obj, createValidation, options)
}