From 09e5ea9cddf2d8dd6c7e79c370caf2585bdfccab Mon Sep 17 00:00:00 2001 From: Felix from Macbook Date: Fri, 7 Sep 2018 22:41:30 +0200 Subject: [PATCH 1/3] added expandEnv for toml file --- config.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/config.go b/config.go index 01f6f3f..189624c 100644 --- a/config.go +++ b/config.go @@ -2,10 +2,12 @@ package main import ( "fmt" - "github.com/BurntSushi/toml" - "github.com/pkg/errors" "io/ioutil" "net/url" + "os" + + "github.com/BurntSushi/toml" + "github.com/pkg/errors" ) var ( @@ -194,12 +196,15 @@ func ReadConfig(tomlStr string) (*S3SFTPProxyConfig, error) { } func ReadConfigFromFile(tomlFile string) (*S3SFTPProxyConfig, error) { - tomlStr, err := ioutil.ReadFile(tomlFile) + tomlBytes, err := ioutil.ReadFile(tomlFile) if err != nil { return nil, errors.Wrapf(err, "failed to open %s", tomlFile) } - cfg, err := ReadConfig(string(tomlStr)) + tomlBytes := os.ExpandEnv(string(tomlBytes)) + + cfg, err := ReadConfig(string(tomlBytes)) + if err != nil { return nil, errors.Wrapf(err, "failed to parse %s", tomlFile) } From 25c98d2a482478a5da3a8d094123abdfe8fcfdbc Mon Sep 17 00:00:00 2001 From: Felix Becker Date: Fri, 7 Sep 2018 23:10:10 +0200 Subject: [PATCH 2/3] assignment is already defined --- config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.go b/config.go index 189624c..d2cb43f 100644 --- a/config.go +++ b/config.go @@ -201,7 +201,7 @@ func ReadConfigFromFile(tomlFile string) (*S3SFTPProxyConfig, error) { return nil, errors.Wrapf(err, "failed to open %s", tomlFile) } - tomlBytes := os.ExpandEnv(string(tomlBytes)) + tomlBytes = os.ExpandEnv(string(tomlBytes)) cfg, err := ReadConfig(string(tomlBytes)) From ed2a3bf9d0b8cb8b04bea4f9f21a1556f386c1e3 Mon Sep 17 00:00:00 2001 From: Felix from Macbook Date: Fri, 7 Sep 2018 23:55:23 +0200 Subject: [PATCH 3/3] to byte array missing --- .gitignore | 1 + config.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..56e6b2b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +s3-sftp-proxy \ No newline at end of file diff --git a/config.go b/config.go index d2cb43f..82af53b 100644 --- a/config.go +++ b/config.go @@ -201,7 +201,7 @@ func ReadConfigFromFile(tomlFile string) (*S3SFTPProxyConfig, error) { return nil, errors.Wrapf(err, "failed to open %s", tomlFile) } - tomlBytes = os.ExpandEnv(string(tomlBytes)) + tomlBytes = []byte(os.ExpandEnv(string(tomlBytes))) cfg, err := ReadConfig(string(tomlBytes))