mirror of
https://github.com/zrepl/zrepl.git
synced 2025-02-20 12:22:01 +01:00
endpoint: rename abstraction super-"classes"
This commit is contained in:
parent
4fd369b67f
commit
7061282e08
@ -314,7 +314,7 @@ func ReplicationCursorV2Extractor(fs *zfs.DatasetPath, v zfs.FilesystemVersion)
|
||||
// TODO log this possibly tinkered-with bookmark
|
||||
return nil
|
||||
}
|
||||
return &ListHoldsAndBookmarksOutputBookmark{
|
||||
return &bookmarkBasedAbstraction{
|
||||
Type: AbstractionReplicationCursorBookmarkV2,
|
||||
FS: fs.ToString(),
|
||||
FilesystemVersion: v,
|
||||
@ -351,7 +351,7 @@ func LastReceivedHoldExtractor(fs *zfs.DatasetPath, v zfs.FilesystemVersion, hol
|
||||
|
||||
jobID, err := ParseLastReceivedHoldTag(holdTag)
|
||||
if err == nil {
|
||||
return &ListHoldsAndBookmarksOutputHold{
|
||||
return &holdBasedAbstraction{
|
||||
Type: AbstractionLastReceivedHold,
|
||||
FS: fs.ToString(),
|
||||
FilesystemVersion: v,
|
||||
|
@ -75,7 +75,7 @@ func HoldStep(ctx context.Context, fs string, v zfs.FilesystemVersion, jobID Job
|
||||
return nil, errors.Wrap(err, "step hold: zfs")
|
||||
}
|
||||
|
||||
return &ListHoldsAndBookmarksOutputHold{
|
||||
return &holdBasedAbstraction{
|
||||
Type: AbstractionStepHold,
|
||||
FS: fs,
|
||||
Tag: tag,
|
||||
@ -105,7 +105,7 @@ func HoldStep(ctx context.Context, fs string, v zfs.FilesystemVersion, jobID Job
|
||||
}
|
||||
return nil, errors.Wrap(err, "create step bookmark: zfs")
|
||||
}
|
||||
return &ListHoldsAndBookmarksOutputBookmark{
|
||||
return &bookmarkBasedAbstraction{
|
||||
Type: AbstractionStepBookmark,
|
||||
FS: fs,
|
||||
FilesystemVersion: v,
|
||||
@ -251,7 +251,7 @@ func StepBookmarkExtractor(fs *zfs.DatasetPath, v zfs.FilesystemVersion) (_ Abst
|
||||
return nil
|
||||
}
|
||||
if err == nil {
|
||||
bm := &ListHoldsAndBookmarksOutputBookmark{
|
||||
bm := &bookmarkBasedAbstraction{
|
||||
Type: AbstractionStepBookmark,
|
||||
FS: fs.ToString(),
|
||||
FilesystemVersion: v,
|
||||
@ -271,7 +271,7 @@ func StepHoldExtractor(fs *zfs.DatasetPath, v zfs.FilesystemVersion, holdTag str
|
||||
|
||||
jobID, err := ParseStepHoldTag(holdTag)
|
||||
if err == nil {
|
||||
return &ListHoldsAndBookmarksOutputHold{
|
||||
return &holdBasedAbstraction{
|
||||
Type: AbstractionStepHold,
|
||||
FS: fs.ToString(),
|
||||
Tag: holdTag,
|
||||
|
@ -10,38 +10,38 @@ import (
|
||||
"github.com/zrepl/zrepl/zfs"
|
||||
)
|
||||
|
||||
type ListHoldsAndBookmarksOutputBookmark struct {
|
||||
type bookmarkBasedAbstraction struct {
|
||||
Type AbstractionType
|
||||
FS string
|
||||
zfs.FilesystemVersion
|
||||
JobID JobID
|
||||
}
|
||||
|
||||
func (b ListHoldsAndBookmarksOutputBookmark) GetType() AbstractionType { return b.Type }
|
||||
func (b ListHoldsAndBookmarksOutputBookmark) GetFS() string { return b.FS }
|
||||
func (b ListHoldsAndBookmarksOutputBookmark) GetJobID() *JobID { return &b.JobID }
|
||||
func (b ListHoldsAndBookmarksOutputBookmark) GetFullPath() string {
|
||||
func (b bookmarkBasedAbstraction) GetType() AbstractionType { return b.Type }
|
||||
func (b bookmarkBasedAbstraction) GetFS() string { return b.FS }
|
||||
func (b bookmarkBasedAbstraction) GetJobID() *JobID { return &b.JobID }
|
||||
func (b bookmarkBasedAbstraction) GetFullPath() string {
|
||||
return fmt.Sprintf("%s#%s", b.FS, b.Name) // TODO use zfs.FilesystemVersion.ToAbsPath
|
||||
}
|
||||
func (b ListHoldsAndBookmarksOutputBookmark) MarshalJSON() ([]byte, error) {
|
||||
func (b bookmarkBasedAbstraction) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(AbstractionJSON{b})
|
||||
}
|
||||
func (b ListHoldsAndBookmarksOutputBookmark) String() string {
|
||||
func (b bookmarkBasedAbstraction) String() string {
|
||||
return fmt.Sprintf("%s %s", b.Type, b.GetFullPath())
|
||||
}
|
||||
|
||||
func (b ListHoldsAndBookmarksOutputBookmark) GetFilesystemVersion() zfs.FilesystemVersion {
|
||||
func (b bookmarkBasedAbstraction) GetFilesystemVersion() zfs.FilesystemVersion {
|
||||
return b.FilesystemVersion
|
||||
}
|
||||
|
||||
func (b ListHoldsAndBookmarksOutputBookmark) Destroy(ctx context.Context) error {
|
||||
func (b bookmarkBasedAbstraction) Destroy(ctx context.Context) error {
|
||||
if err := zfs.ZFSDestroyIdempotent(ctx, b.GetFullPath()); err != nil {
|
||||
return errors.Wrapf(err, "destroy %s: zfs", b)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ListHoldsAndBookmarksOutputHold struct {
|
||||
type holdBasedAbstraction struct {
|
||||
Type AbstractionType
|
||||
FS string
|
||||
zfs.FilesystemVersion
|
||||
@ -49,24 +49,24 @@ type ListHoldsAndBookmarksOutputHold struct {
|
||||
JobID JobID
|
||||
}
|
||||
|
||||
func (h ListHoldsAndBookmarksOutputHold) GetType() AbstractionType { return h.Type }
|
||||
func (h ListHoldsAndBookmarksOutputHold) GetFS() string { return h.FS }
|
||||
func (h ListHoldsAndBookmarksOutputHold) GetJobID() *JobID { return &h.JobID }
|
||||
func (h ListHoldsAndBookmarksOutputHold) GetFullPath() string {
|
||||
func (h holdBasedAbstraction) GetType() AbstractionType { return h.Type }
|
||||
func (h holdBasedAbstraction) GetFS() string { return h.FS }
|
||||
func (h holdBasedAbstraction) GetJobID() *JobID { return &h.JobID }
|
||||
func (h holdBasedAbstraction) GetFullPath() string {
|
||||
return fmt.Sprintf("%s@%s", h.FS, h.GetName()) // TODO use zfs.FilesystemVersion.ToAbsPath
|
||||
}
|
||||
func (h ListHoldsAndBookmarksOutputHold) MarshalJSON() ([]byte, error) {
|
||||
func (h holdBasedAbstraction) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(AbstractionJSON{h})
|
||||
}
|
||||
func (h ListHoldsAndBookmarksOutputHold) String() string {
|
||||
func (h holdBasedAbstraction) String() string {
|
||||
return fmt.Sprintf("%s %q on %s", h.Type, h.Tag, h.GetFullPath())
|
||||
}
|
||||
|
||||
func (h ListHoldsAndBookmarksOutputHold) GetFilesystemVersion() zfs.FilesystemVersion {
|
||||
func (h holdBasedAbstraction) GetFilesystemVersion() zfs.FilesystemVersion {
|
||||
return h.FilesystemVersion
|
||||
}
|
||||
|
||||
func (h ListHoldsAndBookmarksOutputHold) Destroy(ctx context.Context) error {
|
||||
func (h holdBasedAbstraction) Destroy(ctx context.Context) error {
|
||||
if err := zfs.ZFSRelease(ctx, h.Tag, h.GetFullPath()); err != nil {
|
||||
return errors.Wrapf(err, "release %s: zfs", h)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user