Documentation
¶
Overview ¶
Package storage provides storage driver management.
Index ¶
- Constants
- func DetectBestDriver(root string) string
- func EnsureDriverDir(root string) error
- func LinkParent(root, childID, parentID string) error
- func SaveLayerMetadata(root, id string, meta map[string]string) error
- type BtrfsDriver
- func (d *BtrfsDriver) Cleanup() error
- func (d *BtrfsDriver) Exists(id string) bool
- func (d *BtrfsDriver) Get(id, _ string) (string, error)
- func (d *BtrfsDriver) GetMetadata(_ string) (map[string]string, error)
- func (d *BtrfsDriver) Name() string
- func (d *BtrfsDriver) Put(id, _ string) (string, error)
- func (d *BtrfsDriver) Remove(id string) error
- type Driver
- type FuseOverlayFSDriver
- func (d *FuseOverlayFSDriver) Cleanup() error
- func (d *FuseOverlayFSDriver) Exists(id string) bool
- func (d *FuseOverlayFSDriver) Get(id, _ string) (string, error)
- func (d *FuseOverlayFSDriver) GetMetadata(id string) (map[string]string, error)
- func (d *FuseOverlayFSDriver) Name() string
- func (d *FuseOverlayFSDriver) Put(id, _ string) (string, error)
- func (d *FuseOverlayFSDriver) Remove(id string) error
- type GCConfig
- type GarbageCollector
- type Manager
- func (m *Manager) Cleanup() error
- func (m *Manager) Driver() Driver
- func (m *Manager) Exists(id string) bool
- func (m *Manager) Get(id, mountLabel string) (string, error)
- func (m *Manager) GetMetadata(id string) (map[string]string, error)
- func (m *Manager) Name() string
- func (m *Manager) Put(id, mountLabel string) (string, error)
- func (m *Manager) Remove(id string) error
- func (m *Manager) Root() string
- func (m *Manager) Stats() StorageStats
- type Overlay2Driver
- func (d *Overlay2Driver) Cleanup() error
- func (d *Overlay2Driver) Exists(id string) bool
- func (d *Overlay2Driver) Get(id, _ string) (string, error)
- func (d *Overlay2Driver) GetMetadata(id string) (map[string]string, error)
- func (d *Overlay2Driver) Name() string
- func (d *Overlay2Driver) Put(id, _ string) (string, error)
- func (d *Overlay2Driver) Remove(id string) error
- type QuotaManager
- type Snapshot
- type SnapshotManager
- func (sm *SnapshotManager) Create(id string, metadata map[string]string) (*Snapshot, error)
- func (sm *SnapshotManager) Delete(id string) error
- func (sm *SnapshotManager) List() ([]*Snapshot, error)
- func (sm *SnapshotManager) Load(id string) (*Snapshot, error)
- func (sm *SnapshotManager) Restore(snapID, targetID string) error
- type StorageStats
- type VFSDriver
- func (d *VFSDriver) Cleanup() error
- func (d *VFSDriver) Exists(id string) bool
- func (d *VFSDriver) Get(id, _ string) (string, error)
- func (d *VFSDriver) GetMetadata(_ string) (map[string]string, error)
- func (d *VFSDriver) Name() string
- func (d *VFSDriver) Put(id, _ string) (string, error)
- func (d *VFSDriver) Remove(id string) error
- type ZFSDriver
- func (d *ZFSDriver) Cleanup() error
- func (d *ZFSDriver) Exists(id string) bool
- func (d *ZFSDriver) Get(id, _ string) (string, error)
- func (d *ZFSDriver) GetMetadata(_ string) (map[string]string, error)
- func (d *ZFSDriver) Name() string
- func (d *ZFSDriver) Put(id, _ string) (string, error)
- func (d *ZFSDriver) Remove(id string) error
Constants ¶
const ( DriverFuseOverlayFS = "fuse-overlayfs" DriverOverlay2 = "overlay2" )
Variables ¶
This section is empty.
Functions ¶
func DetectBestDriver ¶
DetectBestDriver detects the best available storage driver for the system.
func EnsureDriverDir ¶
EnsureDriverDir creates driver directories.
func LinkParent ¶
LinkParent links a child layer to its parent.
Types ¶
type BtrfsDriver ¶
type BtrfsDriver struct {
// contains filtered or unexported fields
}
BtrfsDriver implements the storage driver using btrfs subvolumes.
func NewBtrfsDriver ¶
func NewBtrfsDriver(root string) (*BtrfsDriver, error)
NewBtrfsDriver creates a new btrfs storage driver rooted at root.
func (*BtrfsDriver) Cleanup ¶
func (d *BtrfsDriver) Cleanup() error
Cleanup releases resources held by the btrfs driver.
func (*BtrfsDriver) Exists ¶
func (d *BtrfsDriver) Exists(id string) bool
Exists checks whether a btrfs subvolume for the given layer id exists.
func (*BtrfsDriver) Get ¶
func (d *BtrfsDriver) Get(id, _ string) (string, error)
Get mounts the btrfs subvolume for the given layer id and returns its mount path.
func (*BtrfsDriver) GetMetadata ¶
func (d *BtrfsDriver) GetMetadata(_ string) (map[string]string, error)
GetMetadata returns metadata for the given layer.
func (*BtrfsDriver) Name ¶
func (d *BtrfsDriver) Name() string
Name returns the name of the btrfs driver.
func (*BtrfsDriver) Put ¶
func (d *BtrfsDriver) Put(id, _ string) (string, error)
Put unmounts the btrfs subvolume for the given layer id and returns its mount path.
func (*BtrfsDriver) Remove ¶
func (d *BtrfsDriver) Remove(id string) error
Remove deletes the btrfs subvolume for the given layer id.
type Driver ¶
type Driver interface {
Get(id, mountLabel string) (string, error)
Put(id, mountLabel string) (string, error)
Exists(id string) bool
Cleanup() error
Remove(id string) error
GetMetadata(id string) (map[string]string, error)
Name() string
}
Driver is the interface for storage drivers.
type FuseOverlayFSDriver ¶
type FuseOverlayFSDriver struct {
// contains filtered or unexported fields
}
FuseOverlayFSDriver implements the Driver interface using fuse-overlayfs.
func NewFuseOverlayFSDriver ¶
func NewFuseOverlayFSDriver(root string) (*FuseOverlayFSDriver, error)
NewFuseOverlayFSDriver creates a new fuse-overlayfs driver.
func (*FuseOverlayFSDriver) Cleanup ¶
func (d *FuseOverlayFSDriver) Cleanup() error
func (*FuseOverlayFSDriver) Exists ¶
func (d *FuseOverlayFSDriver) Exists(id string) bool
func (*FuseOverlayFSDriver) GetMetadata ¶
func (d *FuseOverlayFSDriver) GetMetadata(id string) (map[string]string, error)
func (*FuseOverlayFSDriver) Name ¶
func (d *FuseOverlayFSDriver) Name() string
func (*FuseOverlayFSDriver) Remove ¶
func (d *FuseOverlayFSDriver) Remove(id string) error
type GCConfig ¶
type GCConfig struct {
Enabled bool
Interval time.Duration
MaxAge time.Duration
MinFreeSpace int64
}
GCConfig holds configuration for garbage collection.
type GarbageCollector ¶
type GarbageCollector struct {
// contains filtered or unexported fields
}
GarbageCollector runs periodic garbage collection on unused layers.
func NewGarbageCollector ¶
func NewGarbageCollector(store *Manager, cfg GCConfig) *GarbageCollector
NewGarbageCollector creates a new garbage collector for the given storage manager.
func (*GarbageCollector) Start ¶
func (g *GarbageCollector) Start()
Start begins periodic garbage collection.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages storage drivers.
func NewManager ¶
NewManager creates a new storage manager.
func (*Manager) GetMetadata ¶
GetMetadata returns metadata for a container layer.
type Overlay2Driver ¶
type Overlay2Driver struct {
// contains filtered or unexported fields
}
Overlay2Driver implements the Driver interface using native overlay2.
func NewOverlay2Driver ¶
func NewOverlay2Driver(root string) (*Overlay2Driver, error)
NewOverlay2Driver creates a new overlay2 driver.
func (*Overlay2Driver) Cleanup ¶
func (d *Overlay2Driver) Cleanup() error
func (*Overlay2Driver) Exists ¶
func (d *Overlay2Driver) Exists(id string) bool
func (*Overlay2Driver) GetMetadata ¶
func (d *Overlay2Driver) GetMetadata(id string) (map[string]string, error)
func (*Overlay2Driver) Name ¶
func (d *Overlay2Driver) Name() string
func (*Overlay2Driver) Remove ¶
func (d *Overlay2Driver) Remove(id string) error
type QuotaManager ¶
type QuotaManager struct {
// contains filtered or unexported fields
}
QuotaManager manages disk quotas for storage drivers.
func NewQuotaManager ¶
func NewQuotaManager(driver Driver) *QuotaManager
NewQuotaManager creates a new quota manager.
func (*QuotaManager) GetQuota ¶
func (q *QuotaManager) GetQuota(id string) (int64, error)
GetQuota returns the current quota for a container layer.
type Snapshot ¶
type Snapshot struct {
ID string `json:"id"`
ParentID string `json:"parent_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
Size int64 `json:"size"`
Metadata map[string]string `json:"metadata,omitempty"`
}
Snapshot represents a storage snapshot.
type SnapshotManager ¶
type SnapshotManager struct {
// contains filtered or unexported fields
}
SnapshotManager manages storage snapshots.
func NewSnapshotManager ¶
func NewSnapshotManager(root string, driver Driver) *SnapshotManager
NewSnapshotManager creates a new snapshot manager.
func (*SnapshotManager) Delete ¶
func (sm *SnapshotManager) Delete(id string) error
Delete deletes a snapshot.
func (*SnapshotManager) List ¶
func (sm *SnapshotManager) List() ([]*Snapshot, error)
List returns all snapshots.
func (*SnapshotManager) Load ¶
func (sm *SnapshotManager) Load(id string) (*Snapshot, error)
Load loads a snapshot by ID.
func (*SnapshotManager) Restore ¶
func (sm *SnapshotManager) Restore(snapID, targetID string) error
Restore restores a snapshot to a container layer.
type StorageStats ¶
type StorageStats struct {
DriverName string `json:"driver_name"`
RootPath string `json:"root_path"`
LayerCount int `json:"layer_count"`
TotalSize int64 `json:"total_size"`
FreeSpace int64 `json:"free_space"`
}
StorageStats returns storage statistics.
type VFSDriver ¶
type VFSDriver struct {
// contains filtered or unexported fields
}
VFSDriver implements the storage driver using the host filesystem directly.
func NewVFSDriver ¶
NewVFSDriver creates a new VFS storage driver.
func (*VFSDriver) GetMetadata ¶
GetMetadata returns metadata for the given layer.
type ZFSDriver ¶
type ZFSDriver struct {
// contains filtered or unexported fields
}
ZFSDriver implements the storage driver using ZFS filesystems.
func NewZFSDriver ¶
NewZFSDriver creates a new ZFS storage driver.
func (*ZFSDriver) Get ¶
Get mounts the ZFS filesystem for the given layer id and returns its mount path.
func (*ZFSDriver) GetMetadata ¶
GetMetadata returns metadata for the given layer.