mirror of
https://github.com/containers/skopeo.git
synced 2025-09-10 11:09:47 +00:00
Bump github.com/containers/storage from 1.42.0 to 1.43.0
Bumps [github.com/containers/storage](https://github.com/containers/storage) from 1.42.0 to 1.43.0. - [Release notes](https://github.com/containers/storage/releases) - [Changelog](https://github.com/containers/storage/blob/main/docs/containers-storage-changes.md) - [Commits](https://github.com/containers/storage/compare/v1.42.0...v1.43.0) --- updated-dependencies: - dependency-name: github.com/containers/storage dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
119
vendor/github.com/mistifyio/go-zfs/v3/zpool.go
generated
vendored
Normal file
119
vendor/github.com/mistifyio/go-zfs/v3/zpool.go
generated
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
package zfs
|
||||
|
||||
// ZFS zpool states, which can indicate if a pool is online, offline, degraded, etc.
|
||||
//
|
||||
// More information regarding zpool states can be found in the ZFS manual:
|
||||
// https://openzfs.github.io/openzfs-docs/man/7/zpoolconcepts.7.html#Device_Failure_and_Recovery
|
||||
const (
|
||||
ZpoolOnline = "ONLINE"
|
||||
ZpoolDegraded = "DEGRADED"
|
||||
ZpoolFaulted = "FAULTED"
|
||||
ZpoolOffline = "OFFLINE"
|
||||
ZpoolUnavail = "UNAVAIL"
|
||||
ZpoolRemoved = "REMOVED"
|
||||
)
|
||||
|
||||
// Zpool is a ZFS zpool.
|
||||
// A pool is a top-level structure in ZFS, and can contain many descendent datasets.
|
||||
type Zpool struct {
|
||||
Name string
|
||||
Health string
|
||||
Allocated uint64
|
||||
Size uint64
|
||||
Free uint64
|
||||
Fragmentation uint64
|
||||
ReadOnly bool
|
||||
Freeing uint64
|
||||
Leaked uint64
|
||||
DedupRatio float64
|
||||
}
|
||||
|
||||
// zpool is a helper function to wrap typical calls to zpool and ignores stdout.
|
||||
func zpool(arg ...string) error {
|
||||
_, err := zpoolOutput(arg...)
|
||||
return err
|
||||
}
|
||||
|
||||
// zpool is a helper function to wrap typical calls to zpool.
|
||||
func zpoolOutput(arg ...string) ([][]string, error) {
|
||||
c := command{Command: "zpool"}
|
||||
return c.Run(arg...)
|
||||
}
|
||||
|
||||
// GetZpool retrieves a single ZFS zpool by name.
|
||||
func GetZpool(name string) (*Zpool, error) {
|
||||
args := zpoolArgs
|
||||
args = append(args, name)
|
||||
out, err := zpoolOutput(args...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// there is no -H
|
||||
out = out[1:]
|
||||
|
||||
z := &Zpool{Name: name}
|
||||
for _, line := range out {
|
||||
if err := z.parseLine(line); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return z, nil
|
||||
}
|
||||
|
||||
// Datasets returns a slice of all ZFS datasets in a zpool.
|
||||
func (z *Zpool) Datasets() ([]*Dataset, error) {
|
||||
return Datasets(z.Name)
|
||||
}
|
||||
|
||||
// Snapshots returns a slice of all ZFS snapshots in a zpool.
|
||||
func (z *Zpool) Snapshots() ([]*Dataset, error) {
|
||||
return Snapshots(z.Name)
|
||||
}
|
||||
|
||||
// CreateZpool creates a new ZFS zpool with the specified name, properties, and optional arguments.
|
||||
//
|
||||
// A full list of available ZFS properties and command-line arguments may be found in the ZFS manual:
|
||||
// https://openzfs.github.io/openzfs-docs/man/7/zfsprops.7.html.
|
||||
// https://openzfs.github.io/openzfs-docs/man/8/zpool-create.8.html
|
||||
func CreateZpool(name string, properties map[string]string, args ...string) (*Zpool, error) {
|
||||
cli := make([]string, 1, 4)
|
||||
cli[0] = "create"
|
||||
if properties != nil {
|
||||
cli = append(cli, propsSlice(properties)...)
|
||||
}
|
||||
cli = append(cli, name)
|
||||
cli = append(cli, args...)
|
||||
if err := zpool(cli...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Zpool{Name: name}, nil
|
||||
}
|
||||
|
||||
// Destroy destroys a ZFS zpool by name.
|
||||
func (z *Zpool) Destroy() error {
|
||||
err := zpool("destroy", z.Name)
|
||||
return err
|
||||
}
|
||||
|
||||
// ListZpools list all ZFS zpools accessible on the current system.
|
||||
func ListZpools() ([]*Zpool, error) {
|
||||
args := []string{"list", "-Ho", "name"}
|
||||
out, err := zpoolOutput(args...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var pools []*Zpool
|
||||
|
||||
for _, line := range out {
|
||||
z, err := GetZpool(line[0])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pools = append(pools, z)
|
||||
}
|
||||
return pools, nil
|
||||
}
|
Reference in New Issue
Block a user