kubestore

package module
v0.0.1-0...-e15eff5 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2021 License: MIT Imports: 17 Imported by: 0

README

License

Kube Store

💾 For when your pod just need to store a little data

License

This code is distributed under the MIT License, see LICENSE.txt for more information.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorKeyNotFound = errors.New("key not found")

ErrorKeyNotFound is a sentinel error for indicating that a key used when calling Store.Get was not found.

Functions

This section is empty.

Types

type Store

type Store interface {
	// Get retrieves the given key contents, and stores it into the given value
	// pointer. Returns ErrorKeyNotFound if the given key was not found.
	Get(ctx context.Context, key string, value interface{}) error

	// Set stores the given value under the given key.
	Set(ctx context.Context, key string, value interface{}) error

	// List returns a list of all keys.
	List(ctx context.Context) ([]string, error)

	// Delete removed the given key.
	Delete(ctx context.Context, key string) error
}

Store represents a type that is capable of managing key/value pairs using some backing medium.

func NewAnnotationStore

func NewAnnotationStore(group, version, resource, name string) (Store, error)

NewAnnotationStore returns a Store backed by the annotations on a resource.

This Store is intended to be used when running inside of a pod, as it depends on the presence of a service account in order to interact with the Kubernetes API.

func NewConfigMapStore

func NewConfigMapStore(name string) (Store, error)

NewConfigMapStore returns a Store backed by a ConfigMap with the given name.

This Store is intended to be used when running inside of a pod, as it depends on the presence of a service account in order to interact with the Kubernetes API.

This Store assumes full control of, and exclusive access to, the backing ConfigMap as it will be created on-demand when calling Store.Set and automatically deleted when calling Store.Delete (in the event that it is empty).

func NewFileStore

func NewFileStore(directory string) Store

NewFileStore returns a Store backed by files contained within the given directory.

This Store is intended to be used as a fallback, or for testing outside of Kubernetes. It has no dependence on being run inside Kubernetes or on the Kubernetes API.

This Store assumes full control of, and exclusive access to, the backing directory as it will be created on-demand when calling Store.Set and automatically deleted when calling Store.Delete (in the event that it does not contain any other files).

func NewSecretStore

func NewSecretStore(name string) (Store, error)

NewSecretStore returns a Store backed by a Secret with the given name.

This Store is intended to be used when running inside of a pod, as it depends on the presence of a service account in order to interact with the Kubernetes API.

This Store assumes full control of, and exclusive access to, the backing Secret as it will be created on-demand when calling Store.Set and automatically deleted when calling Store.Delete (in the event that it is empty).

Jump to

Keyboard shortcuts

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