Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: kpango <[email protected]>
  • Loading branch information
kpango committed May 26, 2020
1 parent 376857c commit d3bcfb8
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 276 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ replace (
github.com/coreos/etcd => go.etcd.io/etcd v0.5.0-alpha.5.0.20200425165423-262c93980547
github.com/docker/docker => github.com/moby/moby v17.12.0-ce-rc1.0.20200309214505-aa6a9891b09c+incompatible
github.com/envoyproxy/protoc-gen-validate => github.com/envoyproxy/protoc-gen-validate v0.3.0-java
github.com/go-sql-driver/mysql => github.com/go-sql-driver/mysql v1.5.1-0.20200521132419-128a6737a202
github.com/go-sql-driver/mysql => github.com/go-sql-driver/mysql v1.5.1-0.20200525102840-8c3a2d9049b4
github.com/gocql/gocql => github.com/gocql/gocql v0.0.0-20200519160334-799061058e31
github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.1
github.com/gophercloud/gophercloud => github.com/gophercloud/gophercloud v0.11.0
Expand All @@ -32,7 +32,7 @@ require (
github.com/cockroachdb/errors v0.0.0-00010101000000-000000000000
github.com/danielvladco/go-proto-gql/pb v0.6.1
github.com/envoyproxy/protoc-gen-validate v0.1.0
github.com/fsnotify/fsnotify v1.4.7
github.com/fsnotify/fsnotify v1.4.9
github.com/go-redis/redis/v7 v7.3.0
github.com/go-sql-driver/mysql v1.5.0
github.com/gocql/gocql v0.0.0-20200131111108-92af2e088537
Expand Down
8 changes: 5 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ github.com/fortytw2/leaktest v1.2.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHqu
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/frankban/quicktest v1.4.0 h1:rCSCih1FnSWJEel/eub9wclBSqpF2F/PuvxUWGWnbO8=
github.com/frankban/quicktest v1.4.0/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc=
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
Expand Down Expand Up @@ -218,8 +219,8 @@ github.com/go-redis/redis v6.15.2+incompatible h1:9SpNVG76gr6InJGxoZ6IuuxaCOQwDA
github.com/go-redis/redis v6.15.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
github.com/go-redis/redis/v7 v7.3.0 h1:3oHqd0W7f/VLKBxeYTEpqdMUsmMectngjM9OtoRoIgg=
github.com/go-redis/redis/v7 v7.3.0/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRfnwdHj/Dcg=
github.com/go-sql-driver/mysql v1.5.1-0.20200521132419-128a6737a202 h1:MVqCQqO9Y9V3LM1TwbOGOuLqlBWiU+TjjMH/M/PfGiw=
github.com/go-sql-driver/mysql v1.5.1-0.20200521132419-128a6737a202/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-sql-driver/mysql v1.5.1-0.20200525102840-8c3a2d9049b4 h1:EwVyKWAXcaG1sJdJu+D7NlZ5WZdze/plTXEBHPrf2mk=
github.com/go-sql-driver/mysql v1.5.1-0.20200525102840-8c3a2d9049b4/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
Expand Down Expand Up @@ -681,6 +682,7 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
4 changes: 2 additions & 2 deletions internal/config/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// Package config providers configuration type and load configuration logic
package config

type Sidecar struct {
type AgentSidecar struct {
// Name string `yaml:"name" json:"name"`

// WatchPaths represents watch path list for backup
Expand All @@ -30,7 +30,7 @@ type Sidecar struct {
AutoBackupDuration string `yaml:"auto_backup_duration" json:"auto_backup_duration"`
}

func (s *Sidecar) Bind() *Sidecar {
func (s *AgentSidecar) Bind() *AgentSidecar {
s.WatchPaths = GetActualValues(s.WatchPaths)
s.AutoBackupDuration = GetActualValue(s.AutoBackupDuration)
s.AutoBackupDurationLimit = GetActualValue(s.AutoBackupDurationLimit)
Expand Down
10 changes: 5 additions & 5 deletions internal/config/sidecar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ import (
"go.uber.org/goleak"
)

func TestSidecar_Bind(t *testing.T) {
func TestAgentSidecar_Bind(t *testing.T) {
type fields struct {
WatchPaths []string
AutoBackupDurationLimit string
AutoBackupDuration string
}
type want struct {
want *Sidecar
want *AgentSidecar
}
type test struct {
name string
fields fields
want want
checkFunc func(want, *Sidecar) error
checkFunc func(want, *AgentSidecar) error
beforeFunc func()
afterFunc func()
}
defaultCheckFunc := func(w want, got *Sidecar) error {
defaultCheckFunc := func(w want, got *AgentSidecar) error {
if !reflect.DeepEqual(got, w.want) {
return errors.Errorf("got = %v, want %v", got, w.want)
}
Expand Down Expand Up @@ -92,7 +92,7 @@ func TestSidecar_Bind(t *testing.T) {
if test.checkFunc == nil {
test.checkFunc = defaultCheckFunc
}
s := &Sidecar{
s := &AgentSidecar{
WatchPaths: test.fields.WatchPaths,
AutoBackupDurationLimit: test.fields.AutoBackupDurationLimit,
AutoBackupDuration: test.fields.AutoBackupDuration,
Expand Down
14 changes: 0 additions & 14 deletions internal/file/watch/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,6 @@ func WithDirs(dirs ...string) Option {
}
}

func WithDir(dir string) Option {
return func(w *watch) error {
if len(dir) == 0 {
return nil
}
if w.dirs != nil {
w.dirs = append(w.dirs, dir)
} else {
w.dirs = []string{dir}
}
return nil
}
}

func WithOnChange(f func(ctx context.Context, name string) error) Option {
return func(w *watch) error {
if f != nil {
Expand Down
113 changes: 0 additions & 113 deletions internal/file/watch/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,119 +250,6 @@ func TestWithDirs(t *testing.T) {
}
}

func TestWithDir(t *testing.T) {
type T = interface{}
type args struct {
dir string
}
type want struct {
obj *T
// Uncomment this line if the option returns an error, otherwise delete it
// err error
}
type test struct {
name string
args args
want want
// Use the first line if the option returns an error. otherwise use the second line
// checkFunc func(want, *T, error) error
// checkFunc func(want, *T) error
beforeFunc func(args)
afterFunc func(args)
}

// Uncomment this block if the option returns an error, otherwise delete it
/*
defaultCheckFunc := func(w want, obj *T, err error) error {
if !errors.Is(err, w.err) {
return errors.Errorf("got error = %v, want %v", err, w.err)
}
if !reflect.DeepEqual(obj, w.obj) {
return errors.Errorf("got = %v, want %v", obj, w.obj)
}
return nil
}
*/

// Uncomment this block if the option do not returns an error, otherwise delete it
/*
defaultCheckFunc := func(w want, obj *T) error {
if !reflect.DeepEqual(obj, w.obj) {
return errors.Errorf("got = %v, want %v", obj, w.c)
}
return nil
}
*/

tests := []test{
// TODO test cases
/*
{
name: "test_case_1",
args: args {
dir: "",
},
want: want {
obj: new(T),
},
},
*/

// TODO test cases
/*
func() test {
return test {
name: "test_case_2",
args: args {
dir: "",
},
want: want {
obj: new(T),
},
}
}(),
*/
}

for _, test := range tests {
t.Run(test.name, func(tt *testing.T) {
defer goleak.VerifyNone(t)
if test.beforeFunc != nil {
test.beforeFunc(test.args)
}
if test.afterFunc != nil {
defer test.afterFunc(test.args)
}

// Uncomment this block if the option returns an error, otherwise delete it
/*
if test.checkFunc == nil {
test.checkFunc = defaultCheckFunc
}
got := WithDir(test.args.dir)
obj := new(T)
if err := test.checkFunc(test.want, obj, got(obj)); err != nil {
tt.Errorf("error = %v", err)
}
*/

// Uncomment this block if the option returns an error, otherwise delete it
/*
if test.checkFunc == nil {
test.checkFunc = defaultCheckFunc
}
got := WithDir(test.args.dir)
obj := new(T)
got(obj)
if err := test.checkFunc(tt.want, obj); err != nil {
tt.Errorf("error = %v", err)
}
*/
})
}
}

func TestWithOnChange(t *testing.T) {
type T = interface{}
type args struct {
Expand Down
6 changes: 3 additions & 3 deletions pkg/agent/sidecar/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Data struct {
Observability *config.Observability `json:"observability" yaml:"observability"`

// Sidecar represent agent storage sync sidecar service configuration
Sidecar *config.Sidecar `json:"sidecar" yaml:"sidecar"`
AgentSidecar *config.AgentSidecar `json:"agent_sidecar" yaml:"agent_sidecar"`
}

func NewConfig(path string) (cfg *Data, err error) {
Expand All @@ -57,8 +57,8 @@ func NewConfig(path string) (cfg *Data, err error) {
cfg.Observability = cfg.Observability.Bind()
}

if cfg.Sidecar != nil {
cfg.Sidecar = cfg.Sidecar.Bind()
if cfg.AgentSidecar != nil {
cfg.AgentSidecar = cfg.AgentSidecar.Bind()
}
return cfg, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/sidecar/handler/grpc/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"reflect"
"testing"

"github.com/vdaas/vald/internal/errors"
"github.com/vdaas/vald/apis/grpc/agent/sidecar"
"github.com/vdaas/vald/internal/errors"
"go.uber.org/goleak"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/sidecar/handler/grpc/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (

func WithStorageObserver(so service.StorageObserver) Option {
return func(s *server) {
if i != nil {
if so != nil {
s.so = so
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/sidecar/handler/rest/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"reflect"
"testing"

"github.com/vdaas/vald/internal/errors"
"github.com/vdaas/vald/apis/grpc/agent/sidecar"
"github.com/vdaas/vald/internal/errors"
"go.uber.org/goleak"
)

Expand Down
14 changes: 0 additions & 14 deletions pkg/agent/sidecar/service/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,3 @@ func WithDirs(dirs ...string) Option {
return nil
}
}

func WithDir(dir string) Option {
return func(o *observer) error {
if len(dir) == 0 {
return nil
}
if o.dirs != nil {
o.dirs = append(o.dirs, dir)
} else {
o.dirs = []string{dir}
}
return nil
}
}
Loading

0 comments on commit d3bcfb8

Please sign in to comment.