Skip to content

Commit e7fc543

Browse files
committed
feat: show in API branch to which the snapshot belongs
1 parent c85f926 commit e7fc543

File tree

6 files changed

+12
-1
lines changed

6 files changed

+12
-1
lines changed

engine/internal/cloning/snapshots.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func (c *Base) fetchSnapshots() error {
4848
PhysicalSize: entry.Used,
4949
LogicalSize: entry.LogicalReferenced,
5050
Pool: entry.Pool,
51+
Branch: entry.Branch,
5152
NumClones: numClones,
5253
}
5354

engine/internal/provision/resources/resources.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type Snapshot struct {
3939
Used uint64 `json:"used"`
4040
LogicalReferenced uint64 `json:"logicalReferenced"`
4141
Pool string `json:"pool"`
42+
Branch string `json:"branch"`
4243
}
4344

4445
// SessionState defines current state of a Session.

engine/internal/provision/thinclones/zfs/branching.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ func (m *Manager) InitBranching() error {
104104
return fmt.Errorf("failed to init main branch dataset: %w", err)
105105
}
106106

107+
m.RefreshSnapshotList()
108+
107109
log.Msg("data branching has been successfully initialized")
108110

109111
return nil

engine/internal/provision/thinclones/zfs/snapshots_filter.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ var defaultFields = snapshotFields{
4141
"usedbysnapshots",
4242
"usedbychildren",
4343
dataStateAtLabel,
44+
branchProp,
4445
}
4546

4647
var defaultSorting = snapshotSorting{

engine/internal/provision/thinclones/zfs/zfs.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ type ListEntry struct {
116116

117117
// Data state timestamp.
118118
DataStateAt time.Time
119+
120+
// Branch to which the snapshot belongs.
121+
Branch string
119122
}
120123

121124
type setFunc func(s string) error
@@ -671,6 +674,7 @@ func (m *Manager) getSnapshots() ([]resources.Snapshot, error) {
671674
Used: entry.Used,
672675
LogicalReferenced: entry.LogicalReferenced,
673676
Pool: m.config.Pool.Name,
677+
Branch: entry.Branch,
674678
}
675679

676680
snapshots = append(snapshots, snapshot)
@@ -796,7 +800,7 @@ func (m *Manager) listDetails(filter snapshotFilter) ([]*ListEntry, error) {
796800
return nil, NewEmptyPoolError(filter.dsType, filter.pool)
797801
}
798802

799-
numberFields := len([]string(filter.fields)) // 14
803+
numberFields := len([]string(filter.fields)) // 15
800804
entries := make([]*ListEntry, len(lines)-headerOffset)
801805

802806
for i := headerOffset; i < len(lines); i++ {
@@ -822,6 +826,7 @@ func (m *Manager) listDetails(filter snapshotFilter) ([]*ListEntry, error) {
822826
MountPoint: fields[2],
823827
Type: fields[5],
824828
Origin: fields[6],
829+
Branch: fields[14],
825830
}
826831

827832
setRules := []setTuple{

engine/pkg/models/snapshot.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type Snapshot struct {
1313
LogicalSize uint64 `json:"logicalSize"`
1414
Pool string `json:"pool"`
1515
NumClones int `json:"numClones"`
16+
Branch string `json:"branch"`
1617
}
1718

1819
// SnapshotView represents a view of snapshot.

0 commit comments

Comments
 (0)