fs: Allow on the fly remotes with :backend: syntax - fixes #2449

This change allows remotes to be created on the fly without a config
file by using the remote type prefixed with a : as the remote name, Eg
:s3: to make an s3 remote.

This assumes the user is supplying the backend config via command line
flags or environment variables.
This commit is contained in:
Nick Craig-Wood
2018-08-07 22:51:06 +01:00
parent 174ca22936
commit 8656bd2bb0
5 changed files with 64 additions and 18 deletions

View File

@@ -16,6 +16,7 @@ func TestParse(t *testing.T) {
{"path/to/file", "", "path/to/file"},
{"remote:path/to/file", "remote", "path/to/file"},
{"remote:/path/to/file", "remote", "/path/to/file"},
{":backend:/path/to/file", ":backend", "/path/to/file"},
} {
gotConfigName, gotFsPath := Parse(test.in)
assert.Equal(t, test.wantConfigName, gotConfigName)
@@ -28,12 +29,21 @@ func TestSplit(t *testing.T) {
remote, wantParent, wantLeaf string
}{
{"", "", ""},
{"remote:", "remote:", ""},
{"remote:potato", "remote:", "potato"},
{"remote:/", "remote:/", ""},
{"remote:/potato", "remote:/", "potato"},
{"remote:/potato/potato", "remote:/potato/", "potato"},
{"remote:potato/sausage", "remote:potato/", "sausage"},
{":remote:", ":remote:", ""},
{":remote:potato", ":remote:", "potato"},
{":remote:/", ":remote:/", ""},
{":remote:/potato", ":remote:/", "potato"},
{":remote:/potato/potato", ":remote:/potato/", "potato"},
{":remote:potato/sausage", ":remote:potato/", "sausage"},
{"/", "/", ""},
{"/root", "/", "root"},
{"/a/b", "/a/", "b"},