mirror of
https://github.com/grafana/grafana.git
synced 2025-01-27 16:57:14 -06:00
79eab65f94
* Add DeleteCollection methods to modes 1 and 4 * Add DeleteCollection implementations for modes 2 and 3
42 lines
1.8 KiB
Go
42 lines
1.8 KiB
Go
package rest
|
|
|
|
import (
|
|
"context"
|
|
|
|
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
|
|
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)}
|
|
}
|
|
|
|
// #TODO remove all DualWriterMode4 methods once we remove the generic DualWriter implementation
|
|
|
|
// Create overrides the behavior of the generic DualWriter and writes only to Storage.
|
|
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)
|
|
}
|
|
|
|
// Get overrides the behavior of the generic DualWriter and retrieves an object from Storage.
|
|
func (d *DualWriterMode4) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
|
|
return d.Storage.Get(ctx, name, &metav1.GetOptions{})
|
|
}
|
|
|
|
func (d *DualWriterMode4) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error) {
|
|
return d.Storage.Delete(ctx, name, deleteValidation, options)
|
|
}
|
|
|
|
// DeleteCollection overrides the behavior of the generic DualWriter and deletes only from Storage.
|
|
func (d *DualWriterMode4) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error) {
|
|
return d.Storage.DeleteCollection(ctx, deleteValidation, options, listOptions)
|
|
}
|