Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
s3-sftp-proxy
13 changes: 9 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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 = []byte(os.ExpandEnv(string(tomlBytes)))

cfg, err := ReadConfig(string(tomlBytes))

if err != nil {
return nil, errors.Wrapf(err, "failed to parse %s", tomlFile)
}
Expand Down