Comments (8)
I thought about this, but TBH, when we started this, I was fairly new to Go. Let me play with it, but seems reasonable. ZFS is somewhat interesting in how volumes/filesystems/etc are treated WRT the same commands.
from go-zfs.
Yeah, certainly! I'm still fairly new to ZFS, and from a systems administrator standpoint, I appreciate how much work it does behind the scenes to blur the lines between different dataset types.
Conversely, from a programmer standpoint, I like the fact that one would never have to wonder if it's possible to send/receive/rollback a clone, since it's clear that those methods are only available and usable with a snapshot.
That is my two-cents on the matter!
from go-zfs.
Should dataset
be an interface? I just wonder for times when you get a list back and just need to iterate, etc.
from go-zfs.
Good question. I suppose it could be, but that would also mean manually implementing the Name()
, Used()
, Avail()
methods on all types, instead of relying on method promotion from the struct (since interfaces can't have struct members, Go doesn't have inheritance, etc.).
If we are trying to distinguish between dataset types, I'm not sure how helpful an interface would be in this case. I would probably still opt toward an unexported type dataset struct
for embedding purposes, but perhaps some experimentation will reveal which method is easier.
from go-zfs.
As far as iterating goes, the following method could perhaps be: https://github.com/mistifyio/go-zfs/blob/master/zfs.go#L38-L41
// Snapshots returns a slice of all snapshots
func Snapshots(filter string) ([]*Snapshot, error) {
datasets, err := listByType("snapshot", filter)
if err != nil {
return nil, err
}
snapshots := make([]*Snapshot, len(datasets))
for i := range datasets {
snapshots[i] = &Snapshot{
dataset: datasets[i],
}
}
return snapshots, nil
}
It's not perfect, but it would do the job.
from go-zfs.
Also, I didn't realize that this library exposed the ability to retrieve any kind of dataset. Perhaps the dataset
type should be Dataset
instead, so that Snapshot
, Volume
, and Clone
still embed Dataset
, but the type is still useful on its own, with its own basic methods.
from go-zfs.
Sorry for all the comments, thoughts keep coming to me. :) I'd be happy to mock up a PR in the next couple of days if you'd like.
from go-zfs.
I did a bit of quick and dirty hacking on my end, but I'm honestly not sure the result is much better. The Clone
, Filesystem
, and Volume
types have almost no merit on their own (and no unique methods). The only type that may be worthwhile would be Snapshot
, but if one is judicious in using the existing API appropriately, perhaps it's not worth the trouble.
For the time being, I'm going to close this issue. Here are the files I modified, just for reference:
https://gist.github.com/mdlayher/9cb32b96a9b6259bdf30
from go-zfs.
Related Issues (20)
- Use string constants for dataset types HOT 5
- Tests for Diff break
- Enable Solaris support for go-zfs HOT 1
- Switch from zfs get to zfs list calls for better performance HOT 1
- unicode decoding is not working
- Add support for zfs set command HOT 1
- add test for zpool fields
- go-zfs.Snapshots("") returns error on freenas/freebsd FreeBSD 10.3-RELEASE. HOT 2
- dataset.GetProperty(key) always returns 'VALUE' HOT 2
- setUint receives empty string for fragmentation in some cases HOT 2
- GetProperty("creation") returns incomplete value
- "error while getting pool information strconv.ParseUint: parsing "": invalid syntax" in docker info HOT 15
- implement `zfs promote` HOT 2
- Function SendSnapshotIncremental HOT 2
- Function ReceiveSnapshot HOT 1
- Consider adding '-p' to dataset.GetProperty ZFS command to receive machine parseable numbers
- "zpool": executable file not found HOT 6
- Way to kill stucked zfs/zpool commands
- Ability to create sparse voumes
- SSH Remote Command Execution HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-zfs.