update github.com/containers/{image,storage}

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2019-08-06 14:13:03 +02:00
parent c040b28fb8
commit 700b3102af
549 changed files with 154297 additions and 23467 deletions

View File

@@ -1,41 +0,0 @@
language: go
sudo: required
dist: trusty
branches:
only:
- master
env:
- rel=0.6.4.2
- rel=0.6.5.4
matrix:
allow_failures:
- env: rel=0.6.5.4
go:
- 1.5
before_install:
- MAKEFLAGS=-j$(($(grep -c '^processor' /proc/cpuinfo) * 2 + 1))
- sudo apt-get update -y && sudo apt-get install -y linux-headers-$(uname -r) uuid-dev tree
- cd /tmp
- curl -L https://github.com/zfsonlinux/zfs/releases/download/zfs-$rel/spl-$rel.tar.gz | tar xz
- curl -L https://github.com/zfsonlinux/zfs/releases/download/zfs-$rel/zfs-$rel.tar.gz | tar xz
- (cd spl-$rel && ./configure --prefix=/usr && make && sudo make install)
- (cd zfs-$rel && ./configure --prefix=/usr && make && sudo make install)
- sudo modprobe zfs
- cd $TRAVIS_BUILD_DIR
- go get github.com/alecthomas/gometalinter
- gometalinter --install --update
script:
- sudo -E $(which go) test -v ./...
- gometalinter --disable=golint --disable=vetshadow --enable=gofmt ./... || true
- gometalinter --disable-all --enable=golint --enable=vetshadow ./... || true
notifications:
email: false
slack:
secure: "AbDJNjWyf/z+neX0HtoIUynjBcdvbhrsuyzoeaImZaanUtyo3cWNpA1M+5CApDQneaKbLqcehDBTjaLQD1fjXXtWrNvq+FgCRDJ1gvZasq13iJfYe3qtLz7n0YGHqEGzZ1lsheWtle/Sg32RlPAUZrHKWPciu7/Fg1k1ca8FsB4="

View File

