mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
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:
@@ -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"},
|
||||
|
||||
Reference in New Issue
Block a user