mirror of
https://github.com/rclone/rclone.git
synced 2025-01-09 07:48:19 +01:00
rc: config/listremotes include from env vars
Fixes: #6540 Discussed: https://forum.rclone.org/t/environment-variable-config-not-used-for-remote-control/39014
This commit is contained in:
parent
8274712c2c
commit
7751d5a00b
@ -59,7 +59,7 @@ func init() {
|
|||||||
rc.Add(rc.Call{
|
rc.Add(rc.Call{
|
||||||
Path: "config/listremotes",
|
Path: "config/listremotes",
|
||||||
Fn: rcListRemotes,
|
Fn: rcListRemotes,
|
||||||
Title: "Lists the remotes in the config file.",
|
Title: "Lists the remotes in the config file and defined in environment variables.",
|
||||||
AuthRequired: true,
|
AuthRequired: true,
|
||||||
Help: `
|
Help: `
|
||||||
Returns
|
Returns
|
||||||
@ -71,8 +71,9 @@ See the [listremotes](/commands/rclone_listremotes/) command for more informatio
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return the a list of remotes in the config file
|
// Return the a list of remotes in the config file
|
||||||
|
// including any defined by environment variables.
|
||||||
func rcListRemotes(ctx context.Context, in rc.Params) (out rc.Params, err error) {
|
func rcListRemotes(ctx context.Context, in rc.Params) (out rc.Params, err error) {
|
||||||
remotes := LoadedData().GetSectionList()
|
remotes := FileSections()
|
||||||
out = rc.Params{
|
out = rc.Params{
|
||||||
"remotes": remotes,
|
"remotes": remotes,
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package config_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
_ "github.com/rclone/rclone/backend/local"
|
_ "github.com/rclone/rclone/backend/local"
|
||||||
@ -68,6 +69,10 @@ func TestRc(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("ListRemotes", func(t *testing.T) {
|
t.Run("ListRemotes", func(t *testing.T) {
|
||||||
|
assert.NoError(t, os.Setenv("RCLONE_CONFIG_MY-LOCAL_TYPE", "local"))
|
||||||
|
defer func() {
|
||||||
|
assert.NoError(t, os.Unsetenv("RCLONE_CONFIG_MY-LOCAL_TYPE"))
|
||||||
|
}()
|
||||||
call := rc.Calls.Get("config/listremotes")
|
call := rc.Calls.Get("config/listremotes")
|
||||||
assert.NotNil(t, call)
|
assert.NotNil(t, call)
|
||||||
in := rc.Params{}
|
in := rc.Params{}
|
||||||
@ -80,6 +85,7 @@ func TestRc(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.Contains(t, remotes, testName)
|
assert.Contains(t, remotes, testName)
|
||||||
|
assert.Contains(t, remotes, "my-local")
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Update", func(t *testing.T) {
|
t.Run("Update", func(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user