state

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package state manages the internal state of the driver which needs to be maintained across driver restarts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessType

type AccessType int
const (
	MountAccess AccessType = iota
	BlockAccess
)

type GroupSnapshot added in v1.13.0

type GroupSnapshot struct {
	Name            string
	Id              string
	SnapshotIDs     []string
	SourceVolumeIDs []string
	CreationTime    *timestamp.Timestamp
	ReadyToUse      bool
}

func (*GroupSnapshot) MatchesSnapshotIDs added in v1.13.0

func (gs *GroupSnapshot) MatchesSnapshotIDs(snapshotIDs []string) bool

func (*GroupSnapshot) MatchesSourceVolumeIDs added in v1.13.0

func (gs *GroupSnapshot) MatchesSourceVolumeIDs(sourceVolumeIDs []string) bool

type Snapshot

type Snapshot struct {
	Name            string
	Id              string
	VolID           string
	Path            string
	CreationTime    *timestamp.Timestamp
	SizeBytes       int64
	ReadyToUse      bool
	GroupSnapshotID string
}

type State

type State interface {
	// GetVolumeByID retrieves a volume by its unique ID or returns
	// an error including that ID when not found.
	GetVolumeByID(volID string) (Volume, error)

	// GetVolumeByName retrieves a volume by its name or returns
	// an error including that name when not found.
	GetVolumeByName(volName string) (Volume, error)

	// GetVolumes returns all currently existing volumes.
	GetVolumes() []Volume

	// UpdateVolume updates the existing hostpath volume,
	// identified by its volume ID, or adds it if it does
	// not exist yet.
	UpdateVolume(volume Volume) error

	// DeleteVolume deletes the volume with the given
	// volume ID. It is not an error when such a volume
	// does not exist.
	DeleteVolume(volID string) error

	// GetSnapshotByID retrieves a snapshot by its unique ID or returns
	// an error including that ID when not found.
	GetSnapshotByID(snapshotID string) (Snapshot, error)

	// GetSnapshotByName retrieves a snapshot by its name or returns
	// an error including that name when not found.
	GetSnapshotByName(volName string) (Snapshot, error)

	// GetSnapshots returns all currently existing snapshots.
	GetSnapshots() []Snapshot

	// UpdateSnapshot updates the existing hostpath snapshot,
	// identified by its snapshot ID, or adds it if it does
	// not exist yet.
	UpdateSnapshot(snapshot Snapshot) error

	// DeleteSnapshot deletes the snapshot with the given
	// snapshot ID. It is not an error when such a snapshot
	// does not exist.
	DeleteSnapshot(snapshotID string) error

	// GetGroupSnapshotByID retrieves a groupsnapshot by its unique ID or
	// returns an error including that ID when not found.
	GetGroupSnapshotByID(vgsID string) (GroupSnapshot, error)

	// GetGroupSnapshotByName retrieves a groupsnapshot by its name or
	// returns an error including that name when not found.
	GetGroupSnapshotByName(volName string) (GroupSnapshot, error)

	// GetGroupSnapshots returns all currently existing groupsnapshots.
	GetGroupSnapshots() []GroupSnapshot

	// UpdateGroupSnapshot updates the existing hostpath groupsnapshot,
	// identified by its snapshot ID, or adds it if it does not exist yet.
	UpdateGroupSnapshot(snapshot GroupSnapshot) error

	// DeleteGroupSnapshot deletes the groupsnapshot with the given
	// groupsnapshot ID. It is not an error when such a groupsnapshot does
	// not exist.
	DeleteGroupSnapshot(groupSnapshotID string) error
}

State is the interface that the rest of the code has to use to access and change state. All error messages contain gRPC status codes and can be returned without wrapping.

func New

func New(statefilePath string) (State, error)

New retrieves the complete state of the driver from the file if given and then ensures that all changes are mirrored immediately in the given file. If not given, the initial state is empty and changes are not saved.

type Strings

type Strings []string

Strings is an ordered set of strings with helper functions for adding, searching and removing entries.

func (*Strings) Add

func (s *Strings) Add(str string)

Add appends at the end.

func (*Strings) Empty

func (s *Strings) Empty() bool

Empty returns true if the list is empty.

func (*Strings) Has

func (s *Strings) Has(str string) bool

Has checks whether the string is already present.

func (*Strings) Remove

func (s *Strings) Remove(str string)

Remove removes the first occurence of the string, if present.

type Volume

type Volume struct {
	VolName        string
	VolID          string
	VolSize        int64
	VolPath        string
	VolAccessType  AccessType
	ParentVolID    string
	ParentSnapID   string
	Ephemeral      bool
	NodeID         string
	Kind           string
	ReadOnlyAttach bool
	Attached       bool
	// Staged contains the staging target path at which the volume
	// was staged. A set of paths is used for consistency
	// with Published.
	Staged Strings
	// Published contains the target paths where the volume
	// was published.
	Published Strings
}

Jump to

Keyboard shortcuts

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