sftp: Rename Dir -> Path

This commit is contained in:
Alexander Neumann 2017-04-10 22:41:06 +02:00
parent ab602c9d14
commit ae290ab374
4 changed files with 21 additions and 20 deletions

View file

@ -79,7 +79,7 @@ var parseTests = []struct {
Config: sftp.Config{
User: "user",
Host: "host",
Dir: "/srv/repo",
Path: "/srv/repo",
},
},
},
@ -89,7 +89,7 @@ var parseTests = []struct {
Config: sftp.Config{
User: "",
Host: "host",
Dir: "/srv/repo",
Path: "/srv/repo",
},
},
},
@ -99,7 +99,7 @@ var parseTests = []struct {
Config: sftp.Config{
User: "user",
Host: "host",
Dir: "srv/repo",
Path: "srv/repo",
},
},
},
@ -109,7 +109,7 @@ var parseTests = []struct {
Config: sftp.Config{
User: "user",
Host: "host",
Dir: "/srv/repo",
Path: "/srv/repo",
},
},
},

View file

@ -10,9 +10,9 @@ import (
// Config collects all information required to connect to an sftp server.
type Config struct {
User, Host, Dir string
Layout string `option:"layout"`
Command string `option:"command"`
User, Host, Path string
Layout string `option:"layout"`
Command string `option:"command"`
}
// ParseConfig parses the string s and extracts the sftp config. The
@ -62,6 +62,6 @@ func ParseConfig(s string) (interface{}, error) {
return Config{
User: user,
Host: host,
Dir: path.Clean(dir),
Path: path.Clean(dir),
}, nil
}

View file

@ -9,53 +9,53 @@ var configTests = []struct {
// first form, user specified sftp://user@host/dir
{
"sftp://user@host/dir/subdir",
Config{User: "user", Host: "host", Dir: "dir/subdir"},
Config{User: "user", Host: "host", Path: "dir/subdir"},
},
{
"sftp://host/dir/subdir",
Config{Host: "host", Dir: "dir/subdir"},
Config{Host: "host", Path: "dir/subdir"},
},
{
"sftp://host//dir/subdir",
Config{Host: "host", Dir: "/dir/subdir"},
Config{Host: "host", Path: "/dir/subdir"},
},
{
"sftp://host:10022//dir/subdir",
Config{Host: "host:10022", Dir: "/dir/subdir"},
Config{Host: "host:10022", Path: "/dir/subdir"},
},
{
"sftp://user@host:10022//dir/subdir",
Config{User: "user", Host: "host:10022", Dir: "/dir/subdir"},
Config{User: "user", Host: "host:10022", Path: "/dir/subdir"},
},
{
"sftp://user@host/dir/subdir/../other",
Config{User: "user", Host: "host", Dir: "dir/other"},
Config{User: "user", Host: "host", Path: "dir/other"},
},
{
"sftp://user@host/dir///subdir",
Config{User: "user", Host: "host", Dir: "dir/subdir"},
Config{User: "user", Host: "host", Path: "dir/subdir"},
},
// second form, user specified sftp:user@host:/dir
{
"sftp:user@host:/dir/subdir",
Config{User: "user", Host: "host", Dir: "/dir/subdir"},
Config{User: "user", Host: "host", Path: "/dir/subdir"},
},
{
"sftp:host:../dir/subdir",
Config{Host: "host", Dir: "../dir/subdir"},
Config{Host: "host", Path: "../dir/subdir"},
},
{
"sftp:user@host:dir/subdir:suffix",
Config{User: "user", Host: "host", Dir: "dir/subdir:suffix"},
Config{User: "user", Host: "host", Path: "dir/subdir:suffix"},
},
{
"sftp:user@host:dir/subdir/../other",
Config{User: "user", Host: "host", Dir: "dir/other"},
Config{User: "user", Host: "host", Path: "dir/other"},
},
{
"sftp:user@host:dir///subdir",
Config{User: "user", Host: "host", Dir: "dir/subdir"},
Config{User: "user", Host: "host", Path: "dir/subdir"},
},
}

View file

@ -32,6 +32,7 @@ type SFTP struct {
result <-chan error
backend.Layout
Config
}
var _ restic.Backend = &SFTP{}