storage

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is an error type that can be matched against with `errors.Is`
	// and indicates that no metadata is available.
	ErrNotFound = fmt.Errorf("not found")

	ErrInvalidJSON = fmt.Errorf("invalid JSON")
)

Functions

This section is empty.

Types

type DataWriter

type DataWriter interface {
	WriteFiles(meta metadata.Metadata, files map[string][]byte) error
}

DataWriter is used to write data (e.g. certificate and private keys) to the storage backend.

type Filesystem

type Filesystem struct {

	// FixedFSGroup is an optional field which will set the gid ownership of all
	// volume's data directories to this value.
	// If this value is set, FSGroupVolumeAttributeKey has no effect.
	FixedFSGroup *int64

	// FSGroupVolumeAttributeKey is an optional well-known key in the volume
	// attributes. If this attribute is present in the context when writing
	// files, gid ownership of the volume's data directory will be changed to
	// the value. Attribute value must be a valid int64 value.
	// If FixedFSGroup is defined, this field has no effect.
	FSGroupVolumeAttributeKey string
	// contains filtered or unexported fields
}

func NewFilesystem

func NewFilesystem(log logr.Logger, baseDir string) (*Filesystem, error)

func (*Filesystem) ListVolumes

func (f *Filesystem) ListVolumes() ([]string, error)

func (*Filesystem) PathForVolume

func (f *Filesystem) PathForVolume(volumeID string) string

func (*Filesystem) ReadFile

func (f *Filesystem) ReadFile(volumeID, name string) ([]byte, error)

ReadFile reads the named file within the volume's data directory.

func (*Filesystem) ReadMetadata

func (f *Filesystem) ReadMetadata(volumeID string) (metadata.Metadata, error)

ReadMetadata will return the metadata for the volume with the given ID. Errors wrapping ErrNotFound will be returned if metadata for the ID cannot be found.

func (*Filesystem) RegisterMetadata

func (f *Filesystem) RegisterMetadata(meta metadata.Metadata) (bool, error)

func (*Filesystem) RemoveVolume

func (f *Filesystem) RemoveVolume(volumeID string) error

func (*Filesystem) WriteFiles

func (f *Filesystem) WriteFiles(meta metadata.Metadata, files map[string][]byte) error

WriteFiles writes the given data to filesystem files within the volume's data directory. Filesystem supports changing ownership of the data directory to a custom gid.

func (*Filesystem) WriteMetadata

func (f *Filesystem) WriteMetadata(volumeID string, meta metadata.Metadata) error

type Interface

type Interface interface {
	// PathForVolume returns the data path for the given volume.
	PathForVolume(volumeID string) string

	// RemoveVolume removes all metadata and data for a volume.
	// This is a destructive, irreversible operation.
	RemoveVolume(volumeID string) error

	MetadataReader
	MetadataWriter
	DataWriter
}

All storage implementations must implement this interface.

type MemoryFS

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

func NewMemoryFS

func NewMemoryFS() *MemoryFS

func (*MemoryFS) ListVolumes

func (m *MemoryFS) ListVolumes() ([]string, error)

func (*MemoryFS) PathForVolume

func (m *MemoryFS) PathForVolume(volumeID string) string

func (*MemoryFS) ReadFiles

func (m *MemoryFS) ReadFiles(volumeID string) (map[string][]byte, error)

func (*MemoryFS) ReadMetadata

func (m *MemoryFS) ReadMetadata(volumeID string) (metadata.Metadata, error)

func (*MemoryFS) RegisterMetadata

func (m *MemoryFS) RegisterMetadata(meta metadata.Metadata) (bool, error)

func (*MemoryFS) RemoveVolume

func (m *MemoryFS) RemoveVolume(volumeID string) error

func (*MemoryFS) WriteFiles

func (m *MemoryFS) WriteFiles(meta metadata.Metadata, files map[string][]byte) error

func (*MemoryFS) WriteMetadata

func (m *MemoryFS) WriteMetadata(volumeID string, meta metadata.Metadata) error

type MetadataReader

type MetadataReader interface {
	// ReadMetadata will read the metadata for a single volumeID.
	ReadMetadata(volumeID string) (metadata.Metadata, error)

	// ListVolumes will return a list of all volumeIDs in the storage backend.
	// Used when the driver restarts to resume processing of existing data.
	ListVolumes() ([]string, error)
}

MetadataReader allows read-only access to metadata about volumes.

type MetadataWriter

type MetadataWriter interface {
	// WriteMetadata will write the metadata file for the given volume.
	// If the directory for this volume does not exist, it will return an error.
	WriteMetadata(volumeID string, meta metadata.Metadata) error

	// RegisterMetadata will create a directory for the given metadata and, if
	// the metadata file does not already exist or volume context has changed,
	// persist the given metadata file.
	// It will return true if the metadata file has been written, false
	// otherwise.
	RegisterMetadata(meta metadata.Metadata) (bool, error)
}

MetadataWriter writes metadata files to a storage backend.

Jump to

Keyboard shortcuts

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