rest

package
v0.0.0-...-61f3d08 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CurrentMode = Mode2

Functions

This section is empty.

Types

type DualWriter

type DualWriter struct {
	Storage
	Legacy LegacyStorage
}

DualWriter is a storage implementation that writes first to LegacyStorage and then to Storage. If writing to LegacyStorage fails, the write to Storage is skipped and the error is returned. Storage is used for all read operations. This is useful as a migration step from SQL based legacy storage to a more standard kubernetes backed storage interface.

NOTE: Only values supported by legacy storage will be preserved in the CREATE/UPDATE commands. For example, annotations, labels, and managed fields may not be preserved. Everything in upstream storage can be recrated from the data in legacy storage.

The LegacyStorage implementation must implement the following interfaces: - rest.Storage - rest.TableConvertor - rest.Scoper - rest.SingularNameProvider

These interfaces are optional, but they all should be implemented to fully support dual writes: - rest.Creater - rest.Updater - rest.GracefulDeleter - rest.CollectionDeleter

func NewDualWriter

func NewDualWriter(legacy LegacyStorage, storage Storage) *DualWriter

NewDualWriter returns a new DualWriter.

func (*DualWriter) Create

func (d *DualWriter) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error)

Create overrides the default behavior of the Storage and writes to both the LegacyStorage and Storage.

func (*DualWriter) Delete

func (d *DualWriter) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error)

Delete overrides the default behavior of the Storage and delete from both the LegacyStorage and Storage.

func (*DualWriter) DeleteCollection

func (d *DualWriter) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error)

DeleteCollection overrides the default behavior of the Storage and delete from both the LegacyStorage and Storage.

func (*DualWriter) Update

func (d *DualWriter) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error)

Update overrides the default behavior of the Storage and writes to both the LegacyStorage and Storage.

type DualWriterMode

type DualWriterMode int
const (
	Mode1 DualWriterMode = iota
	Mode2
	Mode3
	Mode4
)

type DualWriterMode1

type DualWriterMode1 struct {
	DualWriter
}

func NewDualWriterMode1

func NewDualWriterMode1(legacy LegacyStorage, storage Storage) *DualWriterMode1

NewDualWriterMode1 returns a new DualWriter in mode 1. Mode 1 represents writing to and reading from LegacyStorage.

func (*DualWriterMode1) Create

func (d *DualWriterMode1) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error)

Create overrides the behavior of the generic DualWriter and writes only to LegacyStorage.

func (*DualWriterMode1) Delete

func (d *DualWriterMode1) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error)

func (*DualWriterMode1) DeleteCollection

func (d *DualWriterMode1) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error)

DeleteCollection overrides the behavior of the generic DualWriter and deletes only from LegacyStorage.

func (*DualWriterMode1) Get

func (d *DualWriterMode1) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error)

Get overrides the behavior of the generic DualWriter and reads only from LegacyStorage.

func (*DualWriterMode1) List

List overrides the behavior of the generic DualWriter and reads only from LegacyStorage.

func (*DualWriterMode1) Update

func (d *DualWriterMode1) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error)

type DualWriterMode2

type DualWriterMode2 struct {
	DualWriter
}

func NewDualWriterMode2

func NewDualWriterMode2(legacy LegacyStorage, storage Storage) *DualWriterMode2

NewDualWriterMode2 returns a new DualWriter in mode 2. Mode 2 represents writing to LegacyStorage and Storage and reading from LegacyStorage.

func (*DualWriterMode2) Create

func (d *DualWriterMode2) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error)

Create overrides the behavior of the generic DualWriter and writes to LegacyStorage and Storage.

func (*DualWriterMode2) Delete

func (d *DualWriterMode2) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error)

func (*DualWriterMode2) DeleteCollection

func (d *DualWriterMode2) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error)

DeleteCollection overrides the behavior of the generic DualWriter and deletes from both LegacyStorage and Storage.

func (*DualWriterMode2) Get

func (d *DualWriterMode2) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error)

Get overrides the behavior of the generic DualWriter. It retrieves an object from Storage if possible, and if not it falls back to LegacyStorage.

