Gofmt megacommit.
This commit is contained in:
+8
-10
@@ -1,11 +1,11 @@
|
||||
package zfs
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os/exec"
|
||||
"io"
|
||||
"bufio"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
type DatasetMapping interface {
|
||||
@@ -26,10 +26,9 @@ func (m GlobMapping) Map(source DatasetPath) (target DatasetPath, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
target = make([]string, 0, len(source) + len(m.TargetRoot))
|
||||
target = make([]string, 0, len(source)+len(m.TargetRoot))
|
||||
target = append(target, m.TargetRoot...)
|
||||
|
||||
|
||||
for si, sc := range source {
|
||||
target = append(target, sc)
|
||||
if si < len(m.PrefixPath) {
|
||||
@@ -87,7 +86,7 @@ type ExecMapping struct {
|
||||
Args []string
|
||||
}
|
||||
|
||||
func NewExecMapping(name string, args... string) (m *ExecMapping) {
|
||||
func NewExecMapping(name string, args ...string) (m *ExecMapping) {
|
||||
m = &ExecMapping{
|
||||
Name: name,
|
||||
Args: args,
|
||||
@@ -100,7 +99,6 @@ func (m ExecMapping) Map(source DatasetPath) (target DatasetPath, err error) {
|
||||
var stdin io.Writer
|
||||
var stdout io.Reader
|
||||
|
||||
|
||||
cmd := exec.Command(m.Name, m.Args...)
|
||||
|
||||
if stdin, err = cmd.StdinPipe(); err != nil {
|
||||
@@ -124,7 +122,7 @@ func (m ExecMapping) Map(source DatasetPath) (target DatasetPath, err error) {
|
||||
}
|
||||
}()
|
||||
|
||||
if _, err = io.WriteString(stdin, source.ToString() + "\n"); err != nil {
|
||||
if _, err = io.WriteString(stdin, source.ToString()+"\n"); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -136,8 +134,8 @@ func (m ExecMapping) Map(source DatasetPath) (target DatasetPath, err error) {
|
||||
t := resp.Text()
|
||||
|
||||
switch {
|
||||
case t == "NOMAP":
|
||||
return nil, NoMatchError
|
||||
case t == "NOMAP":
|
||||
return nil, NoMatchError
|
||||
}
|
||||
|
||||
target = toDatasetPath(t) // TODO discover garbage?
|
||||
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
package zfs
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGlobMapping(t *testing.T) {
|
||||
@@ -40,7 +40,7 @@ func TestComboMapping(t *testing.T) {
|
||||
}
|
||||
|
||||
c := ComboMapping{
|
||||
Mappings: []DatasetMapping{m1,m2},
|
||||
Mappings: []DatasetMapping{m1, m2},
|
||||
}
|
||||
|
||||
var r DatasetPath
|
||||
@@ -48,7 +48,7 @@ func TestComboMapping(t *testing.T) {
|
||||
|
||||
p := toDatasetPath("a/b/q")
|
||||
|
||||
r,err = m2.Map(p)
|
||||
r, err = m2.Map(p)
|
||||
assert.Equal(t, NoMatchError, err)
|
||||
|
||||
r, err = c.Map(p)
|
||||
|
||||
+9
-9
@@ -1,14 +1,14 @@
|
||||
package zfs
|
||||
|
||||
import (
|
||||
"github.com/zrepl/zrepl/model"
|
||||
"os/exec"
|
||||
"bufio"
|
||||
"strings"
|
||||
"errors"
|
||||
"io"
|
||||
"fmt"
|
||||
"github.com/zrepl/zrepl/model"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func InitialSend(snapshot string) (io.Reader, error) {
|
||||
@@ -62,9 +62,9 @@ func zfsList(root string, filter DatasetFilter) (datasets []DatasetPath, err err
|
||||
const ZFS_LIST_FIELD_COUNT = 1
|
||||
|
||||
cmd := exec.Command(ZFS_BINARY, "list", "-H", "-r",
|
||||
"-t", "filesystem,volume",
|
||||
"-o", "name",
|
||||
root)
|
||||
"-t", "filesystem,volume",
|
||||
"-o", "name",
|
||||
root)
|
||||
|
||||
var stdout io.Reader
|
||||
var stderr io.Reader
|
||||
@@ -103,9 +103,9 @@ func zfsList(root string, filter DatasetFilter) (datasets []DatasetPath, err err
|
||||
|
||||
stderrOutput, err := ioutil.ReadAll(stderr)
|
||||
|
||||
if waitErr:= cmd.Wait(); waitErr != nil {
|
||||
if waitErr := cmd.Wait(); waitErr != nil {
|
||||
err := ZFSError{
|
||||
Stderr: stderrOutput,
|
||||
Stderr: stderrOutput,
|
||||
WaitErr: waitErr,
|
||||
}
|
||||
return nil, err
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package zfs
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestZFSListHandlesProducesZFSErrorOnNonZeroExit(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user