Skip to content

Commit 6e99fc7

Browse files
calmhalbalogic
authored andcommitted
Add depth to a few methods
1 parent 35ad200 commit 6e99fc7

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ func parseInodeChanges(lines [][]string) ([]*InodeChange, error) {
266266
return changes, nil
267267
}
268268

269-
func listByType(t, filter string) ([]*Dataset, error) {
270-
args := []string{"get", "-rHp", "-t", t, "all"}
269+
func listByType(t, filter string, depth int) ([]*Dataset, error) {
270+
args := []string{"get", fmt.Sprintf("-d%d", depth), "-rHp", "-t", t, "all"}
271271
if filter != "" {
272272
args = append(args, filter)
273273
}

zfs.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,29 +117,29 @@ func zfs(arg ...string) ([][]string, error) {
117117
// Datasets returns a slice of ZFS datasets, regardless of type.
118118
// A filter argument may be passed to select a dataset with the matching name,
119119
// or empty string ("") may be used to select all datasets.
120-
func Datasets(filter string) ([]*Dataset, error) {
121-
return listByType("all", filter)
120+
func Datasets(filter string, depth int) ([]*Dataset, error) {
121+
return listByType("all", filter, depth)
122122
}
123123

124124
// Snapshots returns a slice of ZFS snapshots.
125125
// A filter argument may be passed to select a snapshot with the matching name,
126126
// or empty string ("") may be used to select all snapshots.
127-
func Snapshots(filter string) ([]*Dataset, error) {
128-
return listByType(DatasetSnapshot, filter)
127+
func Snapshots(filter string, depth int) ([]*Dataset, error) {
128+
return listByType(DatasetSnapshot, filter, depth)
129129
}
130130

131131
// Filesystems returns a slice of ZFS filesystems.
132132
// A filter argument may be passed to select a filesystem with the matching name,
133133
// or empty string ("") may be used to select all filesystems.
134-
func Filesystems(filter string) ([]*Dataset, error) {
135-
return listByType(DatasetFilesystem, filter)
134+
func Filesystems(filter string, depth int) ([]*Dataset, error) {
135+
return listByType(DatasetFilesystem, filter, depth)
136136
}
137137

138138
// Volumes returns a slice of ZFS volumes.
139139
// A filter argument may be passed to select a volume with the matching name,
140140
// or empty string ("") may be used to select all volumes.
141-
func Volumes(filter string) ([]*Dataset, error) {
142-
return listByType(DatasetVolume, filter)
141+
func Volumes(filter string, depth int) ([]*Dataset, error) {
142+
return listByType(DatasetVolume, filter, depth)
143143
}
144144

145145
// GetDataset retrieves a single ZFS dataset by name. This dataset could be
@@ -337,7 +337,7 @@ func (d *Dataset) Rename(name string, createParent bool, recursiveRenameSnapshot
337337

338338
// Snapshots returns a slice of all ZFS snapshots of a given dataset.
339339
func (d *Dataset) Snapshots() ([]*Dataset, error) {
340-
return Snapshots(d.Name)
340+
return Snapshots(d.Name, 1)
341341
}
342342

343343
// CreateFilesystem creates a new ZFS filesystem with the specified name and

zpool.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ func GetZpool(name string) (*Zpool, error) {
4949
}
5050

5151
// Datasets returns a slice of all ZFS datasets in a zpool.
52-
func (z *Zpool) Datasets() ([]*Dataset, error) {
53-
return Datasets(z.Name)
52+
func (z *Zpool) Datasets(depth int) ([]*Dataset, error) {
53+
return Datasets(z.Name, depth)
5454
}
5555

5656
// Snapshots returns a slice of all ZFS snapshots in a zpool.
57-
func (z *Zpool) Snapshots() ([]*Dataset, error) {
58-
return Snapshots(z.Name)
57+
func (z *Zpool) Snapshots(depth int) ([]*Dataset, error) {
58+
return Snapshots(z.Name, depth)
5959
}
6060

6161
// CreateZpool creates a new ZFS zpool with the specified name, properties,

0 commit comments

Comments
 (0)