Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

configmap: add ClearSetters to get rid of all setters #5178

Nick Craig-Wood1a41c930f3d3
diff --git a/fs/config/configmap/configmap.go b/fs/config/configmap/configmap.go
index 9cd3891f3..77cb0baa9 100644
--- a/fs/config/configmap/configmap.go
+++ b/fs/config/configmap/configmap.go
@@ -60,6 +60,12 @@ func (c *Map) AddSetter(setter Setter) *Map {
return c
}
+// ClearSetters removes all the setters set so far
+func (c *Map) ClearSetters() *Map {
+ c.setters = nil
+ return c
+}
+
// get gets an item with the key passed in and return the value from
// the first getter. If the item is found then it returns true,
// otherwise false.
diff --git a/fs/config/configmap/configmap_test.go b/fs/config/configmap/configmap_test.go
index fc38060b2..961f1a070 100644
--- a/fs/config/configmap/configmap_test.go
+++ b/fs/config/configmap/configmap_test.go
@@ -88,6 +88,21 @@ func TestConfigMapSet(t *testing.T) {
"config1": "beetroot",
"config2": "potato",
}, m2)
+
+ m.ClearSetters()
+
+ // Check that nothing gets set
+ m.Set("config1", "BEETROOT")
+
+ assert.Equal(t, Simple{
+ "config1": "beetroot",
+ "config2": "potato",
+ }, m1)
+ assert.Equal(t, Simple{
+ "config1": "beetroot",
+ "config2": "potato",
+ }, m2)
+
}
func TestConfigMapGetOverride(t *testing.T) {