@@ -2,16 +2,12 @@ package zfs
import (
"bytes"
"errors"
"fmt"
"io"
"os/exec"
"regexp"
"runtime"
"strconv"
"strings"
"github.com/pborman/uuid"
)
type command struct {
@@ -38,17 +34,16 @@ func (c *command) Run(arg ...string) ([][]string, error) {
}
cmd.Stderr = &stderr
id := uuid.New()
joinedArgs := strings.Join(cmd.Args, " ")
logger.Log([]string{"ID:" + id, "START", joinedArgs})
debug := strings.Join([]string{cmd.Path, strings.Join(cmd.Args, " ")}, " ")
if logger != nil {
logger.Log(cmd.Args)
}
err := cmd.Run()
logger.Log([]string{"ID:" + id, "FINISH"})
if err != nil {
return nil, &Error{
Err: err,
Debug: strings.Join([]string{cmd.Path, joinedArgs}, " "),
Debug: debug,
Stderr: stderr.String(),
}
}
@@ -93,46 +88,34 @@ func setUint(field *uint64, value string) error {
}
func (ds *Dataset) parseLine(line []string) error {
prop := line[1]
val := line[2]
var err error
if len(line) != len(dsPropList) {
return errors.New("Output does not match what is expected on this platform")
switch prop {
case "available":
err = setUint(&ds.Avail, val)
case "compression":
setString(&ds.Compression, val)
case "mountpoint":
setString(&ds.Mountpoint, val)
case "quota":
err = setUint(&ds.Quota, val)
case "type":
setString(&ds.Type, val)
case "origin":
setString(&ds.Origin, val)
case "used":
err = setUint(&ds.Used, val)
case "volsize":
err = setUint(&ds.Volsize, val)
case "written":
err = setUint(&ds.Written, val)
case "logicalused":
err = setUint(&ds.Logicalused, val)
}
setString(&ds.Name, line[0])
setString(&ds.Origin, line[1])
if err = setUint(&ds.Used, line[2]); err != nil {
return err
}
if err = setUint(&ds.Avail, line[3]); err != nil {
return err
}
setString(&ds.Mountpoint, line[4])
setString(&ds.Compression, line[5])
setString(&ds.Type, line[6])
if err = setUint(&ds.Volsize, line[7]); err != nil {
return err
}
if err = setUint(&ds.Quota, line[8]); err != nil {
return err
}
if runtime.GOOS == "solaris" {
return nil
}
if err = setUint(&ds.Written, line[9]); err != nil {
return err
}
if err = setUint(&ds.Logicalused, line[10]); err != nil {
return err
}
if err = setUint(&ds.Usedbydataset, line[11]); err != nil {
return err
}
return nil
return err
}
/*
@@ -281,8 +264,7 @@ func parseInodeChanges(lines [][]string) ([]*InodeChange, error) {
}
func listByType(t, filter string) ([]*Dataset, error) {
args := []string{"list", "-rHp", "-t", t, "-o", dsPropListOptions}
args := []string{"get", "-rHp", "-t", t, "all"}
if filter != "" {
args = append(args, filter)
}
@@ -325,8 +307,6 @@ func (z *Zpool) parseLine(line []string) error {
var err error
switch prop {
case "name":
setString(&z.Name, val)
case "health":
setString(&z.Health, val)
case "allocated":
@@ -335,18 +315,6 @@ func (z *Zpool) parseLine(line []string) error {
err = setUint(&z.Size, val)
case "free":
err = setUint(&z.Free, val)
case "fragmentation":
// Trim trailing "%" before parsing uint
err = setUint(&z.Fragmentation, val[:len(val)-1])
case "readonly":
z.ReadOnly = val == "on"
case "freeing":
err = setUint(&z.Freeing, val)
case "leaked":
err = setUint(&z.Leaked, val)
case "dedupratio":
// Trim trailing "x" before parsing float64
z.DedupRatio, err = strconv.ParseFloat(val[:len(val)-1], 64)
}
return err
}

View File

@@ -1,17 +0,0 @@
// +build !solaris
package zfs
import (
"strings"
)
// List of ZFS properties to retrieve from zfs list command on a non-Solaris platform
var dsPropList = []string{"name", "origin", "used", "available", "mountpoint", "compression", "type", "volsize", "quota", "written", "logicalused", "usedbydataset"}
var dsPropListOptions = strings.Join(dsPropList, ",")
// List of Zpool properties to retrieve from zpool list command on a non-Solaris platform
var zpoolPropList = []string{"name", "health", "allocated", "size", "free", "readonly", "dedupratio", "fragmentation", "freeing", "leaked"}
var zpoolPropListOptions = strings.Join(zpoolPropList, ",")
var zpoolArgs = []string{"get", "-p", zpoolPropListOptions}

View File

@@ -1,17 +0,0 @@
// +build solaris
package zfs
import (
"strings"
)
// List of ZFS properties to retrieve from zfs list command on a Solaris platform
var dsPropList = []string{"name", "origin", "used", "available", "mountpoint", "compression", "type", "volsize", "quota"}
var dsPropListOptions = strings.Join(dsPropList, ",")
// List of Zpool properties to retrieve from zpool list command on a non-Solaris platform
var zpoolPropList = []string{"name", "health", "allocated", "size", "free", "readonly", "dedupratio"}
var zpoolPropListOptions = strings.Join(zpoolPropList, ",")
var zpoolArgs = []string{"get", "-p", zpoolPropListOptions}

View File

@@ -32,8 +32,8 @@ type Dataset struct {
Type string
Written uint64
Volsize uint64
Logicalused uint64
Usedbydataset uint64
Logicalused uint64
Quota uint64
}
@@ -92,20 +92,12 @@ type Logger interface {
Log(cmd []string)
}
type defaultLogger struct{}
func (*defaultLogger) Log(cmd []string) {
return
}
var logger Logger = &defaultLogger{}
var logger Logger
// SetLogger set a log handler to log all commands including arguments before
// they are executed
func SetLogger(l Logger) {
if l != nil {
logger = l
}
logger = l
}
// zfs is a helper function to wrap typical calls to zfs.
@@ -145,7 +137,7 @@ func Volumes(filter string) ([]*Dataset, error) {
// GetDataset retrieves a single ZFS dataset by name. This dataset could be
// any valid ZFS dataset type, such as a clone, filesystem, snapshot, or volume.
func GetDataset(name string) (*Dataset, error) {
out, err := zfs("list", "-Hp", "-o", dsPropListOptions, name)
out, err := zfs("get", "-Hp", "all", name)
if err != nil {
return nil, err
}
@@ -180,46 +172,6 @@ func (d *Dataset) Clone(dest string, properties map[string]string) (*Dataset, er
return GetDataset(dest)
}
// Unmount unmounts currently mounted ZFS file systems.
func (d *Dataset) Unmount(force bool) (*Dataset, error) {
if d.Type == DatasetSnapshot {
return nil, errors.New("cannot unmount snapshots")
}
args := make([]string, 1, 3)
args[0] = "umount"
if force {
args = append(args, "-f")
}
args = append(args, d.Name)
_, err := zfs(args...)
if err != nil {
return nil, err
}
return GetDataset(d.Name)
}
// Mount mounts ZFS file systems.
func (d *Dataset) Mount(overlay bool, options []string) (*Dataset, error) {
if d.Type == DatasetSnapshot {
return nil, errors.New("cannot mount snapshots")
}
args := make([]string, 1, 5)
args[0] = "mount"
if overlay {
args = append(args, "-O")
}
if options != nil {
args = append(args, "-o")
args = append(args, strings.Join(options, ","))
}
args = append(args, d.Name)
_, err := zfs(args...)
if err != nil {
return nil, err
}
return GetDataset(d.Name)
}
// ReceiveSnapshot receives a ZFS stream from the input io.Reader, creates a
// new snapshot with the specified name, and streams the input data into the
// newly-created snapshot.
@@ -315,26 +267,6 @@ func (d *Dataset) GetProperty(key string) (string, error) {
return out[0][2], nil
}
// Rename renames a dataset.
func (d *Dataset) Rename(name string, createParent bool, recursiveRenameSnapshots bool) (*Dataset, error) {
args := make([]string, 3, 5)
args[0] = "rename"
args[1] = d.Name
args[2] = name
if createParent {
args = append(args, "-p")
}
if recursiveRenameSnapshots {
args = append(args, "-r")
}
_, err := zfs(args...)
if err != nil {
return d, err
}
return GetDataset(name)
}
// Snapshots returns a slice of all ZFS snapshots of a given dataset.
func (d *Dataset) Snapshots() ([]*Dataset, error) {
return Snapshots(d.Name)
@@ -403,14 +335,13 @@ func (d *Dataset) Rollback(destroyMoreRecent bool) error {
// A recursion depth may be specified, or a depth of 0 allows unlimited
// recursion.
func (d *Dataset) Children(depth uint64) ([]*Dataset, error) {
args := []string{"list"}
args := []string{"get", "-t", "all", "-Hp", "all"}
if depth > 0 {
args = append(args, "-d")
args = append(args, strconv.FormatUint(depth, 10))
} else {
args = append(args, "-r")
}
args = append(args, "-t", "all", "-Hp", "-o", dsPropListOptions)
args = append(args, d.Name)
out, err := zfs(args...)

View File

@@ -15,16 +15,11 @@ const (
// 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
Name string
Health string
Allocated uint64
Size uint64
Free uint64
}
// zpool is a helper function to wrap typical calls to zpool.
@@ -35,9 +30,7 @@ func zpool(arg ...string) ([][]string, error) {
// GetZpool retrieves a single ZFS zpool by name.
func GetZpool(name string) (*Zpool, error) {
args := zpoolArgs
args = append(args, name)
out, err := zpool(args...)
out, err := zpool("get", "all", "-p", name)
if err != nil {
return nil, err
}