From 7751d5a00b957f2ead1956a6232e6e6f1ab1fc35 Mon Sep 17 00:00:00 2001 From: kapitainsky Date: Sun, 25 Jun 2023 11:27:42 +0100 Subject: [PATCH] rc: config/listremotes include from env vars Fixes: #6540 Discussed: https://forum.rclone.org/t/environment-variable-config-not-used-for-remote-control/39014 --- fs/config/rc.go | 5 +++-- fs/config/rc_test.go | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/config/rc.go b/fs/config/rc.go index f5902628d..951adefe5 100644 --- a/fs/config/rc.go +++ b/fs/config/rc.go @@ -59,7 +59,7 @@ func init() { rc.Add(rc.Call{ Path: "config/listremotes", 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, Help: ` 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 +// including any defined by environment variables. func rcListRemotes(ctx context.Context, in rc.Params) (out rc.Params, err error) { - remotes := LoadedData().GetSectionList() + remotes := FileSections() out = rc.Params{ "remotes": remotes, } diff --git a/fs/config/rc_test.go b/fs/config/rc_test.go index fc9f37563..ac5a60ca3 100644 --- a/fs/config/rc_test.go +++ b/fs/config/rc_test.go @@ -2,6 +2,7 @@ package config_test import ( "context" + "os" "testing" _ "github.com/rclone/rclone/backend/local" @@ -68,6 +69,10 @@ func TestRc(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") assert.NotNil(t, call) in := rc.Params{} @@ -80,6 +85,7 @@ func TestRc(t *testing.T) { require.NoError(t, err) assert.Contains(t, remotes, testName) + assert.Contains(t, remotes, "my-local") }) t.Run("Update", func(t *testing.T) {