func (*DualWriterMode2) List

List overrides the behavior of the generic DualWriter. It returns Storage entries if possible and falls back to LegacyStorage entries if not.

func (*DualWriterMode2) Update

func (d *DualWriterMode2) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error)

Update overrides the generic behavior of the Storage and writes first to the legacy storage and then to storage.

type DualWriterMode3

type DualWriterMode3 struct {
	DualWriter
}

func NewDualWriterMode3

func NewDualWriterMode3(legacy LegacyStorage, storage Storage) *DualWriterMode3

NewDualWriterMode3 returns a new DualWriter in mode 3. Mode 3 represents writing to LegacyStorage and Storage and reading from Storage.

func (*DualWriterMode3) Create

func (d *DualWriterMode3) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error)

Create overrides the behavior of the generic DualWriter and writes to LegacyStorage and Storage.

func (*DualWriterMode3) Delete

func (d *DualWriterMode3) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error)

func (*DualWriterMode3) DeleteCollection

func (d *DualWriterMode3) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error)

DeleteCollection overrides the behavior of the generic DualWriter and deletes from both LegacyStorage and Storage.

func (*DualWriterMode3) Get

func (d *DualWriterMode3) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error)

Get overrides the behavior of the generic DualWriter and retrieves an object from Storage.

func (*DualWriterMode3) Update

func (d *DualWriterMode3) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error)

Update overrides the behavior of the generic DualWriter and writes first to Storage and then to LegacyStorage.

type DualWriterMode4

type DualWriterMode4 struct {
	DualWriter
}

func NewDualWriterMode4

func NewDualWriterMode4(legacy LegacyStorage, storage Storage) *DualWriterMode4

NewDualWriterMode4 returns a new DualWriter in mode 4. Mode 4 represents writing and reading from Storage.

func (*DualWriterMode4) Create

func (d *DualWriterMode4) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error)

Create overrides the behavior of the generic DualWriter and writes only to Storage.

func (*DualWriterMode4) Delete

func (d *DualWriterMode4) Delete(ctx context.Context, name string, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions) (runtime.Object, bool, error)

func (*DualWriterMode4) DeleteCollection

func (d *DualWriterMode4) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error)

DeleteCollection overrides the behavior of the generic DualWriter and deletes only from Storage.

func (*DualWriterMode4) Get

func (d *DualWriterMode4) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error)

Get overrides the behavior of the generic DualWriter and retrieves an object from Storage.

func (*DualWriterMode4) Update

func (d *DualWriterMode4) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error)

Update overrides the generic behavior of the Storage and writes only to US.

type LegacyStorage

LegacyStorage is a storage implementation that writes to the Grafana SQL database.

type LegacyStorageSpy

type LegacyStorageSpy struct {
	// contains filtered or unexported fields
}

type LegacyStorageSpyClient

type LegacyStorageSpyClient interface {
	LegacyStorage

	//Counts returns the number of times a certain method was called
	Counts(string) int
}

func NewLegacyStorageSpyClient

func NewLegacyStorageSpyClient(ls LegacyStorage) LegacyStorageSpyClient

type Storage

Storage is a storage implementation that satisfies the same interfaces as genericregistry.Store.

func SelectDualWriter

func SelectDualWriter(mode DualWriterMode, legacy LegacyStorage, storage Storage) Storage

type StorageSpy

type StorageSpy struct {
	// contains filtered or unexported fields
}

type StorageSpyClient

type StorageSpyClient interface {
	Storage

	//Counts returns the number of times a certain method was called
	Counts(string) int
}

func NewStorageSpyClient

func NewStorageSpyClient(s Storage) StorageSpyClient

type UpdatedObjInfoObj

type UpdatedObjInfoObj struct{}

func (UpdatedObjInfoObj) Preconditions

func (u UpdatedObjInfoObj) Preconditions() *metav1.Preconditions

func (UpdatedObjInfoObj) UpdatedObject

func (u UpdatedObjInfoObj) UpdatedObject(ctx context.Context, oldObj runtime.Object) (newObj runtime.Object, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL