Documentation
¶
Index ¶
- Variables
- func ValidateDevicePath(path string) error
- func ValidateHoldTag(tag string) error
- func ValidateMountpoint(path string) error
- func ValidateName(name string) error
- func ValidatePoolName(name string) error
- func ValidatePropertyName(name string) error
- func ValidateSnapshotFullName(name string) error
- func ValidateSnapshotName(name string) error
- type CLIManager
- func (m *CLIManager) CloneFromSnapshot(ctx context.Context, snapshot, newDataset string) error
- func (m *CLIManager) CreateDataset(ctx context.Context, name string, opts DatasetOptions) error
- func (m *CLIManager) CreateSnapshot(ctx context.Context, dataset, snapName string) (*SnapshotInfo, error)
- func (m *CLIManager) DatasetExists(ctx context.Context, name string) (bool, error)
- func (m *CLIManager) DestroyDataset(ctx context.Context, name string, opts DestroyOptions) error
- func (m *CLIManager) DestroySnapshot(ctx context.Context, dataset, snapName string) error
- func (m *CLIManager) EstimateSendSize(ctx context.Context, snapshot string, opts SendOptions) (int64, error)
- func (m *CLIManager) ExportPool(ctx context.Context, pool string) error
- func (m *CLIManager) GetDatasetInfo(ctx context.Context, name string) (*DatasetInfo, error)
- func (m *CLIManager) GetMountpoint(ctx context.Context, dataset string) (string, error)
- func (m *CLIManager) HoldSnapshot(ctx context.Context, dataset, snapName, tag string) error
- func (m *CLIManager) ImportPool(ctx context.Context, pool, device string) error
- func (m *CLIManager) ListDatasets(ctx context.Context, parent string) ([]DatasetInfo, error)
- func (m *CLIManager) ListSnapshots(ctx context.Context, dataset string) ([]SnapshotInfo, error)
- func (m *CLIManager) PoolSpace(ctx context.Context, pool string) (*PoolSpace, error)
- func (m *CLIManager) PoolStatus(ctx context.Context, pool string) (*PoolStatus, error)
- func (m *CLIManager) Receive(ctx context.Context, dataset string, r io.Reader) error
- func (m *CLIManager) ReleaseSnapshot(ctx context.Context, dataset, snapName, tag string) error
- func (m *CLIManager) Rollback(ctx context.Context, dataset, snapName string, opts RollbackOptions) error
- func (m *CLIManager) Send(ctx context.Context, snapshot string, opts SendOptions, w io.Writer) error
- func (m *CLIManager) SetMountpoint(ctx context.Context, dataset, mountpoint string) error
- func (m *CLIManager) SetProperty(ctx context.Context, dataset, property, value string) error
- func (m *CLIManager) SnapshotExists(ctx context.Context, dataset, snapName string) (bool, error)
- type CLIOption
- func WithDefaultCommandTimeout(timeout time.Duration) CLIOption
- func WithLogger(logger *slog.Logger) CLIOption
- func WithMetadataCommandTimeout(timeout time.Duration) CLIOption
- func WithPool(pool string) CLIOption
- func WithSudo(sudo bool) CLIOption
- func WithTransferCommandTimeout(timeout time.Duration) CLIOption
- func WithZFSPath(path string) CLIOption
- func WithZPoolPath(path string) CLIOption
- type DatasetInfo
- type DatasetOptions
- type DestroyOptions
- type MockManager
- func (m *MockManager) ClearError(op string)
- func (m *MockManager) CloneFromSnapshot(_ context.Context, snapshot, newDataset string) error
- func (m *MockManager) CreateDataset(_ context.Context, name string, opts DatasetOptions) error
- func (m *MockManager) CreateSnapshot(_ context.Context, dataset, snapName string) (*SnapshotInfo, error)
- func (m *MockManager) DatasetExists(ctx context.Context, name string) (bool, error)
- func (m *MockManager) DestroyDataset(_ context.Context, name string, opts DestroyOptions) error
- func (m *MockManager) DestroySnapshot(_ context.Context, dataset, snapName string) error
- func (m *MockManager) EstimateSendSize(_ context.Context, snapshot string, opts SendOptions) (int64, error)
- func (m *MockManager) ExportPool(_ context.Context, pool string) error
- func (m *MockManager) GetDatasetInfo(_ context.Context, name string) (*DatasetInfo, error)
- func (m *MockManager) GetMountpoint(_ context.Context, dataset string) (string, error)
- func (m *MockManager) HoldSnapshot(_ context.Context, dataset, snapName, tag string) error
- func (m *MockManager) ImportPool(_ context.Context, pool, device string) error
- func (m *MockManager) ListDatasets(_ context.Context, parent string) ([]DatasetInfo, error)
- func (m *MockManager) ListSnapshots(_ context.Context, dataset string) ([]SnapshotInfo, error)
- func (m *MockManager) PoolSpace(_ context.Context, pool string) (*PoolSpace, error)
- func (m *MockManager) PoolStatus(_ context.Context, pool string) (*PoolStatus, error)
- func (m *MockManager) Receive(_ context.Context, dataset string, r io.Reader) error
- func (m *MockManager) ReleaseSnapshot(_ context.Context, dataset, snapName, tag string) error
- func (m *MockManager) Rollback(_ context.Context, dataset, snapName string, opts RollbackOptions) error
- func (m *MockManager) Send(_ context.Context, snapshot string, opts SendOptions, w io.Writer) error
- func (m *MockManager) SetError(op string, err error)
- func (m *MockManager) SetMountpoint(_ context.Context, dataset, mountpoint string) error
- func (m *MockManager) SetProperty(_ context.Context, dataset, property, value string) error
- func (m *MockManager) SnapshotExists(_ context.Context, dataset, snapName string) (bool, error)
- type PoolSpace
- type PoolState
- type PoolStatus
- type RollbackOptions
- type SendOptions
- type SnapshotInfo
- type ZFSError
- type ZFSManager
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidName = errors.New("zfs: invalid dataset or snapshot name") ErrDatasetNotFound = errors.New("zfs: dataset does not exist") ErrDatasetExists = errors.New("zfs: dataset already exists") ErrSnapshotNotFound = errors.New("zfs: snapshot does not exist") ErrSnapshotExists = errors.New("zfs: snapshot already exists") ErrSnapshotHeld = errors.New("zfs: snapshot has holds and cannot be destroyed") ErrHasClones = errors.New("zfs: dataset has dependent clones") ErrPoolNotFound = errors.New("zfs: pool does not exist") ErrPoolFaulted = errors.New("zfs: pool is in faulted state") ErrPermission = errors.New("zfs: permission denied") ErrBusy = errors.New("zfs: dataset is busy") ErrPoolFull = errors.New("zfs: pool is full") ErrNoSpace = errors.New("zfs: no space left on device") ErrCommandNotFound = errors.New("zfs: zfs/zpool command not found") // Backward-compatible coarse sentinels. ErrNotFound = errors.New("zfs: object does not exist") ErrAlreadyExists = errors.New("zfs: object already exists") )
Functions ¶
func ValidateDevicePath ¶
func ValidateHoldTag ¶
func ValidateMountpoint ¶
func ValidateName ¶
func ValidatePoolName ¶
func ValidatePropertyName ¶
func ValidateSnapshotName ¶
Types ¶
type CLIManager ¶
type CLIManager struct {
// contains filtered or unexported fields
}
CLIManager implements ZFSManager by shelling out to zfs/zpool commands.
func NewCLIManager ¶
func NewCLIManager(opts ...CLIOption) (*CLIManager, error)
func (*CLIManager) CloneFromSnapshot ¶
func (m *CLIManager) CloneFromSnapshot(ctx context.Context, snapshot, newDataset string) error
func (*CLIManager) CreateDataset ¶
func (m *CLIManager) CreateDataset(ctx context.Context, name string, opts DatasetOptions) error
func (*CLIManager) CreateSnapshot ¶
func (m *CLIManager) CreateSnapshot(ctx context.Context, dataset, snapName string) (*SnapshotInfo, error)
func (*CLIManager) DatasetExists ¶
func (*CLIManager) DestroyDataset ¶
func (m *CLIManager) DestroyDataset(ctx context.Context, name string, opts DestroyOptions) error
func (*CLIManager) DestroySnapshot ¶
func (m *CLIManager) DestroySnapshot(ctx context.Context, dataset, snapName string) error
func (*CLIManager) EstimateSendSize ¶
func (m *CLIManager) EstimateSendSize(ctx context.Context, snapshot string, opts SendOptions) (int64, error)
func (*CLIManager) ExportPool ¶
func (m *CLIManager) ExportPool(ctx context.Context, pool string) error
func (*CLIManager) GetDatasetInfo ¶
func (m *CLIManager) GetDatasetInfo(ctx context.Context, name string) (*DatasetInfo, error)
func (*CLIManager) GetMountpoint ¶
func (*CLIManager) HoldSnapshot ¶
func (m *CLIManager) HoldSnapshot(ctx context.Context, dataset, snapName, tag string) error
func (*CLIManager) ImportPool ¶
func (m *CLIManager) ImportPool(ctx context.Context, pool, device string) error
func (*CLIManager) ListDatasets ¶
func (m *CLIManager) ListDatasets(ctx context.Context, parent string) ([]DatasetInfo, error)
func (*CLIManager) ListSnapshots ¶
func (m *CLIManager) ListSnapshots(ctx context.Context, dataset string) ([]SnapshotInfo, error)
func (*CLIManager) PoolStatus ¶
func (m *CLIManager) PoolStatus(ctx context.Context, pool string) (*PoolStatus, error)
func (*CLIManager) ReleaseSnapshot ¶
func (m *CLIManager) ReleaseSnapshot(ctx context.Context, dataset, snapName, tag string) error
func (*CLIManager) Rollback ¶
func (m *CLIManager) Rollback(ctx context.Context, dataset, snapName string, opts RollbackOptions) error
func (*CLIManager) Send ¶
func (m *CLIManager) Send(ctx context.Context, snapshot string, opts SendOptions, w io.Writer) error
func (*CLIManager) SetMountpoint ¶
func (m *CLIManager) SetMountpoint(ctx context.Context, dataset, mountpoint string) error
func (*CLIManager) SetProperty ¶
func (m *CLIManager) SetProperty(ctx context.Context, dataset, property, value string) error
func (*CLIManager) SnapshotExists ¶
type CLIOption ¶
type CLIOption func(*CLIManager)
func WithLogger ¶
func WithZFSPath ¶
func WithZPoolPath ¶
type DatasetInfo ¶
type DatasetOptions ¶
type DestroyOptions ¶
type MockManager ¶
type MockManager struct {
// contains filtered or unexported fields
}
MockManager implements ZFSManager in-memory for tests.
func NewMockManager ¶
func NewMockManager() *MockManager
func (*MockManager) ClearError ¶
func (m *MockManager) ClearError(op string)
func (*MockManager) CloneFromSnapshot ¶
func (m *MockManager) CloneFromSnapshot(_ context.Context, snapshot, newDataset string) error
func (*MockManager) CreateDataset ¶
func (m *MockManager) CreateDataset(_ context.Context, name string, opts DatasetOptions) error
func (*MockManager) CreateSnapshot ¶
func (m *MockManager) CreateSnapshot(_ context.Context, dataset, snapName string) (*SnapshotInfo, error)
func (*MockManager) DatasetExists ¶
func (*MockManager) DestroyDataset ¶
func (m *MockManager) DestroyDataset(_ context.Context, name string, opts DestroyOptions) error
func (*MockManager) DestroySnapshot ¶
func (m *MockManager) DestroySnapshot(_ context.Context, dataset, snapName string) error
func (*MockManager) EstimateSendSize ¶
func (m *MockManager) EstimateSendSize(_ context.Context, snapshot string, opts SendOptions) (int64, error)
func (*MockManager) ExportPool ¶
func (m *MockManager) ExportPool(_ context.Context, pool string) error
func (*MockManager) GetDatasetInfo ¶
func (m *MockManager) GetDatasetInfo(_ context.Context, name string) (*DatasetInfo, error)
func (*MockManager) GetMountpoint ¶
func (*MockManager) HoldSnapshot ¶
func (m *MockManager) HoldSnapshot(_ context.Context, dataset, snapName, tag string) error
func (*MockManager) ImportPool ¶
func (m *MockManager) ImportPool(_ context.Context, pool, device string) error
func (*MockManager) ListDatasets ¶
func (m *MockManager) ListDatasets(_ context.Context, parent string) ([]DatasetInfo, error)
func (*MockManager) ListSnapshots ¶
func (m *MockManager) ListSnapshots(_ context.Context, dataset string) ([]SnapshotInfo, error)
func (*MockManager) PoolStatus ¶
func (m *MockManager) PoolStatus(_ context.Context, pool string) (*PoolStatus, error)
func (*MockManager) ReleaseSnapshot ¶
func (m *MockManager) ReleaseSnapshot(_ context.Context, dataset, snapName, tag string) error
func (*MockManager) Rollback ¶
func (m *MockManager) Rollback(_ context.Context, dataset, snapName string, opts RollbackOptions) error
func (*MockManager) Send ¶
func (m *MockManager) Send(_ context.Context, snapshot string, opts SendOptions, w io.Writer) error
func (*MockManager) SetError ¶
func (m *MockManager) SetError(op string, err error)
func (*MockManager) SetMountpoint ¶
func (m *MockManager) SetMountpoint(_ context.Context, dataset, mountpoint string) error
func (*MockManager) SetProperty ¶
func (m *MockManager) SetProperty(_ context.Context, dataset, property, value string) error
func (*MockManager) SnapshotExists ¶
type RollbackOptions ¶
type RollbackOptions struct {
DestroyLater bool
}
type SendOptions ¶
type SnapshotInfo ¶
type ZFSError ¶
type ZFSError struct {
Op string
Command string
Dataset string
ExitCode int
Stderr string
Err error
}
ZFSError wraps a zfs/zpool command failure with structured context.
type ZFSManager ¶
type ZFSManager interface {
// Dataset operations.
CreateDataset(ctx context.Context, name string, opts DatasetOptions) error
CloneFromSnapshot(ctx context.Context, snapshot, newDataset string) error
DestroyDataset(ctx context.Context, name string, opts DestroyOptions) error
GetMountpoint(ctx context.Context, dataset string) (string, error)
SetMountpoint(ctx context.Context, dataset, mountpoint string) error
SetProperty(ctx context.Context, dataset, property, value string) error
GetDatasetInfo(ctx context.Context, name string) (*DatasetInfo, error)
ListDatasets(ctx context.Context, parent string) ([]DatasetInfo, error)
DatasetExists(ctx context.Context, name string) (bool, error)
// Snapshot operations.
CreateSnapshot(ctx context.Context, dataset, snapName string) (*SnapshotInfo, error)
Rollback(ctx context.Context, dataset, snapName string, opts RollbackOptions) error
ListSnapshots(ctx context.Context, dataset string) ([]SnapshotInfo, error)
DestroySnapshot(ctx context.Context, dataset, snapName string) error
HoldSnapshot(ctx context.Context, dataset, snapName, tag string) error
ReleaseSnapshot(ctx context.Context, dataset, snapName, tag string) error
SnapshotExists(ctx context.Context, dataset, snapName string) (bool, error)
// Pool operations.
PoolStatus(ctx context.Context, pool string) (*PoolStatus, error)
PoolSpace(ctx context.Context, pool string) (*PoolSpace, error)
ImportPool(ctx context.Context, pool, device string) error
ExportPool(ctx context.Context, pool string) error
// Transfer operations.
EstimateSendSize(ctx context.Context, snapshot string, opts SendOptions) (int64, error)
Send(ctx context.Context, snapshot string, opts SendOptions, w io.Writer) error
Receive(ctx context.Context, dataset string, r io.Reader) error
}
ZFSManager provides operations on ZFS datasets, snapshots, and pools. All methods are safe for concurrent use.
Click to show internal directories.
Click to hide internal directories.