Skip to content

Commit

Permalink
Add spaces support
Browse files Browse the repository at this point in the history
  • Loading branch information
Glib Smaga committed Mar 8, 2017
1 parent e3768e6 commit 8671b02
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func unmarshalYAMLValue(reader io.ReadCloser, value interface{}) error {
// TODO: what if someone wanted a literal ${FOO} in config? need a small escape hatch
func interpolateEnvVars(data []byte) ([]byte, error) {
// ${VAR_NAME:default} or ${VAR_NAME}
reg := regexp.MustCompile(`\$\{\w+:?[\w"]*}`)
reg := regexp.MustCompile(`\$\{\w+:?[^}]*}`)

var regErr error
data = reg.ReplaceAllFunc(data, func(in []byte) []byte {
Expand Down
4 changes: 2 additions & 2 deletions config/yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ func TestYAMLEnvInterpolationEmptyString(t *testing.T) {
t.Parallel()

cfg := []byte(`
name: ""
name: ${APP_NAME:my shiny app}
fullTel: 1-800-LOLZ${TELEPHONE_EXTENSION:""}`)

p := NewYAMLProviderFromBytes(cfg)
require.Equal(t, "", p.Get("name").AsString())
require.Equal(t, "my shiny app", p.Get("name").AsString())
require.Equal(t, "1-800-LOLZ", p.Get("fullTel").AsString())
}

Expand Down

0 comments on commit 8671b02

Please sign in to comment.