format source tree using goimports

This commit is contained in:
Christian Schwarz 2019-03-22 19:41:12 +01:00
parent 5324f29693
commit afed762774
93 changed files with 585 additions and 463 deletions

View File

@ -30,6 +30,9 @@ generate: #not part of the build, must do that manually
protoc -I=replication/logic/pdu --go_out=plugins=grpc:replication/logic/pdu replication/logic/pdu/pdu.proto protoc -I=replication/logic/pdu --go_out=plugins=grpc:replication/logic/pdu replication/logic/pdu/pdu.proto
go generate -x ./... go generate -x ./...
format:
goimports -srcdir . -local 'github.com/zrepl/zrepl' -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")
build: build:
@echo "INFO: In case of missing dependencies, run 'make vendordeps'" @echo "INFO: In case of missing dependencies, run 'make vendordeps'"
$(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl" $(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl"

View File

@ -11,7 +11,9 @@
package main package main
import ( import (
"fmt"
_ "fmt" _ "fmt"
_ "github.com/alvaroloes/enumer" _ "github.com/alvaroloes/enumer"
_ "github.com/golang/protobuf/protoc-gen-go" _ "github.com/golang/protobuf/protoc-gen-go"
_ "golang.org/x/tools/cmd/stringer" _ "golang.org/x/tools/cmd/stringer"

View File

@ -2,10 +2,12 @@ package cli
import ( import (
"fmt" "fmt"
"os"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/config"
"os"
) )
var rootArgs struct { var rootArgs struct {
@ -110,7 +112,6 @@ func addSubcommandToCobraCmd(c *cobra.Command, s *Subcommand) {
c.AddCommand(&cmd) c.AddCommand(&cmd)
} }
func Run() { func Run() {
if err := rootCmd.Execute(); err != nil { if err := rootCmd.Execute(); err != nil {
os.Exit(1) os.Exit(1)

View File

@ -3,16 +3,18 @@ package client
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"os"
"github.com/kr/pretty" "github.com/kr/pretty"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"github.com/zrepl/yaml-config" "github.com/zrepl/yaml-config"
"github.com/zrepl/zrepl/cli" "github.com/zrepl/zrepl/cli"
"github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/daemon/job" "github.com/zrepl/zrepl/daemon/job"
"github.com/zrepl/zrepl/daemon/logging" "github.com/zrepl/zrepl/daemon/logging"
"github.com/zrepl/zrepl/logger" "github.com/zrepl/zrepl/logger"
"os"
) )
var configcheckArgs struct { var configcheckArgs struct {
@ -71,7 +73,6 @@ var ConfigcheckCmd = &cli.Subcommand{
} }
} }
whatMap := map[string]func(){ whatMap := map[string]func(){
"all": func() { "all": func() {
o := struct { o := struct {
@ -109,4 +110,3 @@ var ConfigcheckCmd = &cli.Subcommand{
} }
}, },
} }

View File

@ -4,10 +4,11 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"github.com/pkg/errors"
"io" "io"
"net" "net"
"net/http" "net/http"
"github.com/pkg/errors"
) )
func controlHttpClient(sockpath string) (client http.Client, err error) { func controlHttpClient(sockpath string) (client http.Client, err error) {

View File

@ -6,6 +6,7 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"github.com/zrepl/zrepl/zfs" "github.com/zrepl/zrepl/zfs"
"github.com/zrepl/zrepl/cli" "github.com/zrepl/zrepl/cli"

View File

@ -2,11 +2,12 @@ package client
import ( import (
"errors" "errors"
"log"
"os"
"github.com/zrepl/zrepl/cli" "github.com/zrepl/zrepl/cli"
"github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/daemon" "github.com/zrepl/zrepl/daemon"
"log"
"os"
) )
var pprofArgs struct { var pprofArgs struct {

View File

@ -2,6 +2,7 @@ package client
import ( import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/zrepl/zrepl/cli" "github.com/zrepl/zrepl/cli"
"github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/daemon" "github.com/zrepl/zrepl/daemon"

View File

@ -2,15 +2,6 @@ package client
import ( import (
"fmt" "fmt"
"github.com/gdamore/tcell/termbox"
"github.com/pkg/errors"
"github.com/spf13/pflag"
"github.com/zrepl/yaml-config"
"github.com/zrepl/zrepl/cli"
"github.com/zrepl/zrepl/daemon"
"github.com/zrepl/zrepl/daemon/job"
"github.com/zrepl/zrepl/daemon/pruner"
"github.com/zrepl/zrepl/replication/report"
"io" "io"
"math" "math"
"net/http" "net/http"
@ -19,6 +10,17 @@ import (
"strings" "strings"
"sync" "sync"
"time" "time"
"github.com/gdamore/tcell/termbox"
"github.com/pkg/errors"
"github.com/spf13/pflag"
"github.com/zrepl/yaml-config"
"github.com/zrepl/zrepl/cli"
"github.com/zrepl/zrepl/daemon"
"github.com/zrepl/zrepl/daemon/job"
"github.com/zrepl/zrepl/daemon/pruner"
"github.com/zrepl/zrepl/replication/report"
) )
type byteProgressMeasurement struct { type byteProgressMeasurement struct {
@ -53,8 +55,7 @@ func (p *bytesProgressHistory) Update(currentVal int64) (bytesPerSecondAvg int64
return 0, 0 return 0, 0
} }
deltaV := currentVal - p.last.val
deltaV := currentVal - p.last.val;
deltaT := time.Now().Sub(p.last.time) deltaT := time.Now().Sub(p.last.time)
rate := float64(deltaV) / deltaT.Seconds() rate := float64(deltaV) / deltaT.Seconds()
@ -159,7 +160,6 @@ func (t *tui) addIndent(indent int) {
t.moveLine(0, 0) t.moveLine(0, 0)
} }
var statusFlags struct { var statusFlags struct {
Raw bool Raw bool
} }
@ -471,7 +471,8 @@ func (t *tui) renderPrunerReport(r *pruner.Report) {
} }
switch state { switch state {
case pruner.Plan: fallthrough case pruner.Plan:
fallthrough
case pruner.PlanErr: case pruner.PlanErr:
return return
} }
@ -560,7 +561,6 @@ func rightPad(str string, length int, pad string) string {
return str + times(pad, length-len(str)) return str + times(pad, length-len(str))
} }
func leftPad(str string, length int, pad string) string { func leftPad(str string, length int, pad string) string {
if len(str) > length { if len(str) > length {
return str[len(str)-length:] return str[len(str)-length:]

View File

@ -1,13 +1,15 @@
package client package client
import ( import (
"github.com/zrepl/zrepl/cli"
"os" "os"
"github.com/problame/go-netssh"
"github.com/zrepl/zrepl/cli"
"github.com/zrepl/zrepl/config"
"context" "context"
"errors" "errors"
"github.com/problame/go-netssh"
"github.com/zrepl/zrepl/config"
"log" "log"
"path" "path"
) )

View File

@ -2,8 +2,10 @@ package client
import ( import (
"fmt" "fmt"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"github.com/zrepl/zrepl/cli" "github.com/zrepl/zrepl/cli"
"github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/daemon/filters" "github.com/zrepl/zrepl/daemon/filters"
@ -51,8 +53,10 @@ func runTestFilterCmd(subcommand *cli.Subcommand, args []string) error {
return err return err
} }
switch j := job.Ret.(type) { switch j := job.Ret.(type) {
case *config.SourceJob: confFilter = j.Filesystems case *config.SourceJob:
case *config.PushJob: confFilter = j.Filesystems confFilter = j.Filesystems
case *config.PushJob:
confFilter = j.Filesystems
default: default:
return fmt.Errorf("job type %T does not have filesystems filter", j) return fmt.Errorf("job type %T does not have filesystems filter", j)
} }

View File

@ -2,12 +2,14 @@ package client
import ( import (
"fmt" "fmt"
"os"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"github.com/zrepl/zrepl/cli" "github.com/zrepl/zrepl/cli"
"github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/daemon" "github.com/zrepl/zrepl/daemon"
"github.com/zrepl/zrepl/version" "github.com/zrepl/zrepl/version"
"os"
) )
var versionArgs struct { var versionArgs struct {

View File

@ -2,8 +2,6 @@ package config
import ( import (
"fmt" "fmt"
"github.com/pkg/errors"
"github.com/zrepl/yaml-config"
"io/ioutil" "io/ioutil"
"log/syslog" "log/syslog"
"os" "os"
@ -11,6 +9,9 @@ import (
"regexp" "regexp"
"strconv" "strconv"
"time" "time"
"github.com/pkg/errors"
"github.com/zrepl/yaml-config"
) )
type Config struct { type Config struct {
@ -34,11 +35,16 @@ type JobEnum struct {
func (j JobEnum) Name() string { func (j JobEnum) Name() string {
var name string var name string
switch v := j.Ret.(type) { switch v := j.Ret.(type) {
case *SnapJob: name = v.Name case *SnapJob:
case *PushJob: name = v.Name name = v.Name
case *SinkJob: name = v.Name case *PushJob:
case *PullJob: name = v.Name name = v.Name
case *SourceJob: name = v.Name case *SinkJob:
name = v.Name
case *PullJob:
name = v.Name
case *SourceJob:
name = v.Name
default: default:
panic(fmt.Sprintf("unknown job type %T", v)) panic(fmt.Sprintf("unknown job type %T", v))
} }
@ -448,26 +454,46 @@ func (t *SyslogFacility) UnmarshalYAML(u func(interface{}, bool) error) (err err
} }
var level syslog.Priority var level syslog.Priority
switch s { switch s {
case "kern": level = syslog.LOG_KERN case "kern":
case "user": level = syslog.LOG_USER level = syslog.LOG_KERN
case "mail": level = syslog.LOG_MAIL case "user":
case "daemon": level = syslog.LOG_DAEMON level = syslog.LOG_USER
case "auth": level = syslog.LOG_AUTH case "mail":
case "syslog": level = syslog.LOG_SYSLOG level = syslog.LOG_MAIL
case "lpr": level = syslog.LOG_LPR case "daemon":
case "news": level = syslog.LOG_NEWS level = syslog.LOG_DAEMON
case "uucp": level = syslog.LOG_UUCP case "auth":
case "cron": level = syslog.LOG_CRON level = syslog.LOG_AUTH
case "authpriv": level = syslog.LOG_AUTHPRIV case "syslog":
case "ftp": level = syslog.LOG_FTP level = syslog.LOG_SYSLOG
case "local0": level = syslog.LOG_LOCAL0 case "lpr":
case "local1": level = syslog.LOG_LOCAL1 level = syslog.LOG_LPR
case "local2": level = syslog.LOG_LOCAL2 case "news":
case "local3": level = syslog.LOG_LOCAL3 level = syslog.LOG_NEWS
case "local4": level = syslog.LOG_LOCAL4 case "uucp":
case "local5": level = syslog.LOG_LOCAL5 level = syslog.LOG_UUCP
case "local6": level = syslog.LOG_LOCAL6 case "cron":
case "local7": level = syslog.LOG_LOCAL7 level = syslog.LOG_CRON
case "authpriv":
level = syslog.LOG_AUTHPRIV
case "ftp":
level = syslog.LOG_FTP
case "local0":
level = syslog.LOG_LOCAL0
case "local1":
level = syslog.LOG_LOCAL1
case "local2":
level = syslog.LOG_LOCAL2
case "local3":
level = syslog.LOG_LOCAL3
case "local4":
level = syslog.LOG_LOCAL4
case "local5":
level = syslog.LOG_LOCAL5
case "local6":
level = syslog.LOG_LOCAL6
case "local7":
level = syslog.LOG_LOCAL7
default: default:
return fmt.Errorf("invalid syslog level: %q", s) return fmt.Errorf("invalid syslog level: %q", s)
} }

View File

@ -2,11 +2,12 @@ package config
import ( import (
"fmt" "fmt"
"log/syslog"
"testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/zrepl/yaml-config" "github.com/zrepl/yaml-config"
"log/syslog"
"testing"
) )
func testValidGlobalSection(t *testing.T, s string) *Config { func testValidGlobalSection(t *testing.T, s string) *Config {

View File

@ -2,6 +2,7 @@ package config
import ( import (
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

View File

@ -2,9 +2,10 @@ package config
import ( import (
"fmt" "fmt"
"github.com/stretchr/testify/assert"
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert"
) )
func TestSnapshotting(t *testing.T) { func TestSnapshotting(t *testing.T) {

View File

@ -12,6 +12,7 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/zrepl/zrepl/daemon/job" "github.com/zrepl/zrepl/daemon/job"
"github.com/zrepl/zrepl/daemon/nethelpers" "github.com/zrepl/zrepl/daemon/nethelpers"
"github.com/zrepl/zrepl/logger" "github.com/zrepl/zrepl/logger"

View File

@ -3,8 +3,16 @@ package daemon
import ( import (
"context" "context"
"fmt" "fmt"
"os"
"os/signal"
"strings"
"sync"
"syscall"
"time"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/daemon/job" "github.com/zrepl/zrepl/daemon/job"
"github.com/zrepl/zrepl/daemon/job/reset" "github.com/zrepl/zrepl/daemon/job/reset"
@ -12,12 +20,6 @@ import (
"github.com/zrepl/zrepl/daemon/logging" "github.com/zrepl/zrepl/daemon/logging"
"github.com/zrepl/zrepl/logger" "github.com/zrepl/zrepl/logger"
"github.com/zrepl/zrepl/version" "github.com/zrepl/zrepl/version"
"os"
"os/signal"
"strings"
"sync"
"syscall"
"time"
) )
func Run(conf *config.Config) error { func Run(conf *config.Config) error {
@ -79,7 +81,6 @@ func Run(conf *config.Config) error {
jobs.start(ctx, job, true) jobs.start(ctx, job, true)
} }
log.Info("starting daemon") log.Info("starting daemon")
// start regular jobs // start regular jobs

View File

@ -2,10 +2,12 @@ package filters
import ( import (
"fmt" "fmt"
"strings"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/zrepl/zrepl/endpoint" "github.com/zrepl/zrepl/endpoint"
"github.com/zrepl/zrepl/zfs" "github.com/zrepl/zrepl/zfs"
"strings"
) )
type DatasetMapFilter struct { type DatasetMapFilter struct {

View File

@ -1,8 +1,9 @@
package filters package filters
import ( import (
"github.com/zrepl/zrepl/zfs"
"strings" "strings"
"github.com/zrepl/zrepl/zfs"
) )
type AnyFSVFilter struct{} type AnyFSVFilter struct{}
@ -17,7 +18,6 @@ func (AnyFSVFilter) Filter(t zfs.VersionType, name string) (accept bool, err err
return true, nil return true, nil
} }
type PrefixFilter struct { type PrefixFilter struct {
prefix string prefix string
fstype zfs.VersionType fstype zfs.VersionType

View File

@ -6,6 +6,7 @@ import (
"strings" "strings"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/config"
) )

View File

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/zrepl/zrepl/logger" "github.com/zrepl/zrepl/logger"
"github.com/zrepl/zrepl/zfs" "github.com/zrepl/zrepl/zfs"
) )
@ -29,7 +30,6 @@ func WithLogger(ctx context.Context, l Logger) context.Context {
return context.WithValue(ctx, contextKeyLog, l) return context.WithValue(ctx, contextKeyLog, l)
} }
type Job interface { type Job interface {
Name() string Name() string
Run(ctx context.Context) Run(ctx context.Context)
@ -94,12 +94,14 @@ func (s *Status) UnmarshalJSON(in []byte) (err error) {
var st SnapJobStatus var st SnapJobStatus
err = json.Unmarshal(jobJSON, &st) err = json.Unmarshal(jobJSON, &st)
s.JobSpecific = &st s.JobSpecific = &st
case TypePull: fallthrough case TypePull:
fallthrough
case TypePush: case TypePush:
var st ActiveSideStatus var st ActiveSideStatus
err = json.Unmarshal(jobJSON, &st) err = json.Unmarshal(jobJSON, &st)
s.JobSpecific = &st s.JobSpecific = &st
case TypeSource: fallthrough case TypeSource:
fallthrough
case TypeSink: case TypeSink:
var st PassiveStatus var st PassiveStatus
err = json.Unmarshal(jobJSON, &st) err = json.Unmarshal(jobJSON, &st)

View File

@ -7,6 +7,7 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/daemon/filters" "github.com/zrepl/zrepl/daemon/filters"
"github.com/zrepl/zrepl/daemon/job/wakeup" "github.com/zrepl/zrepl/daemon/job/wakeup"

View File

@ -4,11 +4,13 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"time"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/go-logfmt/logfmt" "github.com/go-logfmt/logfmt"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/zrepl/zrepl/logger" "github.com/zrepl/zrepl/logger"
"time"
) )
const ( const (

View File

@ -4,12 +4,14 @@ import (
"bytes" "bytes"
"context" "context"
"crypto/tls" "crypto/tls"
"github.com/pkg/errors"
"github.com/zrepl/zrepl/logger"
"io" "io"
"log/syslog" "log/syslog"
"net" "net"
"time" "time"
"github.com/pkg/errors"
"github.com/zrepl/zrepl/logger"
) )
type EntryFormatter interface { type EntryFormatter interface {

View File

@ -1,10 +1,11 @@
package nethelpers package nethelpers
import ( import (
"github.com/pkg/errors"
"net" "net"
"os" "os"
"path/filepath" "path/filepath"
"github.com/pkg/errors"
) )
func PreparePrivateSockpath(sockpath string) error { func PreparePrivateSockpath(sockpath string) error {

View File

@ -2,15 +2,17 @@ package daemon
import ( import (
"context" "context"
"net"
"net/http"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/daemon/job" "github.com/zrepl/zrepl/daemon/job"
"github.com/zrepl/zrepl/logger" "github.com/zrepl/zrepl/logger"
"github.com/zrepl/zrepl/rpc/dataconn/frameconn" "github.com/zrepl/zrepl/rpc/dataconn/frameconn"
"github.com/zrepl/zrepl/zfs" "github.com/zrepl/zrepl/zfs"
"net"
"net/http"
) )
type prometheusJob struct { type prometheusJob struct {
@ -93,4 +95,3 @@ func (o prometheusJobOutlet) WriteEntry(entry logger.Entry) error {
prom.taskLogEntries.WithLabelValues(o.jobName, entry.Level.String()).Inc() prom.taskLogEntries.WithLabelValues(o.jobName, entry.Level.String()).Inc()
return nil return nil
} }

View File

@ -3,17 +3,19 @@ package pruner
import ( import (
"context" "context"
"fmt" "fmt"
"sort"
"strings"
"sync"
"time"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/logger" "github.com/zrepl/zrepl/logger"
"github.com/zrepl/zrepl/pruning" "github.com/zrepl/zrepl/pruning"
"github.com/zrepl/zrepl/replication/logic/pdu" "github.com/zrepl/zrepl/replication/logic/pdu"
"github.com/zrepl/zrepl/util/envconst" "github.com/zrepl/zrepl/util/envconst"
"sort"
"strings"
"sync"
"time"
) )
// Try to keep it compatible with gitub.com/zrepl/zrepl/endpoint.Endpoint // Try to keep it compatible with gitub.com/zrepl/zrepl/endpoint.Endpoint
@ -524,7 +526,6 @@ tfss_loop:
} }
}) })
} }
// attempts to exec pfs, puts it back into the queue with the result // attempts to exec pfs, puts it back into the queue with the result

View File

@ -79,5 +79,4 @@ func(q *execQueue) Put(fs *fs, err error, done bool) {
}) })
q.mtx.Unlock() q.mtx.Unlock()
} }

View File

@ -1,18 +1,19 @@
package snapper package snapper
import ( import (
"github.com/zrepl/zrepl/config"
"github.com/pkg/errors"
"time"
"context" "context"
"github.com/zrepl/zrepl/daemon/filters"
"fmt" "fmt"
"github.com/zrepl/zrepl/zfs"
"sort" "sort"
"github.com/zrepl/zrepl/logger"
"sync" "sync"
) "time"
"github.com/pkg/errors"
"github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/daemon/filters"
"github.com/zrepl/zrepl/logger"
"github.com/zrepl/zrepl/zfs"
)
//go:generate stringer -type=SnapState //go:generate stringer -type=SnapState
type SnapState uint type SnapState uint
@ -386,4 +387,3 @@ func findSyncPoint(log Logger, fss []*zfs.DatasetPath, prefix string, interval t
return snaptimes[0].time, nil return snaptimes[0].time, nil
} }

View File

@ -3,6 +3,7 @@ package snapper
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/daemon/filters" "github.com/zrepl/zrepl/daemon/filters"
) )

View File

@ -2,6 +2,7 @@ package endpoint
import ( import (
"context" "context"
"github.com/zrepl/zrepl/logger" "github.com/zrepl/zrepl/logger"
) )

View File

@ -7,6 +7,7 @@ import (
"path" "path"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/zrepl/zrepl/replication/logic/pdu" "github.com/zrepl/zrepl/replication/logic/pdu"
"github.com/zrepl/zrepl/util/chainlock" "github.com/zrepl/zrepl/util/chainlock"
"github.com/zrepl/zrepl/zfs" "github.com/zrepl/zrepl/zfs"

View File

@ -4,10 +4,11 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/fatih/color"
"github.com/pkg/errors"
"sync" "sync"
"time" "time"
"github.com/fatih/color"
"github.com/pkg/errors"
) )
type Level int type Level int

View File

@ -2,10 +2,12 @@ package logger_test
import ( import (
"fmt" "fmt"
"github.com/kr/pretty"
"github.com/zrepl/zrepl/logger"
"testing" "testing"
"time" "time"
"github.com/kr/pretty"
"github.com/zrepl/zrepl/logger"
) )
type TestOutlet struct { type TestOutlet struct {

View File

@ -2,12 +2,14 @@ package pruning
import ( import (
"fmt" "fmt"
"github.com/pkg/errors"
"github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/pruning/retentiongrid"
"regexp" "regexp"
"sort" "sort"
"time" "time"
"github.com/pkg/errors"
"github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/pruning/retentiongrid"
) )
// KeepGrid fits snapshots that match a given regex into a retentiongrid.Grid, // KeepGrid fits snapshots that match a given regex into a retentiongrid.Grid,

View File

@ -1,8 +1,9 @@
package pruning package pruning
import ( import (
"github.com/stretchr/testify/assert"
"testing" "testing"
"github.com/stretchr/testify/assert"
) )
func TestShallowCopySnapList(t *testing.T) { func TestShallowCopySnapList(t *testing.T) {

View File

@ -1,8 +1,9 @@
package pruning package pruning
import ( import (
"github.com/pkg/errors"
"sort" "sort"
"github.com/pkg/errors"
) )
type KeepLastN struct { type KeepLastN struct {

View File

@ -1,9 +1,10 @@
package pruning package pruning
import ( import (
"github.com/stretchr/testify/assert"
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert"
) )
func TestKeepLastN(t *testing.T) { func TestKeepLastN(t *testing.T) {

View File

@ -2,9 +2,11 @@ package pruning
import ( import (
"fmt" "fmt"
"github.com/pkg/errors"
"github.com/zrepl/zrepl/config"
"time" "time"
"github.com/pkg/errors"
"github.com/zrepl/zrepl/config"
) )
type KeepRule interface { type KeepRule interface {

View File

@ -2,11 +2,12 @@ package retentiongrid
import ( import (
"fmt" "fmt"
"github.com/stretchr/testify/assert"
"strconv" "strconv"
"strings" "strings"
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert"
) )
type retentionIntervalStub struct { type retentionIntervalStub struct {

View File

@ -10,11 +10,12 @@ import (
"sync" "sync"
"time" "time"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"github.com/zrepl/zrepl/replication/report" "github.com/zrepl/zrepl/replication/report"
"github.com/zrepl/zrepl/util/chainlock" "github.com/zrepl/zrepl/util/chainlock"
"github.com/zrepl/zrepl/util/envconst" "github.com/zrepl/zrepl/util/envconst"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
) )
type interval struct { type interval struct {

View File

@ -10,6 +10,7 @@ import (
"time" "time"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/zrepl/zrepl/replication/report" "github.com/zrepl/zrepl/replication/report"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"

View File

@ -2,8 +2,9 @@ package pdu
import ( import (
"fmt" "fmt"
"github.com/zrepl/zrepl/zfs"
"time" "time"
"github.com/zrepl/zrepl/zfs"
) )
func (v *FilesystemVersion) RelName() string { func (v *FilesystemVersion) RelName() string {

View File

@ -1,9 +1,10 @@
package pdu package pdu
import ( import (
"github.com/stretchr/testify/assert"
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert"
) )
func TestFilesystemVersion_RelName(t *testing.T) { func TestFilesystemVersion_RelName(t *testing.T) {

View File

@ -26,7 +26,7 @@ type Endpoint interface {
ListFilesystems(ctx context.Context, req *pdu.ListFilesystemReq) (*pdu.ListFilesystemRes, error) ListFilesystems(ctx context.Context, req *pdu.ListFilesystemReq) (*pdu.ListFilesystemRes, error)
ListFilesystemVersions(ctx context.Context, req *pdu.ListFilesystemVersionsReq) (*pdu.ListFilesystemVersionsRes, error) ListFilesystemVersions(ctx context.Context, req *pdu.ListFilesystemVersionsReq) (*pdu.ListFilesystemVersionsRes, error)
DestroySnapshots(ctx context.Context, req *pdu.DestroySnapshotsReq) (*pdu.DestroySnapshotsRes, error) DestroySnapshots(ctx context.Context, req *pdu.DestroySnapshotsReq) (*pdu.DestroySnapshotsRes, error)
WaitForConnectivity(ctx context.Context) (error) WaitForConnectivity(ctx context.Context) error
} }
type Sender interface { type Sender interface {

View File

@ -7,6 +7,7 @@ import (
"strings" "strings"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"github.com/zrepl/zrepl/replication/logic/pdu" "github.com/zrepl/zrepl/replication/logic/pdu"
"github.com/zrepl/zrepl/rpc/dataconn/stream" "github.com/zrepl/zrepl/rpc/dataconn/stream"
"github.com/zrepl/zrepl/transport" "github.com/zrepl/zrepl/transport"
@ -214,7 +215,6 @@ func (c *Client) ReqRecv(ctx context.Context, req *pdu.ReceiveReq, streamCopier
return res.res, cause return res.res, cause
} }
func (c *Client) ReqPing(ctx context.Context, req *pdu.PingReq) (*pdu.PingRes, error) { func (c *Client) ReqPing(ctx context.Context, req *pdu.PingReq) (*pdu.PingRes, error) {
conn, err := c.getWire(ctx) conn, err := c.getWire(ctx)
if err != nil { if err != nil {

View File

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"github.com/zrepl/zrepl/logger" "github.com/zrepl/zrepl/logger"
"github.com/zrepl/zrepl/replication/logic/pdu" "github.com/zrepl/zrepl/replication/logic/pdu"
"github.com/zrepl/zrepl/rpc/dataconn/stream" "github.com/zrepl/zrepl/rpc/dataconn/stream"

View File

@ -12,6 +12,7 @@ import (
"time" "time"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/zrepl/zrepl/rpc/dataconn/base2bufpool" "github.com/zrepl/zrepl/rpc/dataconn/base2bufpool"
"github.com/zrepl/zrepl/rpc/dataconn/timeoutconn" "github.com/zrepl/zrepl/rpc/dataconn/timeoutconn"
) )

View File

@ -34,4 +34,3 @@ func (f *shutdownFSM) IsShuttingDown() bool {
defer f.mtx.Unlock() defer f.mtx.Unlock()
return f.state != shutdownStateOpen return f.state != shutdownStateOpen
} }

View File

@ -19,4 +19,3 @@ func TestIsPublicFrameType(t *testing.T) {
assert.True(t, IsPublicFrameType(255)) assert.True(t, IsPublicFrameType(255))
assert.False(t, IsPublicFrameType(rstFrameType)) assert.False(t, IsPublicFrameType(rstFrameType))
} }

View File

@ -5,6 +5,7 @@ import (
"time" "time"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/zrepl/zrepl/rpc/dataconn/frameconn" "github.com/zrepl/zrepl/rpc/dataconn/frameconn"
) )

View File

@ -11,6 +11,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/zrepl/zrepl/logger" "github.com/zrepl/zrepl/logger"
"github.com/zrepl/zrepl/rpc/dataconn/heartbeatconn" "github.com/zrepl/zrepl/rpc/dataconn/heartbeatconn"
"github.com/zrepl/zrepl/util/socketpair" "github.com/zrepl/zrepl/util/socketpair"

View File

@ -11,6 +11,7 @@ import (
netssh "github.com/problame/go-netssh" netssh "github.com/problame/go-netssh"
"github.com/zrepl/yaml-config" "github.com/zrepl/yaml-config"
"github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/transport" "github.com/zrepl/zrepl/transport"
transportconfig "github.com/zrepl/zrepl/transport/fromconfig" transportconfig "github.com/zrepl/zrepl/transport/fromconfig"

View File

@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/zrepl/zrepl/util/socketpair" "github.com/zrepl/zrepl/util/socketpair"
) )

View File

@ -18,11 +18,12 @@ import (
"net" "net"
"time" "time"
"github.com/zrepl/zrepl/logger"
"github.com/zrepl/zrepl/transport"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials"
"google.golang.org/grpc/peer" "google.golang.org/grpc/peer"
"github.com/zrepl/zrepl/logger"
"github.com/zrepl/zrepl/transport"
) )
type Logger = logger.Logger type Logger = logger.Logger

View File

@ -5,10 +5,11 @@ package pdu
import ( import (
fmt "fmt" fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto" proto "github.com/golang/protobuf/proto"
context "golang.org/x/net/context" context "golang.org/x/net/context"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
math "math"
) )
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.

View File

@ -25,8 +25,9 @@ package netadaptor
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/zrepl/zrepl/logger"
"net" "net"
"github.com/zrepl/zrepl/logger"
"github.com/zrepl/zrepl/transport" "github.com/zrepl/zrepl/transport"
) )

View File

@ -12,6 +12,7 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/zrepl/zrepl/replication/logic" "github.com/zrepl/zrepl/replication/logic"
"github.com/zrepl/zrepl/replication/logic/pdu" "github.com/zrepl/zrepl/replication/logic/pdu"
"github.com/zrepl/zrepl/rpc/dataconn" "github.com/zrepl/zrepl/rpc/dataconn"

View File

@ -115,4 +115,3 @@ package rpc
// - remove the comments // // - remove the comments //
// - vim: set virtualedit+=all // - vim: set virtualedit+=all
// - vim: set ft=text // - vim: set ft=text

View File

@ -4,8 +4,8 @@ import (
"context" "context"
"time" "time"
"github.com/zrepl/zrepl/transport"
"github.com/zrepl/zrepl/rpc/transportmux" "github.com/zrepl/zrepl/rpc/transportmux"
"github.com/zrepl/zrepl/transport"
"github.com/zrepl/zrepl/util/envconst" "github.com/zrepl/zrepl/util/envconst"
) )

View File

@ -64,7 +64,7 @@ func (l *demuxListener) Close() error { return nil } // TODO
// This is a protocol constant, changing it breaks the wire protocol. // This is a protocol constant, changing it breaks the wire protocol.
const LabelLen = 64 const LabelLen = 64
func padLabel(out []byte, label string) (error) { func padLabel(out []byte, label string) error {
if len(label) > LabelLen { if len(label) > LabelLen {
return fmt.Errorf("label %q exceeds max length (is %d, max %d)", label, len(label), LabelLen) return fmt.Errorf("label %q exceeds max length (is %d, max %d)", label, len(label), LabelLen)
} }
@ -202,4 +202,3 @@ func MuxConnecter(rawConnecter transport.Connecter, labels []string, timeout tim
} }
return ret, nil return ret, nil
} }

View File

@ -39,7 +39,7 @@ func (e HandshakeError) Temporary() bool {
if e.isAcceptError { if e.isAcceptError {
return true return true
} }
te, ok := e.IOError.(interface{ Temporary() bool }); te, ok := e.IOError.(interface{ Temporary() bool })
return ok && te.Temporary() return ok && te.Temporary()
} }

View File

@ -3,13 +3,15 @@ package versionhandshake
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/zrepl/zrepl/util/socketpair"
"io" "io"
"strings" "strings"
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/zrepl/zrepl/util/socketpair"
) )
func TestHandshakeMessage_Encode(t *testing.T) { func TestHandshakeMessage_Encode(t *testing.T) {
@ -23,8 +25,6 @@ func TestHandshakeMessage_Encode(t *testing.T) {
enc := string(encB) enc := string(encB)
t.Logf("enc: %s", enc) t.Logf("enc: %s", enc)
assert.False(t, strings.ContainsAny(enc[0:10], " ")) assert.False(t, strings.ContainsAny(enc[0:10], " "))
assert.True(t, enc[10] == ' ') assert.True(t, enc[10] == ' ')

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"net" "net"
"time" "time"
"github.com/zrepl/zrepl/transport" "github.com/zrepl/zrepl/transport"
) )
@ -41,7 +42,7 @@ type HandshakeListener struct {
timeout time.Duration timeout time.Duration
} }
func (l HandshakeListener) Addr() (net.Addr) { return l.l.Addr() } func (l HandshakeListener) Addr() net.Addr { return l.l.Addr() }
func (l HandshakeListener) Close() error { return l.l.Close() } func (l HandshakeListener) Close() error { return l.l.Close() }

View File

@ -4,7 +4,9 @@ package fromconfig
import ( import (
"fmt" "fmt"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/transport" "github.com/zrepl/zrepl/transport"
"github.com/zrepl/zrepl/transport/local" "github.com/zrepl/zrepl/transport/local"
@ -35,7 +37,6 @@ func ListenerFactoryFromConfig(g *config.Global, in config.ServeEnum) (transport
return l, err return l, err
} }
func ConnecterFromConfig(g *config.Global, in config.ConnectEnum) (transport.Connecter, error) { func ConnecterFromConfig(g *config.Global, in config.ConnectEnum) (transport.Connecter, error) {
var ( var (
connecter transport.Connecter connecter transport.Connecter

View File

@ -3,6 +3,7 @@ package local
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/transport" "github.com/zrepl/zrepl/transport"
) )
@ -26,4 +27,3 @@ func (c *LocalConnecter) Connect(dialCtx context.Context) (transport.Wire, error
l := GetLocalListener(c.listenerName) l := GetLocalListener(c.listenerName)
return l.Connect(dialCtx, c.clientIdentity) return l.Connect(dialCtx, c.clientIdentity)
} }

View File

@ -3,11 +3,12 @@ package local
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/util/socketpair"
"net" "net"
"sync" "sync"
"github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/transport" "github.com/zrepl/zrepl/transport"
"github.com/zrepl/zrepl/util/socketpair"
) )
var localListeners struct { var localListeners struct {
@ -16,7 +17,7 @@ var localListeners struct {
mtx sync.Mutex mtx sync.Mutex
} }
func GetLocalListener(listenerName string) (*LocalListener) { func GetLocalListener(listenerName string) *LocalListener {
localListeners.init.Do(func() { localListeners.init.Do(func() {
localListeners.m = make(map[string]*LocalListener) localListeners.m = make(map[string]*LocalListener)
@ -88,7 +89,7 @@ func (localAddr) Network() string { return "local" }
func (a localAddr) String() string { return a.S } func (a localAddr) String() string { return a.S }
func (l *LocalListener) Addr() (net.Addr) { return localAddr{"<listening>"} } func (l *LocalListener) Addr() net.Addr { return localAddr{"<listening>"} }
func (l *LocalListener) Accept(ctx context.Context) (*transport.AuthConn, error) { func (l *LocalListener) Accept(ctx context.Context) (*transport.AuthConn, error) {
respondToRequest := func(req connectRequest, res connectResult) (err error) { respondToRequest := func(req connectRequest, res connectResult) (err error) {

View File

@ -2,12 +2,14 @@ package ssh
import ( import (
"context" "context"
"time"
"github.com/jinzhu/copier" "github.com/jinzhu/copier"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/problame/go-netssh" "github.com/problame/go-netssh"
"github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/transport" "github.com/zrepl/zrepl/transport"
"time"
) )
type SSHStdinserverConnecter struct { type SSHStdinserverConnecter struct {

View File

@ -1,16 +1,18 @@
package ssh package ssh
import ( import (
"github.com/problame/go-netssh" "context"
"github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/daemon/nethelpers"
"github.com/zrepl/zrepl/transport"
"fmt" "fmt"
"net" "net"
"path" "path"
"context"
"github.com/pkg/errors"
"sync/atomic" "sync/atomic"
"github.com/pkg/errors"
"github.com/problame/go-netssh"
"github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/daemon/nethelpers"
"github.com/zrepl/zrepl/transport"
) )
func MultiStdinserverListenerFactoryFromConfig(g *config.Global, in *config.StdinserverServer) (transport.AuthenticatedListenerFactory, error) { func MultiStdinserverListenerFactoryFromConfig(g *config.Global, in *config.StdinserverServer) (transport.AuthenticatedListenerFactory, error) {

View File

@ -1,10 +1,12 @@
package tcp package tcp
import ( import (
"github.com/zrepl/zrepl/config"
"net"
"github.com/pkg/errors"
"context" "context"
"net"
"github.com/pkg/errors"
"github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/transport" "github.com/zrepl/zrepl/transport"
) )
@ -79,4 +81,3 @@ func (f *TCPAuthListener) Accept(ctx context.Context) (*transport.AuthConn, erro
} }
return transport.NewAuthConn(nc, clientIdent), nil return transport.NewAuthConn(nc, clientIdent), nil
} }

View File

@ -6,6 +6,7 @@ import (
"net" "net"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/zrepl/zrepl/config" "github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/tlsconf" "github.com/zrepl/zrepl/tlsconf"
"github.com/zrepl/zrepl/transport" "github.com/zrepl/zrepl/transport"

View File

@ -1,16 +1,18 @@
package tls package tls
import ( import (
"context"
"crypto/tls" "crypto/tls"
"crypto/x509" "crypto/x509"
"fmt" "fmt"
"github.com/pkg/errors"
"github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/transport"
"github.com/zrepl/zrepl/tlsconf"
"net" "net"
"time" "time"
"context"
"github.com/pkg/errors"
"github.com/zrepl/zrepl/config"
"github.com/zrepl/zrepl/tlsconf"
"github.com/zrepl/zrepl/transport"
) )
type TLSListenerFactory struct { type TLSListenerFactory struct {
@ -85,5 +87,3 @@ func (l tlsAuthListener) Accept(ctx context.Context) (*transport.AuthConn, error
adaptor := newWireAdaptor(tlsConn, tcpConn) adaptor := newWireAdaptor(tlsConn, tcpConn)
return transport.NewAuthConn(adaptor, cn), nil return transport.NewAuthConn(adaptor, cn), nil
} }

View File

@ -5,6 +5,7 @@ import (
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/zrepl/zrepl/zfs" "github.com/zrepl/zrepl/zfs"
) )

View File

@ -3,11 +3,12 @@ package util
import ( import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"github.com/stretchr/testify/assert"
"io" "io"
"reflect" "reflect"
"testing" "testing"
"testing/quick" "testing/quick"
"github.com/stretchr/testify/assert"
) )
func TestUnchunker(t *testing.T) { func TestUnchunker(t *testing.T) {

View File

@ -2,10 +2,11 @@ package util
import ( import (
"context" "context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
) )
func TestContextWithOptionalDeadline(t *testing.T) { func TestContextWithOptionalDeadline(t *testing.T) {

View File

@ -4,12 +4,13 @@ import (
"bytes" "bytes"
"context" "context"
"fmt" "fmt"
"github.com/zrepl/zrepl/util/envconst"
"io" "io"
"os" "os"
"os/exec" "os/exec"
"syscall" "syscall"
"time" "time"
"github.com/zrepl/zrepl/util/envconst"
) )
// An IOCommand exposes a forked process's std(in|out|err) through the io.ReadWriteCloser interface. // An IOCommand exposes a forked process's std(in|out|err) through the io.ReadWriteCloser interface.

View File

@ -1,8 +1,9 @@
package zfs package zfs
import ( import (
"github.com/stretchr/testify/assert"
"testing" "testing"
"github.com/stretchr/testify/assert"
) )
func TestNewDatasetPathTree(t *testing.T) { func TestNewDatasetPathTree(t *testing.T) {

View File

@ -13,6 +13,7 @@ type DatasetFilter interface {
func NoFilter() DatasetFilter { func NoFilter() DatasetFilter {
return noFilter{} return noFilter{}
} }
type noFilter struct{} type noFilter struct{}
var _ DatasetFilter = noFilter{} var _ DatasetFilter = noFilter{}

View File

@ -2,8 +2,9 @@ package zfs
import ( import (
"fmt" "fmt"
"github.com/pkg/errors"
"strconv" "strconv"
"github.com/pkg/errors"
) )
const ReplicationCursorBookmarkName = "zrepl_replication_cursor" const ReplicationCursorBookmarkName = "zrepl_replication_cursor"

View File

@ -2,9 +2,11 @@ package zfs_test
import ( import (
"context" "context"
"github.com/stretchr/testify/assert"
"github.com/zrepl/zrepl/zfs"
"testing" "testing"
"github.com/stretchr/testify/assert"
"github.com/zrepl/zrepl/zfs"
) )
type ResumeTokenTest struct { type ResumeTokenTest struct {

View File

@ -5,11 +5,12 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/prometheus/client_golang/prometheus"
"io" "io"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"github.com/prometheus/client_golang/prometheus"
) )
type VersionType string type VersionType string

View File

@ -15,9 +15,11 @@ import (
"time" "time"
"context" "context"
"github.com/prometheus/client_golang/prometheus"
"regexp" "regexp"
"strconv" "strconv"
"github.com/prometheus/client_golang/prometheus"
"github.com/zrepl/zrepl/util/envconst" "github.com/zrepl/zrepl/util/envconst"
) )
@ -416,7 +418,6 @@ type sendStream struct {
closeMtx sync.Mutex closeMtx sync.Mutex
stdoutReader *os.File stdoutReader *os.File
opErr error opErr error
} }
func (s *sendStream) Read(p []byte) (n int, err error) { func (s *sendStream) Read(p []byte) (n int, err error) {
@ -553,7 +554,6 @@ func ZFSSend(ctx context.Context, fs string, from, to string, token string) (str
return newSendStreamCopier(stream), err return newSendStreamCopier(stream), err
} }
type DrySendType string type DrySendType string
const ( const (
@ -563,8 +563,10 @@ const (
func DrySendTypeFromString(s string) (DrySendType, error) { func DrySendTypeFromString(s string) (DrySendType, error) {
switch s { switch s {
case string(DrySendTypeFull): return DrySendTypeFull, nil case string(DrySendTypeFull):
case string(DrySendTypeIncremental): return DrySendTypeIncremental, nil return DrySendTypeFull, nil
case string(DrySendTypeIncremental):
return DrySendTypeIncremental, nil
default: default:
return "", fmt.Errorf("unknown dry send type %q", s) return "", fmt.Errorf("unknown dry send type %q", s)
} }
@ -602,7 +604,6 @@ func (s *DrySendInfo) unmarshalZFSOutput(output []byte) (err error) {
return fmt.Errorf("no match for info line (regex1 %s) (regex2 %s)", sendDryRunInfoLineRegexFull, sendDryRunInfoLineRegexIncremental) return fmt.Errorf("no match for info line (regex1 %s) (regex2 %s)", sendDryRunInfoLineRegexFull, sendDryRunInfoLineRegexIncremental)
} }
// unmarshal info line, looks like this: // unmarshal info line, looks like this:
// full zroot/test/a@1 5389768 // full zroot/test/a@1 5389768
// incremental zroot/test/a@1 zroot/test/a@2 5383936 // incremental zroot/test/a@1 zroot/test/a@2 5383936
@ -947,13 +948,27 @@ const (
func (s zfsPropertySource) zfsGetSourceFieldPrefixes() []string { func (s zfsPropertySource) zfsGetSourceFieldPrefixes() []string {
prefixes := make([]string, 0, 7) prefixes := make([]string, 0, 7)
if s&sourceLocal != 0 {prefixes = append(prefixes, "local")} if s&sourceLocal != 0 {
if s&sourceDefault != 0 {prefixes = append(prefixes, "default")} prefixes = append(prefixes, "local")
if s&sourceInherited != 0 {prefixes = append(prefixes, "inherited")} }
if s&sourceNone != 0 {prefixes = append(prefixes, "-")} if s&sourceDefault != 0 {
if s&sourceTemporary != 0 { prefixes = append(prefixes, "temporary")} prefixes = append(prefixes, "default")
if s&sourceReceived != 0 { prefixes = append(prefixes, "received")} }
if s == sourceAny { prefixes = append(prefixes, "") } if s&sourceInherited != 0 {
prefixes = append(prefixes, "inherited")
}
if s&sourceNone != 0 {
prefixes = append(prefixes, "-")
}
if s&sourceTemporary != 0 {
prefixes = append(prefixes, "temporary")
}
if s&sourceReceived != 0 {
prefixes = append(prefixes, "received")
}
if s == sourceAny {
prefixes = append(prefixes, "")
}
return prefixes return prefixes
} }
@ -1010,8 +1025,10 @@ func ZFSDestroy(dataset string) (err error) {
filesystem = dataset filesystem = dataset
} else { } else {
switch dataset[idx] { switch dataset[idx] {
case '@': dstype = "snapshot" case '@':
case '#': dstype = "bookmark" dstype = "snapshot"
case '#':
dstype = "bookmark"
} }
filesystem = dataset[:idx] filesystem = dataset[:idx]
} }

View File

@ -1,8 +1,9 @@
package zfs package zfs
import ( import (
"github.com/stretchr/testify/assert"
"testing" "testing"
"github.com/stretchr/testify/assert"
) )
func TestZFSListHandlesProducesZFSErrorOnNonZeroExit(t *testing.T) { func TestZFSListHandlesProducesZFSErrorOnNonZeroExit(t *testing.T) {