driver

package
v3.0.1-0...-4a278a0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigMapsDriverName = "ConfigMap"

ConfigMapsDriverName is the string name of the driver.

View Source
const (
	// MemoryDriverName is the string name of this driver.
	MemoryDriverName = "Memory"
)
View Source
const SQLDriverName = "SQL"

SQLDriverName is the string name of this driver.

View Source
const SecretsDriverName = "Secret"

SecretsDriverName is the string name of the driver.

Variables

View Source
var (
	// ErrReleaseNotFound indicates that a release is not found.
	ErrReleaseNotFound = errors.New("release: not found")
	// ErrReleaseExists indicates that a release already exists.
	ErrReleaseExists = errors.New("release: already exists")
	// ErrInvalidKey indicates that a release key could not be parsed.
	ErrInvalidKey = errors.New("release: invalid key")
	// ErrNoDeployedReleases indicates that there are no releases with the given key in the deployed state
	ErrNoDeployedReleases = errors.New("has no deployed releases")
)

Functions

func NewErrNoDeployedReleases

func NewErrNoDeployedReleases(releaseName string) error

Types

type ConfigMaps

type ConfigMaps struct {
	Log func(string, ...interface{})
	// contains filtered or unexported fields
}

ConfigMaps is a wrapper around an implementation of a kubernetes ConfigMapsInterface.

func NewConfigMaps

func NewConfigMaps(impl corev1.ConfigMapInterface) *ConfigMaps

NewConfigMaps initializes a new ConfigMaps wrapping an implementation of the kubernetes ConfigMapsInterface.

func (*ConfigMaps) Create

func (cfgmaps *ConfigMaps) Create(key string, rls *rspb.Release) error

Create creates a new ConfigMap holding the release. If the ConfigMap already exists, ErrReleaseExists is returned.

func (*ConfigMaps) Delete

func (cfgmaps *ConfigMaps) Delete(key string) (rls *rspb.Release, err error)

Delete deletes the ConfigMap holding the release named by key.

func (*ConfigMaps) Get

func (cfgmaps *ConfigMaps) Get(key string) (*rspb.Release, error)

Get fetches the release named by key. The corresponding release is returned or error if not found.

func (*ConfigMaps) List

func (cfgmaps *ConfigMaps) List(filter func(*rspb.Release) bool) ([]*rspb.Release, error)

List fetches all releases and returns the list releases such that filter(release) == true. An error is returned if the configmap fails to retrieve the releases.

func (*ConfigMaps) Name

func (cfgmaps *ConfigMaps) Name() string

Name returns the name of the driver.

func (*ConfigMaps) Query

func (cfgmaps *ConfigMaps) Query(labels map[string]string) ([]*rspb.Release, error)

Query fetches all releases that match the provided map of labels. An error is returned if the configmap fails to retrieve the releases.

func (*ConfigMaps) Update

func (cfgmaps *ConfigMaps) Update(key string, rls *rspb.Release) error

Update updates the ConfigMap holding the release. If not found the ConfigMap is created to hold the release.

type Creator

type Creator interface {
	Create(key string, rls *rspb.Release) error
}

Creator is the interface that wraps the Create method.

Create stores the release or returns ErrReleaseExists if an identical release already exists.

type Deletor

type Deletor interface {
	Delete(key string) (*rspb.Release, error)
}

Deletor is the interface that wraps the Delete method.

Delete deletes the release named by key or returns ErrReleaseNotFound if the release does not exist.

type Driver

type Driver interface {
	Creator
	Updator
	Deletor
	Queryor
	Name() string
}

Driver is the interface composed of Creator, Updator, Deletor, and Queryor interfaces. It defines the behavior for storing, updating, deleted, and retrieving Helm releases from some underlying storage mechanism, e.g. memory, configmaps.

type Memory

type Memory struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Memory is the in-memory storage driver implementation.

func NewMemory

func NewMemory() *Memory

NewMemory initializes a new memory driver.

func (*Memory) Create

func (mem *Memory) Create(key string, rls *rspb.Release) error

Create creates a new release or returns ErrReleaseExists.

func (*Memory) Delete

func (mem *Memory) Delete(key string) (*rspb.Release, error)

Delete deletes a release or returns ErrReleaseNotFound.

func (*Memory) Get

func (mem *Memory) Get(key string) (*rspb.Release, error)

Get returns the release named by key or returns ErrReleaseNotFound.

func (*Memory) List

func (mem *Memory) List(filter func(*rspb.Release) bool) ([]*rspb.Release, error)

List returns the list of all releases such that filter(release) == true

func (*Memory) Name

func (mem *Memory) Name() string

Name returns the name of the driver.

func (*Memory) Query

func (mem *Memory) Query(keyvals map[string]string) ([]*rspb.Release, error)

Query returns the set of releases that match the provided set of labels

func (*Memory) SetNamespace

func (mem *Memory) SetNamespace(ns string)

SetNamespace sets a specific namespace in which releases will be accessed. An empty string indicates all namespaces (for the list operation)

func (*Memory) Update

