mirror of
https://github.com/Luzifer/duplicity-backup.git
synced 2024-12-20 18:41:21 +00:00
Fixed several linter warnings
This commit is contained in:
parent
ffc46da241
commit
03550c0003
2 changed files with 25 additions and 10 deletions
10
Makefile
10
Makefile
|
@ -4,6 +4,14 @@ bindata:
|
|||
setup-testenv:
|
||||
go get github.com/onsi/ginkgo/ginkgo
|
||||
go get github.com/onsi/gomega
|
||||
go get github.com/alecthomas/gometalinter
|
||||
gometalinter --install --update
|
||||
|
||||
test:
|
||||
$(GOPATH)/bin/ginkgo
|
||||
ginkgo
|
||||
gometalinter \
|
||||
--cyclo-over=15 \
|
||||
--deadline=10s \
|
||||
--exclude=bindata.go \
|
||||
--exclude=configfile_test.go \
|
||||
-D errcheck
|
||||
|
|
|
@ -34,7 +34,7 @@ type configFile struct {
|
|||
} `yaml:"swift"`
|
||||
Include []string `yaml:"inclist"`
|
||||
Exclude []string `yaml:"exclist"`
|
||||
IncExcFile string `yaml:"incexcfile"`
|
||||
IncExcFile string `yaml:"incexcfile" valid:"customFileExistsValidator,required"`
|
||||
ExcludeDeviceFiles bool `yaml:"excdevicefiles"`
|
||||
Encryption struct {
|
||||
Enable bool `yaml:"enable"`
|
||||
|
@ -66,6 +66,17 @@ type configFile struct {
|
|||
} `yaml:"notifications"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
valid.CustomTypeTagMap.Set("customFileExistsValidator", valid.CustomTypeValidator(func(i interface{}, context interface{}) bool {
|
||||
switch v := i.(type) { // this validates a field against the value in another field, i.e. dependent validation
|
||||
case string:
|
||||
_, err := os.Stat(v)
|
||||
return v == "" || err == nil
|
||||
}
|
||||
return false
|
||||
}))
|
||||
}
|
||||
|
||||
func (c *configFile) validate() error {
|
||||
result, err := valid.ValidateStruct(c)
|
||||
if !result || err != nil {
|
||||
|
@ -88,10 +99,6 @@ func (c *configFile) validate() error {
|
|||
return errors.New("Destination is S3 but AWS credentials are not configured")
|
||||
}
|
||||
|
||||
if _, err := os.Stat(c.IncExcFile); c.IncExcFile != "" && err == os.ErrNotExist {
|
||||
return errors.New("Specified incexcfile does not exist")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -124,14 +131,14 @@ func (c *configFile) GenerateCommand(argv []string, time string) (commandLine []
|
|||
dest = c.Destination
|
||||
commandLine, env, err = c.generateFullCommand(option, time, root, dest, addTime, "")
|
||||
case "cleanup":
|
||||
option = "cleanup"
|
||||
option = command
|
||||
commandLine, env, err = c.generateLiteCommand(option, time, addTime)
|
||||
case "list-current-files":
|
||||
option = "list-current-files"
|
||||
option = command
|
||||
commandLine, env, err = c.generateLiteCommand(option, time, addTime)
|
||||
case "restore":
|
||||
addTime = true
|
||||
option = "restore"
|
||||
option = command
|
||||
root = c.Destination
|
||||
restoreFile := ""
|
||||
|
||||
|
@ -150,7 +157,7 @@ func (c *configFile) GenerateCommand(argv []string, time string) (commandLine []
|
|||
option = "collection-status"
|
||||
commandLine, env, err = c.generateLiteCommand(option, time, addTime)
|
||||
case "verify":
|
||||
option = "verify"
|
||||
option = command
|
||||
root = c.Destination
|
||||
dest = c.RootPath
|
||||
commandLine, env, err = c.generateFullCommand(option, time, root, dest, addTime, "")
|
||||
|
|
Loading…
Reference in a new issue