Documentation
¶
Index ¶
- Constants
- func AssertNameFormat(t *testing.T, fsName, snapName string) bool
- func EqualCreateOptions(t *testing.T, expectedOpts ...CreateOption) func([]CreateOption) bool
- func MustParseTime(t *testing.T, layout, value string) time.Time
- func Transfer(targetFS string, dst ListerReceiver, src ListerSender) error
- type BucketConfig
- type CreateOption
- type Interval
- type Lister
- type ListerReceiver
- type ListerSender
- type Manager
- func (m *Manager) CleanSnapshots(cfg BucketConfig) error
- func (m *Manager) CreateSnapshots(opts ...CreateOption) error
- func (m *Manager) ListSnapshots() ([]Name, error)
- func (m *Manager) ReceiveSnapshot(targetFS string, name Name, r io.Reader) error
- func (m *Manager) SendSnapshot(name Name, w io.Writer, opts ...SendOption) error
- type MockManager
- func (m *MockManager) AssertCreateOptions(t *testing.T) bool
- func (m *MockManager) AssertSendOptions(t *testing.T) bool
- func (m *MockManager) CleanSnapshots(cfg BucketConfig) error
- func (m *MockManager) CreateSnapshots(opts ...CreateOption) error
- func (m *MockManager) ExpectCreateOptions(opts ...CreateOption)
- func (m *MockManager) ExpectSendOptions(opts ...SendOption)
- func (m *MockManager) ListSnapshots() ([]Name, error)
- func (m *MockManager) ReceiveSnapshot(targetFS string, name Name, r io.Reader) error
- func (m *MockManager) SendSnapshot(name Name, w io.Writer, opts ...SendOption) error
- type MockZFSAdapter
- func (m *MockZFSAdapter) CreateSnapshot(name string) error
- func (m *MockZFSAdapter) Destroy(name string) error
- func (m *MockZFSAdapter) List(typ zfs.ListType) ([]string, error)
- func (m *MockZFSAdapter) Receive(name string, r io.Reader) error
- func (m *MockZFSAdapter) Send(name, ref string, w io.Writer) error
- type Name
- type Receiver
- type SendOption
- type Sender
- type ZFSAdapter
Constants ¶
const TimestampFormat = time.RFC3339Nano
TimestampFormat represents the format of timestamps used by zsm to identify snapshots.
Variables ¶
This section is empty.
Functions ¶
func AssertNameFormat ¶
AssertNameFormat asserts that the passed snapName has the expected format for a snapshot of a filesystem with name fsName.
func EqualCreateOptions ¶
func EqualCreateOptions(t *testing.T, expectedOpts ...CreateOption) func([]CreateOption) bool
EqualCreateOptions returns a function that checks if the passed CreateOptions match the expected create options.
EqualCreateOptions is mainly intended for use with mock.MatchedBy.
func MustParseTime ¶
MustParseTime parses the passed value as a time.Time according to layout. It fails the test if the value cannot be parsed.
func Transfer ¶
func Transfer(targetFS string, dst ListerReceiver, src ListerSender) error
Transfer transfers all snapshots not already known on dst from src to dst.
Types ¶
type BucketConfig ¶
type BucketConfig [nIntervals]int
BucketConfig configures the buckets for retaining snapshots.
A value >0 for each of the elements of BucketConfig signals that each corresponding bucket should be filled with that many snapshots, each apart by at least the amount signaled by the bucket name.
Example:
If the element Minute is set to 5 the Minute bucket is to be filled with 5 snapshots at least a minute apart.
type CreateOption ¶
type CreateOption func(*createOpts)
CreateOption modifies the way CreateSnapshot creates a snapshot of one or more ZFS file systems.
func ExcludeFileSystem ¶
func ExcludeFileSystem(fsName string) CreateOption
ExcludeFileSystem marks the passed file System as excluded from creating snapshots.
func FromFileSystem ¶
func FromFileSystem(fsName string) CreateOption
FromFileSystem makes CreateSnapshot create a snapshot of only the passed file system. If FileSystem is passed multiple times to CreateSnapshot it creates snapshots of all the passed file systems.
type Interval ¶
type Interval int
Interval represents the interval between two consecutive snapshots.
type ListerReceiver ¶
ListerReceiver defines a type that can list all snapshots known to it and can receive additional snapshots.
type ListerSender ¶
ListerSender defines a type that can list all snapshots known to it and can send snapshots.
type Manager ¶
type Manager struct {
ZFS ZFSAdapter
}
Manager manages ZFS snapshots.
func (*Manager) CleanSnapshots ¶
func (m *Manager) CleanSnapshots(cfg BucketConfig) error
CleanSnapshots removes all snapshots outdated according to BucketConfig.
func (*Manager) CreateSnapshots ¶
func (m *Manager) CreateSnapshots(opts ...CreateOption) error
CreateSnapshots creates snapshots of the ZFS file system.
By default CreateSnapshots creates snapshots of all ZFS file systems available. This behavior can be modified by passing one or more CreateOptions.
func (*Manager) ListSnapshots ¶
ListSnapshots returns a list of snapshot names managed by zsm.
func (*Manager) ReceiveSnapshot ¶
ReceiveSnapshot receives a snapshot with the passed name.
It writes the data read from r to the snapshot. ReceiveSnapshot returns an error if name.FileSystem does not exist, or if a snapshot with the same name already exists.
func (*Manager) SendSnapshot ¶
SendSnapshot writes the snapshot identified by name to w.
By passing the Reference option only data changed between the passed reference and name is written to w.
type MockManager ¶
MockManager is a mock for Manager and provides the same methods.
MockManager is useful across various packages. It is therefore defined once in the snapshot package and not in the packages, that use the functionality.
func (*MockManager) AssertCreateOptions ¶
func (m *MockManager) AssertCreateOptions(t *testing.T) bool
AssertCreateOptions asserts that the expected send options were actually passed.
func (*MockManager) AssertSendOptions ¶
func (m *MockManager) AssertSendOptions(t *testing.T) bool
AssertSendOptions asserts that the expected send options were actually passed.
func (*MockManager) CleanSnapshots ¶
func (m *MockManager) CleanSnapshots(cfg BucketConfig) error
CleanSnapshots registers a call to CleanSnapshots.
func (*MockManager) CreateSnapshots ¶
func (m *MockManager) CreateSnapshots(opts ...CreateOption) error
CreateSnapshots registers a call to CreateSnapshots.
func (*MockManager) ExpectCreateOptions ¶
func (m *MockManager) ExpectCreateOptions(opts ...CreateOption)
ExpectCreateOptions sets the CreateOptions expected when CreateSnapshot is called.
func (*MockManager) ExpectSendOptions ¶
func (m *MockManager) ExpectSendOptions(opts ...SendOption)
ExpectSendOptions sets the SendOptions expected when SendSnapshot is called.
func (*MockManager) ListSnapshots ¶
func (m *MockManager) ListSnapshots() ([]Name, error)
ListSnapshots registers a call to ListSnapshots.
func (*MockManager) ReceiveSnapshot ¶
ReceiveSnapshot registers a call to ReceiveSnapshot.
func (*MockManager) SendSnapshot ¶
func (m *MockManager) SendSnapshot(name Name, w io.Writer, opts ...SendOption) error
SendSnapshot registers a call to SendSnapshot.
type MockZFSAdapter ¶
MockZFSAdapter mocks calls to the ZFS executable installed on the system.
func (*MockZFSAdapter) CreateSnapshot ¶
func (m *MockZFSAdapter) CreateSnapshot(name string) error
CreateSnapshot registers a mock call to zfs snapshot
func (*MockZFSAdapter) Destroy ¶
func (m *MockZFSAdapter) Destroy(name string) error
Destroy registers a call to zfs destroy.
func (*MockZFSAdapter) List ¶
func (m *MockZFSAdapter) List(typ zfs.ListType) ([]string, error)
List registers a mock call to zfs list
type Name ¶
Name represents a named snapshot created by zsm.
func FakeNames ¶
FakeNames creates n fake snapshots Names. Two consecutive names are delta apart. The last snapshot Name is end.
func MustParseName ¶
MustParseName parses the passed snapshot name using ParseName. If ParseName returns false for its second argument, MustParseName fails the test.
func ParseNameJSON ¶
ParseNameJSON parses a JSON representation of a name.
func ShuffleNamesC ¶
ShuffleNamesC returns a shuffled copy of names.
type SendOption ¶
type SendOption func(*sendOpts)
SendOption configures the way SendSnapshot sends a snapshot to a remote host.
func Reference ¶
func Reference(name Name) SendOption
Reference sets the name of the reference snapshot when sending snapshots.
type Sender ¶
type Sender interface {
SendSnapshot(Name, io.Writer, ...SendOption) error
}
Sender defines the SendSnapshot method.
type ZFSAdapter ¶
type ZFSAdapter interface { CreateSnapshot(string) error List(zfs.ListType) ([]string, error) Destroy(string) error Receive(string, io.Reader) error Send(string, string, io.Writer) error }
ZFSAdapter represents a type which is capable on performing calls to ZFS on the underlying system.