func (mem *Memory) Update(key string, rls *rspb.Release) error

Update updates a release or returns ErrReleaseNotFound.

type Queryor

type Queryor interface {
	Get(key string) (*rspb.Release, error)
	List(filter func(*rspb.Release) bool) ([]*rspb.Release, error)
	Query(labels map[string]string) ([]*rspb.Release, error)
}

Queryor is the interface that wraps the Get and List methods.

Get returns the release named by key or returns ErrReleaseNotFound if the release does not exist.

List returns the set of all releases that satisfy the filter predicate.

Query returns the set of all releases that match the provided label set.

type SQL

type SQL struct {
	Log func(string, ...interface{})
	// contains filtered or unexported fields
}

SQL is the sql storage driver implementation.

func NewSQL

func NewSQL(connectionString string, logger func(string, ...interface{}), namespace string) (*SQL, error)

NewSQL initializes a new sql driver.

func (*SQL) Create

func (s *SQL) Create(key string, rls *rspb.Release) error

Create creates a new release.

func (*SQL) Delete

func (s *SQL) Delete(key string) (*rspb.Release, error)

Delete deletes a release or returns ErrReleaseNotFound.

func (*SQL) Get

func (s *SQL) Get(key string) (*rspb.Release, error)

Get returns the release named by key.

func (*SQL) List

func (s *SQL) List(filter func(*rspb.Release) bool) ([]*rspb.Release, error)

List returns the list of all releases such that filter(release) == true

func (*SQL) Name

func (s *SQL) Name() string

Name returns the name of the driver.

func (*SQL) Query

func (s *SQL) Query(labels map[string]string) ([]*rspb.Release, error)

Query returns the set of releases that match the provided set of labels.

func (*SQL) Update

func (s *SQL) Update(key string, rls *rspb.Release) error

Update updates a release.

type SQLReleaseWrapper

type SQLReleaseWrapper struct {
	// The primary key, made of {release-name}.{release-version}
	Key string `db:"key"`

	// See https://github.com/helm/helm/blob/c9fe3d118caec699eb2565df9838673af379ce12/pkg/storage/driver/secrets.go#L231
	Type string `db:"type"`

	// The rspb.Release body, as a base64-encoded string
	Body string `db:"body"`

	// Release "labels" that can be used as filters in the storage.Query(labels map[string]string)
	// we implemented. Note that allowing Helm users to filter against new dimensions will require a
	// new migration to be added, and the Create and/or update functions to be updated accordingly.
	Name       string `db:"name"`
	Namespace  string `db:"namespace"`
	Version    int    `db:"version"`
	Status     string `db:"status"`
	Owner      string `db:"owner"`
	CreatedAt  int    `db:"createdAt"`
	ModifiedAt int    `db:"modifiedAt"`
}

SQLReleaseWrapper describes how Helm releases are stored in an SQL database

type Secrets

type Secrets struct {
	Log func(string, ...interface{})
	// contains filtered or unexported fields
}

Secrets is a wrapper around an implementation of a kubernetes SecretsInterface.

func NewSecrets

func NewSecrets(impl corev1.SecretInterface) *Secrets

NewSecrets initializes a new Secrets wrapping an implementation of the kubernetes SecretsInterface.

func (*Secrets) Create

func (secrets *Secrets) Create(key string, rls *rspb.Release) error

Create creates a new Secret holding the release. If the Secret already exists, ErrReleaseExists is returned.

func (*Secrets) Delete

func (secrets *Secrets) Delete(key string) (rls *rspb.Release, err error)

Delete deletes the Secret holding the release named by key.

func (*Secrets) Get

func (secrets *Secrets) Get(key string) (*rspb.Release, error)

Get fetches the release named by key. The corresponding release is returned or error if not found.

func (*Secrets) List

func (secrets *Secrets) List(filter func(*rspb.Release) bool) ([]*rspb.Release, error)

List fetches all releases and returns the list releases such that filter(release) == true. An error is returned if the secret fails to retrieve the releases.

func (*Secrets) Name

func (secrets *Secrets) Name() string

Name returns the name of the driver.

func (*Secrets) Query

func (secrets *Secrets) Query(labels map[string]string) ([]*rspb.Release, error)

Query fetches all releases that match the provided map of labels. An error is returned if the secret fails to retrieve the releases.

func (*Secrets) Update

func (secrets *Secrets) Update(key string, rls *rspb.Release) error

Update updates the Secret holding the release. If not found the Secret is created to hold the release.

type StorageDriverError

type StorageDriverError struct {
	ReleaseName string
	Err         error
}

StorageDriverError records an error and the release name that caused it

func (*StorageDriverError) Error

func (e *StorageDriverError) Error() string

func (*StorageDriverError) Unwrap

func (e *StorageDriverError) Unwrap() error

type Updator

type Updator interface {
	Update(key string, rls *rspb.Release) error
}

Updator is the interface that wraps the Update method.

Update updates an existing release or returns ErrReleaseNotFound if the release does not exist.

Jump to

Keyboard shortcuts

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