~mariusor/motley

0a9f3e61f837fe008ad47517edd7d29b99a71b56 — Marius Orcsik 5 months ago fc4e0f1
Don't fallback to /tmp for path
1 files changed, 8 insertions(+), 6 deletions(-)

M internal/config/config.go
M internal/config/config.go => internal/config/config.go +8 -6
@@ 170,11 170,13 @@ func LoadFromEnv(e env.Type, timeOut time.Duration) (Options, error) {
	if to, _ := time.ParseDuration(loadKeyFromEnv(KeyTimeOut, "")); to > 0 {
		conf.TimeOut = to
	}
	conf.Secure, _ = strconv.ParseBool(loadKeyFromEnv(KeyHTTPS, "false"))
	if conf.Secure {
		conf.BaseURL = fmt.Sprintf("https://%s", conf.Host)
	} else {
		conf.BaseURL = fmt.Sprintf("http://%s", conf.Host)
	if conf.Host != "" {
		conf.Secure, _ = strconv.ParseBool(loadKeyFromEnv(KeyHTTPS, "false"))
		if conf.Secure {
			conf.BaseURL = fmt.Sprintf("https://%s", conf.Host)
		} else {
			conf.BaseURL = fmt.Sprintf("http://%s", conf.Host)
		}
	}
	conf.KeyPath = loadKeyFromEnv(KeyKeyPath, "")
	conf.CertPath = loadKeyFromEnv(KeyCertPath, "")


@@ 184,7 186,7 @@ func LoadFromEnv(e env.Type, timeOut time.Duration) (Options, error) {
	conf.Storage = StorageType(strings.ToLower(envStorage))
	conf.StoragePath = loadKeyFromEnv(KeyStoragePath, "")
	if conf.StoragePath == "" {
		conf.StoragePath = os.TempDir()
		conf.StoragePath = "."
	}
	conf.StoragePath = path.Clean(conf.StoragePath)