storage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend[T Object] interface {
	// Get retrieves the value associated with the given key.
	Get(ctx context.Context, key string) (T, error)
	// Set stores the value associated with the given key.
	// The Object should have the method [Object.Validate] called before this.
	Set(ctx context.Context, key string, value T) error
	// Delete removes the value associated with the given key.
	Delete(ctx context.Context, key string) error
	// List returns a list of all keys in the storage.
	List(ctx context.Context) (map[string]T, error)
}

Backend is the interface for a storage backend. A storage backend is responsible for storing and retrieving configurations or data defined by the user.

type ConfigMap

type ConfigMap[T Object] struct {
	// contains filtered or unexported fields
}

ConfigMap is a Backend that uses a Kubernetes config map to store and retrieve objects.

func NewConfigMap

func NewConfigMap[T Object](
	name string,
	cm typedCorev1.ConfigMapInterface,
) *ConfigMap[T]

func (*ConfigMap[T]) Delete

func (c *ConfigMap[T]) Delete(ctx context.Context, key string) error

func (*ConfigMap[T]) Get

func (c *ConfigMap[T]) Get(ctx context.Context, key string) (T, error)

func (*ConfigMap[T]) List

func (c *ConfigMap[T]) List(ctx context.Context) (map[string]T, error)

func (*ConfigMap[T]) Set

func (c *ConfigMap[T]) Set(ctx context.Context, key string, value T) error

type Object

type Object interface {
	// Validate validates the object. It will be given a [cluster.Context]
	// for the current users context and can reach out to the cluster API
	// to validate the object. If the object is not valid, it should return
	// a non-nil error.
	Validate(ctx context.Context, clusterCtx cluster.Context) error
}

Object is an interface that represents a generic object that defines user data. It is the value that will be associated with a key and stored by a Backend. The object will be marshalled and unmarshalled using functions from the yaml library, unless it implements the encoding.TextMarshaler or encoding.TextUnmarshaler interfaces in which case those will be used instead.

type SecretStore

type SecretStore[T Object] struct {
	// contains filtered or unexported fields
}

SecretStore is a Backend that uses a Kubernetes secret to store and retrieve objects.

func NewSecretStore

func NewSecretStore[T Object](
	name string,
	s typedCorev1.SecretInterface,
) *SecretStore[T]

NewSecretStore creates a new SecretStore with the given name and defaults.

func (*SecretStore[T]) Delete

func (c *SecretStore[T]) Delete(ctx context.Context, key string) error

func (*SecretStore[T]) Get

func (c *SecretStore[T]) Get(ctx context.Context, key string) (T, error)

func (*SecretStore[T]) List

func (c *SecretStore[T]) List(ctx context.Context) (map[string]T, error)

func (*SecretStore[T]) Set

func (c *SecretStore[T]) Set(ctx context.Context, key string, value T) error

Jump to

Keyboard shortcuts

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