Skip to content

Commit

Permalink
Update go-ini dep
Browse files Browse the repository at this point in the history
  • Loading branch information
mtibben committed Aug 16, 2020
1 parent d1bdcfd commit 7262236
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/smartystreets/goconvey v1.6.4 // indirect
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 // indirect
gopkg.in/ini.v1 v1.56.0
gopkg.in/ini.v1 v1.60.0
)

replace github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.56.0 h1:DPMeDvGTM54DXbPkVIZsp19fp/I2K7zwA/itHYHKo8Y=
gopkg.in/ini.v1 v1.56.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.60.0 h1:P5ZzC7RJO04094NJYlEnBdFK2wwmnCAy/+7sAzvWs60=
gopkg.in/ini.v1 v1.60.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
18 changes: 4 additions & 14 deletions vault/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ package vault
import (
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"regexp"
"strings"
"time"

Expand Down Expand Up @@ -113,22 +111,14 @@ func LoadConfigFromEnv() (*ConfigFile, error) {
return LoadConfig(file)
}

var iniKeysRegex = regexp.MustCompile(`\n[^\[\=]+\=`)

func (c *ConfigFile) parseFile() error {
log.Printf("Parsing config file %s", c.Path)

src, err := ioutil.ReadFile(c.Path)
if err != nil {
return fmt.Errorf("Error parsing config file %s: %w", c.Path, err)
}
iniWithLowerCaseKeys := iniKeysRegex.ReplaceAllFunc(src, func(w []byte) []byte {
return []byte(strings.ToLower(string(w)))
})

f, err := ini.LoadSources(ini.LoadOptions{
AllowNestedValues: true,
}, iniWithLowerCaseKeys)
AllowNestedValues: true,
InsensitiveSections: false,
InsensitiveKeys: true,
}, c.Path)
if err != nil {
return fmt.Errorf("Error parsing config file %s: %w", c.Path, err)
}
Expand Down

0 comments on commit 7262236

Please sign in to comment.