apis

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver interface {
	// Create a new volume with the given name and options.
	Create(name string, options map[string]string) error

	// List all volumes.
	// Returns a map of volume names to their metadata.
	List() (map[string]*VolumeMetadata, error)

	// Get retrieves the metadata for a volume by name.
	Get(name string) (*VolumeMetadata, error)

	// Remove deletes a volume by name.
	Remove(name string) error

	// Path returns the mount point for a volume by name.
	Path(name string) (string, error)

	// Mount mounts a volume by name and ID.
	Mount(name string, id string) (string, error)

	// Unmount unmounts a volume by name and ID.
	Unmount(name string, id string) error

	// Destroy cleans up any resources used by the driver.
	Destroy() error
}

Driver interface

type VolumeMetadata

type VolumeMetadata struct {
	// CreatedAt is the timestamp when the volume was created
	CreatedAt time.Time `json:"createAt" validate:"required"`

	// Spec contains the volume specification, including options and settings
	Spec *VolumeSpec `json:"spec" validate:"required"`

	// Status contains the current status of the volume, which can be used to store runtime information or state
	Status *VolumeStatus `json:"status" validate:"required"`
}

func (*VolumeMetadata) Marshal

func (vm *VolumeMetadata) Marshal() (data []byte, err error)

Marshal validates the VolumeMetadata struct and marshals it into JSON format.

func (*VolumeMetadata) ToVolume

func (vm *VolumeMetadata) ToVolume(name string, mountpointBase string) *volume.Volume

ToVolume converts the VolumeMetadata struct to a volume.Volume struct, using the provided name and mountpointBase.

func (*VolumeMetadata) Unmarshal

func (vm *VolumeMetadata) Unmarshal(data []byte) (err error)

Unmarshal the JSON data into the VolumeMetadata struct and validates it.

type VolumeSpec

type VolumeSpec struct {
	PurgeAfterDelete bool `json:"purgeAfterDelete,omitempty"`
}

func (*VolumeSpec) Unmarshal

func (spec *VolumeSpec) Unmarshal(data map[string]string) (err error)

Unmarshal takes a map of string key-value pairs and populates the VolumeSpec struct based on the provided data. It returns an error if any of the values are invalid or if there are unknown options.

type VolumeStatus

type VolumeStatus struct {
	// Mountpoint is the relative path to the volume's mount point
	Mountpoint string `json:"mountpoint" validate:"required"`
}

Jump to

Keyboard shortcuts

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