fs: factor OptionToEnv and ConfigToEnv into fs

This commit is contained in:
Nick Craig-Wood
2018-07-16 08:50:52 +01:00
parent b3bd2d1c9e
commit 85d09729f2
3 changed files with 18 additions and 18 deletions
+14
View File
@@ -2,6 +2,7 @@ package fs
import (
"net"
"strings"
"time"
)
@@ -103,3 +104,16 @@ func NewConfig() *ConfigInfo {
return c
}
// ConfigToEnv converts an config section and name, eg ("myremote",
// "ignore-size") into an environment name
// "RCLONE_CONFIG_MYREMOTE_IGNORE_SIZE"
func ConfigToEnv(section, name string) string {
return "RCLONE_CONFIG_" + strings.ToUpper(strings.Replace(section+"_"+name, "-", "_", -1))
}
// OptionToEnv converts an option name, eg "ignore-size" into an
// environment name "RCLONE_IGNORE_SIZE"
func OptionToEnv(name string) string {
return "RCLONE_" + strings.ToUpper(strings.Replace(name, "-", "_", -1))
}